Explorar o código

百度地图地址解析接口bug优化

zhujindu hai 8 meses
pai
achega
d9caf60e45
Modificáronse 1 ficheiros con 103 adicións e 108 borrados
  1. 103 108
      src/views/deviceOutside/suishenbangOutstoreVisit.vue

+ 103 - 108
src/views/deviceOutside/suishenbangOutstoreVisit.vue

@@ -125,7 +125,6 @@ import {
 } from '@/api/index';
 import axios from 'axios';
 import { saveVisitsParams, getOrderUrlByStoreId } from '@/api/inventory';
-import store from '@/store';
 export default {
   name: 'suishenbangOutstoreVisit',
   data() {
@@ -264,8 +263,9 @@ export default {
                   message: '拜访中任务结束成功!',
                 })
                 .then(() => {
-                  store.dispatch('setDeviceOutsidePage', true);
+                  // this.$router.replace({});
                   this.onClickLeft();
+                  // window.location.replace(window.location.origin + '/mobile/outsidelist/index');
                 });
             } else {
               this.$dialog.alert({
@@ -439,112 +439,109 @@ export default {
       markers.setGeometries([]);
       var input = [that.urlParameter.marklat, that.urlParameter.marklon];
       var location = new TMap.LatLng(Number(input[0]), Number(input[1]));
-      geocoder
-        .getAddress({ location: location })
-        .then(
-          function (result) {
-            var addresses = result.result.formatted_addresses;
-            let address_component = result.result.address_component;
-            let province = address_component.province;
-            let city = address_component.city;
-            let district = address_component.district;
-            console.log('province=' + province);
-            console.log('city=' + city);
-            console.log('district=' + district);
-            console.log(addresses);
-            console.log(addresses.recommend);
-            var params = {
-              storeId: that.storeId,
-              storeCode: that.storeCode,
-              visitEntry: visitEntry,
-              lat: that.urlParameter.latNew,
-              lon: that.urlParameter.lonNew,
-              visitModel: that.visitModel,
-              routeDetailsId: that.rdId,
-              visitSource: '1',
-              locationCity: '',
-              locationRemark: addresses.recommend || '',
-              locationAccuracy: that.urlParameter.PointSum,
-              province: address_component.province,
-              city: address_component.city,
-              district: address_component.district,
-            };
-            that.locationAccuracy = that.urlParameter.PointSum;
-            that.city = '';
-            that.address = addresses.recommend || '';
-            localStorage.setItem('address', '');
-            if (that.visitId != null) {
-              params.id = that.visitId;
-            }
-            let loading2 = that.$toast.loading({
-              duration: 0,
-              message: '加载中...',
-              forbidClick: true,
-            });
-            getStoreGroupTask(params).then((res) => {
-              loading2.clear();
-              if (res.code == 200) {
-                localStorage.setItem('visitId', res.data.visitId);
-                that.notes = res.data.notes;
-                that.visitId = res.data.visitId;
-                that.list = res.data.sfaTaskList;
-                that.storeGroupId = res.data.storeGroupId;
-                that.showOrderButton = res.data.showOrderButton;
-                that.startTime = res.data.startTime;
-                that.timeN = setInterval(that.animation, 16);
-                that.visitsRemarks = res.data.visitsRemarks;
-              } else {
-                that.$toast(res.msg);
-              }
-            });
-          },
-          function (err) {
-            var params = {
-              storeId: that.storeId,
-              storeCode: that.storeCode,
-              visitEntry: visitEntry,
-              lat: that.urlParameter.latNew,
-              lon: that.urlParameter.lonNew,
-              visitModel: that.visitModel,
-              routeDetailsId: that.rdId,
-              visitSource: '1',
-              locationCity: '',
-              locationRemark: '',
-              locationAccuracy: that.urlParameter.PointSum,
-            };
-            that.locationAccuracy = that.urlParameter.PointSum;
-            that.city = '';
-            that.address = '';
-            localStorage.setItem('address', '');
-            if (that.visitId != null) {
-              params.id = that.visitId;
+      geocoder.getAddress({ location: location }).then(
+        function (result) {
+          var addresses = result.result.formatted_addresses;
+          let address_component = result.result.address_component;
+          let province = address_component.province;
+          let city = address_component.city;
+          let district = address_component.district;
+          console.log('province=' + province);
+          console.log('city=' + city);
+          console.log('district=' + district);
+          let recommend = '';
+          if (addresses) {
+            recommend = addresses.recommend;
+          }
+          var params = {
+            storeId: that.storeId,
+            storeCode: that.storeCode,
+            visitEntry: visitEntry,
+            lat: that.urlParameter.latNew,
+            lon: that.urlParameter.lonNew,
+            visitModel: that.visitModel,
+            routeDetailsId: that.rdId,
+            visitSource: '1',
+            locationCity: '',
+            locationRemark: recommend,
+            locationAccuracy: that.urlParameter.PointSum,
+            province: address_component.province,
+            city: address_component.city,
+            district: address_component.district,
+          };
+          that.locationAccuracy = that.urlParameter.PointSum;
+          that.city = '';
+          that.address = recommend;
+          localStorage.setItem('address', '');
+          if (that.visitId != null) {
+            params.id = that.visitId;
+          }
+          let loading2 = that.$toast.loading({
+            duration: 0,
+            message: '加载中...',
+            forbidClick: true,
+          });
+          getStoreGroupTask(params).then((res) => {
+            loading2.clear();
+            if (res.code == 200) {
+              localStorage.setItem('visitId', res.data.visitId);
+              that.notes = res.data.notes;
+              that.visitId = res.data.visitId;
+              that.list = res.data.sfaTaskList;
+              that.storeGroupId = res.data.storeGroupId;
+              that.showOrderButton = res.data.showOrderButton;
+              that.startTime = res.data.startTime;
+              that.timeN = setInterval(that.animation, 16);
+              that.visitsRemarks = res.data.visitsRemarks;
+            } else {
+              that.$toast(res.msg);
             }
-            let loading2 = that.$toast.loading({
-              duration: 0,
-              message: '加载中...',
-              forbidClick: true,
-            });
-            getStoreGroupTask(params).then((res) => {
-              loading2.clear();
-              if (res.code == 200) {
-                localStorage.setItem('visitId', res.data.visitId);
-                that.notes = res.data.notes;
-                that.visitId = res.data.visitId;
-                that.list = res.data.sfaTaskList;
-                that.storeGroupId = res.data.storeGroupId;
-                that.showOrderButton = res.data.showOrderButton;
-                that.startTime = res.data.startTime;
-                that.timeN = setInterval(that.animation, 16);
-                that.visitsRemarks = res.data.visitsRemarks;
-              } else {
-                that.$toast(res.msg);
-              }
-            });
+          });
+        },
+        function (err) {
+          var params = {
+            storeId: that.storeId,
+            storeCode: that.storeCode,
+            visitEntry: visitEntry,
+            lat: that.urlParameter.latNew,
+            lon: that.urlParameter.lonNew,
+            visitModel: that.visitModel,
+            routeDetailsId: that.rdId,
+            visitSource: '1',
+            locationCity: '',
+            locationRemark: '',
+            locationAccuracy: that.urlParameter.PointSum,
+          };
+          that.locationAccuracy = that.urlParameter.PointSum;
+          that.city = '';
+          that.address = '';
+          localStorage.setItem('address', '');
+          if (that.visitId != null) {
+            params.id = that.visitId;
           }
-        )
-        .catch(function (err) {
-          console.log(err);
-        });
+          let loading2 = that.$toast.loading({
+            duration: 0,
+            message: '加载中...',
+            forbidClick: true,
+          });
+          getStoreGroupTask(params).then((res) => {
+            loading2.clear();
+            if (res.code == 200) {
+              localStorage.setItem('visitId', res.data.visitId);
+              that.notes = res.data.notes;
+              that.visitId = res.data.visitId;
+              that.list = res.data.sfaTaskList;
+              that.storeGroupId = res.data.storeGroupId;
+              that.showOrderButton = res.data.showOrderButton;
+              that.startTime = res.data.startTime;
+              that.timeN = setInterval(that.animation, 16);
+              that.visitsRemarks = res.data.visitsRemarks;
+            } else {
+              that.$toast(res.msg);
+            }
+          });
+        }
+      );
     },
     addStoreVisit(val, index) {
       this.$router.push({
@@ -573,7 +570,6 @@ export default {
       if (this.$route.query.urltype == 1) {
         window.location.replace(window.location.origin + '/mobile/home');
       } else {
-        // 返回上一页不会刷新页面
         this.$router.go(-1);
       }
     },
@@ -641,7 +637,6 @@ export default {
           loading1.clear();
           if (res.code == 200) {
             this.editDwellTimes();
-            store.dispatch('setDeviceOutsidePage', true);
             if (this.$route.query.linkType == 6) {
               window.location.replace(window.location.origin + '/mobile/topStore?info=y');
             } else {