2023-10-11 11:27:47 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view
|
2023-11-15 19:59:37 +08:00
|
|
|
|
:class="['order']"
|
2023-11-14 17:21:03 +08:00
|
|
|
|
v-if="data"
|
2023-10-11 11:27:47 +08:00
|
|
|
|
>
|
|
|
|
|
<view
|
2023-11-14 17:21:03 +08:00
|
|
|
|
class="order-header"
|
|
|
|
|
@tap="toOrderInfo"
|
2023-10-11 11:27:47 +08:00
|
|
|
|
>
|
|
|
|
|
<view class="order-logo">
|
2023-11-14 17:21:03 +08:00
|
|
|
|
<view class="color-y">Y</view>
|
|
|
|
|
<view>SHOP商城</view>
|
2023-10-11 11:27:47 +08:00
|
|
|
|
</view>
|
2023-11-14 17:21:03 +08:00
|
|
|
|
<view
|
|
|
|
|
class="order-status status-2"
|
|
|
|
|
v-if="data._status"
|
|
|
|
|
>
|
|
|
|
|
{{ data._status._title }}
|
2023-10-11 11:27:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
2023-11-14 17:21:03 +08:00
|
|
|
|
class="order-goods"
|
|
|
|
|
@tap="toOrderInfo"
|
2023-10-11 11:27:47 +08:00
|
|
|
|
>
|
2023-11-14 17:21:03 +08:00
|
|
|
|
<view
|
|
|
|
|
v-for="(item, index) in data.cartInfo"
|
|
|
|
|
class="order-evaluate"
|
|
|
|
|
:class="{evaluateBtn: data._status._type == 3}"
|
|
|
|
|
>
|
2023-10-11 11:27:47 +08:00
|
|
|
|
<view
|
2023-11-14 17:21:03 +08:00
|
|
|
|
v-if="data._status._type == 3 && item.isReply === 0"
|
|
|
|
|
class="order-actions-primary order-evaluate-btn"
|
|
|
|
|
@tap.stop="toEvaluate(item)"
|
2023-10-11 11:27:47 +08:00
|
|
|
|
>
|
|
|
|
|
去评价
|
|
|
|
|
</view>
|
2023-11-14 17:21:03 +08:00
|
|
|
|
<goods
|
|
|
|
|
list
|
|
|
|
|
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>
|
2023-10-11 11:27:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
2023-11-14 17:21:03 +08:00
|
|
|
|
class="order-info"
|
|
|
|
|
@tap="toOrderInfo"
|
2023-10-11 11:27:47 +08:00
|
|
|
|
>
|
2023-11-14 17:21:03 +08:00
|
|
|
|
<view class="text">总价:¥{{ data.cost }}</view>
|
|
|
|
|
<view class="text">优惠:¥{{ couponPrice }}</view>
|
|
|
|
|
<view class="text">运费:¥{{ totalPostage }}</view>
|
|
|
|
|
<view class="text flex flex-ai__center">总计:
|
|
|
|
|
<view class="total-price">¥{{ totalPrice }}</view>
|
2023-10-11 11:27:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2023-11-14 17:21:03 +08:00
|
|
|
|
<view v-if="data._status">
|
|
|
|
|
<view
|
|
|
|
|
class="order-actions"
|
2023-10-11 11:27:47 +08:00
|
|
|
|
|
2023-11-14 17:21:03 +08:00
|
|
|
|
>
|
|
|
|
|
<!-- 未支付 -->
|
|
|
|
|
<view class="order-actions-left">
|
|
|
|
|
</view>
|
|
|
|
|
<view class="order-actions-btns">
|
|
|
|
|
<view
|
2023-11-22 18:55:55 +08:00
|
|
|
|
v-if="data._status._type === '0'"
|
2023-11-14 17:21:03 +08:00
|
|
|
|
class="order-actions-default"
|
2023-11-17 20:55:32 +08:00
|
|
|
|
@tap="showModal(0)"
|
2023-11-14 17:21:03 +08:00
|
|
|
|
>
|
|
|
|
|
取消订单
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
2023-11-22 18:55:55 +08:00
|
|
|
|
v-if="data._status._type === '0'"
|
2023-11-14 17:21:03 +08:00
|
|
|
|
class="order-actions-primary"
|
|
|
|
|
@tap="handlePay"
|
|
|
|
|
>
|
|
|
|
|
立即付款
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
2023-11-22 18:55:55 +08:00
|
|
|
|
v-if="!['0','5','-1','-2'].includes(data._status._type)"
|
2023-11-14 17:21:03 +08:00
|
|
|
|
class="order-actions-default"
|
|
|
|
|
@tap="toSelectRefundGood"
|
|
|
|
|
>
|
|
|
|
|
申请退款
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="order-actions-default"
|
2023-11-22 18:55:55 +08:00
|
|
|
|
v-if="data._status._type === '2'"
|
2023-11-14 17:21:03 +08:00
|
|
|
|
@tap="toOrderInfo"
|
|
|
|
|
>
|
|
|
|
|
查看物流
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
2023-11-22 18:55:55 +08:00
|
|
|
|
v-if="data._status._type === '2'"
|
2023-11-14 17:21:03 +08:00
|
|
|
|
class="order-actions-primary"
|
2023-11-17 20:55:32 +08:00
|
|
|
|
@tap="showModal(2)"
|
2023-11-14 17:21:03 +08:00
|
|
|
|
>
|
|
|
|
|
确认收货
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
v-if="['4'].includes(data._status._type)"
|
|
|
|
|
class="order-actions-default"
|
2023-11-17 20:55:32 +08:00
|
|
|
|
@tap="showModal(1)"
|
2023-11-14 17:21:03 +08:00
|
|
|
|
>
|
|
|
|
|
删除订单
|
|
|
|
|
</view>
|
2023-10-11 11:27:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2023-11-17 20:55:32 +08:00
|
|
|
|
<Modal ref="modalRef" :content="modalTitle" @confirm="handleModalConfirm" />
|
2023-10-11 11:27:47 +08:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2023-11-17 20:55:32 +08:00
|
|
|
|
import { computed, ref, unref } from 'vue';
|
2023-11-14 17:21:03 +08:00
|
|
|
|
import { orderCancel, orderDelete, orderTake } from '@/api/order'
|
2023-11-17 20:55:32 +08:00
|
|
|
|
import Modal from "@/components/Modal/index.vue"
|
2023-10-11 11:27:47 +08:00
|
|
|
|
|
2023-11-14 17:21:03 +08:00
|
|
|
|
import { useRouter } from "@/hooks/useRouter";
|
2023-11-17 20:55:32 +08:00
|
|
|
|
import { useInterface } from "@/hooks/useInterface";
|
2023-10-11 11:27:47 +08:00
|
|
|
|
|
2023-11-14 17:21:03 +08:00
|
|
|
|
const {push} = useRouter()
|
2023-11-17 20:55:32 +08:00
|
|
|
|
const {toast} = useInterface()
|
2023-11-14 17:21:03 +08:00
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['refresh', 'pay'])
|
2023-10-11 11:27:47 +08:00
|
|
|
|
|
|
|
|
|
const props = defineProps(['class', 'data'])
|
|
|
|
|
|
|
|
|
|
const data = ref(props.data)
|
|
|
|
|
|
|
|
|
|
// 运费金额
|
2023-11-14 17:21:03 +08:00
|
|
|
|
const totalPostage = ref(props.data.totalPostage)
|
2023-10-11 11:27:47 +08:00
|
|
|
|
// 实际支付金额
|
|
|
|
|
const payPrice = ref(props.data.payPrice)
|
|
|
|
|
// 优惠券金额
|
|
|
|
|
const couponPrice = ref(props.data.couponPrice)
|
|
|
|
|
// 订单总价
|
|
|
|
|
const totalPrice = ref(props.data.totalPrice)
|
|
|
|
|
|
2023-11-17 20:55:32 +08:00
|
|
|
|
const modalRef = ref()
|
|
|
|
|
const modalType = ref(0) // 0取消订单 1删除订单 2确认收获
|
|
|
|
|
const modalTitle = computed(()=>{
|
|
|
|
|
const tipArr = ['确认取消订单吗?','确认删除订单吗?','确认要确认收货吗?']
|
|
|
|
|
return tipArr[modalType.value]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 弹窗确认
|
|
|
|
|
*/
|
|
|
|
|
function handleModalConfirm(){
|
|
|
|
|
const funcArr = [doCancelRequest,doDeleteRequest,doTakeRequest]
|
|
|
|
|
funcArr[modalType.value]()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 打开弹窗
|
|
|
|
|
* @param {number} type 0取消订单 1删除订单 2确认收获
|
|
|
|
|
*/
|
|
|
|
|
function showModal(type = 0){
|
|
|
|
|
modalType.value = type
|
|
|
|
|
unref(modalRef).show()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 确认取消订单
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
*/
|
|
|
|
|
async function doCancelRequest(){
|
|
|
|
|
await orderCancel({
|
|
|
|
|
id: data.value.orderId
|
|
|
|
|
})
|
|
|
|
|
emit('refresh')
|
|
|
|
|
toast({title: '已取消'});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 确认删除订单
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
*/
|
|
|
|
|
async function doDeleteRequest(){
|
|
|
|
|
await orderDelete({
|
|
|
|
|
uni: data.value.orderId
|
|
|
|
|
})
|
|
|
|
|
emit('refresh')
|
|
|
|
|
toast({title: '删除成功'});
|
2023-10-11 11:27:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-17 20:55:32 +08:00
|
|
|
|
/**
|
|
|
|
|
* 确认收货
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
*/
|
|
|
|
|
async function doTakeRequest(){
|
|
|
|
|
let option = {
|
|
|
|
|
uni: data.value.orderId,
|
|
|
|
|
}
|
|
|
|
|
await orderTake(option)
|
|
|
|
|
emit('refresh')
|
|
|
|
|
toast({title: '已收货'});
|
|
|
|
|
}
|
2023-10-11 11:27:47 +08:00
|
|
|
|
|
2023-11-17 20:55:32 +08:00
|
|
|
|
function toSelectRefundGood(){
|
2023-11-14 17:21:03 +08:00
|
|
|
|
push({url: '/pages/selectRefundGood/selectRefundGood'}, {
|
|
|
|
|
data: {
|
2023-11-22 18:55:55 +08:00
|
|
|
|
id: data.value.id
|
2023-10-11 11:27:47 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-17 20:55:32 +08:00
|
|
|
|
function handlePay(){
|
2023-11-14 17:21:03 +08:00
|
|
|
|
emit('pay', data.value.orderId)
|
2023-10-11 11:27:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-11-17 20:55:32 +08:00
|
|
|
|
function toOrderInfo() {
|
2023-11-14 17:21:03 +08:00
|
|
|
|
push({url: '/pages/orderInfo/orderInfo'}, {
|
|
|
|
|
data: {
|
2023-10-11 11:27:47 +08:00
|
|
|
|
key: data.value.unique,
|
|
|
|
|
orderId: data.value.orderId,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-11-17 20:55:32 +08:00
|
|
|
|
function toEvaluate(item){
|
2023-11-14 17:21:03 +08:00
|
|
|
|
push({url: '/pages/evaluate/evaluate'}, {
|
|
|
|
|
data: {
|
|
|
|
|
unique: item.unique,
|
2023-10-11 11:27:47 +08:00
|
|
|
|
orderId: data.value.orderId,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
2023-11-17 20:55:32 +08:00
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.order-header{
|
|
|
|
|
width: 100%;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
.order-logo,.order-status{
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
}
|
|
|
|
|
.order-logo{
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
}
|
|
|
|
|
.order-status{
|
|
|
|
|
max-width: 80%;
|
|
|
|
|
text-align: right;
|
|
|
|
|
white-space: pre-wrap;
|
|
|
|
|
font-size: 22rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-11 11:27:47 +08:00
|
|
|
|
</style>
|