diff --git a/pages/goods/categoryList/categoryList.js b/pages/goods/categoryList/categoryList.js index fd883c8..a176505 100644 --- a/pages/goods/categoryList/categoryList.js +++ b/pages/goods/categoryList/categoryList.js @@ -28,7 +28,6 @@ Page({ is_country:1, //品牌的控制属性 is_brand:1, - //选择分类的控制属性 select_classify_on:223, index:223, @@ -40,6 +39,7 @@ Page({ cat_id:0, pl_timer: null,//只有品类的定时器 is_pl_time:0, + }, onLoad: function(tt) { const res = wx.getSystemInfoSync(), @@ -74,19 +74,16 @@ Page({ lettersPosition: temp }); - if (this.data.is_used_share==0){ - + if (this.data.is_used_share==0){ this.get_nation(); } - }, onShow:function(){ var that=this; - this.requestFirstCategoris(); + //this.requestFirstCategoris(); if(getApp().globalData.user_id) getApp().requestCardNum(); - getApp().getConfig2(function (e) { var data=e; @@ -98,37 +95,46 @@ Page({ if (e.categoryset.indexOf("," + 3 + ",") != -1) { that.setData({ is_show_pp: 1 }); } if (e.categoryset.indexOf("," + 2 + ",") != -1) { that.setData({ is_show_gb: 1 }); } that.setData({ store_config: e,is_do:1 }); - if ( that.data.is_show_gb != 1 && that.data.is_show_pp != 1){ - - - that.data.pl_timer = setInterval(function () { + //---有勾品类--- + if (that.data.is_show_pl){ that.requestFirstCategoris(); - console.log("8888888888888888888", that.data.one_level_classify.length); - if (that.data.one_level_classify.length>0){ - console.log("7777777777777777777777", that.data.one_level_classify); - //清除定时器 - clearInterval(that.data.pl_timer); - } - },1000); - - console.log(that.data.one_level_classify); - that.setData({ select_classify_on: 0, index: 0, goodslist: one_level_classify[0]}); - - } else if (that.data.is_show_gb != 1 ){ - - - that.setData({ select_classify_on: 220, classify_name: "品牌" }); } + if (that.data.is_show_gb != 1 && that.data.is_show_pp != 1 && that.data.is_show_pl){ + that.data.pl_timer = setInterval(function () { + if (that.data.one_level_classify.length>0){ + var item=that.data.one_level_classify[0],arr=item.array; + //----如果有下级的时候----- + if(item.array && item.array.length>0){ + var is_lev_thr=0 + for(var i=0;i0) {is_lev_thr=1;break; } + } + that.setData({ is_level_three: is_lev_thr }); + if (is_lev_thr!=1) { + that.setData({ select_classify_on: 0, index: 0, classify_name: item.items.name, goodslist: item.array }); + } else { + that.setData({ select_classify_on: 0, index: 0, goodslist: arr }); + } + } + else{ + that.setData({ select_classify_on: 0, index: 0, goodslist: null,classify_name:item.items.name,is_level_three: 0}); + } + clearInterval(that.data.pl_timer); + } + },1000); - var one_level_classify = that.data.one_level_classify; + } else if (that.data.is_show_gb != 1 && that.data.is_show_pp ){ + that.setData({ select_classify_on: 220, classify_name: "品牌" }); + } - + + var one_level_classify = that.data.one_level_classify; + if (that.data.is_show_pl) that.setData({ currentTab: 0 }); else if (that.data.is_show_gb){ that.setData({ currentTab: 1 });that.get_nation(); } else if (that.data.is_show_pp) {that.setData({ currentTab: 2 });that.get_brand(); } - //----求传参过来的控制----- if (getApp().globalData.cat_type == 1 && that.data.is_show_gb ) { that.setData({ currentTab: 1 }); @@ -139,12 +145,9 @@ Page({ } else if (that.data.is_show_pl) { that.setData({ currentTab: 0 }); } - }) - }, - //---------------分类请求接口,数据进行拼装------------------ requestFirstCategoris: function() { var t = this; @@ -206,18 +209,16 @@ Page({ arr[dd].array[pp].arrays.push(need_to_insert); arr.ishaf_three = 0; break; } - } - } } - } + } } console.log("现在是1级与2级所有的数据", arr) t.setData({one_level_classify:arr}); - + } } }); @@ -237,6 +238,7 @@ Page({ } }); }, + switchFirstCategory: function(t) { this.requestCategories(t.currentTarget.dataset.id); }, @@ -360,7 +362,6 @@ Page({ s.setData({ nationlist:dda}) } }); - }, //获取品牌 @@ -392,7 +393,6 @@ Page({ for (var i = 0; i < dda.length; i++) { dda[i].logo = oo.imghost+dda[i].logo; - if (arr.length>0){ var find = 0; //寻找字母在arr数组中是否存在,不存在就要添加,存在就在要这个数组添加元素 @@ -455,50 +455,39 @@ Page({ // 新的版本分类点击一级分类 click_classify:function(e){ this.data.ishaf_three=0; - var indexs=e.currentTarget.dataset.index; + var indexs=e.currentTarget.dataset.index; var name = e.currentTarget.dataset.name; var cid = e.currentTarget.dataset.cid; var pid = e.currentTarget.dataset.pid; var arr = e.currentTarget.dataset.arr; - console.log("数据是什么",arr); - if (indexs==220){ - this.get_brand(); - } + if (indexs==220){ this.get_brand();} if (arr!="undefined" && arr!=undefined){ - if (arr.length==0){ - var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid; - wx.navigateTo({ url: lurl }); - return false; - } - if (arr.length != 0){ - - for(var i=0;i0) { - - this.setData({ is_level_three: 1 }); - break; - } - this.setData({ is_level_three: 0 }); - } - if (this.data.is_level_three!=1) { - - - this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, goodslist: arr }); - - - } else { - this.setData({ select_classify_on: indexs, index: indexs, goodslist: arr }); - + if (arr.length==0){ + this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, + goodslist: null,is_level_three: 0 }); + return false; + } + if (arr.length != 0){ + var is_lev_thr=0 + for(var i=0;i0) {is_lev_thr=1;break; } + } + this.setData({ is_level_three: is_lev_thr }); + if (this.data.is_level_three!=1) { + this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, goodslist: arr }); + } else { + this.setData({ select_classify_on: indexs, index: indexs, goodslist: arr }); + } } } - } - this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, cat_id: cid}); }, -// 图片失败 + + + //图片失败 bind_bnerr_xc: function (e) { var _errImg = e.target.dataset.errorimg; var _errurl = e.target.dataset.url; @@ -529,7 +518,7 @@ Page({ } }) }, - onUnload: function () { + onUnload: function () { this.destroyActivityTimer(); }, diff --git a/pages/goods/categoryList/categoryList.wxml b/pages/goods/categoryList/categoryList.wxml index e07e24c..c66972e 100644 --- a/pages/goods/categoryList/categoryList.wxml +++ b/pages/goods/categoryList/categoryList.wxml @@ -1,5 +1,5 @@ - + 分类 @@ -9,9 +9,7 @@ data-current="2" bindtap="clickTab">品牌 - - - + @@ -19,14 +17,12 @@ - - + - @@ -37,9 +33,7 @@ bindtap="go_cate" data-cid="{{item.id}}" data-pid="{{item.parent_id}}">{{item.name}} - - - + @@ -91,8 +85,7 @@ 去逛逛 - - + 商家暂未设置分类 @@ -101,169 +94,172 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -{{ishaf_three==1?good_list.name:classify_name}} - - - - - - - - {{bitem.name}} - + + + + - - - {{bitem.enname}} + + + - - - - - - - - -{{classify_name}} + + + + + + + + + + + + + + + + + + + - + - - - - - - {{user.name}} - - + + + + + + + + + {{ishaf_three==1?good_list.name:classify_name}} - - - - - - - - -{{classify_name}} - - 更多 - - - - - - - - - {{goods.items.name}} - + + + + + + + {{bitem.name}} + + + {{bitem.enname}} + + + + + + + + + - - - - + + {{classify_name}} + - - - - + + + - -{{goods.items.name}} - - 更多 - - - + + + {{user.name}} + + - - - - - {{item.name}} - - - - + + + + + + + + + {{classify_name}} + + 更多 + + + + + + + + + + {{goods.items.name}} + + + + + 该类别无子级 + + - - - - - + + + + + + + + + + {{goods.items.name}} + + 更多 + + + + + + + + {{item.name}} + + + + - + + + + + + + + + + + 商家暂未设置分类 + 去逛逛 + + \ No newline at end of file diff --git a/pages/goods/categoryList/categoryList.wxss b/pages/goods/categoryList/categoryList.wxss index 7b8606e..86708c4 100644 --- a/pages/goods/categoryList/categoryList.wxss +++ b/pages/goods/categoryList/categoryList.wxss @@ -384,4 +384,6 @@ margin: auto; } .nation_z_name{ max-width: 130rpx} -.nation_y_name{ max-width: 130rpx} \ No newline at end of file +.nation_y_name{ max-width: 130rpx; color: #888} + +.no_child_lev{width: 100%; text-align: center; color: #adadad; padding-top: 30rpx} \ No newline at end of file