diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 6a7e827..a5748d7 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -104,7 +104,10 @@
>
- {{loadingText}}
+
+ {{loadingText}}
+ {{loadedText}}
+
@@ -129,7 +132,8 @@ export default {
indexArr: "",
valueArr: "",
isLoading: true, //初始化加载状态
- loadingText: "~~一开始应该是加载中。。。。等数据传完后,更新为到底了~~",
+ loadingText: "data loading...",
+ loadedText: "~~到底啦~~",
filterDropdownValue: [],
filterData: [],
searchText: "",
@@ -139,7 +143,6 @@ export default {
},
onPageScroll({ scrollTop }) {
// 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
-
this.scrollTop = scrollTop;
console.log("pagescroll====>", this.viewHeight);
},
@@ -169,6 +172,8 @@ export default {
},
getList() {
store.dispatch("index/list");
+ this.isLoading = false; //TODO:::这里不知道怎么改,请同学帮忙写一下。
+ //把data里的isLoading 改为false就可以了
},
// search(params) {
// this.$store.index.
diff --git a/src/store/modules/index.js b/src/store/modules/index.js
index e2e04af..8052746 100644
--- a/src/store/modules/index.js
+++ b/src/store/modules/index.js
@@ -2,94 +2,106 @@
import request from '../request';
const {
- category,
- shopList,
- search,
+ category,
+ shopList,
+ search,
} = urlAlias;
-const state = {
- categoryList: [],
- list: []
-};
+ const state = {
+ categoryList: [],
+ list: []
+ };
-const mutations = {
- LIST: (state, list) => {
- state.list = list;
- },
- CATEGORY: (state, categoryList) => {
- state.categoryList = categoryList;
- }
-};
+ const mutations = {
+ LIST: (state, list) => {
+ state.list = list;
+ },
+ CATEGORY: (state, categoryList) => {
+ state.categoryList = categoryList;
+ }
+ };
-const actions = {
- category({ commit }, param) {
- request({
- url: category,
- success: (res) => {
- console.log('category', res);
- let data = res.data.data;
- for(let i = 0; i<=data.length; i++) {
- if(data[i] && data[i].type !== 'filter'){
- data[i].type = 'hierarchy';
- }
- }
- data.unshift({
- type: "hierarchy",
- name: "全部",
- value: "all",
- isNoPull: true,
- });
- commit('CATEGORY', data);
- },
- fail: (res) => {
- console.log("fail status === > ", res);
- },
- complete: (res) => {
- console.log("complete status === > ", res);
- },
- })
- },
- list({ commit }, param) {
- request({
- url: shopList,
- success: (res) => {
- commit('LIST', res.data.data)
- },
- fail: (res) => {
- console.log("fail status === > ", res);
- },
- complete: (res) => {
- console.log("complete status === > ", res);
- },
- })
- },
- search({ commit }, { params, keyword }) {
- const uid = uni.getStorageSync('uid');
- console.log("params",params, keyword);
- request({
- url: search,
- data: {
- params: JSON.stringify(params),
- uid,
- way: 1,
- keyword,
- },
- success: (res) => {
- commit('LIST', res.data.data);
- },
- fail: (res) => {
- console.log("fail status === > ", res);
- },
- complete: (res) => {
- console.log("complete status === > ", res);
- },
- })
- },
-};
+ const actions = {
+ category({
+ commit
+ }, param) {
+ request({
+ url: category,
+ success: (res) => {
+ console.log('category', res);
+ let data = res.data.data;
+ for (let i = 0; i <= data.length; i++) {
+ if (data[i] && data[i].type !== 'filter') {
+ data[i].type = 'hierarchy';
+ }
+ }
+ data.unshift({
+ type: "hierarchy",
+ name: "全部",
+ value: "all",
+ isNoPull: true,
-export default {
- namespaced: true,
- state,
- mutations,
- actions,
-};
+ });
+ commit('CATEGORY', data);
+ },
+ fail: (res) => {
+ console.log("fail status === > ", res);
+ },
+ complete: (res) => {
+ console.log("complete status === > ", res);
+ },
+ })
+ },
+ list({
+ commit
+ }, param) {
+
+ request({
+ url: shopList,
+ success: (res) => {
+ commit('LIST', res.data.data)
+ },
+ fail: (res) => {
+ console.log("fail status === > ", res);
+ },
+ complete: (res) => {
+ console.log("complete status === > ", res);
+ state.isLoading = false;
+ },
+ })
+ },
+ search({
+ commit
+ }, {
+ params,
+ keyword
+ }) {
+ const uid = uni.getStorageSync('uid');
+ console.log("params", params, keyword);
+ request({
+ url: search,
+ data: {
+ params: JSON.stringify(params),
+ uid,
+ way: 1,
+ keyword,
+ },
+ success: (res) => {
+ commit('LIST', res.data.data);
+ },
+ fail: (res) => {
+ console.log("fail status === > ", res);
+ },
+ complete: (res) => {
+ console.log("complete status === > ", res);
+ },
+ })
+ },
+ };
+
+ export default {
+ namespaced: true,
+ state,
+ mutations,
+ actions,
+ };
\ No newline at end of file