| | |
| | | <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(){ |