From b6496db8bd748ff7488207e5479f7e6a6d79cbcb Mon Sep 17 00:00:00 2001
From: weipengfei <2187978347@qq.com>
Date: Tue, 7 May 2024 13:39:08 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/order.js | 5 +
components/modal.vue | 4 +-
pagesOrder/detail/detail.vue | 53 ++++++--
pagesOrder/order/component/good.vue | 8 +-
pagesOrder/order/order.vue | 182 +++++++++++++++++++++-------
pagesOrder/settle/settle.vue | 17 +--
store/user.js | 4 +-
7 files changed, 204 insertions(+), 69 deletions(-)
diff --git a/api/order.js b/api/order.js
index 403eb0d..f227e97 100644
--- a/api/order.js
+++ b/api/order.js
@@ -23,4 +23,9 @@ export const rePaymentApi = (data)=>{
//订单数量统计
export const orderCountApi = (data)=>{
return request.post('/order/RetailOrder/order_count', data);
+}
+
+//取消订单
+export const cancelOrderApi = (data)=>{
+ return request.post('/order/RetailOrder/cancel_order', data);
}
\ No newline at end of file
diff --git a/components/modal.vue b/components/modal.vue
index e39a18f..fd831f5 100644
--- a/components/modal.vue
+++ b/components/modal.vue
@@ -4,8 +4,8 @@
{{title}}
{{content}}
- {{cancleText}}
- {{confirmText}}
+ {{cancleText}}
+ {{confirmText}}
diff --git a/pagesOrder/detail/detail.vue b/pagesOrder/detail/detail.vue
index 52080ec..ecb2049 100644
--- a/pagesOrder/detail/detail.vue
+++ b/pagesOrder/detail/detail.vue
@@ -104,7 +104,7 @@
取消订单
- 立即支付 ¥{{datas.total}}
+ 立即支付 ¥{{datas.total}}
@@ -128,17 +128,26 @@
import addressPopup from "@/components/addressPopup.vue";
import orderCanclePopup from "@/components/orderCanclePopup.vue";
import modal from "@/components/modal.vue";
- import { orderDetailApi, rePaymentApi } from "@/api/order.js"
+ import { orderDetailApi, cancelOrderApi, rePaymentApi } from "@/api/order.js"
import { addressListsApi, merchantListApi } from "@/api/user.js";
const showCancel = ref(false);
const submitCancel = (e) => {
showCancel.value = false;
- console.log(e);
- uni.showToast({
- title: '取消成功',
- icon: 'none'
+ cancelOrderApi({
+ order_id: datas.value.id,
+ value: e.value
+ }).then(res=>{
+ uni.showToast({
+ title: '取消成功',
+ icon: 'none'
+ })
+ uni.navigateBack({
+ success: () => {
+ uni.$emit('reLoadOrderList')
+ }
+ });
})
}
@@ -154,6 +163,8 @@
timer = setInterval(updateCountdown, 1000);
updateCountdown();
}
+ }).catch(err=>{
+ uni.navigateBack();
})
}
@@ -197,7 +208,35 @@
order_id: datas.value.id,
pay_type: 1
}).then(res=>{
- console.log(res);
+ if(!res.data?.nonceStr) return uni.$u.toast('支付失败!');
+ uni.requestPayment({
+ provider: 'wxpay',
+ timeStamp: res.data.timeStamp,
+ nonceStr: res.data.nonceStr,
+ package: res.data.package,
+ signType: res.data.signType,
+ paySign: res.data.paySign,
+ success: (e) => {
+ if(e.errMsg == 'requestPayment:ok'){
+ uni.showModal({
+ title: '订单支付成功',
+ confirmText: '确认',
+ success: (e) => {
+ uni.navigateBack({
+ success: () => {
+ uni.$emit('reLoadOrderList')
+ }
+ });
+ }
+ })
+ }else uni.$u.toast('支付失败')
+ },
+ fail: (e) => {
+ uni.$u.toast('用户取消支付')
+ }
+ })
+ }).catch(err=>{
+ uni.$u.toast('网络错误')
})
}
diff --git a/pagesOrder/order/component/good.vue b/pagesOrder/order/component/good.vue
index ba78298..4de4a00 100644
--- a/pagesOrder/order/component/good.vue
+++ b/pagesOrder/order/component/good.vue
@@ -27,7 +27,7 @@
取消订单
- 立即支付
+ 立即支付
@@ -67,10 +67,14 @@
})
}
- const emit = defineEmits(['cancleOrder']);
+ const emit = defineEmits(['cancleOrder', 'rePay']);
const cancleOrder = ()=>{
emit('cancleOrder', props.datas)
}
+
+ const rePay = ()=>{
+ emit('rePay', props.datas)
+ }
\ No newline at end of file
diff --git a/pagesOrder/settle/settle.vue b/pagesOrder/settle/settle.vue
index 7b280b3..8798bd5 100644
--- a/pagesOrder/settle/settle.vue
+++ b/pagesOrder/settle/settle.vue
@@ -111,7 +111,7 @@
- 提交订单
+ 提交订单
@@ -206,7 +206,6 @@
uni.$u.toast('定位失败, 请手动选择提货点!')
},
complete: (res) => {
- console.log("===", res);
myAddressInfo.value.long = res.longitude || "";
myAddressInfo.value.lat = res.latitude || "";
getMerchantList();
@@ -259,6 +258,7 @@
mer_id: shopInfo.value.mer_id,
pay_type: 1
}).then(res=>{
+ if(!res.data?.nonceStr) return uni.$u.toast('支付失败!');
uni.requestPayment({
provider: 'wxpay',
timeStamp: res.data.timeStamp,
@@ -285,17 +285,8 @@
uni.$u.toast('用户取消支付')
}
})
- // uni.showModal({
- // title: '订单支付成功',
- // confirmText: '查看订单',
- // cancelText: '继续购买',
- // success: (e) => {
- // if(e.confirm) uni.navigateTo({
- // url: '/pagesOrder/order/order'
- // })
- // else uni.navigateBack();
- // }
- // })
+ }).catch(err=>{
+ uni.$u.toast('网络错误')
})
}
diff --git a/store/user.js b/store/user.js
index bffa282..e677523 100644
--- a/store/user.js
+++ b/store/user.js
@@ -20,7 +20,7 @@ const useUserStore = defineStore("user", () => {
}
// #ifdef H5
- token.value = "31f74a72e2d05673ec14d2a6408718ef"
+ token.value = "f9421a985006bf3f73bbaff6193da353"
userInfo.value = {
avatar: "https://lihaiim.oss-cn-chengdu.aliyuncs.com/image/admin/default_avatar.png",
id: 9,
@@ -29,7 +29,7 @@ const useUserStore = defineStore("user", () => {
mobile: "19330904744",
nickname: "用户1714964250",
supplier: null,
- token: "33bb1ca5e6c98a6f948ad56b75471fb8"
+ token: "f9421a985006bf3f73bbaff6193da353"
}
// #endif