diff --git a/components/swiper-tab/swiper-tab-slide.vue b/components/swiper-tab/swiper-tab-slide.vue index 234c4a9..cc57b2a 100644 --- a/components/swiper-tab/swiper-tab-slide.vue +++ b/components/swiper-tab/swiper-tab-slide.vue @@ -112,7 +112,6 @@ }; }, mounted() { - // 缓存状态栏+标题栏的高度 const query = wx.createSelectorQuery().in(this) query.select('.posi-sticky').boundingClientRect((rect) => { console.log(rect.height); diff --git a/pages/tabbar/cate/cate.vue b/pages/tabbar/cate/cate.vue index 379e223..d047849 100644 --- a/pages/tabbar/cate/cate.vue +++ b/pages/tabbar/cate/cate.vue @@ -12,13 +12,13 @@ - - + + - + {{item.title}} @@ -65,44 +65,10 @@ current:0, scrollHeight:uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 50, newWidth:uni.getSystemInfoSync().windowWidth, - cateList:[ - // {id:1,title:'推荐套装'}, - // {id:1,title:'推荐套装'}, - // {id:1,title:'推荐套装'}, - // {id:1,title:'推荐套装'}, - // {id:1,title:'推荐套装'}, - // {id:1,title:'推荐套装'}, - // {id:1,title:'推荐套装'}, - // {id:1,title:'推荐套装'}, - // {id:1,title:'推荐套装'}, - // {id:1,title:'推荐套装'}, - ], + cateList:[], //分类导航列表 activeIndex:0, - secendCateList:[ - {title:'标题一'}, - {title:'标题二标题二'}, - {title:'标题三'}, - {title:'标题四'}, - {title:'标题五'}, - {title:'标题六标题六标题六'}, - {title:'标题七'}, - {title:'标题八'}, - {title:'标题九'}, - ], - dataList:[ - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题',price:199}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - // {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'标题标题标题标题标题标题标题',price:20000}, - ], + secendCateList:[], + dataList:[], //商品列表 page:1, size:10, total:0, @@ -126,14 +92,16 @@ methods: { // 查询商品列表 checkShopList(id){ + console.log(id,'分类id2') this.ifLoading = true; let params = { page:this.page,// query 否 1 页数 size:this.size,// query 否 10 每页数量 - pid:id + 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) { @@ -152,6 +120,7 @@ this.ifLoading = false; }) }, + // 查询左侧分类列表 checkShopCate(){ this.$requst.post('/api/spu/category',{hasChildren:1}).then(res=>{ @@ -172,6 +141,7 @@ } }) }, + scrollBottomEv(){ console.log('触底了'); if(this.total!=this.dataList.length) { @@ -179,48 +149,47 @@ this.checkShopList(this.pid); } }, + // 一级分类选择 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 = [ - {title:'标题一'}, - {title:'标题二标题二'}, - {title:'标题三'}, - {title:'标题四'}, - {title:'标题五'}, - {title:'标题六标题六标题六'}, - {title:'标题七'}, - {title:'标题八'}, - {title:'标题九'}, - ] + this.secendCateList = []; } - this.checkShopList(id); + this.checkShopList(this.pid); }, + goDetail(id) { uni.navigateTo({ - url:'/pagesB/shop-detail/shop-detail' + 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) { - this.$toolAll.tools.showToast('加入购物车成功(*^▽^*)') + this.$toolAll.tools.showToast('加入购物车成功(*^▽^*)'); } else { this.$toolAll.tools.showToast(res.msg) } }) }, + // tab点击事件 clickTab(index){ this.activeIndex = index; + this.pid = this.secendCateList[this.activeIndex].id; + this.checkShopList(this.pid); }, } } diff --git a/pagesA/order-list/order-list.vue b/pagesA/order-list/order-list.vue index 6667625..14b897f 100644 --- a/pagesA/order-list/order-list.vue +++ b/pagesA/order-list/order-list.vue @@ -8,34 +8,36 @@ - + - + - 订单号:2928392832 - {{['已下单','制作中','已发货','已完成','已取消'][0]}} + 订单号:{{item1.coding}} + {{item1.status_text}} - - + + - {{item1.title}} + {{item2.spu_name}} - 单位:{{item1.title}} + 单位:{{item2.sku_unit}} - ¥{{$toolAll.tools.changeNum(item1.price)}} - x1 + ¥{{$toolAll.tools.changeNum(item2.price)}} + x{{item2.num}} - 合计:¥2390.00 - - 再次购买 + 合计:¥{{item1.original_price}} + 取消订单 + 再次购买 + 确认收货 + - + @@ -62,51 +64,24 @@ data() { return { tagList:[ - {title:'全部'}, - {title:'已下单'}, - {title:'制作中'}, - {title:'已发货'}, - {title:'已完成'}, - {title:'已取消'}, + {title:'全部',tag:'all'}, + {title:'已下单',tag:'order_placed'}, + {title:'制作中',tag:'makeing'}, + {title:'已发货',tag:'shipped'}, + {title:'已完成',tag:'completed'}, + {title:'已取消',tag:'cancel'}, ], activeIndex:0, - dataList:[ - [ - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - ], - [ - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - ], - [ - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - ], - [ - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - ], - [ - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - ], - [ - {title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99}, - ], - ], + dataList:[[],[],[],[],[],[]], flag:true, swiperHeight:uni.getSystemInfoSync().windowHeight, newTop:uni.getSystemInfoSync().statusBarHeight + 50, ifLoading:false, - total:0 + total:0, + totalAll:0, + page: 1, + size: 10, + tag: 'all' } }, onLoad(op) { @@ -117,34 +92,115 @@ if(op.index) { this.activeIndex = op.index; } + this.getOrderList(); }, methods: { tabTap(e) { this.activeIndex = e; + this.page = 1; + this.dataList = [[],[],[],[],[],[]]; + this.getOrderList(); }, swiperChange(e) { this.activeIndex = e.detail.current; }, scrollBottomEv(e) { this.ifLoading = true; - this.total = 0; + + let pageSize = Math.floor(this.totalAll/this.size) + if(this.page < pageSize){ + this.page++; + this.getOrderList(); + }else if(this.page == pageSize){ + this.page++; + this.getOrderList(); + this.total = this.totalAll; + }else{ + this.ifLoading = false; + return false; + } setTimeout(()=>{ this.ifLoading = false; - this.total = this.dataList.length; },2000) }, + // 获取订单列表 + getOrderList(){ + let params = { + page: this.page, + size: this.size, + tag: this.tagList[this.activeIndex].tag + } + this.$requst.get('/api/user/order',params).then(res=>{ + if(res.data.length!=0){ + this.totalAll = res.data.total; + res.data.list.forEach(item=>{ + let dataObj = { + id: item.id, //id + coding: item.coding, //订单号 + original_price: item.original_price, //总价 + status: item.status, //订单状态英文 + status_text: item.status_text, //订单状态中文 + skus: item.skus //订单详情 + } + this.dataList[this.activeIndex].push(dataObj) + }) + console.log(this.dataList[this.activeIndex],'订单列表') + } + }) + }, // 去详情 - goDetail(){ + goDetail(id){ uni.navigateTo({ - url:'/pagesB/order-detail/order-detail' + url:'/pagesB/order-detail/order-detail?id='+id }) }, // 取消订单 - cancleEv(){ - console.log('取消订单'); + cancleEv(coding){ + let params = { + order_coding: coding //订单号 + } + this.$requst.post('/api/order/cancel',params).then(res=>{ + if(res.code==0) { + this.$toolAll.tools.showToast('取消订单成功(*^▽^*)'); + this.dataList = [[],[],[],[],[],[]]; + this.page = 1; + this.getOrderList(); + } else { + this.$toolAll.tools.showToast(res.msg) + } + }) + }, + // 确认收货 + affirmEv(id){ + let params = { + order_id: id //订单号 + } + this.$requst.post('/api/order/accepted',params).then(res=>{ + if(res.code==0) { + this.$toolAll.tools.showToast('确认收货成功(*^▽^*)'); + this.dataList = [[],[],[],[],[],[]]; + this.page = 1; + this.getOrderList(); + } else { + this.$toolAll.tools.showToast(res.msg) + } + }) }, // 再次购买 - buyEv(){ + buyEv(index){ + let buyList = []; + let newArr = this.dataList[this.activeIndex][index]; + newArr.skus.forEach(item=>{ + let obj = { + sku_coding: item.coding, + num: item.num + } + buyList.push(obj); + }) + uni.setStorageSync('buyList',buyList); + uni.navigateTo({ + url:'/pagesB/settlement/settlement' + }) uni.navigateTo({ url:'/pagesB/settlement/settlement' }) diff --git a/pagesB/order-detail/order-detail.vue b/pagesB/order-detail/order-detail.vue index 6b5bc1d..87de3a5 100644 --- a/pagesB/order-detail/order-detail.vue +++ b/pagesB/order-detail/order-detail.vue @@ -6,41 +6,41 @@ 订单编号 - 2928392832 + {{orderDetail.coding}} 下单时间 - 2021-11-30 23:30 + {{orderDetail.status_text}} 订单状态 - 已发货 + {{orderDetail.coding}} 订单信息 - + - 于亿年宝藏中臻选1的宝石级钻石每年开采数LOVE100 星座光的原石挑选 + {{item.spu_name}} - 单位:盒 + 单位:{{item.sku_unit}} - ¥{{$toolAll.tools.changeNum(2000)}} - x1 + ¥{{item.price}} + x{{item.num}} - 总计:¥4000 + 总计:¥{{orderDetail.original_price}} 联系信息 - 徐卫 546546515315 + {{orderDetail.contacts}} {{orderDetail.phone}} - 四川省成都市双店路奥园广场3期1419号 - 婚期:2022-12-23 - 希望到货时间:2022-12-21 + {{orderDetail.address}} + 婚期:{{orderDetail.wedding_date}} + 希望到货时间:{{orderDetail.expected_delivery_date}} @@ -56,7 +56,7 @@ export default { data() { return { - + orderDetail: [] } }, onShareAppMessage(res) { @@ -72,9 +72,22 @@ }, methods: { getDetail(id){ - this.$requst.post('/api/spu/detail',{id}).then(res=>{ - if(res.code==1) { - + this.$requst.post('/api/user/order-detail',{id}).then(res=>{ + if(res.code==0) { + let dataObj = { + coding: res.data.coding, //订单号 + created_at: res.data.created_at, //下单时间 + status_text: res.data.status_text, //订单状态 + expected_delivery_date: res.data.expected_delivery_date, //期望到货时间 + wedding_date: res.data.wedding_date, //婚期 + original_price: res.data.original_price, //总价 + contacts: res.data.contacts, //收件人姓名 + address: res.data.address, //收件地址 + phone: res.data.phone, //联系电话 + skus: res.data.skus //订单详情列表 + } + this.orderDetail = dataObj; + console.log(this.orderDetail,'订单详情2') } }) } diff --git a/pagesB/settlement/settlement.vue b/pagesB/settlement/settlement.vue index 00706c4..b4bbdf5 100644 --- a/pagesB/settlement/settlement.vue +++ b/pagesB/settlement/settlement.vue @@ -49,7 +49,7 @@ } }, onLoad() { - + console.log(uni.getStorageSync('buyList'),'缓存数组') }, methods: { // 提交 diff --git a/pagesB/shop-detail/shop-detail.vue b/pagesB/shop-detail/shop-detail.vue index e1ec662..839f059 100644 --- a/pagesB/shop-detail/shop-detail.vue +++ b/pagesB/shop-detail/shop-detail.vue @@ -61,6 +61,7 @@ this.getDetail(op.id); }, methods: { + // 查询详情事件 getDetail(id){ this.$requst.post('/api/spu/detail',{id}).then(res=>{ @@ -81,6 +82,7 @@ } }) }, + // 立即购买 buyEv(id){ this.$requst.post('/api/order/shopping-cart-add',{sku_id:id,num:1}).then(res=>{ @@ -94,6 +96,7 @@ } }) }, + // 加入购物车 addCartEv(id) { if(this.$toolAll.tools.judgeAuth()) {