From ac11e4fcc0e002df15d81e056101fdfaa715f084 Mon Sep 17 00:00:00 2001
From: duan <1004387497@qq.com>
Date: Thu, 23 May 2024 13:50:20 +0800
Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/js/api.js | 4 ++
pages/order_detail/order_detail.vue | 74 +++++++++++++++++++++--------
pages/product/placeOrder.vue | 2 +-
3 files changed, 59 insertions(+), 21 deletions(-)
diff --git a/common/js/api.js b/common/js/api.js
index 598dcac..13ba547 100644
--- a/common/js/api.js
+++ b/common/js/api.js
@@ -71,6 +71,10 @@ export default {
shopUserInfo(data) {
return uni.api.get("/user/shopUserInfo", data);
},
+ // 优惠券数量
+ userCoupon(data) {
+ return uni.api.get("/user/userCoupon", data);
+ },
// 优惠加倍
yhqDouble(data) { //查询订单支付状态
return uni.api.post("/order/yhqDouble", data);
diff --git a/pages/order_detail/order_detail.vue b/pages/order_detail/order_detail.vue
index 3dee1c0..50b08a2 100644
--- a/pages/order_detail/order_detail.vue
+++ b/pages/order_detail/order_detail.vue
@@ -82,10 +82,10 @@
- 红包/低佣券
+ 红包/抵用券
-
+ 可用优惠券{{couponAmount}}张
@@ -118,7 +118,8 @@
- 会员卡余额{{ amountVIP.amount}} 去充值
@@ -197,7 +198,9 @@
amountVIP: null,
radiovalue1: '1',
vipId: null,
- orderInfo: ''
+ orderInfo: '',
+ // 可用优惠券数据
+ couponAmount: 0
};
},
@@ -213,9 +216,10 @@
this.handlemessage()
uni.$on('message', this.getMessage)
-// 获取余额
-this.getAount()
-
+ // 获取余额
+ this.getAount()
+ // 获取可用优惠券数量
+ this.getcoupon()
this.vipId = uni.cache.get('userInfo').id
},
onShow() {
@@ -223,32 +227,39 @@ this.getAount()
},
created() {
uni.$on('emitclickorderfood', (num) => {
- console.log(num)
- // 总金额 couponsAmount 优惠卷购买金额 couponsPrice优惠金额
+ // 总金额 couponsAmount 优惠卷购买金额 couponsPrice优惠金额 等于1是团购/不等于1
if (num.clickiconone == 1) {
- this.listinfo.amount = (Number(this.listinfo.amounts) - Number(num.couponsPrice)).toFixed(2)
+ this.listinfo.amount = (Number(this.listinfo.amounts) + Number(num.couponsPrice) - Number(num
+ .couponsAmount)).toFixed(2)
} else {
- this.listinfo.amount = (Number(this.listinfo.amounts) + Number(num.couponsAmount) - Number(num
- .couponsPrice)).toFixed(2)
+ this.listinfo.amount = (Number(this.listinfo.amounts) - Number(num.couponsAmount)).toFixed(2)
}
this.emitorderfoodform = num
// this.num += num
})
},
methods: {
- async getAount(){
+ async getcoupon() {
+ let res = await this.api.userCoupon({
+ "orderNum": this.listinfo.amount,
+ "userId": uni.cache.get('userInfo').id,
+ })
+ if (res.code == 0) {
+ this.couponAmount = res.data
+ }
+ },
+ async getAount() {
let res = await this.api.shopUserInfo({
// shopId:店铺ID
"shopId": uni.cache.get('shopUser'),
"userId": uni.cache.get('userInfo').id,
})
- if(res.code==0){
-
+ if (res.code == 0) {
+
this.amountVIP = res.data
}
},
getMessage(msg) {
- console.log('tiaoshi1', msg)
if (msg.status != 'success') {
uni.showToast({
title: msg.msg,
@@ -260,7 +271,6 @@ this.getAount()
} else {
switch (msg.type) {
case 'createOrder': //去结算
- console.log('tiaoshi2', msg)
this.listinfoid = msg.data.id //下单需要的id
this.orderInfo = msg.data
this.showpopupclickdd()
@@ -330,23 +340,38 @@ this.getAount()
},
// 去充值
goRecharge() {
- uni.pro.navigateTo('/pages/member/index')
+ uni.pro.navigateTo('/pages/member/index', {
+ shopId_id: uni.cache.get('shopUser')
+ })
},
// 余额支付
async accountPayevent(id) {
+ console.log(this.amountVIP, '会员信息')
+
let res = await this.api.accountPay({
orderId: id,
memberId: this.vipId
})
console.log(res, '调试12')
if (res) {
-
+ this.ispayPws()
} else {
setTimeout(() => {
this.goRecharge()
}, 1000)
}
},
+ // 是否有支付密码
+ ispayPws() {
+ // 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码
+ if (this.amountVIP.isPwd == 0) {
+ uni.pro.navigateTo('/pages/user/repairpassword', {
+ shopId_id: uni.cache.get('shopUser')
+ })
+ } else {
+
+ }
+ },
async showpopupclickdd(i) {
let res = await this.api.payorderPay({
orderId: this.listinfoid
@@ -400,7 +425,16 @@ this.getAount()
}
});
} else {
- this.accountPayevent(this.listinfoid)
+ // 判断是否有绑定支付密码
+ let isVip = uni.cache.get('userInfo').isPwd
+ console.log(isVip,'调试 123')
+ if (isVip == 0) {
+ uni.pro.navigateTo('/pages/user/repairpassword', {
+ shopId_id: uni.cache.get('shopUser')
+ })
+ } else {
+ this.accountPayevent(this.listinfoid)
+ }
}
// #endif
diff --git a/pages/product/placeOrder.vue b/pages/product/placeOrder.vue
index 3fa5e09..36c8e68 100644
--- a/pages/product/placeOrder.vue
+++ b/pages/product/placeOrder.vue
@@ -31,7 +31,7 @@
- 红包/低佣券
+ 红包/抵用券
{{info.couponDetail.name}}