From 10a47abe135637b9bb7e5f176d7f041184fdc276 Mon Sep 17 00:00:00 2001 From: wwz <1144797966@qq.com> Date: Fri, 28 Mar 2025 18:29:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B4=AD=E7=89=A9=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api/index/tothestore.js | 2 +- common/api/subscribeto.js | 51 +++++ framework/0-conf.js | 4 +- pages.json | 10 +- pages/index/components/diamond.vue | 16 +- pages/index/index.vue | 15 +- pages/index/tothestore.vue | 10 +- pages/order/detail.vue | 1 + pages/product/components/confirmorder.vue | 64 +++--- pages/product/components/shoppingCartes.vue | 17 +- pages/product/index.vue | 209 ++++++++++++-------- pages/subscribeto/index.vue | 95 +++++---- 12 files changed, 299 insertions(+), 195 deletions(-) create mode 100644 common/api/subscribeto.js diff --git a/common/api/index/tothestore.js b/common/api/index/tothestore.js index e27b17e..7b540b4 100644 --- a/common/api/index/tothestore.js +++ b/common/api/index/tothestore.js @@ -12,7 +12,7 @@ export const APIdistiricttopCommon = (data) => { //预约到店(店铺列表) export const APIdistirictsubShopList = (data) => { return request({ - url: url + '/distirict/subShopList', + url: url + '/user/shopInfo/subList', method: 'get', data: data }) diff --git a/common/api/subscribeto.js b/common/api/subscribeto.js new file mode 100644 index 0000000..6441ae2 --- /dev/null +++ b/common/api/subscribeto.js @@ -0,0 +1,51 @@ +// 引入 request 文件 +import request from '@/common/api/request.js' +const urlAccount = '/account' +const urlProduct = '/product' +const urlOrder = '/order' + +// 获取叫号号码 +export const APIcallTabletakeNumber = (data) => { + return request({ + url: urlAccount + '/user/callTable/takeNumber', + method: 'post', + data: data + }) +} + +// 叫号桌型获取 +export const APIusercallTable = (data) => { + return request({ + url: urlAccount + '/user/callTable', + method: 'get', + data: data + }) +} + +// 获取叫号队列 +export const APIqueuecallTable = (data) => { + return request({ + url: urlAccount + '/user/callTable/queue', + method: 'get', + data: data + }) +} + +// 叫号队列详情 +export const APIqueuedetail = (data) => { + return request({ + url: urlAccount + '/user/callTable/queue/detail', + method: 'get', + data: data + }) +} + + +// 消息订阅 +export const APIcallTablesubMsg = (data) => { + return request({ + url: urlAccount + '/user/callTable/subMsg', + method: 'get', + data: data + }) +} \ No newline at end of file diff --git a/framework/0-conf.js b/framework/0-conf.js index df0f1b9..15c661e 100644 --- a/framework/0-conf.js +++ b/framework/0-conf.js @@ -1,11 +1,11 @@ // const debug = process.env.NODE_ENV == 'development' ? true : false; -const debug = false; +const debug = false // #ifdef H5 const proxyApi = "/api" // #endif // #ifdef MP-WEIXIN || APP || MP-ALIPAY -const proxyApi = 'https://tapi.cashier.sxczgkj.cn' // 调试地址 +const proxyApi = 'http://192.168.1.31' // 调试地址 const proxyApiwws = 'wss://sockets.sxczgkj.com/wss' // 调试地址 // // 本地 diff --git a/pages.json b/pages.json index e590e5c..c7e6165 100644 --- a/pages.json +++ b/pages.json @@ -46,7 +46,7 @@ "navigationBarTitleText": "红包中心" } }, - + { "path": "pages/product/index", "style": { @@ -126,7 +126,7 @@ "style": { "navigationBarTitleText": "会员支付码" } - },{ + }, { "path": "pages/user/member/setPassword", "style": { "navigationBarTitleText": "密码设置" @@ -155,6 +155,12 @@ "style": { "navigationBarTitleText": "优惠卷" } + }, + { + "path": "pages/subscribeto/index", + "style": { + "navigationBarTitleText": "叫号" + } } ], "uniIdRouter": {}, diff --git a/pages/index/components/diamond.vue b/pages/index/components/diamond.vue index 7b0e261..14242b3 100644 --- a/pages/index/components/diamond.vue +++ b/pages/index/components/diamond.vue @@ -1,10 +1,12 @@ @@ -84,8 +86,8 @@ } } - .towcontent_item:nth-child(1) { - margin-left: 0rpx; - } + // .towcontent_item:nth-child(1) { + // margin-left: 0rpx; + // } } \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index 5a17a3a..83b3903 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -12,7 +12,7 @@ - + - + @@ -469,9 +468,9 @@ background: #fee06a; } - .fourcontent_item:nth-child(1) { - margin-left: 0; - } + // .fourcontent_item:nth-child(1) { + // margin-left: 0; + // } } diff --git a/pages/index/tothestore.vue b/pages/index/tothestore.vue index e0e209c..6b42467 100644 --- a/pages/index/tothestore.vue +++ b/pages/index/tothestore.vue @@ -127,7 +127,7 @@ address: uni.cache.get('getLocationstorage').address, //地址 lng: uni.cache.get('getLocationstorage').lng, lat: uni.cache.get('getLocationstorage').lat, - distanceInKm: '10', //默认10 以经纬度为中心 多大范围以内 单位km + distance: '2000', //默认10 以经纬度为中心 多大范围以内 单位km isPage: '', //是否分页 1分页 0不分页 page: form.page, //页数 size: form.size, //页容量 @@ -160,7 +160,7 @@ }); onMounted(() => { init_fn() - distiricttopCommon() + // distiricttopCommon() }) onReachBottom(() => { distirictsubShopList() @@ -246,10 +246,10 @@ border-radius: 24rpx 0rpx 0rpx 0rpx; background: #F9F9F9; - .fivecontent_item:nth-child(1) { - margin-top: 0; + // .fivecontent_item:nth-child(1) { + // margin-top: 0; - } + // } .fivecontent_item { background: #FFFFFF; diff --git a/pages/order/detail.vue b/pages/order/detail.vue index 9c5fbac..e7fe9a7 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -442,6 +442,7 @@ buyerRemark: '', seatNum: is_type.value == 0 ? listinfo.seatNum : 0, //用餐人数 }) + orderorderInfo() return false; } else { let checkOrderPay = { diff --git a/pages/product/components/confirmorder.vue b/pages/product/components/confirmorder.vue index afdc5fb..1b032f1 100644 --- a/pages/product/components/confirmorder.vue +++ b/pages/product/components/confirmorder.vue @@ -7,7 +7,6 @@ - {{item.name}} - + - {{item.id == i.productId && item.skuId == i.id ? i.specInfo :""}} + {{item.cartListinfo.sku_id == i.id ? i.name :""}} + + + + + {{i.proName }} + + + + X{{ ifcartNumber(item) }} - ¥{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.salePrice):item.salePrice}} + + ¥{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.salePrice):item.salePrice}} + - - - - 餐位费 - - X{{shopTable.seatNum}} - - {{Seatcharge}} - - - - @@ -103,28 +97,12 @@ - - - - 实付金额 ¥{{ totalPrices }} - 提交订单 @@ -231,7 +209,7 @@ if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) { // memberPrice会员价 return total + parseFloat(item.memberPrice || item.salePrice) * parseFloat(item - .cartNumber); + .cartNumber); } else { // salePrice销售价 return total + parseFloat(item.salePrice || 0) * parseFloat(item.cartNumber); @@ -353,7 +331,17 @@ // } } - + const dataprocessing = computed(() => { + return (item) => { + let res = null + try { + res = JSON.parse(item.pro_group_info) + } catch (error) { + //TODO handle the exception + } + return res + }; + }) const thisdata = reactive({ opacitys: false, diff --git a/pages/product/components/shoppingCartes.vue b/pages/product/components/shoppingCartes.vue index 85d938e..00f378a 100644 --- a/pages/product/components/shoppingCartes.vue +++ b/pages/product/components/shoppingCartes.vue @@ -141,23 +141,26 @@ } // 购物车加减 const cartListadd = async (item, i) => { + // 是否起售 如果小于或者大于都是1 + const cartNumberFloat = parseFloat(item.cartNumber); + const suitNum = item.suitNum >= cartNumberFloat && i == '-' ? item.cartNumber : 1; + emits('customevent', { id: item.cartListId ? item.cartListId : '', type: 'shopping', table_code: uni.cache.get('tableCode'), shop_id: uni.cache.get('shopId'), - operate_type: calculateValue(item.cartNumber, i) == 'del' ? 'del' : item.cartListId && + operate_type: calculateValue(item.cartNumber, i, suitNum) == 'del' ? 'del' : item.cartListId && item.cartNumber > 0 ? 'edit' : 'add', product_id: item.id, sku_id: item.skuId, - number: await calculateValue(item.cartNumber, i), + number: await calculateValue(item.cartNumber, i, suitNum), is_print: 1, }) } const dataprocessing = computed(() => { return (item) => { - console.log(item.pro_group_info) let res = null try { res = JSON.parse(item.pro_group_info) @@ -168,16 +171,16 @@ }; }) - // 封装加法函数 const calculateValue = (cartNumber, i, step = 1) => { if (i == '+') { - const result = parseFloat(cartNumber) + step; + const result = parseFloat(cartNumber) + parseFloat(step); return result.toFixed(2); } else { - const result = parseFloat(cartNumber) - step; + // 当减到0返回del + const result = parseFloat(cartNumber) - parseFloat(step); return result == 0 ? 'del' : result.toFixed(2); } - }; + } // 菜品备注修改 const productBlur = (item) => { diff --git a/pages/product/index.vue b/pages/product/index.vue index ea8f37c..2c5e51a 100644 --- a/pages/product/index.vue +++ b/pages/product/index.vue @@ -43,6 +43,9 @@ 招牌 + + 「{{item.suitNum}}{{item.unitName}}起点」 + - {{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.salePrice):item.salePrice}} - - + + {{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.salePrice):item.salePrice}} + /{{item.unitName}} @@ -72,18 +74,19 @@ - + ¥ - {{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice|| item.salePrice):item.salePrice}} - - - + + {{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice|| item.salePrice):item.salePrice}} + /{{item.unitName}} + @@ -105,8 +108,6 @@ {{ ifcartNumber(item) }} - 热销 {{item1.shortTitle?item1.shortTitle:''}} + + 「{{item1.suitNum}}{{item1.unitName}}起点」 + + @@ -177,13 +183,17 @@ - + - + {{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item1.memberPrice||item1.salePrice):item1.salePrice}} - /{{item1.unitName}} + /{{item1.unitName}} + @@ -233,8 +243,8 @@ - + @@ -325,12 +335,21 @@ {{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1? (specifications.item.result.memberPrice||specifications.item.result.salePrice):specifications.item.result.salePrice}} /{{specifications.item.unitName}} + + 「{{specifications.item.result.suitNum}}{{specifications.item.result.unitName}}起点」 + - {{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1? (specifications.item.memberPrice||specifications.item.salePrice):specifications.item.salePrice}} - /{{specifications.item.unitName}} + + {{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1? (specifications.item.memberPrice||specifications.item.salePrice):specifications.item.salePrice}} + + + /{{specifications.item.unitName}} + + + 「{{specifications.item.suitNum}}{{specifications.item.unitName}}起点」 + @@ -393,6 +412,7 @@ import shoppingCartes from './components/shoppingCartes.vue' import confirmorder from './components/confirmorder.vue' import Loading from '@/components/Loading.vue'; + // 获取全局属性 const { proxy @@ -468,9 +488,7 @@ try { const shopExtend = uni.cache.get('shopTable').shopExtendMap.shopinfo_bg - } catch (error) { - //TODO handle the exception - } + } catch (error) {} // 计算高度 const navScroll = ref(null) @@ -591,11 +609,6 @@ uni.$u.debounce(store.scrollTop = res.scrollTop, 500) uni.$u.debounce(navScroll.value = res.scrollTop, 500) uni.$u.debounce(mainScroll(res), 500) - if (res.scrollTop >= 44) { - // store.showSearch = true - } else { - // store.showSearch = false - } }); // 点击详情 @@ -683,8 +696,6 @@ } }; - // 存储选中的选项 - // 监听 specifications 的变化 watch( () => specifications.item.groupSnap, @@ -695,7 +706,6 @@ } ); - // 存储选中的选项,二维数组 const selectedOptions = ref( specifications.item.groupSnap.map(() => []) @@ -763,12 +773,25 @@ //添加购物车数量 const shopCartNumber = ref(0) - // 多规格 去添加购物车 - const shopCart = (i) => { - if (i == '+') { - shopCartNumber.value++; + // 多规格 套餐添加数量 + const shopCart = async (i) => { + let res = await shoppingcart() + if (i == '-') { + if (!res && shopCartNumber.value == specifications.item.suitNum) { + uni.showToast({ + title: `起点${specifications.item.suitNum}`, + icon: 'none' + }) + return false; + } else { + shopCartNumber.value--; + } } else { - shopCartNumber.value--; + if (!res && shopCartNumber.value < 1) { + shopCartNumber.value = parseFloat(specifications.item.suitNum); + } else { + shopCartNumber.value++; + } } } @@ -844,62 +867,65 @@ }); } + // 判断多规格和套餐 商品是否在购物车有数据 + const shoppingcart = async () => { + let res = null + if (specifications.item.type == "package") { + if (!allConditionsSatisfied.value) { + return false + } + // 是否是套餐package + selectedGroupSnap.value = specifications.item.groupSnap.map((setmenu, index) => { + return { + ...setmenu, + goods: selectedOptions.value[index] + }; + }); + res = await matchingProduct(selectedGroupSnap.value) + } else { + if (!canSubmit.value) { + return false + } + res = await matchingProduct(specifications.item.result) + } + return res; + } // 提交选择并执行下一步操作的方法 const submitSelection = async () => { + if (shopCartNumber.value <= 0) { + return; + } + let res = await shoppingcart() + console.log(res) - if (shopCartNumber.value > 0) { - let res = null - if (specifications.item.type == "package") { - if (!allConditionsSatisfied.value) { - return false - } - // 是否是套餐package - selectedGroupSnap.value = specifications.item.groupSnap.map((setmenu, index) => { - return { - ...setmenu, - goods: selectedOptions.value[index] - }; - }); - res = await matchingProduct(selectedGroupSnap.value) - } else { - if (!canSubmit.value) { - return false - } - res = await matchingProduct(specifications.item.result) - } - console.log(res, 'res') - if (res) { - await calculateValue(res.cartNumber, '+', shopCartNumber.value) - } - // 是否是套餐 有就传 - if (specifications.item.type != "package") { - selectedGroupSnap.value = [] - } - - websocketsendMessage({ - id: res ? res.cartListId : '', - type: 'shopping', - table_code: uni.cache.get('tableCode'), - shop_id: uni.cache.get('shopId'), - operate_type: res ? 'edit' : 'add', - product_id: specifications.product_id, - sku_id: specifications.sku_id, - number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) : - shopCartNumber.value, - pro_group_info: selectedGroupSnap.value, - goods_type: specifications.item.type == "package" ? 'package' : '', - is_print: 1, - product_type: specifications.item.type - }) - // 清空套餐选中 + // 是否是套餐 有就传 + if (specifications.item.type != "package") { selectedGroupSnap.value = [] - showShopsku.value = false } + websocketsendMessage({ + id: res ? res.cartListId : '', + type: 'shopping', + table_code: uni.cache.get('tableCode'), + shop_id: uni.cache.get('shopId'), + operate_type: res ? 'edit' : 'add', + product_id: specifications.product_id, + sku_id: specifications.sku_id, + number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) : shopCartNumber + .value, + pro_group_info: selectedGroupSnap.value, + goods_type: specifications.item.type == "package" ? 'package' : '', + is_print: 1, + product_type: specifications.item.type + }) + // 清空套餐选中 + selectedGroupSnap.value = [] + showShopsku.value = false } + //获取多规格数据 const clickspecifications = async (item, index, indexs, type) => { if (item.isSoldStock == 1 || item.isSaleTime == 0) { @@ -939,6 +965,7 @@ // 单规格 const singleclick = async (item, i) => { + console.log(item) // 判断购物车是否有该选中商品 let res = null try { @@ -948,15 +975,24 @@ } catch (error) { //TODO handle the exception } + // 是否起售 如果小于或者大于都是1 + let suitNum = 1; + const cartNumberFloat = parseFloat(item.cartNumber); + if (!res && item.suitNum > cartNumberFloat) { + suitNum = item.suitNum; + } else if (item.suitNum >= cartNumberFloat && i === '-') { + suitNum = item.cartNumber; + } websocketsendMessage({ id: res ? item.cartListId : '', type: 'shopping', table_code: uni.cache.get('tableCode'), shop_id: uni.cache.get('shopId'), - operate_type: await calculateValue(item.cartNumber, i) == 'del' ? 'del' : res ? 'edit' : 'add', + operate_type: await calculateValue(item.cartNumber, i, suitNum) == 'del' ? 'del' : res ? + 'edit' : 'add', product_id: item.id, sku_id: item.skuId, - number: await calculateValue(item.cartNumber, i), + number: await calculateValue(item.cartNumber, i, suitNum), is_print: 1, product_type: item.type }) @@ -1379,11 +1415,12 @@ } else { uni.showToast({ - title: '暂无列表数据...' + title: '暂无列表数据,请重新扫码', + icon: "none" }); isDataLoaded.value = false; setTimeout(() => { - uni.navigateBack() + uni.pro.switchTab('index/index') }, 1000) return false; } diff --git a/pages/subscribeto/index.vue b/pages/subscribeto/index.vue index 583d772..dff778e 100644 --- a/pages/subscribeto/index.vue +++ b/pages/subscribeto/index.vue @@ -123,6 +123,20 @@ nextTick } from 'vue'; + //接口引入 + import { + APIcallTabletakeNumber, + APIusercallTable, + APIqueuecallTable, + APIqueuedetail, + APIcallTablesubMsg + } from "@/common/api/subscribeto.js"; + + // 获取全局属性 + const { + proxy + } = getCurrentInstance(); + const queueUpList = ref([]) const tableList = ref([]) @@ -131,7 +145,10 @@ show: false, phone: "", callTableId: "", - shopInfo: null, + shopInfo: { + logo: '', + shopName: '' + }, queueInfo: null, shopId: "", queueId: "", @@ -150,15 +167,14 @@ // 获取排号状态 const getQueueUpState = async () => { let params = { - openId: uni.cache.get('miniAppOpenId'), - shopId: this.shopId, + shopId: dataform.shopId, } - if (this.queueId) { - params.queueId = this.queueId; + if (dataform.queueId) { + params.queueId = dataform.queueId; } - let res = await this.api.getQueueUpState(params) + let res = await APIusercallTable(params) - if (res.code == 0) { + if (res) { dataform.shopInfo = res.data.shopInfo; dataform.queueInfo = res.data.queueInfo; dataform.queueId = dataform.queueInfo.id; @@ -167,34 +183,36 @@ // 获取排号数据 const getQueueUpList = async () => { - let res = await this.api.getQueueUpList({ - openId: uni.cache.get('miniAppOpenId'), - shopId: this.shopId, + let res = await APIqueuecallTable({ + shopId: dataform.shopId, }) - if (res.code == 0 && res.data.length > 0) { + if (res) { queueUpList.value = res.data; } } - // 获取桌型数据 + // 叫号队列详情 const getQueueUpTablList = async () => { - let res = await this.api.getQueueUpTablList({ - shopId: this.shopId, + let res = await APIqueuedetail({ + shopId: dataform.shopId, + openId: uni.cache.get('userInfo').wechatOpenId, }) - if (res.code == 0 && res.data.length > 0) { + if (res.queueInfo) { tableList.value = res.data; - dataform.callTableId = res.data[0].id; + + } else { + getQueueUpState() } } // 订阅通知 const subscribe = async () => { - let res = await this.api.setSubMsg({ - openId: uni.cache.get('miniAppOpenId'), - shopId: this.shopId, - queueId: this.queueId, + let res = await APIcallTablesubMsg({ + openId: uni.cache.get('userInfo').wechatOpenId, + shopId: dataform.shopId, + queueId: dataform.queueId, }) - if (res.code == 0) { + if (res) { uni.showToast({ title: '订阅成功', icon: 'none' @@ -229,7 +247,7 @@ if (res.code == 0) { dataform.phone = ""; dataform.queueId = res.data.id; - this.getQueueUpState(); + getQueueUpState(); dataform.show = false; uni.requestSubscribeMessage({ tmplIds: ["qUhvEfvCtIcBA3DOn3QMqsGOolrEpyr0YBh99i-AUqw", @@ -248,15 +266,20 @@ const cancelTakeNumber = async () => { let res = await this.api.cancelTakeNumber({ queueId: dataform.queueInfo.id, - shopId: this.shopId, + shopId: dataform.shopId, }) - if (res.code == 0) { - this.getQueueUpTablList(); - this.getQueueUpState(); + if (res) { + getQueueUpTablList(); + getQueueUpState(); } } - // 取消排队 + // 切换桌型 + const tableCut = (item) => { + dataform.callTableId = item.id; + } + + // 弹窗关闭监听 const close = async () => { this.phone = ""; if (tableList.value.length > 0) { @@ -265,11 +288,6 @@ dataform.show = false; } - // 取消排队 - const tableCut = async (item) => { - dataform.callTableId = item.id; - } - onMounted(async () => { await proxy.$onLaunched; // 获取当前页面栈 @@ -281,22 +299,21 @@ // #ifdef MP-WEIXIN if (options.q) { - this.shopId = getQueryString(decodeURIComponent(options.q), 'shopId') - this.queueId = getQueryString(decodeURIComponent(options.q), 'queueId') + dataform.shopId = getQueryString(decodeURIComponent(options.q), 'shopId') + dataform.queueId = getQueryString(decodeURIComponent(options.q), 'queueId') } // #endif - + console.log(dataform.shopId, 11) // #ifdef MP-ALIPAY if (getApp().globalData.shopId) { - this.shopId = getApp().globalData.shopId + dataform.shopId = getApp().globalData.shopId } if (getApp().globalData.queueId) { - this.queueId = getApp().globalData.queueId + dataform.queueId = getApp().globalData.queueId } // #endif await nextTick() - this.getQueueUpState(); - this.getQueueUpTablList(); + getQueueUpTablList(); })