Commit 5214ca9be215597227be072a6f3d1bc6d5548f5d
Exists in
master
Merge branch 'master' of http://121.40.31.31:8888/jp/gulu-vue
Showing
9 changed files
Show diff stats
src/App.vue
... | ... | @@ -7,13 +7,13 @@ |
7 | 7 | onLaunch(options) { |
8 | 8 | const option = options || {}; |
9 | 9 | // 获取用户来源 |
10 | - console.log('软件启动,输出转来的参数:', option); | |
11 | - console.log('场景值------------------:', option.scene); | |
10 | + // console.log('软件启动,输出转来的参数:', option); | |
11 | + // console.log('场景值------------------:', option.scene); | |
12 | 12 | let loginQueryInfo = option ? option.query : {}; |
13 | 13 | loginQueryInfo = loginQueryInfo || {}; |
14 | - console.log('loginQueryInfo onShow===>', loginQueryInfo); | |
14 | + // console.log('loginQueryInfo onShow===>', loginQueryInfo); | |
15 | 15 | const scene = decodeURIComponent(loginQueryInfo.scene); |
16 | - console.log('decodeURIComponent scense====>', scene); | |
16 | + // console.log('decodeURIComponent scense====>', scene); | |
17 | 17 | let fromInfo = {}; |
18 | 18 | |
19 | 19 | if(scene.length > 0 ) { |
... | ... | @@ -35,9 +35,9 @@ |
35 | 35 | scene: option.scene, |
36 | 36 | } |
37 | 37 | store.dispatch('user/setFrom', fromInfo); |
38 | - console.log('loginQueryInfo.hasOwnProperty=====111===>', getQueryString); | |
38 | + // console.log('loginQueryInfo.hasOwnProperty=====111===>', getQueryString); | |
39 | 39 | } else { |
40 | - console.log('loginQueryInfo.hasOwnProperty====22222====>', loginQueryInfo); | |
40 | + // console.log('loginQueryInfo.hasOwnProperty====22222====>', loginQueryInfo); | |
41 | 41 | if (loginQueryInfo.hasOwnProperty('sid') == false) { |
42 | 42 | loginQueryInfo.sid = 0; |
43 | 43 | } |
... | ... | @@ -67,11 +67,10 @@ |
67 | 67 | } |
68 | 68 | }, |
69 | 69 | onShow() { |
70 | - | |
71 | - console.log('App Show') | |
70 | + // console.log('App Show') | |
72 | 71 | }, |
73 | 72 | onHide() { |
74 | - console.log('App Hide') | |
73 | + // console.log('App Hide') | |
75 | 74 | }, |
76 | 75 | methods: { |
77 | 76 | } | ... | ... |
src/components/HMFilterDropdown/HMFilterDropdown.vue
... | ... | @@ -2,9 +2,25 @@ |
2 | 2 | <view class="HMfilterDropdown" @touchmove.stop.prevent="discard" @tap.stop="discard"> |
3 | 3 | <view class="nav"> |
4 | 4 | <block v-for="(item,index) in menu" :key="index"> |
5 | - <view class="first-menu" :class="{'on':showPage==index}" @tap="togglePage(index)"> | |
5 | + <view | |
6 | + class="first-menu" | |
7 | + :class="{'on':showPage==index || on[index] === 1}" | |
8 | + @tap="togglePage(index)" | |
9 | + v-if="!item.isNoPull" | |
10 | + > | |
11 | + <text class="name">{{item.name}}</text> | |
12 | + <text | |
13 | + class="iconfont triangle" | |
14 | + :style="'transform:rotate('+triangleDeg[index]+'deg);'" | |
15 | + ></text> | |
16 | + </view> | |
17 | + <view | |
18 | + class="first-menu" | |
19 | + :class="{'on':showPage==index || on[index] === 1}" | |
20 | + @tap="showAll()" | |
21 | + v-else | |
22 | + > | |
6 | 23 | <text class="name">{{item.name}}</text> |
7 | - <text class="iconfont triangle" :style="'transform:rotate('+triangleDeg[index]+'deg);'"></text> | |
8 | 24 | </view> |
9 | 25 | </block> |
10 | 26 | </view> |
... | ... | @@ -101,7 +117,8 @@ |
101 | 117 | firstScrollInto: 0, |
102 | 118 | secondScrollInto: 0, |
103 | 119 | componentTop:0 ,//组件top |
104 | - isReadNewSelect:false | |
120 | + isReadNewSelect:false, | |
121 | + on: [1,0,0,0,0], | |
105 | 122 | } |
106 | 123 | }, |
107 | 124 | props: { |
... | ... | @@ -136,9 +153,9 @@ |
136 | 153 | this.defaultActive = JSON.parse(JSON.stringify(newVal)); |
137 | 154 | this.activeMenuArr = JSON.parse(JSON.stringify(newVal)); |
138 | 155 | this.shadowActiveMenuArr = JSON.parse(JSON.stringify(newVal)); |
139 | - if(this.updateMenuName){ | |
140 | - this.setMenuName(); | |
141 | - } | |
156 | + // if(this.updateMenuName){ | |
157 | + // this.setMenuName(); | |
158 | + // } | |
142 | 159 | } |
143 | 160 | }, |
144 | 161 | methods: { |
... | ... | @@ -150,53 +167,54 @@ |
150 | 167 | tmpMenu.push({ |
151 | 168 | //如果没有设置name,则取第一个菜单作为menu.name,filter类型则将"筛选"作为menu.name |
152 | 169 | name: tmpitem.name || (tmpitem.type == "filter" ? "筛选" : tmpitem.submenu[0].name), |
153 | - type: tmpitem.type | |
170 | + type: tmpitem.type, | |
171 | + isNoPull: tmpitem.isNoPull, | |
154 | 172 | }); |
155 | - //初始化选中项数组-ui状态 | |
173 | + // 初始化选中项数组-ui状态 | |
156 | 174 | tmpMenuActiveArr.push(this.processActive(tmpitem)); |
157 | - //初始化角度数组 | |
175 | + // 初始化角度数组 | |
158 | 176 | this.triangleDeg.push(0); |
159 | - //初始化控制显示状态数组 | |
177 | + // 初始化控制显示状态数组 | |
160 | 178 | this.pageState.push(false); |
161 | - //递归处理子菜单数据 | |
179 | + // 递归处理子菜单数据 | |
162 | 180 | tmpitem = this.processSubMenu(tmpitem); |
163 | 181 | this.filterData[i] = tmpitem; |
164 | 182 | } |
165 | 183 | this.menu = tmpMenu; |
166 | - //初始化选中项数组 | |
184 | + // 初始化选中项数组 | |
167 | 185 | tmpMenuActiveArr = this.defaultActive.length>0?this.defaultActive:this.activeMenuArr.length>0?this.activeMenuArr:tmpMenuActiveArr; |
168 | 186 | this.defaultActive = []; |
169 | 187 | this.activeMenuArr = JSON.parse(JSON.stringify(tmpMenuActiveArr)); |
170 | 188 | this.shadowActiveMenuArr = JSON.parse(JSON.stringify(tmpMenuActiveArr)); |
171 | - //加载菜单数据 | |
189 | + // 加载菜单数据 | |
172 | 190 | this.subData = this.filterData; |
173 | - //设定顶部菜单名字 | |
174 | - if(this.updateMenuName){ | |
175 | - this.setMenuName(); | |
176 | - } | |
177 | - }, | |
178 | - setMenuName(){ | |
179 | - for(var i=0;i<this.activeMenuArr.length;i++){ | |
180 | - let row = this.activeMenuArr[i]; | |
181 | - if (typeof(row[0]) != 'object'){ | |
182 | - var tmpsub = false; | |
183 | - if(row.length>0 && row[0]!=null){ | |
184 | - tmpsub = this.subData[i].submenu[row[0]]; | |
185 | - if(row.length>1 && row[1]!=null){ | |
186 | - tmpsub = tmpsub.submenu[row[1]]; | |
187 | - if(row.length>2 && row[2]!=null){ | |
188 | - tmpsub = tmpsub.submenu[row[2]]; | |
189 | - } | |
190 | - } | |
191 | - }else{ | |
192 | - tmpsub = false; | |
193 | - } | |
194 | - if(tmpsub){ | |
195 | - this.menu[i].name = tmpsub.name; | |
196 | - } | |
197 | - } | |
198 | - } | |
191 | + // 设定顶部菜单名字 | |
192 | + // if(this.updateMenuName){ | |
193 | + // this.setMenuName(); | |
194 | + // } | |
199 | 195 | }, |
196 | + // setMenuName(){ | |
197 | + // for(var i=0;i<this.activeMenuArr.length;i++){ | |
198 | + // let row = this.activeMenuArr[i]; | |
199 | + // if (typeof(row[0]) != 'object'){ | |
200 | + // var tmpsub = false; | |
201 | + // if(row.length>0 && row[0]!=null){ | |
202 | + // tmpsub = this.subData[i].submenu[row[0]]; | |
203 | + // if(row.length>1 && row[1]!=null){ | |
204 | + // tmpsub = tmpsub.submenu[row[1]]; | |
205 | + // if(row.length>2 && row[2]!=null){ | |
206 | + // tmpsub = tmpsub.submenu[row[2]]; | |
207 | + // } | |
208 | + // } | |
209 | + // }else{ | |
210 | + // tmpsub = false; | |
211 | + // } | |
212 | + // if(tmpsub){ | |
213 | + // this.menu[i].name = tmpsub.name; | |
214 | + // } | |
215 | + // } | |
216 | + // } | |
217 | + // }, | |
200 | 218 | //展开更多 |
201 | 219 | showMoreSub(index) { |
202 | 220 | this.subData[this.showPage].submenu[this.activeMenuArr[this.showPage][0]].submenu[index].showAllSub = true; |
... | ... | @@ -217,9 +235,9 @@ |
217 | 235 | if (level3_index != null || level2_index != null || (level1_index != null && this.subData[page_index].submenu[level1_index].submenu.length == 0) |
218 | 236 | ) { |
219 | 237 | let sub = this.subData[page_index].submenu[level1_index].submenu[level2_index]; |
220 | - if(this.updateMenuName){ | |
221 | - this.menu[page_index].name = (level3_index != null && sub.submenu[level3_index].name) || (level2_index != null && sub.name) || this.subData[page_index].submenu[level1_index].name; | |
222 | - } | |
238 | + // if(this.updateMenuName){ | |
239 | + // this.menu[page_index].name = (level3_index != null && sub.submenu[level3_index].name) || (level2_index != null && sub.name) || this.subData[page_index].submenu[level1_index].name; | |
240 | + // } | |
223 | 241 | this.shadowActiveMenuArr[page_index] = JSON.parse(JSON.stringify(this.activeMenuArr[page_index])); |
224 | 242 | this.togglePage(this.showPage); |
225 | 243 | } |
... | ... | @@ -286,6 +304,19 @@ |
286 | 304 | this.showPageLayer(index); |
287 | 305 | this.showMask(); |
288 | 306 | } |
307 | + if(this.on[0] === 1) { | |
308 | + this.on[0] = 0; | |
309 | + } | |
310 | + this.on[index] = 1; | |
311 | + }, | |
312 | + showAll() { | |
313 | + this.on = [1,0,0,0,0] | |
314 | + // 输出 | |
315 | + this.$emit('search', { | |
316 | + index: {}, | |
317 | + value: {}, | |
318 | + on: this.on, | |
319 | + }); | |
289 | 320 | }, |
290 | 321 | //hide遮罩层 |
291 | 322 | hideMask() { |
... | ... | @@ -343,8 +374,7 @@ |
343 | 374 | }); |
344 | 375 | }else{ |
345 | 376 | let submenu = this.subData[i].submenu[item[0]]; |
346 | - // console.log(this.subData[i]) | |
347 | - value[i][0] = submenu.value; | |
377 | + value[i][0] = submenu && submenu.value; | |
348 | 378 | if(value[i].length>=2 && item[1]!=null){ |
349 | 379 | if(submenu.submenu.length>0){ |
350 | 380 | submenu = submenu.submenu[item[1]]; |
... | ... | @@ -366,9 +396,10 @@ |
366 | 396 | |
367 | 397 | }); |
368 | 398 | // 输出 |
369 | - this.$emit('confirm', { | |
399 | + this.$emit('search', { | |
370 | 400 | index: index, |
371 | - value: value | |
401 | + value: value, | |
402 | + on: this.on, | |
372 | 403 | }); |
373 | 404 | }, |
374 | 405 | //show菜单页 |
... | ... | @@ -515,13 +546,12 @@ |
515 | 546 | .nav { |
516 | 547 | width: 100%; |
517 | 548 | height: 44px; |
518 | - border-bottom: solid 1rpx #eee; | |
519 | 549 | z-index: 12; |
520 | 550 | background-color: #ffffff; |
521 | 551 | flex-direction: row; |
522 | 552 | .first-menu { |
523 | 553 | width: 100%; |
524 | - font-size: 13px; | |
554 | + font-size: 16px; | |
525 | 555 | color: #333333; |
526 | 556 | flex-direction: row; |
527 | 557 | align-items: center; |
... | ... | @@ -537,6 +567,7 @@ |
537 | 567 | } |
538 | 568 | .name { |
539 | 569 | height: 20px; |
570 | + // font-size: 16px; | |
540 | 571 | text-align: center; |
541 | 572 | text-overflow: clip; |
542 | 573 | overflow: hidden; |
... | ... | @@ -544,6 +575,7 @@ |
544 | 575 | .iconfont { |
545 | 576 | width: 13px; |
546 | 577 | height: 13px; |
578 | + line-height: 16px; | |
547 | 579 | align-items: center; |
548 | 580 | justify-content: center; |
549 | 581 | transition: transform .2s linear, color .2s linear; |
... | ... | @@ -605,7 +637,7 @@ |
605 | 637 | } |
606 | 638 | &.alone { |
607 | 639 | max-height: 345px; |
608 | - min-height: 170px; | |
640 | + min-height: 60rpx; | |
609 | 641 | height: auto; |
610 | 642 | .sub-menu { |
611 | 643 | min-height: calc(44px - 1rpx); |
... | ... | @@ -788,4 +820,4 @@ |
788 | 820 | } |
789 | 821 | } |
790 | 822 | } |
791 | -</style> | |
823 | +</style> | ... | ... |
src/pages/detailsChoiceArgs/detailsChoiceArgs.vue
... | ... | @@ -16,12 +16,6 @@ |
16 | 16 | </view> |
17 | 17 | </view> |
18 | 18 | <view class="goods-data"> |
19 | - <!-- 实用功能折叠框 --> | |
20 | - <MyCollapse :isOpenProps="funIsOpen" :funListProp="funList" :funContentProp="funContent" title="实用功能"></MyCollapse> | |
21 | - <MyCollapse :isOpenProps="kindIsOpen" :funListProp="kindList1" :funList2Prop="kindList2" :funContentProp="kindContent" title="镜片种类"></MyCollapse> | |
22 | - <MyCollapse :isOpenProps="maIsOpen" :funListProp="maList1" :funList2Prop="maList2" :funContentProp="maContent" title="材质选择"></MyCollapse> | |
23 | - <MyCollapse :isOpenProps="reIsOpen" :funListProp="reList1" :funList2Prop="reList2" :funContentProp="reContent" title="折射率"></MyCollapse> | |
24 | - | |
25 | 19 | <view class="opCollapse"> |
26 | 20 | <view class="head"> |
27 | 21 | <view v-if="!opIsOpen">填写验光数据</view> |
... | ... | @@ -157,7 +151,11 @@ |
157 | 151 | </template> |
158 | 152 | </view> |
159 | 153 | </view> |
160 | - | |
154 | + <!-- 实用功能折叠框 --> | |
155 | + <MyCollapse :isOpenProps="funIsOpen" :funListProp="funList" :funContentProp="funContent" title="实用功能"></MyCollapse> | |
156 | + <MyCollapse :isOpenProps="kindIsOpen" :funListProp="kindList1" :funList2Prop="kindList2" :funContentProp="kindContent" title="镜片种类"></MyCollapse> | |
157 | + <MyCollapse :isOpenProps="maIsOpen" :funListProp="maList1" :funList2Prop="maList2" :funContentProp="maContent" title="材质选择"></MyCollapse> | |
158 | + <MyCollapse :isOpenProps="reIsOpen" :funListProp="reList1" :funList2Prop="reList2" :funContentProp="reContent" title="折射率"></MyCollapse> | |
161 | 159 | </view> |
162 | 160 | <view class="submit">立即结算</view> |
163 | 161 | </view> | ... | ... |
src/pages/index/index.vue
... | ... | @@ -4,11 +4,17 @@ |
4 | 4 | <!-- 搜索--> |
5 | 5 | <view class="searchBar"> |
6 | 6 | <icon class="searchIcon" type="search" size="14"></icon> |
7 | - <input class="searchIpt" placeholder="老花镜" confirm-type="search" /> | |
7 | + <input | |
8 | + v-model="searchText" | |
9 | + class="searchIpt" | |
10 | + placeholder="老花镜" | |
11 | + confirm-type="search" | |
12 | + @blur="searchKey" | |
13 | + /> | |
8 | 14 | </view> |
9 | 15 | |
10 | 16 | <!-- 筛选栏--> |
11 | - <view class="screenBar"> | |
17 | + <!-- <view class="screenBar"> | |
12 | 18 | <view v-for="item in screenItems" :key="item.current" @click="onClickItem(item.current)"> |
13 | 19 | <view |
14 | 20 | class="screenItem" |
... | ... | @@ -35,7 +41,7 @@ |
35 | 41 | >{{ item.text }}</view> |
36 | 42 | </view> |
37 | 43 | </view> |
38 | - </view> | |
44 | + </view>--> | |
39 | 45 | </view> |
40 | 46 | <Uni-drawer |
41 | 47 | ref="showRight" |
... | ... | @@ -55,11 +61,12 @@ |
55 | 61 | <!-- 筛选菜单--> |
56 | 62 | <view class="content-wrap"> |
57 | 63 | <view> |
58 | - <HMfilterDropdown | |
59 | - :filterData="filterData" | |
64 | + <HMfilterDropdown | |
65 | + :filterData="categoryList" | |
60 | 66 | :defaultSelected="filterDropdownValue" |
61 | 67 | :updateMenuName="true" |
62 | - @confirm="confirm" | |
68 | + @search="search" | |
69 | + @getList="getList" | |
63 | 70 | data-format="Object" |
64 | 71 | ></HMfilterDropdown> |
65 | 72 | <!-- 商品列表 --> |
... | ... | @@ -91,20 +98,21 @@ export default { |
91 | 98 | }, |
92 | 99 | data() { |
93 | 100 | return { |
94 | - screenItems: [ | |
95 | - { current: 0, text: "全部", hasIcon: false }, | |
96 | - { current: 1, text: "销量", hasIcon: false }, | |
97 | - { current: 2, text: "价格", hasIcon: true }, | |
98 | - { current: 3, text: "折扣", hasIcon: false }, | |
99 | - { current: 4, text: "筛选", hasIcon: true } | |
100 | - ], | |
101 | - current: 0, | |
102 | - showRight: false, | |
101 | + // screenItems: [ | |
102 | + // { current: 0, text: "全部", hasIcon: false }, | |
103 | + // { current: 1, text: "销量", hasIcon: false }, | |
104 | + // { current: 2, text: "价格", hasIcon: true }, | |
105 | + // { current: 3, text: "折扣", hasIcon: false }, | |
106 | + // { current: 4, text: "筛选", hasIcon: true } | |
107 | + // ], | |
108 | + // current: 0, | |
109 | + // showRight: false, | |
103 | 110 | indexArr: "", |
104 | 111 | valueArr: "", |
105 | 112 | loadingText: "~~到底了~~", |
106 | 113 | filterDropdownValue: [], |
107 | 114 | filterData: [], |
115 | + searchText: '', | |
108 | 116 | // goodsList:[ |
109 | 117 | // { goods_id: 0, img: "/static/img/goods/p1.jpg", name: '镜片',originCost:'¥198',price: '¥168', slogan:'1235人浏览',goodType:1 }, |
110 | 118 | // { goods_id: 1, img: '/static/img/goods/p2.jpg', name: '镜框',originCost:'¥198',price: '¥168', slogan:'1235人浏览',goodType:2 }, |
... | ... | @@ -120,62 +128,12 @@ export default { |
120 | 128 | }; |
121 | 129 | }, |
122 | 130 | computed: { |
123 | - goodsList() { | |
124 | - // 也可以从 getters 获取 | |
125 | - return this.$store.state.test.list; | |
126 | - }, | |
131 | + goodsList() { | |
132 | + // 也可以从 getters 获取 | |
133 | + return this.$store.state.index.list; | |
134 | + }, | |
127 | 135 | categoryList(){ |
128 | - // console.log(this.$store.state.categoryOrder.categoryList); | |
129 | - const categoryList = this.$store.state.categoryOrder.categoryList | |
130 | - let newData = [ | |
131 | - { | |
132 | - "name":'产品', | |
133 | - "type": 'filter', | |
134 | - "submenu": [{ | |
135 | - "submenu": [ | |
136 | - | |
137 | - ] | |
138 | - }, | |
139 | - ], | |
140 | - }, | |
141 | - { | |
142 | - "name":'品牌', | |
143 | - "type": 'filter', | |
144 | - "submenu": [{ | |
145 | - "submenu": [ | |
146 | - ] | |
147 | - }, | |
148 | - ] | |
149 | - }, | |
150 | - { | |
151 | - "name":'使用场景', | |
152 | - "type": 'filter', | |
153 | - "submenu": [{ | |
154 | - "submenu": [ | |
155 | - ] | |
156 | - } | |
157 | - ] | |
158 | - }, | |
159 | - { | |
160 | - "name":'材质', | |
161 | - "type": 'filter', | |
162 | - "submenu": [{ | |
163 | - "submenu": [ | |
164 | - ] | |
165 | - } | |
166 | - ] | |
167 | - }, | |
168 | - { | |
169 | - "name":'筛选', | |
170 | - "type": 'filter', | |
171 | - "submenu": [{ | |
172 | - // "name": "折扣(多选)", | |
173 | - "submenu": [ | |
174 | - ] | |
175 | - } | |
176 | - ] | |
177 | - } | |
178 | - ] | |
136 | + return this.$store.state.index.categoryList; | |
179 | 137 | // newData[0].submenu[0].submenu = categoryList[0].submenu |
180 | 138 | // newData[1].submenu[0].submenu = categoryList[3].submenu[5].submenu |
181 | 139 | // newData[2].submenu[0].submenu = categoryList[3].submenu[2].submenu |
... | ... | @@ -183,26 +141,29 @@ export default { |
183 | 141 | // newData[4].submenu[0] = categoryList[3] |
184 | 142 | this.filterData = newData; |
185 | 143 | // this.filterData = categoryList; |
186 | - } | |
187 | - | |
144 | + }, | |
188 | 145 | }, |
189 | 146 | filters: { |
190 | 147 | outData(value) { |
191 | 148 | return JSON.stringify(value); |
192 | 149 | } |
193 | 150 | }, |
194 | - onLoad: function() { | |
195 | - store.dispatch('test/fetch'); | |
196 | - store.dispatch('categoryOrder/fetch') | |
197 | - | |
198 | - // 登陆 | |
199 | - // store.dispatch('user/login') | |
200 | - | |
151 | + onLoad() { | |
152 | + console.log('onload') | |
153 | + store.dispatch('index/category'); | |
154 | + // this.getList(); | |
155 | + store.dispatch('index/list'); | |
201 | 156 | }, |
202 | 157 | methods: { |
203 | 158 | showDrawer(e) { |
204 | 159 | this.$refs[e].open(); |
205 | 160 | }, |
161 | + getList() { | |
162 | + store.dispatch('index/list'); | |
163 | + }, | |
164 | + // search(params) { | |
165 | + // this.$store.index. | |
166 | + // }, | |
206 | 167 | closeDrawer(e) { |
207 | 168 | this.$refs[e].close(); |
208 | 169 | }, |
... | ... | @@ -217,16 +178,35 @@ export default { |
217 | 178 | dropDown() { |
218 | 179 | console.log("下拉"); |
219 | 180 | }, |
181 | + searchKey(e) { | |
182 | + const { value: keyword } = e.detail; | |
183 | + this.keyWords = keyword; | |
184 | + console.log('e', e, keyword); | |
185 | + store.dispatch('index/search', { | |
186 | + params: {}, | |
187 | + keyword, | |
188 | + }); | |
189 | + }, | |
220 | 190 | //接收菜单结果 |
221 | - confirm(e) { | |
222 | - this.indexArr = e.index; | |
223 | - this.valueArr = e.value; | |
224 | - return; | |
225 | - console.log("修改菜单"); | |
226 | - this.filterData[4].submenu[1] = { | |
227 | - name: "项目2", | |
228 | - submenu: [] | |
229 | - }; | |
191 | + search(e) { | |
192 | + console.log("修改菜单-----", e, this.categoryList); | |
193 | + const { on, value, index } = e; | |
194 | + let params = {} | |
195 | + if(on[0] === 1) { | |
196 | + this.searchText = ''; | |
197 | + store.dispatch('index/list'); | |
198 | + } else { | |
199 | + for(let i = 1; i<=on.length; i++){ // on[0]是全部 | |
200 | + if(on[i] === 1) { // 若该选项被选中 | |
201 | + console.log('---', `${this.categoryList[i].value}`); | |
202 | + params[`${this.categoryList[i].value}`] = value[i][0]; | |
203 | + } | |
204 | + } | |
205 | + store.dispatch('index/search', { | |
206 | + params, | |
207 | + keyword: this.keyWords | |
208 | + }); | |
209 | + } | |
230 | 210 | } |
231 | 211 | }, |
232 | 212 | ... | ... |
src/store/modules/categoryOrder.js
... | ... | @@ -1,40 +0,0 @@ |
1 | - import urlAlias from '../url'; | |
2 | - import request from '../request'; | |
3 | - | |
4 | - const { | |
5 | - category | |
6 | - } = urlAlias; | |
7 | - | |
8 | -const state = { | |
9 | - categoryList: [], | |
10 | -}; | |
11 | - | |
12 | -const mutations = { | |
13 | - INIT: (state, categoryList) => { | |
14 | - state.categoryList = categoryList; | |
15 | - }, | |
16 | -}; | |
17 | - | |
18 | -const actions = { | |
19 | - fetch({ commit }, param) { | |
20 | - request({ | |
21 | - url: category, | |
22 | - success: (res) => { | |
23 | - commit('INIT', res.data.data) | |
24 | - }, | |
25 | - fail: (res) => { | |
26 | - console.log("fail status === > ", res); | |
27 | - }, | |
28 | - complete: (res) => { | |
29 | - console.log("complete status === > ", res); | |
30 | - }, | |
31 | - }) | |
32 | - }, | |
33 | -}; | |
34 | - | |
35 | -export default { | |
36 | - namespaced: true, | |
37 | - state, | |
38 | - mutations, | |
39 | - actions, | |
40 | -}; |
src/store/modules/index.js
... | ... | @@ -0,0 +1,95 @@ |
1 | + import urlAlias from '../url'; | |
2 | + import request from '../request'; | |
3 | + | |
4 | + const { | |
5 | + category, | |
6 | + shopList, | |
7 | + search, | |
8 | + } = urlAlias; | |
9 | + | |
10 | +const state = { | |
11 | + categoryList: [], | |
12 | + list: [], | |
13 | +}; | |
14 | + | |
15 | +const mutations = { | |
16 | + LIST: (state, list) => { | |
17 | + state.list = list; | |
18 | + }, | |
19 | + CATEGORY: (state, categoryList) => { | |
20 | + state.categoryList = categoryList; | |
21 | + }, | |
22 | +}; | |
23 | + | |
24 | +const actions = { | |
25 | + category({ commit }, param) { | |
26 | + request({ | |
27 | + url: category, | |
28 | + success: (res) => { | |
29 | + console.log('category', res); | |
30 | + let data = res.data.data; | |
31 | + for(let i = 0; i<=data.length; i++) { | |
32 | + if(data[i] && data[i].type !== 'filter'){ | |
33 | + data[i].type = 'hierarchy'; | |
34 | + } | |
35 | + } | |
36 | + data.unshift({ | |
37 | + type: "hierarchy", | |
38 | + name: "全部", | |
39 | + value: "all", | |
40 | + isNoPull: true, | |
41 | + }); | |
42 | + commit('CATEGORY', data); | |
43 | + }, | |
44 | + fail: (res) => { | |
45 | + console.log("fail status === > ", res); | |
46 | + }, | |
47 | + complete: (res) => { | |
48 | + console.log("complete status === > ", res); | |
49 | + }, | |
50 | + }) | |
51 | + }, | |
52 | + list({ commit }, param) { | |
53 | + request({ | |
54 | + url: shopList, | |
55 | + success: (res) => { | |
56 | + commit('LIST', res.data.data) | |
57 | + }, | |
58 | + fail: (res) => { | |
59 | + console.log("fail status === > ", res); | |
60 | + }, | |
61 | + complete: (res) => { | |
62 | + console.log("complete status === > ", res); | |
63 | + }, | |
64 | + }) | |
65 | + }, | |
66 | + search({ commit }, { params, keyword }) { | |
67 | + const uid = uni.getStorageSync('uid'); | |
68 | + console.log("params",params, keyword); | |
69 | + request({ | |
70 | + url: search, | |
71 | + data: { | |
72 | + params: JSON.stringify(params), | |
73 | + uid, | |
74 | + way: 1, | |
75 | + keyword, | |
76 | + }, | |
77 | + success: (res) => { | |
78 | + commit('LIST', res.data.data); | |
79 | + }, | |
80 | + fail: (res) => { | |
81 | + console.log("fail status === > ", res); | |
82 | + }, | |
83 | + complete: (res) => { | |
84 | + console.log("complete status === > ", res); | |
85 | + }, | |
86 | + }) | |
87 | + } | |
88 | +}; | |
89 | + | |
90 | +export default { | |
91 | + namespaced: true, | |
92 | + state, | |
93 | + mutations, | |
94 | + actions, | |
95 | +}; | ... | ... |
src/store/modules/user.js
... | ... | @@ -73,6 +73,7 @@ const actions = { |
73 | 73 | success: (res) => { |
74 | 74 | console.log('userInfo=====', res); |
75 | 75 | const { data: { data: { uid, username: nickName, openid, headerphoto } } } = res; |
76 | + uni.setStorageSync('uid', uid); | |
76 | 77 | const userInfo = { |
77 | 78 | uid, |
78 | 79 | openid, |
... | ... | @@ -112,6 +113,7 @@ const actions = { |
112 | 113 | success: (res) => { |
113 | 114 | console.log('userInfo=====', res); |
114 | 115 | const { data: { data: { uid, username: nickName, openid, headerphoto } } } = res; |
116 | + uni.setStorageSync('uid', uid); | |
115 | 117 | const userInfo = { |
116 | 118 | uid, |
117 | 119 | openid, | ... | ... |
src/store/request.js
src/store/url.js
1 | 1 | const urlAlias = { |
2 | - // 获取首页商品列表 | |
3 | - shopList: '/app/prod/list', | |
4 | - | |
5 | - // 获取首页商品列表 | |
6 | - category: '/app/prod/category2', | |
7 | - // 获取商品信息 | |
8 | - read: '/app/prod/read', | |
2 | + // 获取商品信息 | |
3 | + read: '/app/prod/read', | |
9 | 4 | |
10 | 5 | // 首页 |
11 | 6 | shopList: '/app/prod/list', // 获取首页商品列表 |
12 | - category: '/app/prod/category', // 获取首页商品分类 | |
7 | + category: '/app/prod/category2', // 获取首页商品分类 | |
8 | + search: '/app/prod/search', // 首页搜索商品 | |
13 | 9 | |
14 | 10 | // 登陆 |
15 | 11 | login: '/app/glass/getOpenId', // 登陆 | ... | ... |