From b1e0dfb3529061eb9151dac684d5d8371be54606 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=AD=8F=E5=95=BE?= <1144797966@qq.com>
Date: Fri, 10 May 2024 10:59:34 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=89=AB=E7=A0=81=E7=82=B9?=
=?UTF-8?q?=E9=A4=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/js/api.js | 3 +
pages/index/components/diamond.vue | 41 ++---
pages/index/index - 副本.vue | 267 ++++++++++++++++++++++++++++
pages/member/index.vue | 2 +-
pages/order_detail/order_detail.vue | 2 +-
pages/order_food/order_food.vue | 49 +++--
6 files changed, 320 insertions(+), 44 deletions(-)
create mode 100644 pages/index/index - 副本.vue
diff --git a/common/js/api.js b/common/js/api.js
index 03fc904..bf078f0 100644
--- a/common/js/api.js
+++ b/common/js/api.js
@@ -111,4 +111,7 @@ export default {
loginOut(data) { //退出登录
return uni.api.post("/loginOut", data);
},
+ productqueryShopIdByTableCode(data) { //通过桌码获取shopId
+ return uni.api.get("/product/queryShopIdByTableCode", data);
+ },
}
\ No newline at end of file
diff --git a/pages/index/components/diamond.vue b/pages/index/components/diamond.vue
index c49de6b..1eed5df 100644
--- a/pages/index/components/diamond.vue
+++ b/pages/index/components/diamond.vue
@@ -38,42 +38,35 @@
});
break;
case 'relative':
- uni.pro.navigateTo(item.absUrl,item);
+ uni.pro.navigateTo(item.absUrl, item);
break;
case 'scan':
if (!uni.utils.pluschooseImage()) {
return false
}
- // #ifdef H5
- if (this.wxSdk) {
- wx.scanQRCode({
- needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
- scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
- success: res => {
- // 当needResult 为 1 时,扫码返回的结果
- console.log(res.resultStr, res)
- }
- });
- } else {
- uni.showModal({
- title: '注意',
- content: '微信sdk初始化失败,请重新加载',
- success: res => {
- window.location.reload();
- }
- });
- }
- // #endif
// #ifdef APP || MP-WEIXIN
uni.scanCode({
- success: res => {
- console.log(res.result, res)
+ success: (res) => {
+ let tableCode = this.getQueryString(decodeURIComponent(res.result), 'code')
+ if (tableCode) {
+ uni.pro.navigateTo('order_food/order_food', {
+ tableCode: tableCode,
+ })
+ }
}
});
// #endif
break;
}
- }
+ },
+ getQueryString(url, name) { //解码
+ var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
+ var r = url.substr(1).match(reg)
+ if (r != null) {
+ return r[2]
+ }
+ return null;
+ },
}
};
diff --git a/pages/index/index - 副本.vue b/pages/index/index - 副本.vue
new file mode 100644
index 0000000..488dfce
--- /dev/null
+++ b/pages/index/index - 副本.vue
@@ -0,0 +1,267 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ {{userInfo.nickName}}
+
+
+
+ 会员码
+
+
+
+
+ {{shopUser.amount || '0'}}
+ 余额
+
+
+ {{shopUser.levelConsume || '0'}}
+ 积分
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/member/index.vue b/pages/member/index.vue
index 887ab52..4dbbec3 100644
--- a/pages/member/index.vue
+++ b/pages/member/index.vue
@@ -78,7 +78,7 @@
return false;
}
let res = await this.api.paymemeberIn({
- shopId: uni.cache.get('shopUser').shopId, // 判断显示哪家的作品,
+ shopId: uni.cache.get('shopUser'), // 判断显示哪家的作品,
amount: this.amount // 判断显示哪家的作品,
})
if (res) {
diff --git a/pages/order_detail/order_detail.vue b/pages/order_detail/order_detail.vue
index f99abed..4d62408 100644
--- a/pages/order_detail/order_detail.vue
+++ b/pages/order_detail/order_detail.vue
@@ -15,7 +15,7 @@
订单完成
- 已发
+ 已发
申请退单
diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue
index 3e310e0..72750fb 100644
--- a/pages/order_food/order_food.vue
+++ b/pages/order_food/order_food.vue
@@ -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)