Compare View
Commits (2)
-
Master See merge request !10
Showing
2 changed files
Show diff stats
src/pages/index/index.vue
... | ... | @@ -104,7 +104,10 @@ |
104 | 104 | ></Card> |
105 | 105 | </view> |
106 | 106 | </view> |
107 | - <view class="loading-text">{{loadingText}}</view> | |
107 | + <view class="loading-text"> | |
108 | + <text v-if="isLoading==true">{{loadingText}}</text> | |
109 | + <text v-else>{{loadedText}}</text> | |
110 | + </view> | |
108 | 111 | </view> |
109 | 112 | <!-- </scroll-view> --> |
110 | 113 | </view> |
... | ... | @@ -129,7 +132,8 @@ export default { |
129 | 132 | indexArr: "", |
130 | 133 | valueArr: "", |
131 | 134 | isLoading: true, //初始化加载状态 |
132 | - loadingText: "~~一开始应该是加载中。。。。等数据传完后,更新为到底了~~", | |
135 | + loadingText: "data loading...", | |
136 | + loadedText: "~~到底啦~~", | |
133 | 137 | filterDropdownValue: [], |
134 | 138 | filterData: [], |
135 | 139 | searchText: "", |
... | ... | @@ -139,7 +143,6 @@ export default { |
139 | 143 | }, |
140 | 144 | onPageScroll({ scrollTop }) { |
141 | 145 | // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件 |
142 | - | |
143 | 146 | this.scrollTop = scrollTop; |
144 | 147 | console.log("pagescroll====>", this.viewHeight); |
145 | 148 | }, |
... | ... | @@ -169,6 +172,8 @@ export default { |
169 | 172 | }, |
170 | 173 | getList() { |
171 | 174 | store.dispatch("index/list"); |
175 | + this.isLoading = false; //TODO:::这里不知道怎么改,请同学帮忙写一下。 | |
176 | + //把data里的isLoading 改为false就可以了 | |
172 | 177 | }, |
173 | 178 | // search(params) { |
174 | 179 | // this.$store.index. | ... | ... |
src/store/modules/index.js
... | ... | @@ -2,94 +2,106 @@ |
2 | 2 | import request from '../request'; |
3 | 3 | |
4 | 4 | const { |
5 | - category, | |
6 | - shopList, | |
7 | - search, | |
5 | + category, | |
6 | + shopList, | |
7 | + search, | |
8 | 8 | } = urlAlias; |
9 | 9 | |
10 | -const state = { | |
11 | - categoryList: [], | |
12 | - list: [] | |
13 | -}; | |
10 | + const state = { | |
11 | + categoryList: [], | |
12 | + list: [] | |
13 | + }; | |
14 | 14 | |
15 | -const mutations = { | |
16 | - LIST: (state, list) => { | |
17 | - state.list = list; | |
18 | - }, | |
19 | - CATEGORY: (state, categoryList) => { | |
20 | - state.categoryList = categoryList; | |
21 | - } | |
22 | -}; | |
15 | + const mutations = { | |
16 | + LIST: (state, list) => { | |
17 | + state.list = list; | |
18 | + }, | |
19 | + CATEGORY: (state, categoryList) => { | |
20 | + state.categoryList = categoryList; | |
21 | + } | |
22 | + }; | |
23 | 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 | -}; | |
24 | + const actions = { | |
25 | + category({ | |
26 | + commit | |
27 | + }, param) { | |
28 | + request({ | |
29 | + url: category, | |
30 | + success: (res) => { | |
31 | + console.log('category', res); | |
32 | + let data = res.data.data; | |
33 | + for (let i = 0; i <= data.length; i++) { | |
34 | + if (data[i] && data[i].type !== 'filter') { | |
35 | + data[i].type = 'hierarchy'; | |
36 | + } | |
37 | + } | |
38 | + data.unshift({ | |
39 | + type: "hierarchy", | |
40 | + name: "全部", | |
41 | + value: "all", | |
42 | + isNoPull: true, | |
89 | 43 | |
90 | -export default { | |
91 | - namespaced: true, | |
92 | - state, | |
93 | - mutations, | |
94 | - actions, | |
95 | -}; | |
44 | + }); | |
45 | + commit('CATEGORY', data); | |
46 | + }, | |
47 | + fail: (res) => { | |
48 | + console.log("fail status === > ", res); | |
49 | + }, | |
50 | + complete: (res) => { | |
51 | + console.log("complete status === > ", res); | |
52 | + }, | |
53 | + }) | |
54 | + }, | |
55 | + list({ | |
56 | + commit | |
57 | + }, param) { | |
58 | + | |
59 | + request({ | |
60 | + url: shopList, | |
61 | + success: (res) => { | |
62 | + commit('LIST', res.data.data) | |
63 | + }, | |
64 | + fail: (res) => { | |
65 | + console.log("fail status === > ", res); | |
66 | + }, | |
67 | + complete: (res) => { | |
68 | + console.log("complete status === > ", res); | |
69 | + state.isLoading = false; | |
70 | + }, | |
71 | + }) | |
72 | + }, | |
73 | + search({ | |
74 | + commit | |
75 | + }, { | |
76 | + params, | |
77 | + keyword | |
78 | + }) { | |
79 | + const uid = uni.getStorageSync('uid'); | |
80 | + console.log("params", params, keyword); | |
81 | + request({ | |
82 | + url: search, | |
83 | + data: { | |
84 | + params: JSON.stringify(params), | |
85 | + uid, | |
86 | + way: 1, | |
87 | + keyword, | |
88 | + }, | |
89 | + success: (res) => { | |
90 | + commit('LIST', res.data.data); | |
91 | + }, | |
92 | + fail: (res) => { | |
93 | + console.log("fail status === > ", res); | |
94 | + }, | |
95 | + complete: (res) => { | |
96 | + console.log("complete status === > ", res); | |
97 | + }, | |
98 | + }) | |
99 | + }, | |
100 | + }; | |
101 | + | |
102 | + export default { | |
103 | + namespaced: true, | |
104 | + state, | |
105 | + mutations, | |
106 | + actions, | |
107 | + }; | |
96 | 108 | \ No newline at end of file | ... | ... |