import { View, Text } from "@tarojs/components" import { useEffect, useState } from "react" import Taro, { useDidShow } from "@tarojs/taro" import CustomNav from '@/components/CustomNav' import ButtontWX from '@/components/ButtontWX' import formatTimes from "@/utils/codeSegment" import withLayout from '@/layouts' import formatPrice from "@/utils/formatPrice" import AssessModel from "@/components/AssessModel" import { orderPrepay, orderDelete, orderInfo, orderRefund } from "@/services/order" // import BottomMoadl from '@/components/BottomMoadl/index' import './style.less' export default withLayout((props) => { // const { stateType } = props const $instance = Taro.getCurrentInstance() const { orderId, stateType, stateStyle } = $instance.router.params const [orderInfos, setOrderInfos] = useState() console.log("🚀 ~ file: index.jsx ~ line 27 ~ stateType ~ stateType", stateType) const [isAssessVisible, setIsAssessVisible] = useState(false) //底部弹窗 // const [showFrame, setShowFrame] = useState(false) // const setRecommend = () => { // setShowFrame(!showFrame) // } const cancelPay = () => { Taro.showModal({ title: '提示', content: '您确定要取消此订单吗?', success: function (res) { if (res.confirm) { orderDelete(orderId).then((e) => { console.log('订单取消/删除', e); Taro.showToast({ title: '订单取消成功', icon: 'success', duration: 2000 }).then(() => { setTimeout(() => { Taro.navigateBack({ delta: 1 }) }, 1000) }) }) } else if (res.cancel) { console.log('用户点击取消') } } }) } useEffect(() => { if (orderId) { orderInfo(orderId).then((res) => { setOrderInfos(res) }) } else { Taro.showToast({ title: '暂无订单详情', icon: 'error', duration: 2000 }).then(() => { setTimeout(() => { Taro.navigateBack({ delta: 1 }) }, 1000) }) } }, [orderId]) const requestPayment = (params) => { Taro.hideLoading() console.log("🚀 ~ file: index.jsx ~ line 92 ~ requestPayment ~ params", params) Taro.requestPayment({ ...params, package: params.packageValue, success: () => { Taro.showToast({ title: "支付成功", icon: "success", duration: 1000, }).then(() => { setTimeout(() => { Taro.reLaunch({ url: `/pages/index/index?tab=1` }) }, 400) }) }, fail: (e) => { Taro.showToast({ title: "支付失败", icon: "none", duration: 2000, }); Taro.reLaunch({ // url: `/pages/MineUserAll/AllOrder/index?tabJump=1` }) }, }) } const pay = () => { orderPrepay(orderId, { payType: 'wx', }).then((e) => { console.log('订单返回', e); Taro.showLoading({ title: '支付中', }) requestPayment(e) }) //支付逻辑 } //退单 const orderRefunds = () => { Taro.showLoading({ title: '退单申请中', }) orderRefund(orderId).then(() => { Taro.showLoading() Taro.showToast({ title: "退单成功", icon: "none", duration: 2000, }).then(() => { setTimeout(() => { Taro.navigateBack({ delta: 1 }) }, 400) }) }).catch(() => { Taro.showLoading() Taro.showToast({ title: "请重试", icon: "error", duration: 2000, }); }) } const startModle = () => { setIsAssessVisible(true) } const onClose = () => { setIsAssessVisible(false) Taro.navigateBack({ delta: 1 }) } return ( {/* */} 订单编号:{orderInfos?.orderNo} 农机名称:{orderInfos?.machineryName} 作业面积:{orderInfos?.amount} 需求时间:{formatTimes(orderInfos?.appointmentDate, 'yyyy-MM-dd')} 下单时间:{formatTimes(orderInfos?.createDate, 'yyyy-MM-dd')} 订单状态:{stateType === '已付款' ? '已付款,待调度' : stateType} 费用:{formatPrice(orderInfos?.charges)} 状态:{orderInfos?.payStatus === 1 ? '已付款' : '待付款'} <> { stateType == '已完成' ? <> : stateType == '进行中' ? <> : stateType == '待评价' ? : stateType == '待作业' ? : stateType == '待付款' ? <> : stateType == '已付款' ? // : stateType == '待作业' ? : stateType == '已退单' ? <> : stateType == '退单申请中' ? : <> } ) })