diff --git a/components/shopping-carts/cart-slide.vue b/components/shopping-carts/cart-slide.vue index 43117f3..6f9b8ef 100644 --- a/components/shopping-carts/cart-slide.vue +++ b/components/shopping-carts/cart-slide.vue @@ -113,6 +113,7 @@ // return this.$toolAll.tools.addXiaoShu(allPrice); return allPrice.toString(); }, + // 要删除的数量 buyNum() { let buyNum = 0; @@ -123,6 +124,7 @@ }) return buyNum; }, + // 全选 allChoose() { let ifAll = false; @@ -241,12 +243,6 @@ chooseEv(index) { this.listData[index].ifcheck = !this.listData[index].ifcheck; }, - // 去商品详情事件 - goDetail(id) { - uni.navigateTo({ - url:'/pagesB/shop-detail/shop-detail' - }) - }, // 数量加减事件 addCutEv(index,num) { if(this.listData[index].slide_x==0){ @@ -259,6 +255,16 @@ // 减 ,如果当前商品数量大于最小值 if(this.listData[index].num > this.minNum) { this.listData[index].num--; + }else{ + uni.showModal({ + title: '提示', + content: '是否将该商品移除购物车?', + success: (res)=> { + if (res.confirm) { + this.delShopEv(this.listData[index].id); + } + } + }); } } this.$requst.post('/api/order/shopping-cart-change-num',{id:this.listData[index].id,num:this.listData[index].num}).then(res=>{ @@ -268,6 +274,18 @@ }) } }, + // 删除商品 + delShopEv(id){ + this.$requst.post('/api/order/shopping-cart-del',{id:id}).then(res=>{ + if(res.code==0){ + this.$toolAll.tools.showToast('删除成功'); + this.getList(); + }else{ + this.$toolAll.tools.showToast(res.msg) + } + }) + }, + // 查看商品详情 goDetail(id) { uni.navigateTo({ diff --git a/pages/tabbar/cate/cate.vue b/pages/tabbar/cate/cate.vue index c7094a8..78a5020 100644 --- a/pages/tabbar/cate/cate.vue +++ b/pages/tabbar/cate/cate.vue @@ -5,7 +5,7 @@ - + {{item.title}} @@ -13,28 +13,29 @@ - - - - - - - - - {{item.title}} - - ¥{{item.price}} - - - 立即选购 + + + + {{cateList[index].title}} + + + + {{item1.title}} + + ¥{{item1.price}} + + + 立即选购 + - - - - @@ -70,12 +71,12 @@ activeIndex:0, secendCateList:[], dataList:[], //商品列表 - page:1, - size:10, total:0, flag:true, ifLoading:false, - pid:''//分类id + pid:'',//分类id + doms:'', + topList:[] } }, computed:{ @@ -92,20 +93,17 @@ }, methods: { // 查询商品列表 - checkShopList(id){ - console.log(id,'分类id2') - this.ifLoading = true; - let params = { - page:this.page,// query 否 1 页数 - size:this.size,// query 否 10 每页数量 - category_id:id - } - this.$requst.post('/api/spu/list',params).then(res=>{ - if(res.code==0) { - console.log(res,'商品列表') - this.total = res.data.total; - if(this.page==1) this.dataList = []; - if(res.data.list.length) { + checkShopList(){ + for(let i=0;i{ + if(res.code==0) { + this.total = res.data.total; + let newArr = []; res.data.list.forEach(item=>{ let obj = { id:item.id, @@ -114,12 +112,17 @@ title:item.name, price:this.$toolAll.tools.changeNum(parseInt(item.price)+'') } - this.dataList.push(obj); + newArr.push(obj); }) + this.dataList[i] = newArr; + if(i == this.cateList.length-1){ + console.log(i,123) + this.getNodesInfo(); + this.ifLoading = false; + } } - } - this.ifLoading = false; - }) + }) + } }, // 查询左侧分类列表 @@ -134,50 +137,61 @@ this.newWidth = this.newWidth - rect.width - 20; }).exec() },200) - this.pid = this.cateList[this.current].id; - if(this.cateList[this.current].child) { - this.secendCateList = this.cateList[this.current].child; - this.checkShopList(this.secendCateList[0].id); - }else{ - this.checkShopList(this.cateList[this.current].id); - } + this.checkShopList(); } }) }, scrollBottomEv(){ console.log('触底了'); - if(this.total!=this.dataList.length) { - this.page++; - this.checkShopList(this.pid); - } + // setTimeout(()=>{ + // this.current =this.cateList.length - 1; + // },80) }, // 一级分类选择 chooseCate(index,id) { - this.current = index; - this.page = 1; - this.pid = id; - console.log(this.pid,'分类id') - // if(this.activeIndex>this.cateList[index].child.length-1) { - // this.activeIndex = this.cateList[index].child.length-1; - // } - if(this.cateList[index].child) { - this.secendCateList = this.cateList[index].child; - this.activeIndex = 0; - this.pid = this.secendCateList[0].id; - } else { - this.secendCateList = []; - } - this.checkShopList(this.pid); + this.current =index + this.doms = 'product'+index }, + // 滚动 + scrolls(e){ + let scrollTop = e.target.scrollTop + for(let i =0;i=h1&&scrollTop{ + const query = uni.createSelectorQuery().in(this); + query.selectAll('.posir').boundingClientRect().exec((res)=>{ + console.log(res,234) + let nodes = res[0] + let rel =[]; + nodes.map(item=>{ + rel.push(item.top) + }) + this.topList = rel + }) + },200) + + }, + + // 跳转详情页 goDetail(id) { uni.navigateTo({ url:'/pagesB/shop-detail/shop-detail?id='+id }) }, + // 加入购物车 addCartEv(id) { this.$requst.post('/api/order/shopping-cart-add',{sku_id:id,num:1}).then(res=>{ if(res.code==0) { @@ -188,17 +202,15 @@ } }) }, - - // tab点击事件 - clickTab(index){ - this.activeIndex = index; - this.pid = this.secendCateList[this.activeIndex].id; - this.checkShopList(this.pid); - }, } } diff --git a/pagesB/order-detail/order-detail.vue b/pagesB/order-detail/order-detail.vue index 87de3a5..07abc74 100644 --- a/pagesB/order-detail/order-detail.vue +++ b/pagesB/order-detail/order-detail.vue @@ -1,5 +1,5 @@