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) { shopUserInfo(data) {
return uni.api.get("/user/shopUserInfo", data); return uni.api.get("/user/shopUserInfo", data);
}, },
// 优惠券数量
userCoupon(data) {
return uni.api.get("/user/userCoupon", data);
},
// 优惠加倍 // 优惠加倍
yhqDouble(data) { //查询订单支付状态 yhqDouble(data) { //查询订单支付状态
return uni.api.post("/order/yhqDouble", data); return uni.api.post("/order/yhqDouble", data);

View File

@@ -82,10 +82,10 @@
<view> <view>
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/hongbao.png" <image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/hongbao.png"
style="width: 30rpx;height: 30.24rpx;;" mode=""></image> style="width: 30rpx;height: 30.24rpx;;" mode=""></image>
红包/低佣 红包/抵用
</view> </view>
<view @click="orderfoodindex"> <view @click="orderfoodindex">
<!-- {{info.couponDetail.name}} --> 可用优惠券{{couponAmount}}
</view> </view>
</view> </view>
<!-- 支付方式 --> <!-- 支付方式 -->
@@ -118,7 +118,8 @@
</u-radio> </u-radio>
</u-radio-group> </u-radio-group>
<view style="font-weight: 400;font-size: 24rpx;color: #333333;margin-left: 60rpx;"> <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> @click="goRecharge">去充值</text>
</view> </view>
</view> </view>
@@ -197,7 +198,9 @@
amountVIP: null, amountVIP: null,
radiovalue1: '1', radiovalue1: '1',
vipId: null, vipId: null,
orderInfo: '' orderInfo: '',
// 可用优惠券数据
couponAmount: 0
}; };
}, },
@@ -213,9 +216,10 @@
this.handlemessage() this.handlemessage()
uni.$on('message', this.getMessage) uni.$on('message', this.getMessage)
// 获取余额 // 获取余额
this.getAount() this.getAount()
// 获取可用优惠券数量
this.getcoupon()
this.vipId = uni.cache.get('userInfo').id this.vipId = uni.cache.get('userInfo').id
}, },
onShow() { onShow() {
@@ -223,32 +227,39 @@ this.getAount()
}, },
created() { created() {
uni.$on('emitclickorderfood', (num) => { uni.$on('emitclickorderfood', (num) => {
console.log(num) // 总金额 couponsAmount 优惠卷购买金额 couponsPrice优惠金额 等于1是团购/不等于1
// 总金额 couponsAmount 优惠卷购买金额 couponsPrice优惠金额
if (num.clickiconone == 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 { } else {
this.listinfo.amount = (Number(this.listinfo.amounts) + Number(num.couponsAmount) - Number(num this.listinfo.amount = (Number(this.listinfo.amounts) - Number(num.couponsAmount)).toFixed(2)
.couponsPrice)).toFixed(2)
} }
this.emitorderfoodform = num this.emitorderfoodform = num
// this.num += num // this.num += num
}) })
}, },
methods: { 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({ let res = await this.api.shopUserInfo({
// shopId:店铺ID // shopId:店铺ID
"shopId": uni.cache.get('shopUser'), "shopId": uni.cache.get('shopUser'),
"userId": uni.cache.get('userInfo').id, "userId": uni.cache.get('userInfo').id,
}) })
if(res.code==0){ if (res.code == 0) {
this.amountVIP = res.data this.amountVIP = res.data
} }
}, },
getMessage(msg) { getMessage(msg) {
console.log('tiaoshi1', msg)
if (msg.status != 'success') { if (msg.status != 'success') {
uni.showToast({ uni.showToast({
title: msg.msg, title: msg.msg,
@@ -260,7 +271,6 @@ this.getAount()
} else { } else {
switch (msg.type) { switch (msg.type) {
case 'createOrder': //去结算 case 'createOrder': //去结算
console.log('tiaoshi2', msg)
this.listinfoid = msg.data.id //下单需要的id this.listinfoid = msg.data.id //下单需要的id
this.orderInfo = msg.data this.orderInfo = msg.data
this.showpopupclickdd() this.showpopupclickdd()
@@ -330,23 +340,38 @@ this.getAount()
}, },
// 去充值 // 去充值
goRecharge() { goRecharge() {
uni.pro.navigateTo('/pages/member/index') uni.pro.navigateTo('/pages/member/index', {
shopId_id: uni.cache.get('shopUser')
})
}, },
// 余额支付 // 余额支付
async accountPayevent(id) { async accountPayevent(id) {
console.log(this.amountVIP, '会员信息')
let res = await this.api.accountPay({ let res = await this.api.accountPay({
orderId: id, orderId: id,
memberId: this.vipId memberId: this.vipId
}) })
console.log(res, '调试12') console.log(res, '调试12')
if (res) { if (res) {
this.ispayPws()
} else { } else {
setTimeout(() => { setTimeout(() => {
this.goRecharge() this.goRecharge()
}, 1000) }, 1000)
} }
}, },
// 是否有支付密码
ispayPws() {
// 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码
if (this.amountVIP.isPwd == 0) {
uni.pro.navigateTo('/pages/user/repairpassword', {
shopId_id: uni.cache.get('shopUser')
})
} else {
}
},
async showpopupclickdd(i) { async showpopupclickdd(i) {
let res = await this.api.payorderPay({ let res = await this.api.payorderPay({
orderId: this.listinfoid orderId: this.listinfoid
@@ -400,7 +425,16 @@ this.getAount()
} }
}); });
} else { } 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 // #endif

View File

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