From c4246ca910f28014efaace64ebf92f47a673a9cf Mon Sep 17 00:00:00 2001 From: queenwuli <942534046@qq.com> Date: Mon, 25 Jan 2021 11:47:46 +0800 Subject: [PATCH] gx --- hive-app/pages/workbench/selectService/index.vue | 109 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 88 insertions(+), 21 deletions(-) diff --git a/hive-app/pages/workbench/selectService/index.vue b/hive-app/pages/workbench/selectService/index.vue index 7fd66a9..71593c1 100644 --- a/hive-app/pages/workbench/selectService/index.vue +++ b/hive-app/pages/workbench/selectService/index.vue @@ -57,7 +57,7 @@ <text>{{op.num}}</text> </template> <text class="iconfont iconjia blue-btn-circle ml-10" - @click.stop="addGoods(op, item.proj)"></text> + @click.stop="addGoods(op)"></text> </view> </view> </view> @@ -104,6 +104,9 @@ }, onLoad(options) { this.id = options.id; + if(options.selectItems){ + this.selectItems = JSON.parse(decodeURIComponent(options.selectItems)); + } uni.setNavigationBarTitle({ title: '当前客户:' + options.vipName }); @@ -124,7 +127,7 @@ }, methods:{ openShoppingCart(){ - this.$refs.shopCart.show() + this.$refs.shopCart.toggle() }, // 搜索 search(val){ @@ -138,20 +141,34 @@ },'POST').then((res) => { if(res.status == 200){ let result = res.mapInfo.proj; - this.projectList = result.proj.map((item) => { - return Object.assign(item, {num: 0}); + let projectList = result.proj; + let comboList = result.composeProj; + // 项目 + projectList.forEach((item) => { + item.num = 0; + this.selectItems.forEach((op) => { + if(item.id == op.id){ + item.num = op.num; + } + }) }); + // 套餐 - let arr = result.composeProj; - arr.forEach((item) => { + comboList.forEach((item) => { item.proj.forEach((op) => { op.num = 0; + this.selectItems.forEach((key) => { + if(op.id == key.id){ + op.num = key.num; + } + }) op.totalCount = item.count; op.isCourse = item.isCourse; op.parentId = item.id; }) }); - this.comboList = arr; + this.projectList = projectList; + this.comboList = comboList; } }) }, @@ -172,11 +189,8 @@ * goods.isCourse: 套餐类型 Y-任选套餐 N-固定套餐 * */ addGoods(goods){ - let index = this.selectItems.indexOf(goods); - // 当前总数 - let curCount = this.getCurCount(goods.parentId) - + let curCount = this.getCurCount(goods.parentId) // 任选套餐,当前总数不能超出总剩余数 if(goods.isCourse === 'Y' && curCount >= goods.totalCount){ this.$toast.info('超出剩余次数~') @@ -187,21 +201,70 @@ return; } goods.num++; + + let selectIndex = this.selectItems.findIndex((item) => { + return item.id == goods.id; + }); // 该商品若已在购物车,则购物车数量上+1,否则加入购物车 - if(index > -1){ - this.selectItems[index].num = goods.num; + if(selectIndex > -1){ + this.selectItems[selectIndex].num = goods.num; }else{ this.selectItems.push(goods); } + + // 项目 + let projectIndex = this.projectList.findIndex((item) => { + return item.id == goods.id; + }) + if(projectIndex > -1){ + this.projectList[projectIndex].num = goods.num; + } + // 套餐 + let comboParentIndex = this.comboList.findIndex((item) => { + return item.id == goods.parentId; + }) + let comboIndex = null; + if(comboParentIndex > -1){ + comboIndex = this.comboList[comboParentIndex].proj.findIndex((item) => { + return item.id == goods.id; + }) + } + if(comboParentIndex > -1 && comboIndex > -1){ + this.comboList[comboParentIndex].proj[comboIndex].num = goods.num; + } }, decreaseGoods(goods){ - let index = this.selectItems.indexOf(goods); goods.num = goods.num <= 0 ? 0 : goods.num - 1; + + let selectIndex = this.selectItems.findIndex((item) => { + return item.id == goods.id; + }); // 该商品若已在购物车,则购物车数量上-1,否则从购物车删除 - if(index > -1 && this.selectItems[index].num >= 1){ - this.selectItems[index].num = goods.num; + if(goods.num >= 1){ + this.selectItems[selectIndex].num = goods.num; }else{ - this.selectItems.splice(index, 1); + this.selectItems.splice(selectIndex, 1); + } + + // 项目 + let projectIndex = this.projectList.findIndex((item) => { + return item.id == goods.id; + }) + if(projectIndex > -1){ + this.projectList[projectIndex].num = goods.num; + } + // 套餐 + let comboParentIndex = this.comboList.findIndex((item) => { + return item.id == goods.parentId; + }) + let comboIndex = null; + if(comboParentIndex > -1){ + comboIndex = this.comboList[comboParentIndex].proj.findIndex((item) => { + return item.id == goods.id; + }) + } + if(comboParentIndex > -1 && comboIndex > -1){ + this.comboList[comboParentIndex].proj[comboIndex].num = goods.num; } }, clearShopCart(){ @@ -284,6 +347,7 @@ border-radius: 4px; } .status{ + flex: 0 0 80px; width: 80px; text-align: right; color: #a5abaf; @@ -298,8 +362,11 @@ display: flex; justify-content: space-between; background: #FFFFFF; - padding: 10px 10px; - box-shadow: 0 6px 100px rgba(237,234,244,1); + padding: 10px; + padding-bottom: 10px; + padding-bottom: calc(10px + constant(safe-area-inset-bottom)); + padding-bottom: calc(10px + env(safe-area-inset-bottom)); + box-shadow: 0 -6px 6px rgba(237,234,244,0.2); } .footer .icon-car-wrap{ position: relative; @@ -323,8 +390,8 @@ } .footer .btn{ border-radius: 20px; - line-height: 34px; - padding: 0 24px; + line-height: 36px; + padding: 0 26px; font-size: 14px; } .no-record{ -- Gitblit v1.9.1