【订单详情】

1. 取消订单
2. 删除订单
pull/1/MERGE
YunaiV 2023-07-02 00:15:10 +08:00
parent 2aef6a4fe5
commit 00ed94c762
3 changed files with 110 additions and 94 deletions

View File

@ -32,6 +32,14 @@ export function getOrderPage(data) {
return request.get("app-api/trade/order/page", data);
}
export function cancelOrder(id) {
return request.delete("app-api/trade/order/cancel?id=" + id, {});
}
export function deleteOrder(id) {
return request.delete("app-api/trade/order/delete?id=" + id, {});
}
export function getOrderItem(id) {
return request.get("app-api/trade/order/item/get", {
id

View File

@ -327,6 +327,7 @@
import { mapGetters } from "vuex";
import dayjs from '@/plugin/dayjs/dayjs.min.js';
import * as Util from '@/utils/util.js';
import {cancelOrder, deleteOrder} from "../../api/trade/order";
export default {
components: {
payment,
@ -429,6 +430,64 @@
}, '/pages/users/order_list/index');
});
},
/**
* 打开支付组件
*/
goPay() {
uni.navigateTo({
url: `/pages/goods/cashier/index?order_id=${this.orderInfo.payOrderId}&from_type=order`
})
},
/**
* 取消订单
*/
cancelOrder() {
uni.showModal({
title: '提示',
content: '确认取消该订单?',
success: res => {
if (res.confirm) {
OrderApi.cancelOrder(this.orderInfo.id).then(() => {
this.$util.Tips({
title: '取消成功'
})
this.getOrderInfo();
}).catch((err) => {
this.$util.Tips({
title: err
})
this.getOrderInfo();
});
}
}
});
},
/**
* 删除订单
*/
delOrder: function() {
uni.showModal({
title: '提示',
content: '确认删除该订单?',
success: res => {
if (res.confirm) {
OrderApi.deleteOrder(this.orderInfo.id).then(() => {
this.$util.Tips({
title: '删除成功'
}, {
tab: 3,
url: '/pages/users/order_list/index'
})
}).catch((err) => {
this.$util.Tips({
title: err
})
this.getOrderInfo();
});
}
}
});
},
// TODO
@ -514,60 +573,6 @@
}
})
},
/**
* 打开支付组件
*/
goPay() {
uni.navigateTo({
url: `/pages/goods/cashier/index?order_id=${this.orderInfo.payOrderId}&from_type=order`
})
},
/**
* 删除订单
*/
delOrder: function() {
let that = this;
orderDel(this.id).then(res => {
return that.$util.Tips({
title: '删除成功',
icon: 'success'
}, {
tab: 3,
url: 1
});
}).catch(err => {
return that.$util.Tips({
title: err
});
});
},
cancelOrder() {
let self = this
uni.showModal({
title: '提示',
content: '确认取消该订单?',
success: function(res) {
if (res.confirm) {
orderCancel(self.orderInfo.id)
.then((data) => {
self.$util.Tips({
title: '取消成功'
}, {
tab: 3
})
})
.catch(() => {
self.$util.Tips({
title: err
})
self.getDetail();
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
// ========== ==========
/**

View File

@ -106,7 +106,6 @@
</view>
</template>
<script>
import { orderCancel, orderDel } from '@/api/order.js';
import { openOrderSubscribe } from '@/utils/SubscribeMessage.js';
import home from '@/components/home';
import payment from '@/components/payment';
@ -251,52 +250,56 @@
// #endif
},
/**
* 取消订单 TODO 芋艿未实现
* 取消订单
*/
cancelOrder: function(index, order_id) {
if (!order_id) {
return this.$util.Tips({
title: '缺少订单号无法取消订单'
});
}
uni.showLoading({
title: '正在删除中'
});
orderCancel(order_id).then(res => {
uni.hideLoading();
return this.$util.Tips({
title: '删除成功',
icon: 'success'
}, () => {
this.orderList.splice(index, 1);
this.$set(this, 'orderList', this.orderList);
this.$set(this.orderData, 'unpaid_count', this.orderData.unpaid_count - 1);
this.getOrderData();
});
}).catch(err => {
return this.$util.Tips({
title: err
});
uni.showModal({
title: '提示',
content: '确认取消该订单?',
success: res => {
if (res.confirm) {
OrderApi.cancelOrder(order_id).then(() => {
this.$util.Tips({
title: '取消成功'
}, () => {
this.orderList.splice(index, 1);
this.$set(this, 'orderList', this.orderList);
this.getOrderData();
})
}).catch((err) => {
this.$util.Tips({
title: err
})
});
}
}
});
},
/**
* 删除订单 TODO 芋艿未实现
* 删除订单
*/
delOrder: function(order_id, index) {
orderDel(order_id).then(res => {
this.orderList.splice(index, 1);
this.$set(this, 'orderList', this.orderList);
this.$set(this.orderData, 'unpaid_count', this.orderData.unpaid_count - 1);
this.getOrderData();
return this.$util.Tips({
title: '删除成功',
icon: 'success'
});
}).catch(err => {
return this.$util.Tips({
title: err
});
})
uni.showModal({
title: '提示',
content: '确认删除该订单?',
success: res => {
if (res.confirm) {
OrderApi.deleteOrder(order_id).then(() => {
this.$util.Tips({
title: '删除成功'
}, () => {
this.orderList.splice(index, 1);
this.$set(this, 'orderList', this.orderList);
this.getOrderData();
})
}).catch((err) => {
this.$util.Tips({
title: err
})
});
}
}
});
},
fen2yuan(price) {