合并扫码点餐
This commit is contained in:
@@ -267,15 +267,33 @@
|
||||
}
|
||||
this.countScrollTitle(e.scrollTop);
|
||||
},
|
||||
onLoad(e) {
|
||||
uni.$on('message', this.getMessage)
|
||||
async onLoad(e) {
|
||||
if (e.q) {
|
||||
this.scanCodehandle(e.q)
|
||||
this.tableCode = this.getQueryString(decodeURIComponent(e.q), 'code')
|
||||
uni.cache.set('tableCode', this.tableCode)
|
||||
// this.scanCodehandle()
|
||||
} else {
|
||||
this.tableCode = e.tableCode
|
||||
uni.cache.set('tableCode', this.tableCode)
|
||||
this.handlemessage()
|
||||
// this.handlemessage()
|
||||
}
|
||||
let res = await this.api.productqueryShopIdByTableCode({
|
||||
code: uni.cache.get('tableCode')
|
||||
})
|
||||
try {
|
||||
if (res.data) {
|
||||
uni.cache.set('shopUser', res.data)
|
||||
if (e.q) {
|
||||
this.scanCodehandle()
|
||||
} else {
|
||||
this.handlemessage()
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
uni.$on('message', this.getMessage)
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.countTitleTopNum();
|
||||
});
|
||||
@@ -326,18 +344,15 @@
|
||||
this.productqueryProduct() //list 数据
|
||||
break;
|
||||
case 'createOrder': //去结算
|
||||
// uni.$emit('createOrdermessage', msg.data)
|
||||
let item = JSON.stringify(msg.data)
|
||||
uni.redirectTo({
|
||||
url: '/pages/order_detail/order_detail?tableId=' + item
|
||||
});
|
||||
break;
|
||||
case 'addcart':
|
||||
console.log('addcart', 315)
|
||||
this.cartLists = msg
|
||||
if (msg.data.length != 0) {
|
||||
msg.data.forEach((item, index, arr) => { //初始化skuidname的数据 选择第一个
|
||||
console.log(item.skuId, 111111, this.skuidsearch)
|
||||
if (item.skuId == this.skuidsearch) {
|
||||
this.$set(this, 'amountcartNumber', item.number)
|
||||
} else {
|
||||
@@ -350,7 +365,6 @@
|
||||
this.productqueryProduct() //list 数据
|
||||
break;
|
||||
default:
|
||||
console.log('default', 320)
|
||||
this.cartLists = msg
|
||||
this.productqueryProduct() //list 数据
|
||||
}
|
||||
@@ -359,7 +373,7 @@
|
||||
handlemessage() {
|
||||
this.socketTicket ? this.socketTicket.Close() : null //调用前先判断是否有socket正在进行 先关闭后链接
|
||||
this.socketTicket = new webSocketUtils(
|
||||
`${uni.conf.baseUrlwws}/websocket/table/${this.tableCode}/${uni.cache.get('shopUser').shopId}/${uni.cache.get('userInfo').id}`,
|
||||
`${uni.conf.baseUrlwws}/websocket/table/${this.tableCode}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`,
|
||||
5000)
|
||||
|
||||
},
|
||||
@@ -370,8 +384,7 @@
|
||||
}
|
||||
},
|
||||
scanCodehandle(e) {
|
||||
this.tableCode = this.getQueryString(decodeURIComponent(e), 'code')
|
||||
uni.cache.set('tableCode', this.tableCode)
|
||||
|
||||
// #ifdef MP-WEIXIN || MP-ALIPAY
|
||||
uni.login({ //alipay weixin
|
||||
provider: 'weixin',
|
||||
@@ -395,7 +408,7 @@
|
||||
uni.cache.set('miniAppOpenId', res.data.userInfo
|
||||
.miniAppOpenId)
|
||||
uni.cache.set('userInfo', res.data.userInfo);
|
||||
uni.cache.set('shopUser', res.data.shopUser);
|
||||
// uni.cache.set('shopUser', res.data.shopUser);
|
||||
this.handlemessage()
|
||||
}
|
||||
},
|
||||
@@ -435,7 +448,7 @@
|
||||
"num": a == '-' ? -1 : 1, //skuId
|
||||
"type": "addcart", //“addcart:添加购物车,create0rder:生成订单,clearCart:清空购物车”,
|
||||
"productId": item.id, //商品id
|
||||
"shopId": uni.cache.get('shopUser').shopId,
|
||||
"shopId": uni.cache.get('shopUser'),
|
||||
"userId": uni.cache.get('userInfo').id
|
||||
};
|
||||
uni.$u.debounce(this.socketSendMsg(data), 500)
|
||||
@@ -499,7 +512,7 @@
|
||||
async hodgepodge(item, a, c) { //去获取商品id 库存等
|
||||
try {
|
||||
let res = await this.api.productqueryProductSku({
|
||||
shopId: uni.cache.get('shopUser').shopId,
|
||||
shopId: uni.cache.get('shopUser'),
|
||||
productId: item.id, //商品id
|
||||
spec_tag: this.skuidname.join(",")
|
||||
})
|
||||
@@ -518,7 +531,7 @@
|
||||
"num": c == '-' ? -1 : 1, //数量
|
||||
"type": "addcart", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
|
||||
"productId": item.id, //商品id
|
||||
"shopId": uni.cache.get('shopUser').shopId,
|
||||
"shopId": uni.cache.get('shopUser'),
|
||||
"userId": uni.cache.get('userInfo').id
|
||||
};
|
||||
} else {
|
||||
@@ -527,7 +540,7 @@
|
||||
"num": '', //数量
|
||||
"type": "sku", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
|
||||
"productId": item.id, //商品id
|
||||
"shopId": uni.cache.get('shopUser').shopId,
|
||||
"shopId": uni.cache.get('shopUser'),
|
||||
"userId": uni.cache.get('userInfo').id
|
||||
};
|
||||
}
|
||||
@@ -546,7 +559,7 @@
|
||||
"num": '', //数量
|
||||
"type": "createOrder", //“addcart:添加购物车,create0rder:生成订单,clearCart:庆康购物车”,
|
||||
"productId": '', //商品id
|
||||
"shopId": uni.cache.get('shopUser').shopId,
|
||||
"shopId": uni.cache.get('shopUser'),
|
||||
"userId": uni.cache.get('userInfo').id
|
||||
}
|
||||
uni.$u.debounce(this.socketSendMsg(data), 500)
|
||||
@@ -559,7 +572,7 @@
|
||||
"num": '', //skuId
|
||||
"type": "clearCart", //“addcart:添加购物车,create0rder:生成订单,clearCart:清空购物车”,
|
||||
"productId": '', //商品id
|
||||
"shopId": uni.cache.get('shopUser').shopId,
|
||||
"shopId": uni.cache.get('shopUser'),
|
||||
"userId": uni.cache.get('userInfo').id
|
||||
};
|
||||
uni.$u.debounce(this.socketSendMsg(data), 500)
|
||||
|
||||
Reference in New Issue
Block a user