| | |
| | | <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> |
| | |
| | | }, |
| | | onLoad(options) { |
| | | this.id = options.id; |
| | | if(options.selectItems){ |
| | | this.selectItems = JSON.parse(decodeURIComponent(options.selectItems)); |
| | | } |
| | | uni.setNavigationBarTitle({ |
| | | title: '当前客户:' + options.vipName |
| | | }); |
| | |
| | | },'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; |
| | | } |
| | | }) |
| | | }, |
| | |
| | | * 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('超出剩余次数~') |
| | |
| | | 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(){ |
| | |
| | | border-radius: 4px; |
| | | } |
| | | .status{ |
| | | flex: 0 0 80px; |
| | | width: 80px; |
| | | text-align: right; |
| | | color: #a5abaf; |
| | |
| | | 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; |
| | |
| | | } |
| | | .footer .btn{ |
| | | border-radius: 20px; |
| | | line-height: 34px; |
| | | padding: 0 24px; |
| | | line-height: 36px; |
| | | padding: 0 26px; |
| | | font-size: 14px; |
| | | } |
| | | .no-record{ |