代码提交
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
:class="['order']"
|
||||
v-if="data"
|
||||
>
|
||||
|
||||
<view
|
||||
class="order-header"
|
||||
@tap="toOrderInfo"
|
||||
@ -61,7 +60,6 @@
|
||||
<view class="total-price">¥{{ totalPrice }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="data._status">
|
||||
<view
|
||||
class="order-actions"
|
||||
@ -74,7 +72,7 @@
|
||||
<view
|
||||
v-if="data._status._type == 0"
|
||||
class="order-actions-default"
|
||||
@tap="handleCancel"
|
||||
@tap="showModal(0)"
|
||||
>
|
||||
取消订单
|
||||
</view>
|
||||
@ -102,31 +100,34 @@
|
||||
<view
|
||||
v-if="data._status._type == 2"
|
||||
class="order-actions-primary"
|
||||
@tap="handleOrderTake"
|
||||
@tap="showModal(2)"
|
||||
>
|
||||
确认收货
|
||||
</view>
|
||||
<view
|
||||
v-if="['4'].includes(data._status._type)"
|
||||
class="order-actions-default"
|
||||
@tap="handleDelete"
|
||||
@tap="showModal(1)"
|
||||
>
|
||||
删除订单
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<Modal ref="modalRef" :content="modalTitle" @confirm="handleModalConfirm" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref, unref } from 'vue';
|
||||
import { orderCancel, orderDelete, orderTake } from '@/api/order'
|
||||
import Modal from "@/components/Modal/index.vue"
|
||||
|
||||
import { useRouter } from "@/hooks/useRouter";
|
||||
import { useInterface } from "@/hooks/useInterface";
|
||||
|
||||
const {push} = useRouter()
|
||||
const {toast} = useInterface()
|
||||
|
||||
const emit = defineEmits(['refresh', 'pay'])
|
||||
|
||||
@ -143,28 +144,69 @@ 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 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()
|
||||
}
|
||||
|
||||
const toSelectRefundGood = () => {
|
||||
/**
|
||||
* 确认取消订单
|
||||
* @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: '删除成功'});
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认收货
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function doTakeRequest(){
|
||||
let option = {
|
||||
uni: data.value.orderId,
|
||||
}
|
||||
await orderTake(option)
|
||||
emit('refresh')
|
||||
toast({title: '已收货'});
|
||||
}
|
||||
|
||||
function toSelectRefundGood(){
|
||||
push({url: '/pages/selectRefundGood/selectRefundGood'}, {
|
||||
data: {
|
||||
orderId: data.value.orderId,
|
||||
@ -174,18 +216,12 @@ const toSelectRefundGood = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handlePay = () => {
|
||||
function handlePay(){
|
||||
emit('pay', data.value.orderId)
|
||||
/* push({url: '/pages/selectPlay/selectPlay'}, {
|
||||
data: {
|
||||
key: data.value.unique,
|
||||
orderId: data.value.orderId,
|
||||
}
|
||||
})*/
|
||||
}
|
||||
|
||||
|
||||
const toOrderInfo = () => {
|
||||
function toOrderInfo() {
|
||||
push({url: '/pages/orderInfo/orderInfo'}, {
|
||||
data: {
|
||||
key: data.value.unique,
|
||||
@ -195,7 +231,7 @@ const toOrderInfo = () => {
|
||||
}
|
||||
|
||||
|
||||
const toEvaluate = (item) => {
|
||||
function toEvaluate(item){
|
||||
push({url: '/pages/evaluate/evaluate'}, {
|
||||
data: {
|
||||
unique: item.unique,
|
||||
@ -205,52 +241,23 @@ const toEvaluate = (item) => {
|
||||
}
|
||||
|
||||
|
||||
const handleDelete = async () => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确认取消订单',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
await orderDelete({
|
||||
uni: data.value.orderId
|
||||
})
|
||||
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,
|
||||
}
|
||||
await orderTake(option)
|
||||
emit('refresh')
|
||||
uni.showToast({
|
||||
title: '已收货',
|
||||
duration: 2000
|
||||
});
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
<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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user