123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- 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 (
- <View className='page-index'>
- <View className='index-navbar'>
- <CustomNav title='订单详情' />
- </View>
- <AssessModel orderId={orderId} showCutover={isAssessVisible} maskClosable={isAssessVisible} onClose={onClose} onFinish={onClose} />
- {/* <BottomMoadl frameTitle='支付方式' flag={showFrame} onRecommend={setRecommend} /> */}
- <View className='orders-listBox-RihtboxBoxOrderViewText'>
- <View className='View-LiftTextTop'>订单编号:<Text>{orderInfos?.orderNo}</Text></View>
- <View>农机名称:<Text>{orderInfos?.machineryName}</Text></View>
- <View>作业面积:<Text>{orderInfos?.amount}</Text></View>
- <View>需求时间:<Text>{formatTimes(orderInfos?.appointmentDate, 'yyyy-MM-dd')}</Text></View>
- <View>下单时间:<Text>{formatTimes(orderInfos?.createDate, 'yyyy-MM-dd')}</Text></View>
- <View>订单状态:<Text style={{ color: `${stateStyle}` }} >{stateType === '已付款' ? '已付款,待调度' : stateType}</Text></View>
- <View className='View-LiftTextBotton'>
- <View className='feiyongStyle'>费用:<Text className='feiyongStyle-charges' >{formatPrice(orderInfos?.charges)}</Text></View>
- <View className='feiyongStyle'>状态:<Text style={{ color: `${stateStyle}` }} className='feiyongStyle-stateStyle' >{orderInfos?.payStatus === 1 ? '已付款' : '待付款'}</Text></View>
- </View>
- </View>
- <View className='BottomtBut' >
- <>
- {
- stateType == '已完成' ? <></>
- : stateType == '进行中' ? <></>
- : stateType == '待评价' ? <ButtontWX butText='评价' onClick={startModle} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
- : stateType == '待作业' ? <ButtontWX butText='退单' onClick={orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
- : stateType == '待付款' ? <>
- <ButtontWX butText='取消' styleType onClick={cancelPay} butWidth={150} butHeight={39} butFontSize={16} butBorderRadius={49} />
- <ButtontWX butText='支付' onClick={pay} butWidth={150} butHeight={39} butFontSize={16} butBorderRadius={49} />
- </> : stateType == '已付款' ?
- <ButtontWX butText='退单' onClick={orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
- // <ButtontWX butText={`${orderInfos?.payStatus == 3 ? '退单申请中' : '退单'}`} disabled={orderInfos?.payStatus == 3 ? true : false} onClick={orderInfos?.payStatus == 3 ? '' : orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
- : stateType == '待作业' ? <ButtontWX butText={`${orderInfos?.payStatus == 3 ? '退单申请中' : '退单'}`} disabled={orderInfos?.payStatus == 3 ? true : false} onClick={orderInfos?.payStatus == 3 ? '' : orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
-
- : stateType == '已退单' ? <></>
- : stateType == '退单申请中' ? <ButtontWX butText={`${orderInfos?.payStatus == 3 ? '退单申请中' : '退单'}`} disabled={orderInfos?.payStatus == 3 ? true : false} onClick={orderInfos?.payStatus == 3 ? '' : orderRefunds} butWidth={323} butHeight={49} butFontSize={16} butBorderRadius={49} />
-
- : <></>
- }
- </>
-
-
-
-
- </View>
- </View>
- )
- })
|