更改下单页面

This commit is contained in:
魏啾
2024-05-31 17:26:02 +08:00
parent 65be66ba91
commit def9db0884
5 changed files with 870 additions and 147 deletions

View File

@@ -296,6 +296,14 @@
uni.$off('message')
},
onShow() {
// uni.onNetworkStatusChange((res) => { //监听网络状态变化
// if (!res.isConnected) {
// // 检查网络是否连接
// } else {
// console.log(res, 111);
// // ...这里写你的业务逻辑
// }
// });
setTimeout(() => {
if (uni.cache.get('token') && uni.cache.get('tableCode')) {
this.productqueryShopIdByTableCode() //获取shop User id
@@ -311,7 +319,7 @@
try {
if (res.data) {
let time = new Date
console.log(time,'时间戳')
console.log(time, '时间戳')
uni.cache.set('shopUser', res.data)
this.handlemessage()
}
@@ -341,16 +349,15 @@
this.productqueryProduct() //list 数据
break;
case 'clearCart':
console.log('clearCart')
this.specifications.duoguge = ''
this.skuidname = []
this.showCart = false
setTimeout(() => {
uni.showToast({
title: '清空购物车成功',
title: msg.msg,
icon: "none",
})
}, 1000)
}, 500)
this.cartLists = msg
this.productqueryProduct() //list 数据
break;
@@ -362,12 +369,12 @@
this.cartLists = msg
this.productqueryProduct() //list 数据
break;
// case 'createOrder': //去结算
// let item = JSON.stringify(msg.data)
// uni.redirectTo({
// url: '/pages/order_detail/order_detail?tableId=' + item
// });
// break;
case 'createOrder': //去结算
let item = JSON.stringify(msg.data)
uni.redirectTo({
url: '/pages/order_detail/order_detail?tablelist=' + item
});
break;
case 'queryCart': //待提交
// let queryCart = JSON.stringify(msg.data)
// uni.pro.navigateTo('order_detail/order_detail', {
@@ -400,12 +407,10 @@
}
},
handlemessage() {
console.log(this.socketTicket,'是否存在socketTicket1')
// 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)
console.log(this.socketTicket,'是否存在socketTicket3')
},
// 数据处理
socketSendMsg(data) {
@@ -574,31 +579,29 @@
}
uni.$u.debounce(this.socketSendMsg(data), 500)
}
} catch (e) {
uni.showToast({
title: '获取失败',
icon: "none",
})
}
} catch (e) {}
},
orderdetail() {
// uni.pro.navigateTo('order_detail/order_detail', {
// tableId: item
// })
// if (this.showCart) {
let data = { //定义socket数据传参
// let data = { //缓存的生成订单 //去结算
// "skuId": '',
// "num": '', //数量
// "type": "queryCart", //“addcart:添加购物车create0rder:生成订单clearCart:庆康购物车”,
// "productId": '', //商品id
// "shopId": uni.cache.get('shopUser'),
// "userId": uni.cache.get('userInfo').id
// }
let data = { // 直接生成订单
"skuId": '',
"num": '', //数量
"type": "queryCart", //“addcart:添加购物车create0rder:生成订单clearCart:庆康购物车”,
"type": "createOrder", //“addcart:添加购物车create0rder:生成订单clearCart:庆康购物车”,
"couponsId": '', //优惠券ID,
"isYhq": 0, // 是否使用优惠券( 1 使用, 0 不使用),
"isBuyYhq": 0, // 是否购买优惠券( 1 购买, 0 不够买)
"productId": '', //商品id
"shopId": uni.cache.get('shopUser'),
"userId": uni.cache.get('userInfo').id
"userId": uni.cache.get('userInfo').id,
}
uni.$u.debounce(this.socketSendMsg(data), 500)
// } else {
// this.showCart = true
// }
},
orderfoodindex() {
uni.pro.navigateTo('index/coupons/index', {