diff --git a/framework/0-conf.js b/framework/0-conf.js index 5d0ebde..2cc2c99 100644 --- a/framework/0-conf.js +++ b/framework/0-conf.js @@ -6,12 +6,12 @@ const proxyApi = "/api" // const proxyApi = 'http://192.168.1.15:9888/cashierService' // 王伟 // const proxyApi = 'http://192.168.1.27:9888/cashierService' // 帆哥 // const proxyApiwws = 'ws://192.168.1.15:9888/netty' // 测试 -// const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试 -// const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/netty' // 测试 +const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试 +const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/netty' // 测试 // const proxyApi = 'https://pre-cashier.sxczgkj.cn/cashierService' // 预发布 // const proxyApiwws = 'wss://pre-cashier.sxczgkj.cn/netty' // 预发布 -const proxyApi = 'https://cashier.sxczgkj.cn/cashierService' // 线上 -const proxyApiwws = 'wss://cashier.sxczgkj.cn/netty' // 线上 +// const proxyApi = 'https://cashier.sxczgkj.cn/cashierService' // 线上 +// const proxyApiwws = 'wss://cashier.sxczgkj.cn/netty' // 线上 // #endif // #ifdef H5 diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue index c54b0fd..6c7ced1 100644 --- a/pages/order_food/order_food.vue +++ b/pages/order_food/order_food.vue @@ -102,7 +102,7 @@ - 选规格 - + 选规格 @@ -300,12 +300,13 @@ v-if="specifications.tagSnap"> {{item.name}} + ({{item.number}}/{{item.count}}) {{item1.name}} @@ -407,6 +408,7 @@ shopId: "", tableCode: "", orderAMeal: true, + groupProductldList: [], } }, onPageScroll(e) { @@ -711,6 +713,9 @@ } else { num = this.skuNumber + this.amountcartNumber; } + if (item.type == 'package'&&item.groupType == 1) { + num = this.amountcartNumber; + } let params = { "skuId": this.skuId, "num": num, //数量 @@ -721,6 +726,10 @@ "note": item.note, "userId": uni.cache.get('userInfo').id, } + //套餐数据 + if ( this.groupProductldList.length > 0 ) { + params.groupProductldList = this.groupProductldList; + } if (this.shopInfo.storeInfo.eatModel.indexOf('dine-in') != -1) { params.tableId = this.tableCode;} this.addCart(params); }, @@ -748,6 +757,7 @@ if (res.code == 0) { this.showShopsku = false; this.pagemetashow = false; + this.isSpec = false; } }, @@ -804,16 +814,23 @@ * @param {Object} index1 */ async clickspecifications(item1, index, index1, type) { - if ( item1.isPauseSale != 0 || item1.isSale == 0 ) { - return; - } this.skuidname = [] this.specifications = item1 this.specifications.indexa = index this.specifications.indexb = index1 this.specifications.typeName = type + if ( item1.type == 'package'&&item1.groupType == 1 ) { + this.groupProductldList = []; + this.optionalPackage(item1, index, index1, type) + this.hodgepodge(this.specifications, 2) //获取skuid /2查找价格和数量 + return; + } + if ( item1.isPauseSale != 0 || item1.isSale == 0 ) { + return; + } + try { - if (item1.productSkuResult == null) { + if (item1.productSkuResult == null||(item1.type == 'package'&&item1.groupType == 0)) { this.isSpec = true; // 但但单个规格弹框的处理 this.hodgepodge(this.specifications, 2) //获取skuid /2查找价格和数量 @@ -876,7 +893,39 @@ //TODO handle the exception } }, - + + /** + * 可选套餐处理 + */ + optionalPackage(item1, index, index1, type) { + this.specifications = item1 + this.skuidname = []; + this.specifications.tagSnap = item1.proGroupVo.map((item,index) => { + let res = { + id: item1.id, //商品id + name: item.title, + count: item.count, + number: item.number, + start: -1, + children: [] + } + item.goods.forEach((v, e) => { + res.children.push({ + name: v.proName, + proId: v.proId, //商品id + disabled: true, + isGrounding: true, + isPauseSale: 0, + selected: false, + }) + }) + return res + }) + this.salePrice = this.isVip == 1 && item1.lowMemberPrice > 0 ? item1.lowMemberPrice : item1.lowPrice // 价格 + this.showShopsku = true //打开弹框 + console.log(this.specifications) + }, + /** * 规格选择监听 * @param {Object} e @@ -885,73 +934,114 @@ * @param {Object} item */ async morloe(e, index, index1, item) { - if (!e.isGrounding || !e.disabled || e.isPauseSale == 1) { - return; - } - - let querySpecList = []; - this.skuBtnText = "添加到购物车"; - this.isSpec = true; - // 设置当前选中下标 - if (this.specifications.tagSnap[index].start != index1) { - this.$set(this.specifications.tagSnap[index], 'start', index1) - } else { - this.$set(this.specifications.tagSnap[index], 'start', -1) - index = index - 1; - } - this.skuidname = []; - // 选择规格下面的其他规格可点击状态重置 - this.specifications.tagSnap.forEach((val, i, arr) => { - if (i > index) { - val.children.forEach((v1, e1) => { - v1.isGrounding = i == (index+1) ? false : true; - v1.isPauseSale = i == (index+1) ? 1 : 0; - v1.disabled = i == (index+1) ? true : false; + //套餐处理 + if ( this.specifications.type == 'package'&&this.specifications.groupType == 1){ + // 当前分类下选中数量 + this.isSpec = true; + let number = 0; + this.skuidname = []; + this.groupProductldList = [] + this.specifications.tagSnap[index].children.map(v=>{ + if ( v.selected ) { number++ } + }) + // 判断选择数量是否大于可选数量 + if ( number < item.number ) { + this.specifications.tagSnap[index].children[index1].selected = !e.selected + } else { + this.specifications.tagSnap[index].children[index1].selected = false + } + this.specifications.tagSnap.forEach(v=>{ + v.children.forEach(v1=>{ + if (v1.selected) { + this.groupProductldList.push(v1.proId) + } }) - val.start = -1; + }) + // 获取下一个没有选中的分类 + for (let i = 0; i < this.specifications.tagSnap.length; i++) { + let count = 0; + for (let o = 0; o < this.specifications.tagSnap[i].children.length; o++) { + if (this.specifications.tagSnap[i].children[o].selected ) { + count++ + } + } + if ( count < this.specifications.tagSnap[i].number ) { + this.isSpec = false; + this.skuBtnText = `您${this.specifications.tagSnap[i].name}选择数量不足` + break; // 终止循环 + } + } - if (val.start >= 0) { - this.skuidname.push(val.children[val.start].name) + } else { + if (!e.isGrounding || !e.disabled || e.isPauseSale == 1) { + return; } - }) + + let querySpecList = []; + this.skuBtnText = "添加到购物车"; + this.isSpec = true; + // 设置当前选中下标 + if (this.specifications.tagSnap[index].start != index1) { + this.$set(this.specifications.tagSnap[index], 'start', index1) + } else { + this.$set(this.specifications.tagSnap[index], 'start', -1) + index = index - 1; + } + this.skuidname = []; + // 选择规格下面的其他规格可点击状态重置 + this.specifications.tagSnap.forEach((val, i, arr) => { + if (i > index) { + val.children.forEach((v1, e1) => { + v1.isGrounding = i == (index+1) ? false : true; + v1.isPauseSale = i == (index+1) ? 1 : 0; + v1.disabled = i == (index+1) ? true : false; + }) + val.start = -1; + } + if (val.start >= 0) { + this.skuidname.push(val.children[val.start].name) + } + }) + + // 获取下一个没有选中的分类 + for (let i = 0; i < this.specifications.tagSnap.length; i++) { + if (this.specifications.tagSnap[i].start < 0) { + this.isSpec = false; + this.skuBtnText = `您还没选择${this.specifications.tagSnap[i].name}哦` + break; // 终止循环 + } + } + + let filteredJson; + let isSkuidname = []; + //提前下一列规格循环,查看是否有下架规格 + if (this.specifications.tagSnap[index + 1]) { + for (let o = 0; o < this.specifications.tagSnap[index + 1].children.length; o++) { + isSkuidname = JSON.parse(JSON.stringify(this.skuidname)); + isSkuidname.push(this.specifications.tagSnap[index + 1].children[o].name) + // 上下架状态处理 + filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0); + for (let i = 0; i < filteredJson.length; i++) { + if (filteredJson[i].isGrounding) { + this.specifications.tagSnap[index + 1].children[o].isGrounding = true; + break; // 终止循环 + } + } + // 售罄状态处理 + for (let i = 0; i < filteredJson.length; i++) { + if (filteredJson[i].isPauseSale == 0) { + this.specifications.tagSnap[index + 1].children[o].isPauseSale = 0; + break; // 终止循环 + } + } + + } + } + this.hodgepodge(this.specifications, 2) + } - // 获取下一个没有选中的分类 - for (let i = 0; i < this.specifications.tagSnap.length; i++) { - if (this.specifications.tagSnap[i].start < 0) { - this.isSpec = false; - this.skuBtnText = `您还没选择${this.specifications.tagSnap[i].name}哦` - break; // 终止循环 - } - } - - let filteredJson; - let isSkuidname = []; - //提前下一列规格循环,查看是否有下架规格 - if (this.specifications.tagSnap[index + 1]) { - for (let o = 0; o < this.specifications.tagSnap[index + 1].children.length; o++) { - isSkuidname = JSON.parse(JSON.stringify(this.skuidname)); - isSkuidname.push(this.specifications.tagSnap[index + 1].children[o].name) - // 上下架状态处理 - filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0); - for (let i = 0; i < filteredJson.length; i++) { - if (filteredJson[i].isGrounding) { - this.specifications.tagSnap[index + 1].children[o].isGrounding = true; - break; // 终止循环 - } - } - // 售罄状态处理 - for (let i = 0; i < filteredJson.length; i++) { - if (filteredJson[i].isPauseSale == 0) { - this.specifications.tagSnap[index + 1].children[o].isPauseSale = 0; - break; // 终止循环 - } - } - - } - } this.$forceUpdate(); - this.hodgepodge(this.specifications, 2) }, /** diff --git a/pages/order_food/order_food_search.vue b/pages/order_food/order_food_search.vue index 977f3fe..79567f4 100644 --- a/pages/order_food/order_food_search.vue +++ b/pages/order_food/order_food_search.vue @@ -70,7 +70,7 @@ - + 选规格 @@ -126,11 +126,12 @@ v-if="specifications.tagSnap"> {{item.name}} + ({{item.number}}/{{item.count}}) {{item1.name}} @@ -193,11 +194,6 @@ pagemetashow: false, userInfo: uni.cache.get('userInfo'), //个人信息 opacity: false, //是否显示 - fillHeight: 0, // 填充高度,用于最后一项低于滚动区域时使用 - leftArray: [], - mainArray: [], - leftIndex: 0, - isFixed: false, showShopInfo: false, //店铺信息弹窗是否显示 showShopsku: false, //多规格弹窗是否显示 skuId: null, // 多规格ID @@ -216,8 +212,6 @@ salePrice: '', //钱数 cartListsdatashow: false, //是否显示购物车 showCart: false, - lastbottom: '', //元素最低端的距离 - scrollxleft: true, orderdetailFlag: true, searchList: [], @@ -225,6 +219,8 @@ shopId: null, tableCode: null, + groupProductldList: [], + } }, onPageScroll(e) { @@ -420,6 +416,9 @@ } else { num = this.skuNumber + this.amountcartNumber; } + if (item.type == 'package'&&item.groupType == 1) { + num = this.amountcartNumber; + } let params = { "skuId": this.skuId, "num": num, //数量 @@ -430,6 +429,10 @@ "userId": uni.cache.get('userInfo').id, "tableId": uni.cache.get('tableCode'), } + //套餐数据 + if ( this.groupProductldList.length > 0 ) { + params.groupProductldList = this.groupProductldList; + } this.addCart(params); }, @@ -455,6 +458,8 @@ if (res.code == 0) { this.showShopsku = false; this.pagemetashow = false; + this.isSpec = false; + } }, @@ -512,15 +517,22 @@ * @param {Object} index1 */ async clickspecifications(item1, index1, type) { - if ( item1.isPauseSale != 0 || item1.isSale == 0) { - return; - } this.skuidname = [] this.specifications = item1 this.specifications.indexb = index1 this.specifications.typeName = type + if ( item1.type == 'package'&&item1.groupType == 1 ) { + this.groupProductldList = []; + this.optionalPackage(item1, index, index1, type) + this.hodgepodge(this.specifications, 2) //获取skuid /2查找价格和数量 + return; + } + if ( item1.isPauseSale != 0 || item1.isSale == 0) { + return; + } + try { - if (item1.productSkuResult == null) { + if (item1.productSkuResult == null||(item1.type == 'package'&&item1.groupType == 0)) { this.isSpec = true; // 但但单个规格弹框的处理 this.hodgepodge(this.specifications, 2) //获取skuid /2查找价格和数量 @@ -581,7 +593,39 @@ //TODO handle the exception } }, - + + /** + * 可选套餐处理 + */ + optionalPackage(item1, index, index1, type) { + this.specifications = item1 + this.skuidname = []; + this.specifications.tagSnap = item1.proGroupVo.map((item,index) => { + let res = { + id: item1.id, //商品id + name: item.title, + count: item.count, + number: item.number, + start: -1, + children: [] + } + item.goods.forEach((v, e) => { + res.children.push({ + name: v.proName, + proId: v.proId, //商品id + disabled: true, + isGrounding: true, + isPauseSale: 0, + selected: false, + }) + }) + return res + }) + this.salePrice = this.isVip == 1 && item1.lowMemberPrice > 0 ? item1.lowMemberPrice : item1.lowPrice // 价格 + this.showShopsku = true //打开弹框 + console.log(this.specifications) + }, + /** * 规格选择监听 * @param {Object} e @@ -590,74 +634,114 @@ * @param {Object} item */ async morloe(e, index, index1, item) { - - if (!e.isGrounding || !e.disabled || e.isPauseSale == 1) { - return; - } - - let querySpecList = []; - this.skuBtnText = "添加到购物车"; - this.isSpec = true; - // 设置当前选中下标 - if (this.specifications.tagSnap[index].start != index1) { - this.$set(this.specifications.tagSnap[index], 'start', index1) - } else { - this.$set(this.specifications.tagSnap[index], 'start', -1) - index = index - 1; - } - this.skuidname = []; - // 选择规格下面的其他规格可点击状态重置 - this.specifications.tagSnap.forEach((val, i, arr) => { - if (i > index) { - val.children.forEach((v1, e1) => { - v1.isGrounding = i == (index+1) ? false : true; - v1.isPauseSale = i == (index+1) ? 1 : 0; - v1.disabled = i == (index+1) ? true : false; + //套餐处理 + if ( this.specifications.type == 'package'&&this.specifications.groupType == 1){ + // 当前分类下选中数量 + this.isSpec = true; + let number = 0; + this.skuidname = []; + this.groupProductldList = [] + this.specifications.tagSnap[index].children.map(v=>{ + if ( v.selected ) { number++ } + }) + // 判断选择数量是否大于可选数量 + if ( number < item.number ) { + this.specifications.tagSnap[index].children[index1].selected = !e.selected + } else { + this.specifications.tagSnap[index].children[index1].selected = false + } + this.specifications.tagSnap.forEach(v=>{ + v.children.forEach(v1=>{ + if (v1.selected) { + this.groupProductldList.push(v1.proId) + } }) - val.start = -1; - } - if (val.start >= 0) { - this.skuidname.push(val.children[val.start].name) - } - }) - - // 获取下一个没有选中的分类 - for (let i = 0; i < this.specifications.tagSnap.length; i++) { - if (this.specifications.tagSnap[i].start < 0) { - this.isSpec = false; - this.skuBtnText = `您还没选择${this.specifications.tagSnap[i].name}哦` - break; // 终止循环 - } - } - - let filteredJson; - let isSkuidname = []; - //提前下一列规格循环,查看是否有下架规格 - if (this.specifications.tagSnap[index + 1]) { - for (let o = 0; o < this.specifications.tagSnap[index + 1].children.length; o++) { - isSkuidname = JSON.parse(JSON.stringify(this.skuidname)); - isSkuidname.push(this.specifications.tagSnap[index + 1].children[o].name) - // 上下架状态处理 - filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0); - for (let i = 0; i < filteredJson.length; i++) { - if (filteredJson[i].isGrounding) { - this.specifications.tagSnap[index + 1].children[o].isGrounding = true; - break; // 终止循环 + }) + // 获取下一个没有选中的分类 + for (let i = 0; i < this.specifications.tagSnap.length; i++) { + let count = 0; + for (let o = 0; o < this.specifications.tagSnap[i].children.length; o++) { + if (this.specifications.tagSnap[i].children[o].selected ) { + count++ } } - // 售罄状态处理 - for (let i = 0; i < filteredJson.length; i++) { - if (filteredJson[i].isPauseSale == 0) { - this.specifications.tagSnap[index + 1].children[o].isPauseSale = 0; - break; // 终止循环 - } + if ( count < this.specifications.tagSnap[i].number ) { + this.isSpec = false; + this.skuBtnText = `您${this.specifications.tagSnap[i].name}选择数量不足` + break; // 终止循环 } - + } + } else { + if (!e.isGrounding || !e.disabled || e.isPauseSale == 1) { + return; + } + + let querySpecList = []; + this.skuBtnText = "添加到购物车"; + this.isSpec = true; + // 设置当前选中下标 + if (this.specifications.tagSnap[index].start != index1) { + this.$set(this.specifications.tagSnap[index], 'start', index1) + } else { + this.$set(this.specifications.tagSnap[index], 'start', -1) + index = index - 1; + } + this.skuidname = []; + // 选择规格下面的其他规格可点击状态重置 + this.specifications.tagSnap.forEach((val, i, arr) => { + if (i > index) { + val.children.forEach((v1, e1) => { + v1.isGrounding = i == (index+1) ? false : true; + v1.isPauseSale = i == (index+1) ? 1 : 0; + v1.disabled = i == (index+1) ? true : false; + }) + val.start = -1; + } + if (val.start >= 0) { + this.skuidname.push(val.children[val.start].name) + } + }) + + // 获取下一个没有选中的分类 + for (let i = 0; i < this.specifications.tagSnap.length; i++) { + if (this.specifications.tagSnap[i].start < 0) { + this.isSpec = false; + this.skuBtnText = `您还没选择${this.specifications.tagSnap[i].name}哦` + break; // 终止循环 + } + } + + let filteredJson; + let isSkuidname = []; + //提前下一列规格循环,查看是否有下架规格 + if (this.specifications.tagSnap[index + 1]) { + for (let o = 0; o < this.specifications.tagSnap[index + 1].children.length; o++) { + isSkuidname = JSON.parse(JSON.stringify(this.skuidname)); + isSkuidname.push(this.specifications.tagSnap[index + 1].children[o].name) + // 上下架状态处理 + filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0); + for (let i = 0; i < filteredJson.length; i++) { + if (filteredJson[i].isGrounding) { + this.specifications.tagSnap[index + 1].children[o].isGrounding = true; + break; // 终止循环 + } + } + // 售罄状态处理 + for (let i = 0; i < filteredJson.length; i++) { + if (filteredJson[i].isPauseSale == 0) { + this.specifications.tagSnap[index + 1].children[o].isPauseSale = 0; + break; // 终止循环 + } + } + + } + } + this.hodgepodge(item, 2) } + this.$forceUpdate(); - this.hodgepodge(item, 2) }, /** @@ -669,6 +753,7 @@ */ async hodgepodge(item, a, c, num) { //此接口去获取商品id !!!赋值库存 数量 价格等 try { + let res = await this.api.productqueryProductSku({ code: uni.cache.get('tableCode'), shopId: this.shopId,