Files

517 lines
13 KiB
Vue
Raw Normal View History

2023-10-11 11:27:47 +08:00
<template>
<layout class="orderInfo">
<uv-navbar
2023-11-14 17:21:03 +08:00
:fixed="false"
title="订单详情"
left-arrow
2023-11-22 18:55:55 +08:00
@leftClick="goList"
2023-10-11 11:27:47 +08:00
/>
<view v-if="orderInfoData">
<view class="orderInfo-header background-warp">
<view class="background">
<image
2023-11-14 17:21:03 +08:00
class="image"
2023-11-22 18:55:55 +08:00
:src="orderDetailsBg"
2023-11-14 17:21:03 +08:00
mode="widthFix"
2023-10-11 11:27:47 +08:00
/>
</view>
<view class="background-content page-space">
<view class="order-status-info">
2023-11-14 17:21:03 +08:00
<view
class="order-status"
:class="'order-status-'+ orderInfoData.status"
>
2023-11-17 20:55:32 +08:00
<view>{{ orderInfoData._status._title }}</view>
2023-10-11 11:27:47 +08:00
</view>
<view class="order-date">
2023-11-17 20:55:32 +08:00
{{orderInfoData._status._type === "2"?`${remainTimeStr}`:orderInfoData._status._msg }}
2023-10-11 11:27:47 +08:00
</view>
</view>
<view class="address noBorder">
<view class="address-icon">
<image
2023-11-14 17:21:03 +08:00
class="image"
2023-11-22 18:55:55 +08:00
:src="orderAddressIcon"
2023-10-11 11:27:47 +08:00
/>
</view>
<view class="address-main">
<view class="address-header">
<view class="address-name">{{ orderInfoData.realName }}</view>
<view class="address-phone">{{ orderInfoData.userPhone }}</view>
</view>
<view class="address-content">
<view class="address-desc">{{ orderInfoData.userAddress }}</view>
</view>
</view>
</view>
</view>
</view>
<view class="page-space">
<view class="order-goods page-card mb-20">
<!-- <view class="order-header">
<view class="order-logo">
<image
class="image"
2023-11-17 20:55:32 +08:00
src="https://b2c-pro-static-dev.zkthink.com/static/images/flashKilling.png"
2023-10-11 11:27:47 +08:00
alt=""
/>
</view>
</view> -->
2023-11-14 17:21:03 +08:00
<view
v-for="(item, index) in orderInfoData.cartInfo"
class="order-evaluate"
:class="{evaluateBtn: orderInfoData._status._type == 3}"
2023-10-11 11:27:47 +08:00
>
2023-11-14 17:21:03 +08:00
<goods
list
2023-11-15 19:59:37 +08:00
link
2023-11-14 17:21:03 +08:00
interval
desc="3"
showAction
model
:purchase="item.cartNum"
:data="item.productInfo"
2023-10-11 11:27:47 +08:00
>
2023-11-14 17:21:03 +08:00
<template #price>
{{ item.truePrice }}
</template>
</goods>
<view
v-if="orderInfoData.status == 2 && item.isReply === 0"
@tap.stop="toEvaluate(item)"
class="order-actions-primary order-evaluate-btn"
>去评价
</view>
</view>
2023-10-11 11:27:47 +08:00
<view class="order-infos infos mb-20 infos-right border-top">
<view class="info-cell">
2023-11-14 17:21:03 +08:00
<view class="info-cell-label">商品总价</view>
<view class="info-cell-value">¥{{ orderInfoData.cost }}</view>
2023-10-11 11:27:47 +08:00
</view>
<view class="info-cell ">
<view class="info-cell-label">优惠</view>
2023-11-14 17:21:03 +08:00
<view class="info-cell-value">¥{{ orderInfoData.couponPrice }}</view>
2023-10-11 11:27:47 +08:00
</view>
<view class="info-cell ">
<view class="info-cell-label">运费</view>
2023-11-14 17:21:03 +08:00
<view class="info-cell-value">¥{{ orderInfoData.totalPostage }}</view>
2023-10-11 11:27:47 +08:00
</view>
<view class="info-cell ">
<view class="info-cell-label">总计</view>
2023-11-14 17:21:03 +08:00
<view class="info-cell-value">¥{{ orderInfoData.payPrice }}</view>
2023-10-11 11:27:47 +08:00
</view>
</view>
</view>
<view class="mb-20 card">
<view class="card-head">
<view class="card-title">
订单信息
</view>
</view>
<view class="card-content">
<view class="infos">
<view class="info-cell">
<view class="info-cell-label">
订单编号
</view>
<view class="info-cell-value">
{{ orderInfoData.orderId }}
</view>
2023-11-14 17:21:03 +08:00
<view
class="info-cell-operation"
@click="setData(orderInfoData.orderId,'复制成功')"
>
2023-10-11 11:27:47 +08:00
复制
</view>
</view>
<view class="info-cell">
<view class="info-cell-label">
创建时间
</view>
<view class="info-cell-value">
2023-11-14 17:21:03 +08:00
{{ $timeFormat(orderInfoData.createTime, 'yyyy-mm-dd hh:MM:ss') }}
2023-10-11 11:27:47 +08:00
</view>
</view>
<view
2023-11-14 17:21:03 +08:00
class="info-cell"
2023-11-17 20:55:32 +08:00
v-if="orderInfoData.status > 0 && orderInfoData.payTime"
2023-10-11 11:27:47 +08:00
>
<view class="info-cell-label">
2023-11-14 17:21:03 +08:00
付款时间
2023-10-11 11:27:47 +08:00
</view>
<view class="info-cell-value">
2023-11-14 17:21:03 +08:00
{{ $timeFormat(orderInfoData.payTime, 'yyyy-mm-dd hh:MM:ss') }}
2023-10-11 11:27:47 +08:00
</view>
</view>
<view
2023-11-14 17:21:03 +08:00
class="info-cell"
v-if="orderInfoData.deliveryTime"
2023-10-11 11:27:47 +08:00
>
<view class="info-cell-label">
发货时间
</view>
<view class="info-cell-value">
2023-11-14 17:21:03 +08:00
{{ $timeFormat(orderInfoData.deliveryTime, 'yyyy-mm-dd hh:MM:ss') }}
2023-10-11 11:27:47 +08:00
</view>
</view>
</view>
</view>
</view>
<view
2023-11-14 17:21:03 +08:00
class="mb-20 card"
v-if="orderInfoData.status >= 1"
2023-10-11 11:27:47 +08:00
>
<view class="card-head">
<view class="card-title">
物流信息
</view>
</view>
<view
2023-11-14 17:21:03 +08:00
class="card-content "
v-if="expressData"
2023-10-11 11:27:47 +08:00
>
<view class="paddingH-10">
2023-11-14 17:21:03 +08:00
<view class="no-express" v-if="expressData.length === 0">暂无轨迹信息</view>
2023-10-11 11:27:47 +08:00
<uv-steps
2023-11-14 17:21:03 +08:00
v-else
current="0"
direction="column"
activeColor="#EE6D46"
inactiveColor="#E5E5E5"
2023-10-11 11:27:47 +08:00
>
<uv-steps-item
2023-11-14 17:21:03 +08:00
v-for="(item, index) in expressData"
:key="index"
:title="item.acceptStation"
:desc="item.acceptTime"
2023-10-11 11:27:47 +08:00
></uv-steps-item>
</uv-steps>
</view>
</view>
</view>
</view>
<view class="bottom-bar-bg"></view>
<view
2023-11-14 17:21:03 +08:00
class="order-actions bottom-bar"
2023-11-22 18:55:55 +08:00
2023-10-11 11:27:47 +08:00
>
<view class="order-actions-left">
</view>
<view class="order-actions-btns">
2023-11-22 18:55:55 +08:00
<!--待付款-->
2023-10-11 11:27:47 +08:00
<view
2023-11-22 18:55:55 +08:00
v-if="orderInfoData._status._type === '0'"
2023-11-14 17:21:03 +08:00
class="order-actions-delete"
2023-11-17 20:55:32 +08:00
@tap="showModal(1)"
2023-10-11 11:27:47 +08:00
>
取消订单
</view>
<view
2023-11-22 18:55:55 +08:00
v-if="orderInfoData._status._type === '0'"
2023-11-14 17:21:03 +08:00
class="order-actions-primary"
@tap="handlePay"
2023-10-11 11:27:47 +08:00
>
立即付款
</view>
2023-11-22 18:55:55 +08:00
<!-- 除了待付款和已取消 -->
2023-10-11 11:27:47 +08:00
<view
2023-11-22 18:55:55 +08:00
v-if="!['0','5','-1','-2'].includes(orderInfoData._status._type)"
2023-11-14 17:21:03 +08:00
class="order-actions-delete"
@tap="toSelectRefundGood(orderInfoData)"
2023-10-11 11:27:47 +08:00
>
申请退款
</view>
2023-11-22 18:55:55 +08:00
<!-- 已完成 -->
2023-10-11 11:27:47 +08:00
<view
2023-11-22 18:55:55 +08:00
v-if="['4'].includes(orderInfoData._status._type)"
2023-11-14 17:21:03 +08:00
class="order-actions-primary"
2023-11-17 20:55:32 +08:00
@tap="showModal(0)"
2023-10-11 11:27:47 +08:00
>
删除订单
</view>
2023-11-22 18:55:55 +08:00
<!-- 已发货 待收货 -->
2023-10-11 11:27:47 +08:00
<view
2023-11-22 18:55:55 +08:00
v-if="orderInfoData._status._type === '2'"
2023-11-14 17:21:03 +08:00
class="order-actions-primary"
2023-11-22 18:55:55 +08:00
@tap="showModal(2)"
2023-10-11 11:27:47 +08:00
>
2023-11-22 18:55:55 +08:00
确认收货
2023-10-11 11:27:47 +08:00
</view>
</view>
</view>
</view>
</layout>
2023-11-14 17:21:03 +08:00
<!-- 支付弹窗 -->
<PayPopup
ref="payPopupRef"
2023-11-17 20:55:32 +08:00
@confrim="paySuccess"
2023-11-14 17:21:03 +08:00
/>
2023-11-17 20:55:32 +08:00
<Modal ref="modalRef" :content="modalTitle" @confirm="confirmModal" />
2023-10-11 11:27:47 +08:00
</template>
<script setup>
2023-11-22 18:55:55 +08:00
import { orderDetailsBg, orderAddressIcon } from "@/utils/images";
2023-11-17 20:55:32 +08:00
import { computed, ref, unref } from 'vue'
2023-10-11 11:27:47 +08:00
import { onLoad } from '@dcloudio/uni-app'
2023-11-14 17:21:03 +08:00
import { orderCancel, orderDelete, orderExpress, orderInfo, orderTake } from '@/api/order'
2023-10-11 11:27:47 +08:00
import { orderReStatus } from '@/config'
2023-11-14 17:21:03 +08:00
import { useRouter } from "@/hooks/useRouter";
import { useShearPlate } from "@/hooks/useShearPlate";
import { useGlobalProperties } from "@/hooks";
import PayPopup from "@/components/PayPopup/index.vue";
2023-11-17 20:55:32 +08:00
import Modal from "@/components/Modal/index.vue";
import { useInterface } from "@/hooks/useInterface";
import {formatRemainTime} from "@/utils/utils";
2023-10-11 11:27:47 +08:00
2023-11-14 17:21:03 +08:00
const {$timeFormat} = useGlobalProperties()
2023-10-11 11:27:47 +08:00
2023-11-14 17:21:03 +08:00
const {getParams, push, goBack} = useRouter()
2023-11-17 20:55:32 +08:00
const {toast} = useInterface();
2023-10-11 11:27:47 +08:00
const orderInfoData = ref(null)
const orderInfoStatusMsg = ref('')
const expressData = ref(null)
2023-11-17 20:55:32 +08:00
const remainTimeStr = ref('')
2023-10-11 11:27:47 +08:00
2023-11-14 17:21:03 +08:00
const {setData} = useShearPlate();
2023-10-11 11:27:47 +08:00
const handleOrderInfo = async (option) => {
const res = await orderInfo(option)
orderInfoData.value = res
2023-11-14 17:21:03 +08:00
res.status = res.paid === 1 && res.status === 0 ? 99 : res.status
2023-10-11 11:27:47 +08:00
handleMsg(res.status)
2023-11-17 20:55:32 +08:00
if (parseInt(res._status._type) > 1) {
console.log(parseInt(res._status._type),'parseInt(res._status._type)')
if(parseInt(res._status._type) === 2){
remainTimeStr.value = formatRemainTime(res._status._payRemainTime)
}
2023-11-22 18:55:55 +08:00
await orderExpress({
2023-10-11 11:27:47 +08:00
orderCode: orderInfoData.value.orderId,
shipperCode: orderInfoData.value.deliverySn,
logisticCode: orderInfoData.value.deliveryId,
2023-11-22 18:55:55 +08:00
}).then(res=>{
expressData.value = res.traces.reverse()
}).catch(err=>{
console.log(err,'err')
2023-10-11 11:27:47 +08:00
})
2023-11-22 18:55:55 +08:00
2023-10-11 11:27:47 +08:00
}
}
const handlePay = () => {
2023-11-14 17:21:03 +08:00
openPay(orderInfoData.value.orderId)
2023-11-17 20:55:32 +08:00
2023-11-14 17:21:03 +08:00
}
2023-10-11 11:27:47 +08:00
2023-11-14 17:21:03 +08:00
// 返回列表
const goList = ()=>{
2023-11-15 19:59:37 +08:00
let status = 0
switch (orderInfoData.value.status){
case -1:
status = -1
break
case 0:
status = 0
break
2023-11-22 18:55:55 +08:00
case 4:
status = -1
break
2023-11-15 19:59:37 +08:00
case 99:
status = 1
break
default:
status = orderInfoData.value.status +1
}
2023-11-14 17:21:03 +08:00
push({url: '/pages/orderList/orderList'}, {
data: {
2023-11-15 19:59:37 +08:00
type: status
2023-11-22 18:55:55 +08:00
}
2023-10-11 11:27:47 +08:00
})
}
2023-11-14 17:21:03 +08:00
// 去评价
2023-10-11 11:27:47 +08:00
const toEvaluate = (item) => {
2023-11-14 17:21:03 +08:00
push({url: '/pages/evaluate/evaluate'}, {
data: {
2023-10-11 11:27:47 +08:00
unique: item.unique,
2023-11-22 18:55:55 +08:00
orderId: item.orderId
2023-11-17 20:55:32 +08:00
},
type:'redirectTo'
2023-10-11 11:27:47 +08:00
})
}
const toSelectRefundGood = () => {
2023-11-14 17:21:03 +08:00
push({url: '/pages/selectRefundGood/selectRefundGood'}, {
data: {
2023-11-22 18:55:55 +08:00
id: orderInfoData.value.id
2023-10-11 11:27:47 +08:00
}
})
}
const handleMsg = (status) => {
orderInfoStatusMsg.value = orderReStatus[status]
}
2023-11-17 20:55:32 +08:00
const modalRef = ref()
const modalType = ref(0) // 0删除 1取消 2确认收货
const modalTitle = computed(()=>{
const tipsArr = ['确认删除订单吗?','确认取消订单吗?','确认要确认收货吗?']
return tipsArr[modalType.value]
})
/**
* 打开弹窗
* @param {number} type 0删除记录 1撤销申请 2确认收货
*/
function showModal(type){
modalType.value = type
unref(modalRef).show()
2023-10-11 11:27:47 +08:00
}
2023-11-17 20:55:32 +08:00
/**
* 确认弹窗
*/
function confirmModal(){
const funcArr = [doDeleteRequest,doCancelRequest,doTakeRequest]
funcArr[modalType.value]()
}
async function doDeleteRequest(){
await orderDelete({
uni: orderInfoData.value.orderId
})
toast({title: '删除成功'});
2023-11-22 18:55:55 +08:00
setTimeout(()=>{
goList()
},2000)
2023-11-17 20:55:32 +08:00
}
async function doCancelRequest(){
await orderCancel({
id: orderInfoData.value.orderId
})
toast({title: '取消成功'});
2023-11-22 18:55:55 +08:00
setTimeout(()=>{
goList()
},2000)
2023-10-11 11:27:47 +08:00
}
2023-11-17 20:55:32 +08:00
async function doTakeRequest(){
let option = {
uni: orderInfoData.value.orderId,
}
await orderTake(option)
toast({title: '收货成功'});
await handleOrderInfo({
key: option.uni
})
}
2023-11-14 17:21:03 +08:00
// ============================== 支付相关 ===============================
const payPopupRef = ref()
function openPay(orderId) {
unref(payPopupRef).show(orderId)
}
function paySuccess() {
push({url: '/pages/payStatus/index?type=1'})
}
onLoad((options) => {
const params = getParams(options)
2023-10-11 11:27:47 +08:00
handleOrderInfo({
2023-11-14 17:21:03 +08:00
key: params.orderId
2023-10-11 11:27:47 +08:00
})
})
</script>
2023-11-14 17:21:03 +08:00
<style lang="scss">
2023-11-22 18:55:55 +08:00
@import "../../style/images";
2023-10-11 11:27:47 +08:00
.orderList {
padding: 20rpx 0;
}
2023-11-14 17:21:03 +08:00
.order-header {
}
2023-10-11 11:27:47 +08:00
.order-status-info {
padding: 50rpx 0;
.order-status {
display: flex;
align-items: center;
height: 42rpx;
font-size: 30rpx;
color: #FFFFFF;
margin-bottom: 20rpx;
2023-11-14 17:21:03 +08:00
padding-left: 50rpx;
background-size: 40rpx 40rpx;
background-position: left center;
background-repeat: no-repeat;
2023-10-11 11:27:47 +08:00
.image {
width: 40rpx;
height: 40rpx;
margin-right: 10rpx;
}
2023-11-14 17:21:03 +08:00
2023-11-17 20:55:32 +08:00
&.order-status-0,&.order-status--1,&.order-status-4,&.order-status-5,&.order-status-6,&.order-status-7 {
2023-11-22 18:55:55 +08:00
background-image: $orderStateMoney;
2023-11-14 17:21:03 +08:00
}
&.order-status-1, &.order-status-99 {
2023-11-22 18:55:55 +08:00
background-image: $orderStateReturn;
2023-11-14 17:21:03 +08:00
}
&.order-status-2, &.order-status-3 {
2023-11-22 18:55:55 +08:00
background-image: $orderStateFinish;
2023-11-14 17:21:03 +08:00
}
2023-10-11 11:27:47 +08:00
}
.order-date {
height: 33rpx;
font-size: 24rpx;
color: #FFFFFF;
}
}
.order-infos {
margin: 0 40rpx;
padding: 40rpx 0 20rpx;
&:after {
content: '';
}
}
2023-11-14 17:21:03 +08:00
.no-express{
font-size: 26rpx;
padding: 20rpx 14rpx 30rpx;
}
2023-10-11 11:27:47 +08:00
</style>