From 17fa125337f99f288f0a5a1c5cef6594ef3ef8c9 Mon Sep 17 00:00:00 2001 From: shuxiaoquan <853623962@qq.com> Date: Thu, 14 Mar 2024 14:54:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=88=86=E7=B1=BB=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 39c3da3..a5b9699 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -670,7 +670,26 @@ }).then(res => { if (res.status == 200) { this.tabList = res.data.list; - this.catagoryList = res.data.list[0].children || [] + + let arr = [], total = (this.tabList && this.tabList.length > 0 ?this.tabList[0].children.length:0) + if(this.tabList[0].children && this.tabList[0].children.length > 0){ + this.tabList[0].children.map(a=>{ + arr.push(a) + }) + } + if(5- total >= 0 && arr.length > 0){ + this.tabList[0].children.map(a=>{ + if(a.children && a.children.length > 0){ + a.children.map((b,idx)=>{ + if(idx < (20-arr.length)){ + arr.push(b) + } + }) + } + }) + } + this.catagoryList = arr; + // this.catagoryList = res.data.list[0].children || [] if (this.current == 0) { this.getRankingList(this.tabList[0].category_id) // this.getNewGoods(this.tabList[0].category_id) @@ -700,7 +719,26 @@ }, changeGoodsType(index) { this.tabCurrent = index; - this.catagoryList = this.tabList[index].children || []; + this.isToggle = false; + let arr = [], total = this.tabList[index].children.length + if(this.tabList[index].children && this.tabList[index].children.length > 0){ + this.tabList[index].children.map(a=>{ + arr.push(a) + }) + } + if(5- total >= 0 && arr.length > 0){ + this.tabList[index].children.map(a=>{ + if(a.children && a.children.length > 0){ + a.children.map((b,idx)=>{ + if(idx < (20-arr.length)){ + arr.push(b) + } + }) + } + }) + } + // this.catagoryList = this.tabList[index].children || []; + this.catagoryList = arr this.getRankingList(this.tabList[index].category_id) // this.getNewGoods(this.tabList[index].category_id) this.getNewGoods()