Commit bfdcaca15ad6587f00cbb6d6195bad2346996fc1
1 parent
08db1d6e
阶梯购商品搜索优化
Showing
3 changed files
with
46 additions
and
16 deletions
pages/goods/goodsList/goodsList.js
... | ... | @@ -69,7 +69,12 @@ Page({ |
69 | 69 | |
70 | 70 | if (0 != t.is_new && t.is_new != undefined) { url += "&is_new=" + t.is_new; } |
71 | 71 | if (0 != t.is_hot && t.is_hot != undefined) { url += "&is_hot=" + t.is_hot; } |
72 | - if (0 != t.ladder_id && t.ladder_id != undefined) { url += "&ladder_id=" + t.ladder_id; } | |
72 | + if (0 != t.ladder_id && t.ladder_id != undefined) { | |
73 | + url += "&ladder_id=" + t.ladder_id; | |
74 | + this.setData({ | |
75 | + ladder_id:t.ladder_id, | |
76 | + }) | |
77 | + } | |
73 | 78 | |
74 | 79 | var user_id=getApp().globalData.user_id; |
75 | 80 | if(!user_id) user_id=0; | ... | ... |
pages/goods/goodsList/goodsList.wxml
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | <view class="pd20 flex ai-center jc_sb"> |
20 | 20 | <!-- 搜索框 --> |
21 | 21 | <view class="search-box f1"> |
22 | - <navigator hover-class="none" url="/pages/goods/search/search"><text class="iconfont icon-sousuo pdr10"></text>搜索店铺商品</navigator> | |
22 | + <navigator hover-class="none" url="/pages/goods/search/search?ladder_id={{ladder_id}}"><text class="iconfont icon-sousuo pdr10"></text>搜索店铺商品</navigator> | |
23 | 23 | </view> |
24 | 24 | <!-- 单列/双列 显示切换 --> |
25 | 25 | <text class="iconfont {{isToggle ? 'icon-fenxiang':'icon-fenlie'}} pdl30 fs36" bindtap="bindToggleDisplay"></text> | ... | ... |
pages/goods/search/search.js
... | ... | @@ -108,7 +108,13 @@ Page({ |
108 | 108 | if (0 != t.brand_id && t.brand_id!=undefined){ url += "&brand_id=" + t.brand_id;} |
109 | 109 | if (0 != t.nation_id && t.nation_id!=undefined) { url += "&nation_id=" + t.nation_id;} |
110 | 110 | if (0 != t.max_price && t.max_price!=undefined) { url += "&min_pirce=" + t.min_pirce + "&max_price=" + t.max_price;} |
111 | - | |
111 | + if (0 != t.ladder_id && t.ladder_id != undefined) { | |
112 | + url += "&ladder_id=" + t.ladder_id; | |
113 | + this.setData({ | |
114 | + baseUrl:url, | |
115 | + | |
116 | + }) | |
117 | + } | |
112 | 118 | if (url != this.data.baseUrl) return this.requestSearch(url); |
113 | 119 | this.openSearchModal(); |
114 | 120 | // 获取历史搜索记录 |
... | ... | @@ -200,20 +206,39 @@ Page({ |
200 | 206 | break |
201 | 207 | } |
202 | 208 | if(url!=null && url!=''){ |
203 | - await getApp().request.promiseGet(url, {}).then(res => { | |
209 | + await getApp().request.promiseGet(url, {}).then(async res => { | |
204 | 210 | var prom =null; |
205 | - if(res && res.data) prom=res.data.data; | |
206 | - if (prom != null && prom.is_end==0 && prom.end_time>now && (prom.start_time<now || (prom.show_time && prom.show_time<now)) ) { | |
207 | - item.prom_price = res.data.data.price; | |
208 | - if(res.data.data.user_price) item.prom_price=res.data.data.user_price; | |
209 | - var vNum=res.data.data.virtual_num?res.data.data.virtual_num:0; | |
210 | - var vNum1=res.data.data.virtualNum?res.data.data.virtualNum:0; | |
211 | - var vNum2=res.data.data.virtual?res.data.data.virtual:0; | |
212 | - item.sales_sum=res.data.data.buy_num+(vNum+vNum1+vNum2); | |
213 | - }else{ | |
214 | - item.prom_type=0; | |
215 | - item.prom_id=0; | |
216 | - item.prom_price=null; | |
211 | + var flag=null; | |
212 | + if(res.data.code==0 && res.data.data){ | |
213 | + prom=res.data.data; | |
214 | + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/1",{ | |
215 | + data:{ | |
216 | + store_id: oo.stoid, | |
217 | + is_end: 0, | |
218 | + is_show: 1, | |
219 | + user_id: getApp().globalData.user_id, | |
220 | + pageSize:1000 | |
221 | + } | |
222 | + }).then(pd=>{ | |
223 | + let pd_list=pd.data.data.pageData; | |
224 | + if(res.data.code==0 && pd_list.length>0){ | |
225 | + flag =pd_list.some(pd=>{ | |
226 | + return pd.goods_id==item.goods_id | |
227 | + }) | |
228 | + } | |
229 | + if (prom != null && prom.is_end==0 && prom.end_time>now && flag && (prom.start_time<now || (prom.show_time && prom.show_time<now)) ) { | |
230 | + item.prom_price = res.data.data.price; | |
231 | + if(res.data.data.user_price) item.prom_price=res.data.data.user_price; | |
232 | + var vNum=prom.virtual_num?prom.virtual_num:0; | |
233 | + var vNum1=prom.virtualNum?prom.virtualNum:0; | |
234 | + var vNum2=prom.virtual?prom.virtual:0; | |
235 | + item.sales_sum=prom.buy_num+(vNum+vNum1+vNum2); | |
236 | + }else{ | |
237 | + item.prom_type=0; | |
238 | + item.prom_id=0; | |
239 | + item.prom_price=null; | |
240 | + } | |
241 | + }) | |
217 | 242 | } |
218 | 243 | }) |
219 | 244 | } | ... | ... |