import { View } from "@tarojs/components"
import { memo, useEffect, useState, useMemo } from "react"
import styles from "./index.module.scss"
import classnames from "classnames";
interface prosObj {
    obj?: {
        sale_mode?: Number,
        collect_status?: Number | string,
        status?: Number,
        payment_method?: Number,
        settle_mode?: Number | string,
    }
    handApplyGoods?: () => void,
    handApplyMoney?: () => void,
    handSureGoods?: () => void,
}

export default memo((props: prosObj) => {
    const {
        obj = {
            sale_mode: 0,
            collect_status: '',
            status: '',
            payment_method: 0,
            settle_mode: ''
        },
        handApplyGoods,
        handApplyMoney,
        handSureGoods
    } = props

    //判断显示申请退货
    const showTuihuo = useMemo(() => {
        if (
            (obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 0) ||
            (obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 1) ||
            (obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 2) ||
            (obj.sale_mode === 0 && obj.status == 9 && obj.settle_mode == 3) ||
            (obj.sale_mode === 2 && obj.status == 9)
        ) {
            return true
        } else return false
    }, [obj])
    //判断显示申请退款
    const showTuikuan = useMemo(() => {
        if (
            (obj.sale_mode === 0 && obj.status == 2 && obj.collect_status == 1) ||
            (obj.sale_mode === 0 && obj.status == 7 && obj.collect_status == 0) ||
            (obj.sale_mode === 0 && obj.status == 11 && (obj.collect_status == 1 || obj.collect_status == 2)) ||
            (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 0) ||
            (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 2) ||
            (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 1) ||
            (obj.sale_mode === 1 && obj.status == 0) ||
            (obj.sale_mode === 1 && obj.status == 9) ||
            (obj.sale_mode === 2 && obj.status == 0 && obj.collect_status == 1) ||
            (obj.sale_mode === 2 && obj.status == 0 && obj.collect_status == 2)
        ) {
            return true
        } else return false
    }, [obj])
    //判断显示确认收货
    const showTake = useMemo(() => {
        if (
            (obj.sale_mode === 0 && obj.status == 8 && obj.collect_status == 0) ||
            (obj.sale_mode === 0 && obj.status == 8 && obj.collect_status == 1) ||
            (obj.sale_mode === 0 && obj.status == 8 && obj.collect_status == 2) ||
            (obj.sale_mode === 0 && obj.status == 8 && obj.settle_mode == 3) ||
            (obj.sale_mode === 1 && obj.status == 8) ||
            (obj.sale_mode === 2 && obj.status == 8)
        ) {
            return true
        } else return false
    }, [obj])


    return (
        < >


            {
                showTuihuo && <View className={styles.title} onClick={() => handApplyGoods?.()}>申请退货</View>
            }

            {
                showTuikuan && <View className={styles.tuikuan} onClick={() => handApplyMoney?.()}>申请退款</View>

            }

            {
                showTake && <View className={styles.tuikuan} onClick={() => handSureGoods?.()}>确认收货</View>
            }

            {
                !showTuihuo && !showTuikuan && !showTake && <View className={styles.title} >暂无更多</View>
            }
        </>
    )
})