更新优化

This commit is contained in:
魏啾
2024-06-14 18:30:19 +08:00
parent 139e4039a5
commit cba4e6065e
20 changed files with 94 additions and 258 deletions

View File

@@ -220,7 +220,6 @@
},
onLoad(e) {
// console.log(e, 140)
this.$store.dispatch("set_shopid"); //获取shapid
let res = JSON.parse(e.tableId)
this.listinfo.detailList = res
this.listinfo.amount = e.amount // 算完了的价格

View File

@@ -183,24 +183,6 @@
</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 {
@@ -231,39 +213,19 @@
},
onUnload() {
// uni.switchTab({
// url: '/pages/order/order'
// })
uni.$off('getMessage')
this.ispws = false
},
onLoad(e) {
this.listinfo = JSON.parse(e.tablelist)
// 获取余额
// this.getAount()
// 获取用户信息,判断是否设置支付密码
this.getuserinfo()
},
onShow() {
// this.$store.dispatch("set_shopid"); //获取shapid
// 获取余额
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)
},
async getcoupon() {
let res = await this.api.userCoupon({
@@ -276,12 +238,10 @@
},
async getAount() {
let res = await this.api.shopUserInfo({
// shopId:店铺ID
"shopId": this.$store.state.shopId,
"shopId": uni.cache.get('shopUser'),
"userId": uni.cache.get('userInfo').id,
})
if (res.code == 0) {
this.amountVIP = res.data
}
},
@@ -293,35 +253,16 @@
})
this.socketTicket.Close()
uni.$off('getMessage')
console.log(msg, 'socke返回数据')
} else if (msg.type == 'createOrder') {
console.log(msg, 'createOrder执行')
this.listinfoid = msg.data.id //下单需要的id
this.orderInfo = msg.data
if (this.radiovalue1 == 1) {
this.showpopupclickdds() //微信支付
// this.showpopupclickdds() //微信支付
}
}
},
handlemessage() {
console.log(this.socketTicket, 'detail页面')
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)
this.socketTicket = new webSocketUtils(
`${uni.conf.baseUrlwws}`,
5000, {
tableId: uni.cache.get('tableCode'),
shopId: uni.cache.get('shopUser'),
userId: uni.cache.get('userInfo').id,
"type": "connect",
})
},
// 数据处理
socketSendMsg(data) {
if (this.socketTicket) {
@@ -351,54 +292,13 @@
orderId: this.listinfo.id,
})
},
creactorder() {
let data = { //定义socket数据传参
"skuId": '',
"num": '', //数量
"type": "createOrder", //“addcart:添加购物车create0rder:生成订单clearCart:庆康购物车”,
"couponsId": this.emitorderfoodform.id ? this.emitorderfoodform.id : '', //优惠券ID,
"isYhq": this.emitorderfoodform.id ? 1 : 0, // 是否使用优惠券( 1 使用, 0 不使用),
"isBuyYhq": this.emitorderfoodform.clickiconone == 1 ? 1 : 0, // 是否购买优惠券( 1 购买, 0 不够买)
"productId": '', //商品id
"shopId": this.$store.state.shopId,
"userId": uni.cache.get('userInfo').id,
// tableId:uni.cache.get('tableCode')
}
let res = 0
if (res.code == 0) {
this.listinfoid = msg.data.id //下单需要的id
this.orderInfo = msg.data
if (this.radiovalue1 == 1) {
this.showpopupclickdds() //微信支付
}
}
},
// 去结算
showpopupclick() {
let data = { //定义socket数据传参
"skuId": '',
"num": '', //数量
"type": "createOrder", //“addcart:添加购物车create0rder:生成订单clearCart:庆康购物车”,
"couponsId": this.emitorderfoodform.id ? this.emitorderfoodform.id : '', //优惠券ID,
"isYhq": this.emitorderfoodform.id ? 1 : 0, // 是否使用优惠券( 1 使用, 0 不使用),
"isBuyYhq": this.emitorderfoodform.clickiconone == 1 ? 1 : 0, // 是否购买优惠券( 1 购买, 0 不够买)
"productId": '', //商品id
"shopId": this.$store.state.shopId,
"userId": uni.cache.get('userInfo').id,
// tableId:uni.cache.get('tableCode')
}
this.socketSendMsg(data)
},
// 去充值
goRecharge() {
uni.pro.navigateTo('/pages/member/index', {
shopId: this.amountVIP.shopId
shopId: uni.cache.get('shopUser')
})
},
showpopupclickdd() {
// radiovalue1为1是微信支付
if (this.radiovalue1 == 1) {
this.showpopupclickdds() //微信支付
@@ -426,10 +326,10 @@
orderId: this.listinfo.id
}) //判断是否支付成功
if (res.code == 0) {
// uni.showLoading({
// title: '加载中',
// mask: true
// })
uni.showLoading({
title: '加载中',
mask: true
})
// #ifdef MP-WEIXIN
// 微信支付还是余额支付
uni.requestPayment({
@@ -451,14 +351,19 @@
uni.cache.set('shopUser', '') //删除shopUser
_this.paymodfiyOrderInfo()
uni.redirectTo({
url: '/pages/order/order_detail?orderId=' + _this
url: '/pages/order/order_detail?orderId=' +
_this
.listinfo.id
});
},
})
},
fail: () => {
uni.hideLoading()
}
});
// #endif
uni.hideLoading()
}
},
// 余额支付