优化余额支付返回,和长连接

This commit is contained in:
duan
2024-06-03 14:54:02 +08:00
parent 3d2fce5745
commit e2c096e65a
4 changed files with 85 additions and 25 deletions

View File

@@ -182,6 +182,24 @@
</template>
<script>
/** 扫码支付逻辑
* 进入该页面调用一次获取用户信息的接口
* 扫码后,未登录去登录
* 登录后链接wx接口拿到列表
* 下单后,通过切换微信\余额两种支付方式
* 余额支付点击立即付款获取userinfo中的字段是否设置支付密码。未设置去设置
* 如果设置发送数据通过wx接口获取creatdorder返回调用支付密码。。。
* 输入完支付密码后,接口返回
* 微信支付
*
*
*
* 接口/pay/accountPay
* 返回 code 都为0
* data -> 1 支付成功
* -> 2 余额不足
* ->3 未设置支付密码前后都做。根据userinfo的ispws做判断的。
**/
import webSocketUtils from '@/common/js/websocket.js'
import payPassword from '@/components/payPassword.vue'
export default {
@@ -219,11 +237,22 @@
this.listinfo = JSON.parse(e.tablelist)
// 获取余额
this.getAount()
// 获取用户信息,判断是否设置支付密码
this.getuserinfo()
},
onShow() {
this.getAount()
this.getuserinfo()
},
methods: {
async getuserinfo() {
let res = await this.api.loginwxuserInfo({
userId: uni.cache.get('userInfo').id
})
if (res.code == 0) {
uni.cache.set('userInfo', res.data);
}
},
groupChange(n) {
this.radiovalue1 = n
uni.cache.set('radiovalue1', n)
@@ -351,12 +380,16 @@
},
showpopupclickdd() {
// radiovalue1为1是微信支付
if (this.radiovalue1 == 1) {
this.showpopupclickdds() //微信支付
} else {
// 判断是否有绑定支付密码
// 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码
if (uni.cache.get('userInfo').isPwd == 0) {
let {
isPwd
} = uni.cache.get('userInfo')
// console.log(isPwd,'是否设置了支付密码')
if (isPwd == 0) {
uni.pro.navigateTo('/pages/user/repairpassword', {
shopId_id: uni.cache.get('shopUser')
})
@@ -411,32 +444,55 @@
let res = await this.api.accountPay({
orderId: this.listinfo.id,
memberId: this.amountVIP.id,
pwd: pwd
pwd
})
if (res.code == 0) {
uni.showToast({
icon: 'none',
title: '支付成功',
success: () => {
setTimeout(res => {
uni.cache.set('shopUser', '') //删除shopUser
uni.redirectTo({
url: '/pages/order/order_detail?orderId=' + this
.listinfo.id,
});
}, 500)
}
})
} else if (res.data == 1) {
setTimeout(() => {
// 去充值
this.goRecharge()
}, 2000)
// data ->1 支付成功
// ->2 余额不足
// ->3 未设置支付密码,
// ->4 不是会员,
if (res.data == 1) {
this.showToastUppop('支付成功')
setTimeout(res => {
uni.redirectTo({
url: '/pages/order/order_detail?orderId=' + this
.listinfo.id
});
}, 700)
} else if (res.data == 2) {
this.showToastUppop('余额不足')
setTimeout(() => {
// 去充值
this.goRecharge()
}, 1500)
} else if (res.data == 3) {
this.showToastUppop('未设置支付密码')
setTimeout(() => {
uni.pro.navigateTo('/pages/user/repairpassword', {
shopId_id: uni.cache.get('shopUser')
})
}, 1500)
} else if (res.data == 4) {
this.showToastUppop('非会员请充值')
setTimeout(() => {
// 去充值
this.goRecharge()
}, 1500)
}
}
},
showToastUppop(title) {
uni.showToast({
icon: 'none',
title,
success: () => {
}
})
},
clickselect(b) {
this.pay_type = b
},