import { Component } from 'react'
import { connect } from 'react-redux'
import Taro from '@tarojs/taro'
import { View, Text, Button } from '@tarojs/components'
import { classNames, formatPriceToHundred } from '@/utils'
import { SpOrderItem, SpNewShopItem } from '@/components'
import { AtCountdown } from 'taro-ui'
import './new-item.scss'
@connect(({ colors, sys }) => ({
colors: colors.current,
pointName: sys.pointName
}))
export default class TradeItem extends Component {
static defaultProps = {
customFooter: false,
customRender: false,
noHeader: false,
showActions: false,
isShowNational: false,
payType: '',
info: {},
rateStatus: false,
isShowDistributorInfo: true,
onClickBtn: () => { },
onClick: () => { }
}
static options = {
addGlobalClass: true
}
handleClickBtn (type) {
const { info } = this.props
this.props.onClickBtn && this.props.onClickBtn(type, info)
}
computeTotalPrice () {
let total
const {
info: { totalItems, point, order_class, freight_fee, freight_type, total_fee, payment, receipt_type },
payType,
pointName
} = this.props
const [int, decimal] = String(payment || '').split('.')
if (order_class === 'pointsmall') {
if (freight_type === 'point' || (freight_type === 'cash' && freight_fee == 0)) {
total = `总计:${point} ${pointName}`
} else if (freight_type === 'cash' && freight_fee != 0) {
total = `总计:${point} ${pointName} + ¥${formatPriceToHundred(freight_fee)}`
}
} else {
if (payType === 'dhpoint') {
total = `总计:${total_fee}${pointName}`
} else {
total = `总计:¥ ${parseInt(int).toLocaleString() + (decimal ? '.' + decimal : '')}`
}
}
return (
{receipt_type === 'dada' && (
达达同城配送
)}
共{totalItems}件商品
{/* {total} */}
总计:
{`¥ ${parseInt(int).toLocaleString() + (decimal ? '.' + decimal : '')}`}
)
}
// 修改地址
clickToEditAddress () {
const { choose } = this.props.info
console.log("🚀 ~ TradeItem ~ this.props.info:", this.props.info)
return
Taro.navigateTo({
url: `/marketing/pages/member/address?isSelected=${choose}`
})
}
render () {
const {
customFooter,
onClick,
info = {},
payType,
showActions,
colors,
rateStatus,
isShowDistributorInfo,
onTimeUp = () => { }
} = this.props
if (!info) {
return null
}
//info.create_date
//订单号 info.tid
return (
{isShowDistributorInfo && (
)}
订单编号:{info.tid}
{info.status === 'WAIT_BUYER_PAY' &&
等待付款
{info.timer && 0}
onTimeUp={onTimeUp}
/>}
}
订单时间:{info.create_date}
{info &&
info.order &&
info.order.map((item, idx) => (
))}
{this.props.customRender ? this.props.customRender : this.computeTotalPrice()}
{customFooter && {this.props.renderFooter}}
{!customFooter && info.status === 'WAIT_BUYER_PAY' && (
{/* {info.status_desc} */}
{(info.order_status_des === 'PAYED' || info.order_status_des === 'NOTPAY') &&
!info.is_logistics &&
info.can_apply_cancel != 0 &&
(info.receipt_type !== 'dada' || (info.dada && info.dada.dada_status === 0)) ? (
) : null}
)}
{!customFooter && info.status === 'WAIT_SELLER_SEND_GOODS' && (
{/* {info.status_desc} */}
{false && (info.order_status_des === 'PAYED' || info.order_status_des === 'NOTPAY') &&
info.can_apply_cancel != 0 &&
!info.is_logistics &&
(info.receipt_type !== 'dada' || (info.dada && info.dada.dada_status === 0)) ? (
) : null}
{info.pay_status === 'PAYED' &&
info.delivery_status != 'PENDING' &&
info.receipt_type !== 'dada' && (
)}
)}
{!customFooter && info.status === 'TRADE_CLOSED' && (
{/* {info.status_desc} */}
)}
{!customFooter && info.status === 'WAIT_BUYER_CONFIRM_GOODS' && (
{info.receipt_type !== 'dada' && (
确认收货
查看物流
)}
{/* {info.status_desc} */}
{/* {info.receipt_type !== 'dada' && (
)} */}
{!info.aftersales_bn && info.receipt_type !== 'dada' && (
)}
{!info.aftersales_bn ? :
}
)}
{!customFooter && info.status === 'TRADE_SUCCESS' && (
再次购买
{/* {info.status_desc} */}
{/* {rateStatus && info.is_rate == 0 ? (
) : null} */}
{
!info.aftersales_bn && (
)}
{info.is_rate == 0 && !info.aftersales_bn && }
)}
{!customFooter && !!info.aftersales_bn && info.status !== 'WAIT_BUYER_CONFIRM_GOODS' && (
{/* {info.status_desc} */}
)}
)
}
}