Files

259 lines
5.8 KiB
Vue
Raw Normal View History

2023-10-11 11:27:47 +08:00
<template>
<view>
<view
2023-11-14 17:21:03 +08:00
:class="['order', className]"
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
v-if="data._status._type == 0"
class="order-actions-default"
@tap="handleCancel"
>
取消订单
</view>
<view
v-if="data._status._type == 0"
class="order-actions-primary"
@tap="handlePay"
>
立即付款
</view>
<view
v-if="['1','2','3','4'].includes(data._status._type)"
class="order-actions-default"
@tap="toSelectRefundGood"
>
申请退款
</view>
<view
class="order-actions-default"
v-if="data._status._type == 2"
@tap="toOrderInfo"
>
查看物流
</view>
<view
v-if="data._status._type == 2"
class="order-actions-primary"
@tap="handleOrderTake"
>
确认收货
</view>
<view
v-if="['4'].includes(data._status._type)"
class="order-actions-default"
@tap="handleDelete"
>
删除订单
</view>
2023-10-11 11:27:47 +08:00
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
2023-11-14 17:21:03 +08:00
import { orderCancel, orderDelete, orderTake } from '@/api/order'
2023-10-11 11:27:47 +08:00
2023-11-14 17:21:03 +08:00
import { useRouter } from "@/hooks/useRouter";
2023-10-11 11:27:47 +08:00
2023-11-14 17:21:03 +08:00
const {push} = useRouter()
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)
const handleCancel = async () => {
uni.showModal({
title: '提示',
content: '确认取消订单',
success: async (res) => {
if (res.confirm) {
await orderCancel({
id: data.value.orderId
})
data.value = null
uni.showToast({
title: '已取消',
duration: 2000
});
} else if (res.cancel) {
}
}
});
}
const toSelectRefundGood = () => {
2023-11-14 17:21:03 +08:00
push({url: '/pages/selectRefundGood/selectRefundGood'}, {
data: {
2023-10-11 11:27:47 +08:00
orderId: data.value.orderId,
id: data.value.id,
2023-11-14 17:21:03 +08:00
status: data.value.status
2023-10-11 11:27:47 +08:00
}
})
}
const handlePay = () => {
2023-11-14 17:21:03 +08:00
emit('pay', data.value.orderId)
/* push({url: '/pages/selectPlay/selectPlay'}, {
data: {
key: data.value.unique,
orderId: data.value.orderId,
}
})*/
2023-10-11 11:27:47 +08:00
}
const 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-14 17:21:03 +08:00
const toEvaluate = (item) => {
push({url: '/pages/evaluate/evaluate'}, {
data: {
unique: item.unique,
2023-10-11 11:27:47 +08:00
orderId: data.value.orderId,
}
})
}
const handleDelete = async () => {
uni.showModal({
title: '提示',
content: '确认取消订单',
success: async (res) => {
if (res.confirm) {
await orderDelete({
2023-11-14 17:21:03 +08:00
uni: data.value.orderId
2023-10-11 11:27:47 +08:00
})
data.value = null
uni.showToast({
title: '已删除',
duration: 2000
});
} else if (res.cancel) {
}
}
});
}
const handleOrderTake = async () => {
uni.showModal({
title: '提示',
content: '确认收货',
success: async (res) => {
if (res.confirm) {
let option = {
uni: data.value.orderId,
}
2023-11-14 17:21:03 +08:00
await orderTake(option)
2023-10-11 11:27:47 +08:00
emit('refresh')
2023-11-14 17:21:03 +08:00
uni.showToast({
title: '已收货',
duration: 2000
});
2023-10-11 11:27:47 +08:00
} else if (res.cancel) {
}
}
});
}
</script>
2023-11-14 17:21:03 +08:00
<style lang="scss">
2023-10-11 11:27:47 +08:00
</style>