This commit is contained in:
duan
2024-05-23 13:50:20 +08:00
parent d0cf4a5cc6
commit ac11e4fcc0
3 changed files with 59 additions and 21 deletions

View File

@@ -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);

View File

@@ -82,10 +82,10 @@
<view>
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/hongbao.png"
style="width: 30rpx;height: 30.24rpx;;" mode=""></image>
红包/低佣
红包/抵用
</view>
<view @click="orderfoodindex">
<!-- {{info.couponDetail.name}} -->
可用优惠券{{couponAmount}}
</view>
</view>
<!-- 支付方式 -->
@@ -118,7 +118,8 @@
</u-radio>
</u-radio-group>
<view style="font-weight: 400;font-size: 24rpx;color: #333333;margin-left: 60rpx;">
会员卡余额{{ amountVIP.amount}} <text style="font-weight: 500;font-size: 28rpx;margin-left: 16rpx;color: #FF4C11;"
会员卡余额{{ amountVIP.amount}} <text
style="font-weight: 500;font-size: 28rpx;margin-left: 16rpx;color: #FF4C11;"
@click="goRecharge">去充值</text>
</view>
</view>
@@ -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
@@ -399,9 +424,18 @@ this.getAount()
console.log(data, '成功与否')
}
});
} else {
// 判断是否有绑定支付密码
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
}

View File

@@ -31,7 +31,7 @@
<view>
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/hongbao.png"
style="width: 30rpx;height: 30.24rpx;;" mode=""></image>
红包/低佣
红包/抵用
</view>
<view>
{{info.couponDetail.name}}