Browse Source

添加店铺列表的分页功能

huxz 8 years ago
parent
commit
03339b38f3

+ 32 - 2
components/provider/Suppliers.vue

@@ -45,6 +45,15 @@
       </tr>
       </tr>
       </tbody>
       </tbody>
     </table>
     </table>
+    <div style="float: right;">
+      <el-pagination
+        :current-page.sync="pageParams.page"
+        :page-size="pageParams.count"
+        layout="prev, pager, next, jumper"
+        :total="stores.totalElements"
+        @current-change="handleCurrentChange">
+      </el-pagination>
+    </div>
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
@@ -72,7 +81,6 @@ export default {
     search () {
     search () {
       this.pageParams.page = 1
       this.pageParams.page = 1
       this.pageParams.keyword = this.keyword === '' ? null : this.keyword
       this.pageParams.keyword = this.keyword === '' ? null : this.keyword
-      console.log(this.pageParams)
       this.$store.dispatch('provider/findStoreList', this.pageParams)
       this.$store.dispatch('provider/findStoreList', this.pageParams)
     },
     },
     showLittleDescription (description) {
     showLittleDescription (description) {
@@ -80,11 +88,33 @@ export default {
         return '暂无简介'
         return '暂无简介'
       }
       }
       return description.slice(0, 160)
       return description.slice(0, 160)
+    },
+    async pageCommodity (pageParams) {
+      pageParams.op = 'pageByType'
+
+      try {
+        let { data } = await this.$http.get('/api/store-service/stores', { params: pageParams })
+        console.log('DATA', data)
+        this.$store.commit('provider/stores/GET_STORE_LIST_SUCCESS', data)
+      } catch (err) {
+        this.$store.commit('provider/stores/GET_STORE_LIST_FAILURE', err)
+      }
+    },
+    handleCurrentChange (page) {
+      this.pageParams.page = page
+      this.pageParams.keyword = this.keyword === '' ? null : this.keyword
+
+      this.pageCommodity(this.pageParams)
     }
     }
   }
   }
 }
 }
 </script>
 </script>
-<style scoped>
+<style>
+  .el-pagination .el-pager li.active{
+    background-color: #5078cb;
+    border-color: #337ab7;
+  }
+
   #store-list{
   #store-list{
 		width: 1190px;
 		width: 1190px;
 		padding: 0;
 		padding: 0;

+ 6 - 2
components/store/CommodityList.vue

@@ -194,8 +194,12 @@ export default {
       params.page = pageParams.page
       params.page = pageParams.page
       params.count = pageParams.count
       params.count = pageParams.count
 
 
-      let { data } = await this.$http.get('/api/commodity/commodities', { params })
-      this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_SUCCESS', data)
+      try {
+        let { data } = await this.$http.get('/api/commodity/commodities', { params })
+        this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_SUCCESS', data)
+      } catch (err) {
+        this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_FAILURE', err)
+      }
     },
     },
     handleCurrentChange (page) {
     handleCurrentChange (page) {
       console.log(page)
       console.log(page)

+ 0 - 1
store/provider.js

@@ -100,7 +100,6 @@ export const actions = {
     commit('stores/REQUEST_STORE_LIST')
     commit('stores/REQUEST_STORE_LIST')
     return axios.get('/api/store-service/stores', { params })
     return axios.get('/api/store-service/stores', { params })
       .then(response => {
       .then(response => {
-        console.log('RESPONSE', response.data)
         commit('stores/GET_STORE_LIST_SUCCESS', response.data)
         commit('stores/GET_STORE_LIST_SUCCESS', response.data)
       }, err => {
       }, err => {
         commit('stores/GET_STORE_LIST_FAILURE', err)
         commit('stores/GET_STORE_LIST_FAILURE', err)

+ 0 - 1
store/provider/storeCms.js

@@ -61,7 +61,6 @@ export const mutations = {
   GET_RECOMMEND_STORE_SUCCESS (state, result) {
   GET_RECOMMEND_STORE_SUCCESS (state, result) {
     state.recommendStore.fetching = false
     state.recommendStore.fetching = false
     state.recommendStore.data = result
     state.recommendStore.data = result
-    console.log('Recommend Store', result.length)
   },
   },
   REQUEST_HOT_COMPONENTS (state) {
   REQUEST_HOT_COMPONENTS (state) {
     state.hotComponents.fetching = true
     state.hotComponents.fetching = true