From 83e446d4dcd0aed30fca26b7a98fb78f4a32c197 Mon Sep 17 00:00:00 2001
From: "Adam.Gong" <admin@xiuyetang.com>
Date: Sat, 30 May 2020 15:05:18 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AE=A2=E5=8D=95=E6=95=B0?=
 =?UTF-8?q?=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/pages/index/index.vue  |  11 ++-
 src/store/modules/index.js | 184 ++++++++++++++++++++++++---------------------
 2 files changed, 106 insertions(+), 89 deletions(-)

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 @@
               ></Card>
             </view>
           </view>
-          <view class="loading-text">{{loadingText}}</view>
+          <view class="loading-text">
+            <text v-if="isLoading==true">{{loadingText}}</text>
+            <text v-else>{{loadedText}}</text>
+          </view>
         </view>
         <!-- </scroll-view> -->
       </view>
@@ -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
-- 
2.0.0