import { View } from '@tarojs/components'
import { memo, useEffect, useMemo, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'

interface prosObj {
  obj?: {
    sale_mode?: Number
    collect_status?: Number | string
    status?: Number
    payment_method?: Number
    settle_mode?: Number | string
    is_shipper_picks_up?: boolean
  }
  handApplyGoods?: () => void
  handApplyMoney?: () => void
  goodsObj?: any
  // handSureGoods?: () => void,
}
const BottomApply = (props: prosObj) => {
  const {
    obj = {
      sale_mode: 0,
      collect_status: '',
      status: '',
      payment_method: 0,
      settle_mode: '',
      is_shipper_picks_up: false,
    },
    handApplyGoods,
    handApplyMoney,
    goodsObj = {},
    // handSureGoods
  } = props

  // 判断显示申请退货
  const showTuihuo = useMemo(() => {
    if (
      (obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 0 && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 1 && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 2 && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 0 && obj.status == 9 && obj.settle_mode == 3 && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 2 && obj.status == 9 && goodsObj?.av_return_product?.length)
    ) {
      return true
    }
    else { return false }
  }, [obj])
  // 判断显示申请退款
  const showTuikuan = useMemo(() => {
    if (
      (obj.sale_mode === 0 && obj.status == 2 && obj.collect_status == 1 && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 0 && obj.status == 7 && obj.collect_status == 2 && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 0 && obj.status == 7 && obj.collect_status == 3 && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 0 && obj.status == 11 && (obj.collect_status == 1 || obj.collect_status == 2) && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 0 && goodsObj?.av_return_product?.length && !obj.is_shipper_picks_up)
            || (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 2 && goodsObj?.av_return_product?.length && !obj.is_shipper_picks_up)
            || (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 1 && goodsObj?.av_return_product?.length && !obj.is_shipper_picks_up)
            || (obj.sale_mode === 1 && obj.status == 0 && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 1 && obj.status == 9 && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 2 && obj.status == 0 && obj.collect_status == 1 && goodsObj?.av_return_product?.length)
            || (obj.sale_mode === 2 && obj.status == 0 && obj.collect_status == 2 && goodsObj?.av_return_product?.length)
    ) {
      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 && <View className={styles.title} >暂无更多</View>
      }
    </>
  )
}
export default memo(BottomApply)
