搜索和品类筛选逻辑修改 — review by 黄敬囿
Showing
9 changed files
with
76 additions
and
54 deletions
@@ -15,7 +15,7 @@ Component({ | @@ -15,7 +15,7 @@ Component({ | ||
15 | }, | 15 | }, |
16 | ready: function () { | 16 | ready: function () { |
17 | //头条列表渲染不支持字典循环,故转换成数组 2018/12/7 | 17 | //头条列表渲染不支持字典循环,故转换成数组 2018/12/7 |
18 | - if (onlyTextBrand == '1') { | 18 | + if (this.properties.onlyTextBrand == '1') { |
19 | let textBrandKey = []; | 19 | let textBrandKey = []; |
20 | let textBrandData = []; | 20 | let textBrandData = []; |
21 | for (const iterator of Object.keys(this.properties.data)) { | 21 | for (const iterator of Object.keys(this.properties.data)) { |
@@ -242,7 +242,7 @@ Page({ | @@ -242,7 +242,7 @@ Page({ | ||
242 | // } | 242 | // } |
243 | // logEvent(YB_CATEGORY_FL,param); | 243 | // logEvent(YB_CATEGORY_FL,param); |
244 | tt.navigateTo({ | 244 | tt.navigateTo({ |
245 | - url: '../goodsList/goodsList' + queryString | 245 | + url: '../productList/index' + queryString |
246 | }); | 246 | }); |
247 | 247 | ||
248 | }, | 248 | }, |
@@ -276,9 +276,9 @@ Page({ | @@ -276,9 +276,9 @@ Page({ | ||
276 | let queryString = "?gender=" + gender + "&sort=" + sort + "&title=" + categoryName + | 276 | let queryString = "?gender=" + gender + "&sort=" + sort + "&title=" + categoryName + |
277 | "&categoryId=" + parentCategoryId + "&subCategoryId=" + categoryId + "&firstProductSkn=" + firstProductSkn; | 277 | "&categoryId=" + parentCategoryId + "&subCategoryId=" + categoryId + "&firstProductSkn=" + firstProductSkn; |
278 | 278 | ||
279 | - tt.navigateTo({ | ||
280 | - url: '../productList/index' + queryString | ||
281 | - }); | 279 | + tt.navigateTo({ |
280 | + url: '../productList/index' + queryString | ||
281 | + }); | ||
282 | }, | 282 | }, |
283 | 283 | ||
284 | /** | 284 | /** |
@@ -248,7 +248,7 @@ Page(extend({}, Actionsheet,{ | @@ -248,7 +248,7 @@ Page(extend({}, Actionsheet,{ | ||
248 | msort: msort, | 248 | msort: msort, |
249 | misort: misort, | 249 | misort: misort, |
250 | page_name: this.data.current_page_name, | 250 | page_name: this.data.current_page_name, |
251 | - sharePath: '/pages/goodsList/goodsList?union_type=' + app.globalData.user_union_type + "&" + params, | 251 | + sharePath: '/pages/productList/index?union_type=' + app.globalData.user_union_type + "&" + params, |
252 | sort: this.data.sort, | 252 | sort: this.data.sort, |
253 | categoryID: this.data.current_page_param, | 253 | categoryID: this.data.current_page_param, |
254 | } | 254 | } |
@@ -48,19 +48,28 @@ Page({ | @@ -48,19 +48,28 @@ Page({ | ||
48 | }, | 48 | }, |
49 | onLoad: function (option) { | 49 | onLoad: function (option) { |
50 | try{ | 50 | try{ |
51 | + console.log('===================================='); | ||
52 | + console.log(option); | ||
53 | + console.log('===================================='); | ||
51 | if(option){ | 54 | if(option){ |
52 | let categoryId = option.categoryId; | 55 | let categoryId = option.categoryId; |
53 | - let firstProductSkn = option.firstProductSkn; | ||
54 | - // let navigate = option.navigate; | ||
55 | - let sort = option.sort; | ||
56 | - let subCategoryId = option.subCategoryId; | ||
57 | - let title = option.title; | 56 | + let firstProductSkn = option.firstProductSkn ? option.firstProductSkn : ''; |
57 | + let sort = option.sort ? option.sort : ''; | ||
58 | + let subCategoryId = option.subCategoryId ? option.subCategoryId : ''; | ||
59 | + let title = option.title ? option.title : ''; | ||
60 | + let gender = option.gender ? option.gender : ''; | ||
58 | console.log("categoryId:"+categoryId+"==subCategoryId:"+subCategoryId+"==sort:"+sort+"==firstProductSkn:"+firstProductSkn); | 61 | console.log("categoryId:"+categoryId+"==subCategoryId:"+subCategoryId+"==sort:"+sort+"==firstProductSkn:"+firstProductSkn); |
59 | 62 | ||
60 | - this.data.categoryId = option.categoryId; | ||
61 | - this.data.subCategoryId = option.subCategoryId; | ||
62 | - this.data.sort = option.sort; | ||
63 | - this.data.firstProductSkn = option.firstProductSkn; | 63 | + this.data.categoryId = categoryId; |
64 | + this.data.subCategoryId = subCategoryId; | ||
65 | + this.data.sort = sort; | ||
66 | + this.data.firstProductSkn = firstProductSkn; | ||
67 | + this.data.title = title; | ||
68 | + this.data.gender = gender; | ||
69 | + | ||
70 | + tt.setNavigationBarTitle({ | ||
71 | + title: title | ||
72 | + }); | ||
64 | } | 73 | } |
65 | let systemInfo = tt.getSystemInfoSync(); | 74 | let systemInfo = tt.getSystemInfoSync(); |
66 | let contentWidth = systemInfo.screenWidth; | 75 | let contentWidth = systemInfo.screenWidth; |
@@ -81,9 +90,20 @@ Page({ | @@ -81,9 +90,20 @@ Page({ | ||
81 | }, | 90 | }, |
82 | onShow: function () { | 91 | onShow: function () { |
83 | if(this.data.isRefresh){ | 92 | if(this.data.isRefresh){ |
84 | - let current = this.data.activeIndex | ||
85 | - let tab = this.data.tabs[current]; | ||
86 | - this.fechProductList(tab,1); | 93 | + let filter = this.data.filter; |
94 | + if(filter){ | ||
95 | + for(var i = 0; i < filter.length; i++){ | ||
96 | + let filterItem = filter[i]; | ||
97 | + let itemId = filterItem.filterId; | ||
98 | + let selectedIdParam = filterItem.selectedIdParam; | ||
99 | + if(selectedIdParam){ | ||
100 | + this.data.filterParams[itemId] = selectedIdParam; | ||
101 | + } | ||
102 | + } | ||
103 | + let current = this.data.activeIndex | ||
104 | + let tab = this.data.tabs[current]; | ||
105 | + this.fechProductList(tab,1); | ||
106 | + } | ||
87 | } | 107 | } |
88 | }, | 108 | }, |
89 | onTabClick: function (e) { | 109 | onTabClick: function (e) { |
@@ -145,16 +165,18 @@ Page({ | @@ -145,16 +165,18 @@ Page({ | ||
145 | let categoryId = that.data.categoryId; | 165 | let categoryId = that.data.categoryId; |
146 | let subCategoryId = that.data.subCategoryId; | 166 | let subCategoryId = that.data.subCategoryId; |
147 | let firstProductSkn = that.data.firstProductSkn; | 167 | let firstProductSkn = that.data.firstProductSkn; |
168 | + let title = that.data.title; | ||
169 | + let gender = that.data.gender; | ||
148 | let param = { | 170 | let param = { |
149 | method: "app.search.category", | 171 | method: "app.search.category", |
150 | firstProductSkn: firstProductSkn, | 172 | firstProductSkn: firstProductSkn, |
151 | - gender:"1,3", | ||
152 | - limit: 10, | 173 | + gender, |
174 | + limit: 60, | ||
153 | page: currentPage, | 175 | page: currentPage, |
154 | sort: sort, | 176 | sort: sort, |
155 | - subCategoryId: subCategoryId, | ||
156 | - title: "POLO", | ||
157 | - order: order, | 177 | + categoryId, |
178 | + subCategoryId, | ||
179 | + title | ||
158 | } | 180 | } |
159 | let params = Object.assign(filterParams, param); | 181 | let params = Object.assign(filterParams, param); |
160 | api.get({data: params}) | 182 | api.get({data: params}) |
@@ -13,7 +13,7 @@ Page({ | @@ -13,7 +13,7 @@ Page({ | ||
13 | selectedFilter = lastPageData.filter; | 13 | selectedFilter = lastPageData.filter; |
14 | } | 14 | } |
15 | //有筛选数据使用筛选数据,没有筛选数据使用接口请求的数据 | 15 | //有筛选数据使用筛选数据,没有筛选数据使用接口请求的数据 |
16 | - debugger | 16 | + |
17 | if(selectedFilter && selectedFilter.length > 0){ | 17 | if(selectedFilter && selectedFilter.length > 0){ |
18 | this.setData({ | 18 | this.setData({ |
19 | filter: selectedFilter, | 19 | filter: selectedFilter, |
@@ -26,30 +26,33 @@ Page({ | @@ -26,30 +26,33 @@ Page({ | ||
26 | 26 | ||
27 | }, | 27 | }, |
28 | fechFilter: function(option) { | 28 | fechFilter: function(option) { |
29 | + console.log('===================================='); | ||
30 | + console.log(option); | ||
31 | + console.log('===================================='); | ||
29 | let that = this; | 32 | let that = this; |
30 | - let sort = option.sort; | ||
31 | - let categoryId = option.categoryId; | ||
32 | - let subCategoryId = option.subCategoryId; | ||
33 | - let firstProductSkn = option.firstProductSkn; | 33 | + let sort = option.sort ? option.sort : ''; |
34 | + let categoryId = option.categoryId ? option.categoryId : ''; | ||
35 | + let subCategoryId = option.subCategoryId ? option.subCategoryId : ''; | ||
36 | + let firstProductSkn = option.firstProductSkn ? option.firstProductSkn : ''; | ||
37 | + let query = option.query ? option.query : ''; | ||
38 | + let method = option.method ? option.method : "app.search.category.filter"; | ||
34 | let params = { | 39 | let params = { |
35 | - categoryId: categoryId, | ||
36 | - firstProductSkn: firstProductSkn, | ||
37 | - limit: 20, | ||
38 | - method: "app.search.category.filter", | 40 | + categoryId, |
41 | + firstProductSkn, | ||
42 | + method, | ||
43 | + query, | ||
39 | new_filter: 1, | 44 | new_filter: 1, |
40 | // order: "", | 45 | // order: "", |
41 | - page: 1, | ||
42 | - sort: sort, | ||
43 | - subCategoryId: subCategoryId, | 46 | + sort, |
47 | + subCategoryId, | ||
44 | } | 48 | } |
45 | api.get({data: params}) | 49 | api.get({data: params}) |
46 | .then(data => { | 50 | .then(data => { |
47 | let filter = data.data.filter; | 51 | let filter = data.data.filter; |
48 | let newFilter = this.parseFilter(filter); | 52 | let newFilter = this.parseFilter(filter); |
49 | - that.setData({ | ||
50 | - filter: newFilter, | ||
51 | - }); | ||
52 | - | 53 | + that.setData({ |
54 | + filter: newFilter, | ||
55 | + }); | ||
53 | }); | 56 | }); |
54 | 57 | ||
55 | }, | 58 | }, |
1 | { | 1 | { |
2 | - "usingComponents": { | ||
3 | - "proFilter": "../../components/productFilter/proFilter", | ||
4 | - "filter-item": "../../components/productFilter/item/filter-item", | ||
5 | - "filter-title": "../../components/productFilter/item/filter-title" | ||
6 | - } | ||
7 | - | 2 | + "navigationBarTitleText": "筛选", |
3 | + "usingComponents": { | ||
4 | + "proFilter": "../../components/productFilter/proFilter", | ||
5 | + "filter-item": "../../components/productFilter/item/filter-item", | ||
6 | + "filter-title": "../../components/productFilter/item/filter-title" | ||
7 | + } | ||
8 | } | 8 | } |
@@ -558,11 +558,8 @@ Page(extend({}, Actionsheet,{ | @@ -558,11 +558,8 @@ Page(extend({}, Actionsheet,{ | ||
558 | }, | 558 | }, |
559 | 559 | ||
560 | jumpToFilterPage: function () { | 560 | jumpToFilterPage: function () { |
561 | - let params = Object.assign({ method: 'miniapp.search.fuzzy.filter' }, this.data.keyword_param); | ||
562 | - let storageKey = this.data.filterStorageKey; | ||
563 | - let paramString = JSON.stringify(params); | ||
564 | tt.navigateTo({ | 561 | tt.navigateTo({ |
565 | - url: '../goodsList/productListFilterPage?storageKey=' + storageKey + '¶ms=' + paramString | 562 | + url: '../productListFilter/filter?storageKey=' + this.data.filterStorageKey + '&method=' + 'miniapp.search.fuzzy.filter' + '&query=' + this.data.keyword |
566 | }) | 563 | }) |
567 | }, | 564 | }, |
568 | 565 |
@@ -6,7 +6,7 @@ import router from './router'; | @@ -6,7 +6,7 @@ import router from './router'; | ||
6 | 6 | ||
7 | const ACTION_TYPE = { | 7 | const ACTION_TYPE = { |
8 | h5: 'go.h5', | 8 | h5: 'go.h5', |
9 | - goodsList: 'go.list', | 9 | + productList: 'go.list', |
10 | brandStore: 'go.shop', | 10 | brandStore: 'go.shop', |
11 | } | 11 | } |
12 | 12 | ||
@@ -63,13 +63,13 @@ export default { | @@ -63,13 +63,13 @@ export default { | ||
63 | this.go('webview', yohobuy); | 63 | this.go('webview', yohobuy); |
64 | break; | 64 | break; |
65 | } | 65 | } |
66 | - case ACTION_TYPE.goodsList: { | 66 | + case ACTION_TYPE.productList: { |
67 | let yohobuy = { | 67 | let yohobuy = { |
68 | ...yoho.params, | 68 | ...yoho.params, |
69 | url: yoho.params.url, | 69 | url: yoho.params.url, |
70 | action: yoho.action | 70 | action: yoho.action |
71 | } | 71 | } |
72 | - this.go('goodsList', yohobuy); | 72 | + this.go('productList', yohobuy); |
73 | break; | 73 | break; |
74 | } | 74 | } |
75 | case ACTION_TYPE.brandStore: { | 75 | case ACTION_TYPE.brandStore: { |
@@ -2,8 +2,8 @@ export default { | @@ -2,8 +2,8 @@ export default { | ||
2 | home: { | 2 | home: { |
3 | path: '../index/index' | 3 | path: '../index/index' |
4 | }, | 4 | }, |
5 | - goodsList: { | ||
6 | - path: '../goodsList/goodsList' | 5 | + productList: { |
6 | + path: '../productList/index' | ||
7 | }, | 7 | }, |
8 | brandStore: { | 8 | brandStore: { |
9 | path: '../goodsList/brandStore' | 9 | path: '../goodsList/brandStore' |
-
Please register or login to post a comment