225 lines
5.0 KiB
Vue
225 lines
5.0 KiB
Vue
<template>
|
|
<view
|
|
class="flex-center"
|
|
:class="{
|
|
'ju-flex-end': props.type == 2,
|
|
'ju-between': props.type != 2,
|
|
}"
|
|
>
|
|
<view class="more size24" v-if="props.type != 2"></view>
|
|
<view class="flex-center ju-flex-end">
|
|
<view v-for="(item, index) in btns" :key="index">
|
|
<view
|
|
v-if="
|
|
item.value.split(',').indexOf(String(props?.data?.status)) !== -1 &&
|
|
!(item.id === 3 && Number(props?.data?.type) === 5) &&
|
|
!(item.id === 3 && props?.data?.payChannelCode === 'cash_payment')
|
|
"
|
|
class="btn size28 f500"
|
|
@click.stop="btnClick(item.id)"
|
|
:style="{ color: item.color, background: item.background, border: item.border }"
|
|
:class="{ btn1: props.type == 2 }"
|
|
>
|
|
{{ item.name }}
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, getCurrentInstance, defineProps, defineEmits } from 'vue';
|
|
import sheep from '@/sheep';
|
|
import OrderApi from '@/sheep/api/trade/order';
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
let emit = defineEmits(['downData']);
|
|
const props = defineProps({
|
|
data: {
|
|
type: Object,
|
|
default() {
|
|
return {};
|
|
},
|
|
},
|
|
type: {
|
|
type: String,
|
|
default: '0', //0列表2订单详情
|
|
},
|
|
});
|
|
let btns = ref([
|
|
{
|
|
id: 1,
|
|
name: '取消订单',
|
|
value: '0,70',
|
|
},
|
|
{
|
|
id: 2,
|
|
name: '去付款',
|
|
value: '0',
|
|
color: '#EE0A24',
|
|
background: 'rgba(238,10,36,0.2)',
|
|
border: 'none',
|
|
},
|
|
{
|
|
//在订单详情退货
|
|
id: 3,
|
|
name: '申请售后',
|
|
value: '10,20',
|
|
},
|
|
{
|
|
id: 4,
|
|
name: '确认收货',
|
|
value: '20,60',
|
|
color: '#EE0A24',
|
|
background: 'rgba(238,10,36,0.2)',
|
|
border: 'none',
|
|
},
|
|
{
|
|
id: 5,
|
|
name: '再次购买',
|
|
value: '30,50,40',
|
|
color: '#FA9C31',
|
|
},
|
|
{
|
|
id: 6,
|
|
name: '取消售后',
|
|
value: '60',
|
|
},
|
|
]);
|
|
const btnClick = (index) => {
|
|
let timestamp = new Date().getTime();
|
|
let payExpireTime = props.data.payExpireTime;
|
|
if (timestamp > payExpireTime && props.data.status == 0 && index == 2) {
|
|
uni.showToast({
|
|
title: '订单已过期',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
}
|
|
if (index === 3 && Number(props?.data?.type) === 5) {
|
|
return;
|
|
}
|
|
let id = props.data?.id;
|
|
switch (index) {
|
|
case 1:
|
|
cancelOrder();
|
|
break;
|
|
case 2:
|
|
payOrder(id);
|
|
break;
|
|
case 3:
|
|
applyAfterSale();
|
|
break;
|
|
case 4:
|
|
confirmReceive();
|
|
break;
|
|
case 5:
|
|
buyAgain();
|
|
break;
|
|
case 6:
|
|
cancelAfterSale();
|
|
break;
|
|
}
|
|
};
|
|
// 取消订单
|
|
const cancelOrder = () => {
|
|
let orderId = props.data?.id;
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: '确定要取消订单吗?',
|
|
confirmColor: '#FA7E31',
|
|
success: async function (res) {
|
|
if (!res.confirm) {
|
|
return;
|
|
}
|
|
|
|
upData();
|
|
const { code } = await OrderApi.cancelOrder(orderId);
|
|
if (code === 0) {
|
|
uni.showToast({
|
|
title: '订单已取消',
|
|
icon: 'none',
|
|
});
|
|
upData();
|
|
}
|
|
},
|
|
});
|
|
};
|
|
// 去付款
|
|
const payOrder = (id) => {
|
|
sheep.$router.go('/pages/pay/index', {
|
|
id: props.data.payOrderId,
|
|
});
|
|
};
|
|
// 申请售后
|
|
const applyAfterSale = () => {
|
|
const source = String(props?.data?.__source || props?.data?.source || '').trim();
|
|
sheep.$router.go('/pages/order/aftersale/apply', {
|
|
...props.data,
|
|
id: props?.data?.id,
|
|
orderId: props?.data?.id,
|
|
...(source ? { source } : {}),
|
|
});
|
|
};
|
|
// 确认收货
|
|
const confirmReceive = () => {
|
|
let change = false;
|
|
if (props.data?.items.length) {
|
|
props.data.items.forEach((item) => {
|
|
if (item.afterSaleStatus == 10) {
|
|
change = true;
|
|
return;
|
|
}
|
|
});
|
|
}
|
|
if (change) {
|
|
uni.showToast({
|
|
title: '有售后中的商品,请先处理完售后',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
}
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: '确认收货吗?',
|
|
confirmColor: '#FA7E31',
|
|
success: async function (res) {
|
|
if (!res.confirm) {
|
|
return;
|
|
}
|
|
// 正常的确认收货流程
|
|
const { code } = await OrderApi.receiveOrder(props.data?.id);
|
|
if (code === 0) {
|
|
upData();
|
|
}
|
|
},
|
|
});
|
|
};
|
|
// 再次购买
|
|
const buyAgain = () => {};
|
|
// 取消售后
|
|
const cancelAfterSale = () => {};
|
|
const upData = () => {
|
|
emit('downData');
|
|
};
|
|
</script>
|
|
<style scoped lang="scss">
|
|
.more {
|
|
}
|
|
|
|
.btn {
|
|
line-height: 24rpx;
|
|
padding: 10rpx 24rpx;
|
|
box-sizing: border-box;
|
|
border: 2rpx solid #999999;
|
|
border-radius: 10rpx;
|
|
margin-left: 12rpx;
|
|
color: #999999;
|
|
}
|
|
|
|
.btn1 {
|
|
// line-height: 74rpx;
|
|
// padding: 0 30rpx;
|
|
}
|
|
</style>
|