Browse Source

feat 代码优化

Funny 3 years ago
parent
commit
8d1b826c48

+ 8 - 0
src/components/accountCompoents/consumption.vue

@@ -102,6 +102,14 @@ export default {
       },
     };
   },
+  watch: {
+    "$store.state.userInfo": {
+      handler(newVal, oldVal) {
+        this.memberType = newVal.memberType;
+      },
+      deep: true,
+    },
+  },
   created() {
     this.init();
     this.search();

+ 8 - 0
src/components/accountCompoents/wallet.vue

@@ -72,6 +72,14 @@ export default {
       memberType: this.$store.state.userInfo.memberType,
     };
   },
+  watch: {
+    "$store.state.userInfo": {
+      handler(newVal, oldVal) {
+        this.memberType = newVal.memberType;
+      },
+      deep: true,
+    },
+  },
   components: {
     qrCode,
   },

+ 12 - 10
src/components/manualCreate.vue

@@ -161,6 +161,8 @@ export default {
       products: [],
       addressType: 1,
       name: "",
+      sendType: this.$store.state.userInfo.memberType === 1 ? 0 : 1,
+      memberType: this.$store.state.userInfo.memberType,
       form: {
         name: "",
         sendAddress: {
@@ -227,18 +229,18 @@ export default {
     addressManagement,
   },
   // 监听属性 类似于data概念
-  computed: {
-    // sendType: this.$store.state.userInfo.memberType === 1 ? 0 : 1, // 0是个人地址发单 1是门店地址发单
-    sendType() {
-      return this.$store.state.userInfo.memberType === 1 ? 0 : 1;
-    },
-    // memberType: this.$store.state.userInfo.memberType,
-    memberType() {
-      return this.$store.state.userInfo.memberType;
-    },
-  },
+  computed: {},
   // 监控data中的数据变化
   watch: {
+    "$store.state.userInfo": {
+      handler(newVal, oldVal) {
+        this.sendType = newVal.memberType === 1 ? 0 : 1;
+        this.memberType = newVal.memberType;
+        this.form.type = newVal.memberType === 1 ? 1 : 2;
+        this.form.shopId = newVal.shopId;
+      },
+      deep: true,
+    },
     sendType: {
       handler(newVal, oldVal) {
         this.searchKey = "";

+ 8 - 0
src/components/orderSearch.vue

@@ -171,6 +171,14 @@ export default {
     sendOrderPopup,
     OrderList,
   },
+  watch:{
+    "$store.state.userInfo": {
+      handler(newVal, oldVal) {
+        this.memberType = newVal.memberType;
+      },
+      deep: true,
+    },
+  },
   created() {
     let searchKey = this.$route.query.searchKey;
     if (searchKey) {

+ 8 - 0
src/components/settingComponents/voiceSetting.vue

@@ -101,6 +101,14 @@ export default {
       memberType: this.$store.state.userInfo.memberType,
     };
   },
+  watch:{
+    "$store.state.userInfo": {
+      handler(newVal, oldVal) {
+        this.memberType = newVal.memberType;
+      },
+      deep: true,
+    },
+  },
   created() {
     this.getConfig();
     this.queryPushMessageStatus();

+ 6 - 0
src/components/shopCompoents/bindDelivery.vue

@@ -123,6 +123,12 @@ export default {
     };
   },
   watch: {
+    "$store.state.userInfo": {
+      handler(newVal, oldVal) {
+        this.memberType = newVal.memberType;
+      },
+      deep: true,
+    },
     jumpUrl(newVal, oldVal) {
       if (this.jumpUrl) {
         this.fullscreenLoading = true;

+ 6 - 0
src/components/shopCompoents/bindPrinter.vue

@@ -87,6 +87,12 @@ export default {
     curIdx(newVal, oldVal) {
       this.shopDeviceList(newVal);
     },
+    "$store.state.userInfo": {
+      handler(newVal, oldVal) {
+        this.memberType = newVal.memberType;
+      },
+      deep: true,
+    },
   },
   created() {
     if (this.memberType !== 1) {

+ 8 - 0
src/components/shopCompoents/shopList.vue

@@ -52,6 +52,14 @@ export default {
       memberType: this.$store.state.userInfo.memberType,
     };
   },
+  watch:{
+    "$store.state.userInfo": {
+      handler(newVal, oldVal) {
+        this.memberType = newVal.memberType;
+      },
+      deep: true,
+    },
+  },
   mounted() {
     if (this.memberType !== 1) {
       this.getData();

+ 8 - 0
src/components/shopInfo.vue

@@ -54,6 +54,14 @@ export default {
       memberType: this.$store.state.userInfo.memberType,
     };
   },
+  watch: {
+    "$store.state.userInfo": {
+      handler(newVal, oldVal) {
+        this.memberType = newVal.memberType;
+      },
+      deep: true,
+    },
+  },
   created() {
     this.getProductList();
     bus.$on("goPrinter", () => {