panhui 4 gadi atpakaļ
vecāks
revīzija
36e540f9a3
3 mainītis faili ar 26 papildinājumiem un 5 dzēšanām
  1. 1 5
      src/components/CardCase.vue
  2. 16 0
      src/mixins/common.js
  3. 9 0
      src/pages/Home.vue

+ 1 - 5
src/components/CardCase.vue

@@ -115,11 +115,7 @@ export default {
             } else if (list.length < 6) {
                 list.push(id);
             } else {
-                wx.showToast({
-                    icon: 'none',
-                    title: '最多选择六张',
-                    mask: true
-                });
+                this.toast('最多选择六张');
             }
             this.nowChoose = list;
         },

+ 16 - 0
src/mixins/common.js

@@ -72,6 +72,22 @@ export default {
             } else {
                 return num;
             }
+        },
+        toast(title, icon = 'none', duration = 1500) {
+            wx.showToast({
+                icon: icon,
+                title: title,
+                mask: true,
+                duration: duration
+            });
+        },
+        showLoading() {
+            wx.showLoading({
+                title: '加载中...'
+            });
+        },
+        hideLoading() {
+            wx.hideLoading();
         }
     }
 };

+ 9 - 0
src/pages/Home.vue

@@ -71,16 +71,25 @@ export default {
             this.getData();
         },
         getData() {
+            this.showLoading();
+            this.list = [];
             this.empty = false;
             this.$http
                 .get('/cardCase/showCasesMA', {
                     caseStatus: this.getStatus(this.active)
                 })
                 .then(res => {
+                    this.hideLoading();
                     this.list = res;
                     if (res.length === 0) {
                         this.empty = true;
                     }
+                })
+                .catch(e => {
+                    this.hideLoading();
+                    if (e.error) {
+                        this.toast(e.rror);
+                    }
                 });
         }
     },