Browse Source

计划外列表页面刷新优化

zhujindu 10 months ago
parent
commit
6dbb04e5d9
2 changed files with 37 additions and 66 deletions
  1. 10 10
      src/components/tabBar.vue
  2. 27 56
      src/views/deviceOutside/index.vue

+ 10 - 10
src/components/tabBar.vue

@@ -32,7 +32,7 @@
       <van-tabbar-item name="MyList">
         <span>我的</span>
         <template #icon>
-          <van-icon :name="tabBarActive == 'MyList' ? storeselect : store" />
+          <van-icon :name="tabBarActive == 'MyList' ? storeselect : storePng" />
         </template>
       </van-tabbar-item>
     </van-tabbar>
@@ -46,10 +46,11 @@ import jihua from '@/assets/Icon/jihua.png';
 import jihuaselect from '@/assets/Icon/jihuaselect.png';
 import out from '@/assets/Icon/out.png';
 import outselect from '@/assets/Icon/outselect.png';
-import store from '@/assets/Icon/store.png';
+import storePng from '@/assets/Icon/store.png';
 import storeselect from '@/assets/Icon/storeselect.png';
 import ai from '@/assets/Icon/ai.png';
 import aiselect from '@/assets/Icon/aiselect.png';
+import store from '@/store';
 export default {
   name: 'tabBar',
   props: {
@@ -62,7 +63,7 @@ export default {
     return {
       ai: ai,
       aiselect: aiselect,
-      store: store,
+      storePng: storePng,
       storeselect: storeselect,
       honeselect: honeselect,
       home: home,
@@ -85,14 +86,13 @@ export default {
     },
   },
   methods: {
-    tabBarChange(index) {
-      if (
-        localStorage.getItem('loginName') == 'lihaoyang.sm' ||
-        localStorage.getItem('loginName') == 'zhangjunyang.sm'
-      ) {
-        this.show = true;
+    tabBarChange(name) {
+      // 计划外
+      if (name == 'outsidelist') {
+        // 进入计划内刷新列表
+        // store.dispatch('setDeviceOutsidePage', true);
       }
-      this.$router.push({ name: index + '' });
+      this.$router.push({ name: name + '' });
     },
   },
 };

+ 27 - 56
src/views/deviceOutside/index.vue

@@ -757,6 +757,7 @@ export default {
     store.dispatch('setDeviceOutsidePage', false);
   },
   mounted() {
+    localStorage.setItem('tabVal', '1');
     // 上拉边界下拉出现白色空白
     let node = document.getElementsByClassName('deviceOutside')[0];
     node.addEventListener(
@@ -799,11 +800,7 @@ export default {
         this.storeCategoryList = this.result.join(',');
       }
       // 当前tabs,0:销售部;1:我的
-      if (localStorage.getItem('tabVal')) {
-        this.tabVal = localStorage.getItem('tabVal');
-      } else {
-        this.tabVal = '1';
-      }
+      this.tabVal = localStorage.getItem('tabVal');
       this.query = this.$route.query; // 路由参数
       localStorage.removeItem('visitId');
       if (localStorage.getItem('postType') == 'GZ') {
@@ -899,6 +896,7 @@ export default {
         from: 'outPlan',
       }).then((res) => {
         if (res.code == 200 && res.data) {
+          store.dispatch('setDeviceOutsidePage', true);
           window.location.href = res.data;
         } else {
           this.Toast({
@@ -1143,8 +1141,8 @@ export default {
       }).then((res) => {
         this.disabled = false;
         this.toastLoading().clear();
+        this.loading = false;
         if (res.code == 200) {
-          this.loading = false;
           if (this.pageNum == '1') {
             this.list = [];
           }
@@ -1173,45 +1171,18 @@ export default {
         }
       });
     },
-    positionFn(val) {
-      getPosition(true)
-        .then((res) => {
-          let { TXisBD } = res;
-          this.lat = TXisBD.lat;
-          this.lon = TXisBD.lon;
-          if (val == 1) {
-            if (this.tabVal == 1) {
-              this.getUserOutPlaListFun();
-            } else {
-              this.getUserOrgStoreList();
-            }
-          } else {
-            this.getUserOutPlaListFun();
-          }
-        })
-        .catch((error) => {
-          this.$dialog.alert({
-            message: error,
-          });
-        });
-    },
     getUserOutPlaListFun() {
       this.storeType = localStorage.getItem('storeType');
-      var that = this;
       this.disabled = true;
-      let loading3 = this.$toast.loading({
-        duration: 0,
-        message: '加载中...',
-        forbidClick: true,
-      });
+      this.toastLoading(0, '加载中...', true);
       this.endShow = false;
       if (this.refreshing) {
         this.list = [];
         this.refreshing = false;
       }
       getUserOutPlaList({
-        lat: that.lat,
-        lon: that.lon,
+        lat: this.lat,
+        lon: this.lon,
         chainCode: this.chainCode ? this.chainCode : '',
         storeLabelTypes: this.storeLabelTypes.join(','),
         pageNum: this.pageNum,
@@ -1221,9 +1192,9 @@ export default {
         genDate: this.genDate,
       }).then((res) => {
         this.disabled = false;
+        this.toastLoading().clear();
+        this.loading = false;
         if (res.code == 200) {
-          loading3.clear();
-          this.loading = false;
           this.list = this.list.concat(res.rows);
           if (this.list.length >= res.total) {
             this.finished = true;
@@ -1871,14 +1842,7 @@ export default {
                     accuracy: resData.accuracy,
                   }).then((response) => {
                     // 进入拜访之前先刷新页面
-                    this.pageNum = 1;
-                    this.list = [];
-                    this.finished = true;
-                    if (this.tabVal == 1) {
-                      this.getUserOutPlaListFun();
-                    } else {
-                      this.getUserOrgStoreList();
-                    }
+                    store.dispatch('setDeviceOutsidePage', true);
                     this.$router.push({
                       path: '/outabnormalVisit',
                       query: {
@@ -2083,6 +2047,7 @@ export default {
     },
     // 滚动条与底部距离小于 offset 时触发 初始化会触发
     onLoad() {
+      this.toastLoading(0, '加载中...', true);
       // 授权
       getTicketFun().then(() => {
         var postType = localStorage.getItem('postType');
@@ -2091,16 +2056,22 @@ export default {
         } else {
           this.typeShow = true;
         }
-        if (this.lon == '' && this.tabVal != 1) {
-          this.positionFn(1);
-        } else {
-          if (this.tabVal == 1) {
-            this.positionFn();
-            // this.getUserOutPlaListFun();
-          } else {
-            this.getUserOrgStoreList();
-          }
-        }
+        getPosition(true)
+          .then((res) => {
+            let { TXisBD } = res;
+            this.lat = TXisBD.lat;
+            this.lon = TXisBD.lon;
+            if (this.tabVal == '1') {
+              this.getUserOutPlaListFun();
+            } else {
+              this.getUserOrgStoreList();
+            }
+          })
+          .catch((error) => {
+            this.$dialog.alert({
+              message: error,
+            });
+          });
       });
     },
     // 跳转好帮手门店详情