优化问题

This commit is contained in:
duan
2024-05-30 09:12:02 +08:00
parent 66e15baaee
commit cb7d853707
8 changed files with 296 additions and 146 deletions

View File

@@ -94,7 +94,8 @@
支付方式
</view>
<view class="">
<u-radio-group v-model="radiovalue1" iconPlacement="right" :size="28" placement="column">
<u-radio-group v-model="radiovalue1" iconPlacement="right" @change="groupChange" :size="28"
placement="column">
<u-radio activeColor="#ffd158" name="1">
<view class="dfs">
<image style="width:44rpx;height:44rpx"
@@ -177,7 +178,7 @@
</view>
</view>
<!-- 支付密码 -->
<payPassword ref="payPwd" @accountPayevent="accountPayevent" v-show="ispws"></payPassword>
<payPassword ref="payPwd" @accountPayevent="accountPayevent" v-if="ispws"></payPassword>
</view>
</template>
@@ -215,13 +216,10 @@
onUnload() {
uni.$off('getMessage')
// uni.showToast({
// title: this.radiovalue1 + '-110',
// duration:5000
// })
this.ispws = false
},
onLoad(e) {
// console.log(e, 140)
let res = JSON.parse(e.tableId)
this.listinfo.detailList = res
@@ -254,6 +252,11 @@
})
},
methods: {
groupChange(n) {
// console.log('groupChange', n);
this.radiovalue1 = n
uni.cache.set('radiovalue1',n)
},
// fangdouevent() {
// this.$u.debounce(() => {
// this.showpopupclick()
@@ -269,6 +272,7 @@
}
},
async getAount() {
console.log(uni.cache.get('userInfo'), '余额中userId不显示打印')
let res = await this.api.shopUserInfo({
// shopId:店铺ID
"shopId": uni.cache.get('shopUser'),
@@ -280,7 +284,6 @@
}
},
getMessage(msg) {
if (msg.status != 'success') {
uni.showToast({
title: msg.msg,
@@ -288,23 +291,17 @@
})
this.socketTicket.Close()
uni.$off('getMessage')
return false;
} else {
switch (msg.type) {
case 'createOrder': //去结算
this.listinfoid = msg.data.id //下单需要的id
this.orderInfo = msg.data
this.showpopupclickdd()
// let item = JSON.stringify(msg.data)
// uni.redirectTo({
// url: '/pages/order_detail/order_detail?tableId=' + item
// });
break;
}
console.log(msg, 'socke返回数据')
} else if (msg.type == 'createOrder') {
console.log(msg, 'createOrder执行')
this.listinfoid = msg.data.id //下单需要的id
this.orderInfo = msg.data
this.showpopupclickdd()
}
},
handlemessage() {
this.socketTicket ? this.socketTicket.Close() : null //调用前先判断是否有socket正在进行 先关闭后链接
// this.socketTicket ? this.socketTicket.Close() : null //调用前先判断是否有socket正在进行 先关闭后链接
this.socketTicket = new webSocketUtils(
`${uni.conf.baseUrlwws}/websocket/table/${uni.cache.get('tableCode')}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`,
5000)
@@ -358,65 +355,14 @@
// 去充值
goRecharge() {
uni.pro.navigateTo('/pages/member/index', {
shopId_id: uni.cache.get('shopUser')
shopId_id: this.amountVIP.shopId
})
},
async showpopupclickdd(i) {
showpopupclickdd(i) {
console.log(this.radiovalue1, 'radiovalue1的值')
if (this.radiovalue1 == 1) {
let res = await this.api.payorderPay({
orderId: this.listinfoid
}) //判断是否支付成功
if (res.code == 0) {
// uni.showLoading({
// title: '加载中',
// mask: true
// })
// #ifdef MP-WEIXIN
// 微信支付还是余额支付
uni.requestPayment({
provider: 'wxpay', //支付类型-固定值
partnerid: res.data.appId, // 微信支付商户号
timeStamp: res.data.timeStamp, // 时间戳(单位:秒)
nonceStr: res.data.nonceStr, // 随机字符串
package: res.data.package, // 固定值
signType: res.data.signType, //固定值
paySign: res.data.paySign, //签名
success: (res) => {
uni.showToast({
title: "支付成功"
})
uni.cache.set('shopUser', '') //删除shopUser
this.paymodfiyOrderInfo()
setTimeout(res => {
uni.redirectTo({
url: '/pages/order/successful?orderId=' + this
.listinfoid + '&orderInfo=' + JSON.stringify(
this.orderInfo) + '&payType' + this
.radiovalue1
});
}, 1000)
// uni.redirectTo({
// url: "/pages/mall/order/ordersuccess?id=" + datareslane.data
// .order_id,
// });
},
fail: (err) => {
uni.showToast({
icon: 'none',
title: '支付失败'
})
uni.hideLoading()
// uni.redirectTo({
// url: '/pages/order/order_detail?orderId=' + this.listinfoid
// });
},
complete: (data) => {
console.log(data, '成功与否')
}
});
// #endif
}
this.showpopupclickdds()
} else {
// 判断是否有绑定支付密码
// 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码
@@ -433,6 +379,63 @@
}
}
},
// 微信支付
async showpopupclickdds() {
let res = await this.api.payorderPay({
orderId: this.listinfoid
}) //判断是否支付成功
if (res.code == 0) {
// uni.showLoading({
// title: '加载中',
// mask: true
// })
// #ifdef MP-WEIXIN
// 微信支付还是余额支付
uni.requestPayment({
provider: 'wxpay', //支付类型-固定值
partnerid: res.data.appId, // 微信支付商户号
timeStamp: res.data.timeStamp, // 时间戳(单位:秒)
nonceStr: res.data.nonceStr, // 随机字符串
package: res.data.package, // 固定值
signType: res.data.signType, //固定值
paySign: res.data.paySign, //签名
success: (res) => {
uni.showToast({
title: "支付成功"
})
uni.cache.set('shopUser', '') //删除shopUser
this.paymodfiyOrderInfo()
setTimeout(res => {
uni.redirectTo({
url: '/pages/order/successful?orderId=' + this
.listinfoid + '&orderInfo=' + JSON.stringify(
this.orderInfo) + '&payType' + this
.radiovalue1
});
}, 1000)
// uni.redirectTo({
// url: "/pages/mall/order/ordersuccess?id=" + datareslane.data
// .order_id,
// });
},
fail: (err) => {
uni.showToast({
icon: 'none',
title: '支付失败'
})
// uni.hideLoading()
// uni.redirectTo({
// url: '/pages/order/order_detail?orderId=' + this.listinfoid
// });
},
complete: (data) => {
console.log(data, '成功与否')
}
});
// #endif
}
},
// 余额支付
async accountPayevent(pwd) {
this.ispws = false