Commit ea408f73984e6f38a8954bf5feac5855ba278abc
Merge branch 'work-1.1_20191010' of http://git.vipzhuang.cn/wxd/MShopWeApp into work-1.1_20191010
Showing
3 changed files
with
228 additions
and
49 deletions
pages/goods/categoryList/categoryList.js
... | ... | @@ -35,6 +35,9 @@ Page({ |
35 | 35 | index:223, |
36 | 36 | classify_name:"国家",//项目类型 |
37 | 37 | brand_list:null,//品牌列表 |
38 | + | |
39 | + one_level_classify:[],// 新的版本左边的边分类1级 | |
40 | + ishaf_three:0//判断有没有3级 | |
38 | 41 | }, |
39 | 42 | onLoad: function(tt) { |
40 | 43 | const res = wx.getSystemInfoSync(), |
... | ... | @@ -68,9 +71,9 @@ Page({ |
68 | 71 | this.setData({ |
69 | 72 | lettersPosition: temp |
70 | 73 | }); |
71 | - console.log(this.data.is_used_share,"是什么东西啊"); | |
74 | + | |
72 | 75 | if (this.data.is_used_share==0){ |
73 | - console.log("有进来m"); | |
76 | + | |
74 | 77 | this.get_nation(); |
75 | 78 | } |
76 | 79 | |
... | ... | @@ -78,9 +81,15 @@ Page({ |
78 | 81 | }, |
79 | 82 | |
80 | 83 | onShow:function(){ |
84 | + getApp | |
81 | 85 | var that=this; |
82 | 86 | |
83 | 87 | getApp().getConfig2(function (e) { |
88 | + var data=e; | |
89 | + var switch_list_data = data.switch_list; | |
90 | + var switch_list = JSON.parse(switch_list_data); | |
91 | + var is_newsgoodstype = switch_list.is_newsgoodstype; | |
92 | + that.setData({ is_used_share :is_newsgoodstype}); | |
84 | 93 | if (e.categoryset.indexOf("," + 1 + ",") != -1) { that.setData({ is_show_pl: 1 }); } |
85 | 94 | if (e.categoryset.indexOf("," + 3 + ",") != -1) { that.setData({ is_show_pp: 1 }); } |
86 | 95 | if (e.categoryset.indexOf("," + 2 + ",") != -1) { that.setData({ is_show_gb: 1 }); } |
... | ... | @@ -115,13 +124,15 @@ Page({ |
115 | 124 | success: function(e) { |
116 | 125 | var arr=new Array(); |
117 | 126 | var dda = e.data.data.pageData; |
118 | - console.log(dda.length); | |
127 | + | |
128 | + console.log(dda, "所有的数据"); | |
129 | + if (this.data.is_used_share == 0) {//is_used_share控制新旧版本 | |
119 | 130 | for(var i=0;i<dda.length;i++){ |
120 | 131 | if (parseInt(dda[i].level)==1){ |
121 | 132 | var item = {items: dda[i], array: new Array()} |
122 | 133 | arr.push(item); |
123 | 134 | } else if (parseInt(dda[i].level) == 2){ |
124 | - for (var j = 0; j < arr.length;j++ ){ | |
135 | + for (var j = 0; j < arr.length;j++ ){ | |
125 | 136 | if (parseInt(dda[i].parent_id) == parseInt(arr[j].items.id)){ |
126 | 137 | arr[j].array.push(dda[i]); break; |
127 | 138 | } |
... | ... | @@ -131,6 +142,50 @@ Page({ |
131 | 142 | } |
132 | 143 | } |
133 | 144 | t.setData({ catelist: arr}); |
145 | + }else{ | |
146 | + //新的版本 | |
147 | + for (var i = 0; i < dda.length; i++) { | |
148 | + | |
149 | + | |
150 | + //--要排队的元素--- | |
151 | + var need_to_insert=dda[i]; | |
152 | + | |
153 | + if (parseInt(need_to_insert.level) == 1) { | |
154 | + var item = { items: need_to_insert, array: new Array() }//判断数组的长度看看有没有2级菜单 | |
155 | + arr.push(item); | |
156 | + } else if (parseInt(need_to_insert.level) == 2) { | |
157 | + for (var j = 0; j < arr.length; j++) { | |
158 | + if (parseInt(need_to_insert.parent_id) == parseInt(arr[j].items.id)) { | |
159 | + | |
160 | + var ishaf_two = { items: need_to_insert, arrays: new Array() }; | |
161 | + arr[j].array.push(ishaf_two); arr.ishaf_two = 0; break; | |
162 | + } | |
163 | + } | |
164 | + } else if (parseInt(need_to_insert.level) == 3) {//判断有3级的时候在二级里添加一个数组 | |
165 | + | |
166 | + for (var dd = 0; dd < arr.length; dd++) { | |
167 | + for (var pp = 0; pp < arr[dd].array.length; pp++) { | |
168 | + //--判断二级-- | |
169 | + var two_item = arr[dd].array; | |
170 | + | |
171 | + if (two_item && two_item.length>0){ | |
172 | + | |
173 | + if (parseInt(need_to_insert.parent_id) == parseInt(two_item[pp].items.id)) { | |
174 | + | |
175 | + arr[dd].array[pp].arrays.push(need_to_insert); arr.ishaf_three = 0; break; | |
176 | + } | |
177 | + | |
178 | + } | |
179 | + | |
180 | + } | |
181 | + } | |
182 | + } | |
183 | + | |
184 | + } | |
185 | + | |
186 | + console.log("现在是1级与2级所有的数据", arr) | |
187 | + t.setData({one_level_classify:arr}); | |
188 | + } | |
134 | 189 | } |
135 | 190 | }); |
136 | 191 | }, |
... | ... | @@ -271,7 +326,8 @@ Page({ |
271 | 326 | }, |
272 | 327 | success: function (e) { |
273 | 328 | var dda = e.data.data.pageData; |
274 | - | |
329 | + | |
330 | + | |
275 | 331 | s.setData({ nationlist:dda}) |
276 | 332 | } |
277 | 333 | }); |
... | ... | @@ -368,15 +424,52 @@ Page({ |
368 | 424 | this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; |
369 | 425 | |
370 | 426 | }, |
371 | - // 新的版本分类 | |
427 | + // 新的版本分类点击一级分类 | |
372 | 428 | click_classify:function(e){ |
429 | + this.data.ishaf_three=0; | |
373 | 430 | var indexs=e.currentTarget.dataset.index; |
374 | 431 | var name = e.currentTarget.dataset.name; |
375 | - console.log("获取当前下标",indexs); | |
376 | - this.setData({ select_classify_on: indexs, index: indexs, classify_name:name}); | |
432 | + var cid = e.currentTarget.dataset.cid; | |
433 | + var pid = e.currentTarget.dataset.pid; | |
434 | + var arr = e.currentTarget.dataset.arr; | |
435 | + | |
377 | 436 | if (indexs==220){ |
378 | 437 | this.get_brand(); |
379 | 438 | } |
439 | + | |
440 | + if (arr!="undefined" && arr!=undefined){ | |
441 | + if (arr.length==0){ | |
442 | + var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid; | |
443 | + wx.navigateTo({ url: lurl }); | |
444 | + return false; | |
445 | + } | |
446 | + if (arr.length != 0){ | |
447 | + | |
448 | + for(var i=0;i<arr.length;i++){ | |
449 | + if(arr[i].arrays.length<0){ | |
450 | + console.log(arr,"二级数据"); | |
451 | + this.setData({select_classify_on: indexs, index: indexs, classify_name: name, goodslist:arr}); | |
452 | + | |
453 | + }else{ | |
454 | + | |
455 | + console.log("aaaaaaaaaaaaaaaaa", arr[i].length); | |
456 | + this.setData({ select_classify_on: indexs, index: indexs, goodslist: arr }); | |
457 | + // if (arr[i].length>0){ | |
458 | + console.log("000000"); | |
459 | + // for (var z = 0;z<arr[i].length;z++){ | |
460 | + // var arr = arr[i]; | |
461 | + // console.log(z,"三级的数据", arr); | |
462 | + // this.setData({ select_classify_on: indexs, index: indexs,goodslist: arr}); | |
463 | + // } | |
464 | + console.log("这是什么东西", this.data.goodslist); | |
465 | + // } | |
466 | + } | |
467 | + // } | |
468 | + } | |
469 | + } | |
470 | + } | |
471 | + | |
472 | + this.setData({ select_classify_on: indexs, index: indexs, classify_name: name }); | |
380 | 473 | |
381 | 474 | }, |
382 | 475 | // 图片失败 |
... | ... | @@ -387,7 +480,33 @@ Page({ |
387 | 480 | var _errObj = {}; |
388 | 481 | _errObj[_errImg] = "/miniapp/images/default_g_img.gif"; |
389 | 482 | this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; |
390 | - | |
483 | + }, | |
484 | + //选择更多 | |
485 | + select_more:function(e){ | |
486 | + var cid = e.currentTarget.dataset.cid; | |
487 | + var pid = e.currentTarget.dataset.pid; | |
488 | + console.log("选择更多"+cid); | |
489 | + var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid; | |
490 | + wx.navigateTo({ url: lurl }); | |
491 | + | |
492 | + }, | |
493 | +//扫一扫 | |
494 | + getScancode:function(){ | |
495 | + var _this = this; | |
496 | + // 允许从相机和相册扫码 | |
497 | + wx.scanCode({ | |
498 | + success: (res) => { | |
499 | + // var result = res.result; | |
500 | + // console.log("扫一扫返回",result); | |
501 | + // wx.navigateTo({ | |
502 | + | |
503 | + // url: "/pages/goods/search/search?s_key=" + result, | |
504 | + // }); | |
505 | + } | |
506 | + }) | |
507 | + }, | |
508 | + onUnload: function () { | |
509 | + this.destroyActivityTimer(); | |
391 | 510 | }, |
392 | 511 | |
393 | 512 | }); |
394 | 513 | \ No newline at end of file | ... | ... |
pages/goods/categoryList/categoryList.wxml
1 | -<block wx:if="{{is_used_share}}"> | |
1 | +<block wx:if="{{is_used_share==0}}"> | |
2 | 2 | <view class='top_view' wx:if="{{is_show_pl || is_show_gb || is_show_pp }}"> |
3 | 3 | <view class="swiper-tab" > |
4 | 4 | <view wx:if="{{is_show_pl}}" class="swiper-tab-item {{currentTab==0?'active':''}}" |
... | ... | @@ -102,9 +102,9 @@ |
102 | 102 | </block> |
103 | 103 | <block wx:else> |
104 | 104 | <!-- 新版分类头部 --> |
105 | -<view class="xc-search-box flex-center white_b" bindtap="goseach"> | |
106 | - <view class="share-height t-c"> | |
107 | - <image class="scanning_black-img"src="../../../images/scanning_black.png"></image> | |
105 | +<view class="xc-search-box flex-center white_b"> | |
106 | + <view class="share-height t-c" bindtap="getScancode" > | |
107 | + <image class="scanning_black-img"src="{{iurl}}/miniapp/images/goodscategory/scanning_black.png"></image> | |
108 | 108 | <view class="fs24"> |
109 | 109 | 扫一扫 |
110 | 110 | </view> |
... | ... | @@ -122,28 +122,41 @@ |
122 | 122 | <!-- 分类项目的类型 --> |
123 | 123 | <view class="project_type"> |
124 | 124 | <view class="project_type-frame"> |
125 | - <view bindtap="click_classify" class="share_type fs32 flex-space-between xc-letter-spacing {{select_classify_on==223?'select_classify':''}}"data-index="223"data-name="国家" wx:if="{{is_country}}"> | |
126 | - <text>国</text><text>家</text> | |
125 | + <view wx:if="{{is_show_gb}}"> | |
126 | + <view bindtap="click_classify" class="share_type fs32 flex-space-between xc-letter-spacing {{select_classify_on==223?'select_classify':''}}"data-index="223"data-name="国家" wx:if="{{is_country}}"> | |
127 | + <text>国</text><text>家</text> | |
128 | + <!-- <view wx:for="{{classify_name}}" wx:for-item="name"wx:for-index="index"> | |
129 | + <view> | |
130 | + {{name}} | |
131 | + </view> | |
132 | + </view> --> | |
133 | + </view> | |
127 | 134 | </view> |
135 | + <view wx:if="{{is_show_pp}}"> | |
128 | 136 | <view bindtap="click_classify" class="{{select_classify_on==220?'select_classify':''}} share_type fs32 flex-space-between xc-letter-spacing" wx:if="{{is_brand}}"data-index="220"data-name="品牌"> |
129 | 137 | <text>品</text><text>牌</text> |
130 | 138 | </view> |
131 | - <block wx:for="{{name}}" wx:for-item="ittm"wx:for-index="index"> | |
132 | - <view bindtap="click_classify" class="{{select_classify_on==index?'select_classify width80':''}} share_type fs32 t-c {{ittm.names.length==2? 'world_sn':''}} {{select_classify_on==index&&ittm.names.length==2?'text-indent':''}} {{select_classify_on==index&&ittm.names.length==3?'text3':''}}"data-index="{{index}}"data-name="{{ittm.names}}"> | |
133 | - <view class="{{ittm.names.length==3?'flex-center-around':'flex-space-between'}}" wx:if="{{ittm.names.length<4}}"> | |
134 | - <view wx:for="{{ittm.names}}" wx:for-item="names"wx:for-index="index"> | |
139 | + </view> | |
140 | + <view wx:if="{{is_show_pl}}"> | |
141 | + | |
142 | + <view wx:for="{{one_level_classify}}" wx:for-item="ittms" > | |
143 | + <view bindtap="click_classify" data-arr="{{ittms.array}}" data-cid="{{ittms.items.id}}" data-pid="0" class="{{select_classify_on==index?'select_classify width80':''}} share_type fs32 t-c {{ittms.items.name.length==2? 'world_sn':''}} {{select_classify_on==index&&ittms.items.name.length==2?'text-indent':''}} {{select_classify_on==index&&ittms.items.name.length==3?'text3':''}}"data-index="{{index}}"data-name="{{ittms.items.name}}"> | |
144 | + <view class="{{ittms.items.name.length==3?'flex-center-around':'flex-space-between'}}" wx:if="{{ittms.items.name.length<4}}"> | |
145 | + <view wx:for="{{ittms.items.name}}" wx:for-item="name"wx:for-index="index"> | |
135 | 146 | <view> |
136 | - {{names}} | |
147 | + {{name}} | |
137 | 148 | </view> |
138 | 149 | </view> |
139 | 150 | |
140 | 151 | </view> |
141 | - <view wx:else> | |
142 | - {{ittm.names}} | |
152 | + <view wx:else class="sort-name"> | |
153 | + {{ittms.items.name}} | |
143 | 154 | </view> |
144 | 155 | </view> |
145 | - </block> | |
146 | - | |
156 | + | |
157 | + </view> | |
158 | + | |
159 | +</view> | |
147 | 160 | </view> |
148 | 161 | |
149 | 162 | </view> |
... | ... | @@ -152,18 +165,18 @@ |
152 | 165 | |
153 | 166 | |
154 | 167 | <!-- 分类项目的内容 --> |
155 | -<view class="classify_content"> | |
156 | -<view class="classify_name fs32 flex-space-between"> | |
157 | -<view>{{classify_name}}</view> | |
158 | -<view class="flex select_more"> | |
159 | - <view class="red-co fs32">选择更多</view> | |
160 | - <view class="bg_right width_height"></view> | |
161 | -</view> | |
162 | 168 | |
163 | -</view> | |
169 | +<view class="classify_content"> | |
164 | 170 | <!-- 国家的样式 --> |
165 | 171 | <block wx:if="{{select_classify_on==223}}"> |
166 | - <view class="flex classify_content-frame" > | |
172 | +<view class="classify_name fs32 flex-space-between"> | |
173 | +<view>{{ishaf_three==1?good_list.name:classify_name}}</view> | |
174 | +<!-- <view class="flex select_more" > | |
175 | + | |
176 | + <view class="bg_right width_height"></view> | |
177 | +</view> --> | |
178 | +</view> | |
179 | + <view class=" classify_content-frame flex-space-between" > | |
167 | 180 | <view bindtap="go_nation" class="country_img-frame rel outer_location"wx:for="{{nationlist}}" wx:for-item="bitem" wx:for-index="pidx" data-nid="{{bitem.id}}" > |
168 | 181 | <image class="country_img" src="{{iurl}}{{bitem.logo}}"></image> |
169 | 182 | <view class='nation_box abs box'> |
... | ... | @@ -174,9 +187,26 @@ |
174 | 187 | </view> |
175 | 188 | </view> |
176 | 189 | </view> |
190 | + | |
191 | +<!-- <view class="classify_content-frame flex-wrap"> | |
192 | + <view class="brand_img_frame t-c ib" data-cid="{{item.items.id}}" data-pid="0"wx:for="{{ishaf_three==1?goodslist.arrays:goodslist}}" wx:for-index="index" wx:for-item="item" bindtap="go_cate"> | |
193 | + <image class="brand_img"src="{{ishaf_three==1?(item.items.icoimg==null?iurl+'/miniapp/images/no_cate_def.png':item.items.icoimg):(item.image==null?iurl+'/miniapp/images/no_cate_def.png':item.image)}}"binderror="goods_bnerr" data-err="goodslist[{{index}}].logo"></image> | |
194 | + <view class="brand_img_name fs24">{{ishaf_three==1?item.name:item.items.name}}</view> | |
195 | + </view> | |
196 | +</view> --> | |
197 | + | |
177 | 198 | </block> |
178 | 199 | <!-- 品牌 --> |
179 | 200 | <block wx:if="{{select_classify_on==220}}"> |
201 | + | |
202 | +<view class="classify_name fs32 flex-space-between"> | |
203 | +<view>{{classify_name}}</view> | |
204 | +<!-- <view class="flex select_more" > | |
205 | + | |
206 | + <view class="bg_right width_height"></view> | |
207 | +</view> --> | |
208 | +</view> | |
209 | + | |
180 | 210 | <view class="classify_content-frame flex flex-wrap"> |
181 | 211 | |
182 | 212 | <block wx:for="{{groups}}" wx:for-item="brand_list" wx:for-index="pidx"> |
... | ... | @@ -187,22 +217,40 @@ |
187 | 217 | <view class="brand_img_name fs24">{{user.name}}</view> |
188 | 218 | </view> |
189 | 219 | </view> |
220 | + | |
221 | + | |
190 | 222 | </block> |
191 | 223 | </view> |
192 | 224 | </block> |
225 | + | |
226 | + | |
227 | + | |
193 | 228 | <!-- 商品 --> |
194 | 229 | <block wx:if="{{select_classify_on!=220&&select_classify_on!=223}}"> |
195 | -<view class="classify_content-frame flex flex-wrap"> | |
196 | - | |
230 | +<block wx:for="{{goodslist}}"wx:for-item="goods"wx:for-index="inds"> | |
231 | +<view> | |
197 | 232 | |
198 | - <view class="brand_img_frame t-c"wx:for="{{goodslist}}" wx:for-index="index" wx:for-item="item" > | |
199 | - <image class="brand_img"src="{{item.logo}}"binderror="goods_bnerr" data-err="goodslist[{{index}}].logo"></image> | |
200 | - <view class="brand_img_name fs24">{{item.good_name}}</view> | |
201 | - </view> | |
202 | 233 | |
203 | - | |
234 | +<view class="classify_name fs32 flex-space-between"data-pid="0"data-cid="{{goods.items.id}}" bindtap='select_more'> | |
235 | +<view>{{goods.items.name}}</view> | |
236 | +<view class="flex select_more" > | |
237 | + <view class="red-co fs32" >选择更多</view> | |
238 | + <view class="bg_right width_height"></view> | |
239 | +</view> | |
240 | +</view> | |
204 | 241 | |
242 | + | |
243 | +<block wx:if="{{goods.arrays.length>0}}"> | |
244 | +<view class="classify_content-frame flex-wrap"> | |
245 | + <view class="brand_img_frame t-c ib" data-cid="{{item.items.id}}" data-pid="0"wx:for="{{goods.arrays}}" wx:for-index="index" wx:for-item="item" bindtap="go_cate"> | |
246 | + <image class="brand_img"src="{{item.items.icoimg==null?iurl+'/miniapp/images/no_cate_def.png':item.items.icoimg}}"binderror="goods_bnerr" data-err="goodslist[{{index}}].logo"></image> | |
247 | + <view class="brand_img_name fs24">{{item.name}}</view> | |
248 | + </view> | |
205 | 249 | </view> |
250 | +<view class="divider_line"></view> | |
251 | +</block> | |
252 | +</view> | |
253 | +</block> | |
206 | 254 | </block> |
207 | 255 | </view> |
208 | 256 | ... | ... |
pages/goods/categoryList/categoryList.wxss
... | ... | @@ -203,17 +203,20 @@ margin-top: 8rpx; |
203 | 203 | width: 33%; |
204 | 204 | height: 100%; |
205 | 205 | border-right: 1rpx solid #eee; |
206 | + white-space: nowrap; | |
207 | + | |
206 | 208 | } |
207 | 209 | .share_type{ |
208 | 210 | margin: auto; |
209 | - width: 60%; | |
211 | + width: 58%; | |
210 | 212 | margin-top: 35rpx; |
213 | +overflow: hidden; | |
211 | 214 | |
212 | 215 | } |
213 | 216 | .xc-letter-spacing{ |
214 | 217 | padding-left: 29rpx; |
215 | 218 | padding-right: 29rpx; |
216 | -width: 52%; | |
219 | +width: 51%; | |
217 | 220 | margin: auto; |
218 | 221 | margin-top: 35rpx; |
219 | 222 | |
... | ... | @@ -222,7 +225,7 @@ margin-top: 35rpx; |
222 | 225 | .world_sn{ |
223 | 226 | white-space: nowrap; |
224 | 227 | overflow: hidden; |
225 | -width: 50%; | |
228 | +width: 58%; | |
226 | 229 | /* letter-spacing: 60rpx; */ |
227 | 230 | margin: auto; |
228 | 231 | margin-top: 35rpx; |
... | ... | @@ -262,8 +265,8 @@ width: 60%; |
262 | 265 | width: 90%; |
263 | 266 | margin: auto; |
264 | 267 | flex-wrap:wrap; |
265 | - justify-content:space-between; | |
266 | - height: 90%; | |
268 | + max-height: 90%; | |
269 | + | |
267 | 270 | overflow-y:scroll; |
268 | 271 | overflow: hidden scroll; |
269 | 272 | |
... | ... | @@ -271,7 +274,7 @@ width: 60%; |
271 | 274 | .country_img-frame{ |
272 | 275 | width: 48%; |
273 | 276 | height: 140rpx; |
274 | - | |
277 | + | |
275 | 278 | } |
276 | 279 | .country_img{ |
277 | 280 | width: 100%; |
... | ... | @@ -318,12 +321,13 @@ line-height: 65rpx; |
318 | 321 | width: 30%; |
319 | 322 | height: 220rpx; |
320 | 323 | margin-top: 18rpx; |
324 | + margin-right: 15rpx; | |
321 | 325 | |
322 | 326 | } |
323 | 327 | |
324 | 328 | .brand_img{ |
325 | 329 | width:100%; |
326 | - height: 70%; | |
330 | + height: 61.5%; | |
327 | 331 | margin-bottom: 10rpx |
328 | 332 | } |
329 | 333 | .brand_img-name{ |
... | ... | @@ -344,6 +348,14 @@ width: 62%; |
344 | 348 | line-height: 37rpx; |
345 | 349 | height: 35rpx; |
346 | 350 | margin-top: 24rpx; |
351 | + } | |
352 | + .divider_line{ | |
353 | + width: 100%; | |
354 | + border-bottom: 6rpx solid #eee; | |
355 | + } | |
356 | + .sort-name{ | |
357 | + width: 132rpx; | |
358 | +overflow: hidden; | |
359 | +margin: auto; | |
347 | 360 | |
348 | - | |
349 | - } | |
350 | 361 | \ No newline at end of file |
362 | +} | |
351 | 363 | \ No newline at end of file | ... | ... |