Просмотр исходного кода

erge branch 'master' of http://git.huaml.com/zhh/front-end

开单页面
fuwei 5 лет назад
Родитель
Сommit
201b394326
2 измененных файлов с 89 добавлено и 86 удалено
  1. 54 54
      ghs/src/mixins/list.js
  2. 35 32
      ghs/src/store/index.js

+ 54 - 54
ghs/src/mixins/list.js

@@ -1,56 +1,56 @@
 export default {
-	watch: {
-		'list.loading'(val) {
-			if (val) {
-				uni.showLoading({
-					title: '加载中...',
-					mask: true
-				})
-			} else {
-				uni.hideLoading()
-			}
-		}
-	},
-	data() {
-		return {
-			list: {
-				data: [],
-				page: 1,
-				pageSize: 20,
-				loading: true,
-				finished: false,
-				total: 0,
-				totalPage: 0
-			}
-		}
-	},
-	methods: {
-		resetList() {
-			this.list = {
-				data: [],
-				page: 1,
-				pageSize: 20,
-				loading: true,
-				finished: false,
-				total: null,
-				totalPage: null
-			}
-		},
-		completes(res, listKey) {
-			this.list.loading = false
-			if (res.code !== 1) {
-				this.list.finished = true
-			}
-			let listArr = res.data.list || res.data.data || res.data[listKey]
-			this.list.data = this.list.page === 1 ? listArr : this.list.data.concat(listArr)
-			this.list.total = res.data.totalPage * this.list.pageSize
-			this.list.totalPage = res.data.totalPage || res.totalPage
-			if (!res.data.moreData) {
-				this.list.finished = true
-			} else {
-				++this.list.page
-			}
-		}
-	}
-
+  watch: {
+    'list.loading'(val) {
+      if (val) {
+        uni.showLoading({
+          title: '加载中...',
+          mask: true,
+        })
+      } else {
+        uni.hideLoading()
+      }
+    },
+  },
+  data() {
+    return {
+      list: {
+        data: [],
+        page: 1,
+        pageSize: 20,
+        loading: true,
+        finished: false,
+        total: 0,
+        totalPage: 0,
+      },
+    }
+  },
+  methods: {
+    resetList() {
+      this.list = {
+        data: [],
+        page: 1,
+        pageSize: 20,
+        loading: true,
+        finished: false,
+        total: null,
+        totalPage: null,
+      }
+    },
+    completes(res, listKey) {
+      this.list.loading = false
+      if (res.code !== 1) {
+        this.list.finished = true
+      }
+      let listArr = res.data.list || res.data.data || res.data[listKey]
+      this.list.data =
+        this.list.page === 1 ? listArr : this.list.data.concat(listArr)
+      this.list.total = res.data.totalPage * this.list.pageSize
+      this.list.totalPage = res.data.totalPage || res.totalPage
+      if (!res.data.moreData) {
+        this.list.finished = true
+      } else {
+        ++this.list.page
+      }
+    },
+  },
 }

+ 35 - 32
ghs/src/store/index.js

@@ -6,38 +6,41 @@ import util from '@/utils/util'
 Vue.use(Vuex)
 
 const store = new Vuex.Store({
-	modules,
-	state: {
-		allOptions: ''
-	},
-	getters: {
-		allOptions: state => state.allOptions ||
-		 (util.isEmpty(uni.getStorageSync('allOptions')) ? {} : JSON.parse(uni.getStorageSync('allOptions')))
-	},
-	mutations: {
-		// 全局选项
-		setAllOptions(state, data = {}) {
-			  state.allOptions = data
-			  uni.setStorageSync('allOptions', JSON.stringify(data))
-		}
-	  },
-	actions: {
-		getAllOptions({ commit }) {
-		// sysBudgetStatus 预算   sysRenovationStatus 装修类型  sysBookingStatus 派单状态
-			return getOptions({
-				type: ''
-			}).then((res) => {
-				if (res.status === 'success') {
-					commit('setAllOptions', res.data)
-				} else {
-					uni.showToast({
-						title: res.errors.message,
-						icon: 'none'
-					})
-				}
-			})
-		}
-	}
+  modules,
+  state: {
+    allOptions: '',
+  },
+  getters: {
+    allOptions: (state) =>
+      state.allOptions ||
+      (util.isEmpty(uni.getStorageSync('allOptions'))
+        ? {}
+        : JSON.parse(uni.getStorageSync('allOptions'))),
+  },
+  mutations: {
+    // 全局选项
+    setAllOptions(state, data = {}) {
+      state.allOptions = data
+      uni.setStorageSync('allOptions', JSON.stringify(data))
+    },
+  },
+  actions: {
+    getAllOptions({ commit }) {
+      // sysBudgetStatus 预算   sysRenovationStatus 装修类型  sysBookingStatus 派单状态
+      return getOptions({
+        type: '',
+      }).then((res) => {
+        if (res.status === 'success') {
+          commit('setAllOptions', res.data)
+        } else {
+          uni.showToast({
+            title: res.errors.message,
+            icon: 'none',
+          })
+        }
+      })
+    },
+  },
 })
 
 export default store