ソースを参照

计划内进入拜访初始化不请求拜访任务

zhujindu 1 年間 前
コミット
aa481ae77e

+ 3 - 3
src/views/deviceOutside/index.vue

@@ -1610,8 +1610,8 @@ export default {
             storeId: val.storeId,
             lat: location.lat,
             lon: location.lon,
-          }).then((res) => {
-            if (res.code == 200) {
+          }).then((response) => {
+            if (response.code == 200) {
               this.$dialog
                 .alert({
                   title: '系统提示',
@@ -1624,7 +1624,7 @@ export default {
               localStorage.setItem('ORGName', val.deptName);
               localStorage.setItem('chainNameR', val.storeName);
             } else {
-              this.$toast(res.msg);
+              this.$toast(response.msg);
             }
           });
         });

+ 98 - 169
src/views/deviceWithin/index.vue

@@ -699,9 +699,6 @@ export default {
               lat = val.lat;
               lon = val.lon;
             }
-            // var location=that.CJ02BD(res.latitude,res.longitude)
-            // that.location = location;
-            // checkStoreAddressFun(val,res,location)
             this.$router.push({
               path: '/storeVisitpage',
               query: {
@@ -764,169 +761,14 @@ export default {
                 localStorage.setItem('ORGName', val.deptName);
                 localStorage.setItem('chainNameR', val.storeName);
               } else {
-                let loading1 = this.$toast.loading({
-                  duration: 0,
-                  message: '加载中...',
-                  forbidClick: true,
+                getPosition().then((res) => {
+                  let { TXisBD, resData } = res;
+                  this.lat = TXisBD.lat;
+                  this.lon = TXisBD.lon;
+                  localStorage.setItem('lat', this.lat);
+                  localStorage.setItem('lon', this.lon);
+                  this.checkStoreAddressByStoreCodeFun(val, TXisBD, resData);
                 });
-                let url = window.location.href;
-                let wx = this.wx;
-                let qiyeData;
-                const instance = axios.create();
-                instance.defaults.headers.common['userId'] = localStorage.getItem('loginName');
-                instance
-                  .get(process.env.VUE_APP_BASE_API + 'mobile/wx/ticket', {
-                    params: {
-                      url: url,
-                    },
-                  })
-                  .then((response) => {
-                    if (response.status == 200) {
-                      this.cont = 3;
-                      var flat = true;
-                      var times = setInterval(() => {
-                        this.cont--;
-                        if (this.cont == '0') {
-                          if (flat) {
-                            loading1.clear();
-                            clearInterval(times);
-                            that.$dialog
-                              .alert({
-                                message: '定位失败,请开启企微定位权限',
-                              })
-                              .then(() => {});
-                          } else {
-                            clearInterval(times);
-                          }
-                        }
-                      }, 1000);
-                      qiyeData = response.data.data;
-                      wx.config({
-                        beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
-                        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-                        appId: qiyeData.appId, // 必填,企业微信的corpID
-                        timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
-                        nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
-                        signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
-                        jsApiList: ['ready', 'getLocation'], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
-                      });
-                      wx.ready(() => {
-                        wx.getLocation({
-                          type: 'gcj02',
-                          success: (res) => {
-                            flat = false;
-                            var location = this.CJ02BD(res.latitude, res.longitude);
-                            this.location = location;
-                            checkStoreAddressByStoreCode({
-                              storeCode: val.storeCode,
-                              lon: location.lon,
-                              lat: location.lat,
-                            }).then((response) => {
-                              loading1.clear();
-                              if (val.lat == '' || val.lat == null) {
-                                that.lat = location.lat;
-                                that.lon = location.lon;
-                              } else {
-                                that.lat = val.lat;
-                                that.lon = val.lon;
-                              }
-                              let PointSum = that
-                                .twoPointSum(that.lat, that.lon, location.lat, location.lon)
-                                .toFixed(2);
-                              let PointSumval = that
-                                .twoPointSum(location.lat, location.lon, location.lat, location.lon)
-                                .toFixed(2);
-                              // GZ:工装店铺 直接进入拜访
-                              if (localStorage.getItem('postType') == 'GZ') {
-                                localStorage.setItem('startTime', new Date());
-                                localStorage.setItem('ORGName', val.deptName);
-                                localStorage.setItem('chainNameR', val.storeName);
-                                this.toSuishenbangOutstoreVisit(res, val, location, PointSumval);
-                                return;
-                              }
-                              // 门店编码校验门店地址不通过
-                              if (response.code != 200) {
-                                // updateAddress : ,1:同城AB+金牌,去修改地址;2:非金牌店铺,非同城店铺偏差过大不允许拜访,可以重置定位;0非金牌店铺,非同城店铺 位置信息不存在 可以继续拜访
-                                if (response.data.updateAddress == 0) {
-                                  // 非金牌店铺,非同城店铺 位置信息不存在 可以继续拜访
-                                  this.$dialog
-                                    .confirm({
-                                      confirmButtonText: '确定拜访',
-                                      cancelButtonText: '取消拜访',
-                                      title: '系统提示',
-                                      message:
-                                        '该客户没有经纬度,此次拜访会保存定位点作为客户经纬度,下次拜访时判断是否偏差过大。',
-                                      closeOnClickOverlay: true,
-                                    })
-                                    .then(() => {
-                                      this.toSuishenbangOutstoreVisit(
-                                        res,
-                                        val,
-                                        location,
-                                        PointSumval
-                                      );
-                                    });
-                                } else if (response.data.updateAddress == 1) {
-                                  // 同城AB+金牌,去修改地址
-                                  // addressUpdateTimesOver: true=已经达到最大次数,不让修改; false=没有达到可以修改
-                                  if (!response.data.addressUpdateTimesOver) {
-                                    this.$dialog
-                                      .confirm({
-                                        title: '系统提示',
-                                        message: response.msg + '请立即修改后再拜访',
-                                        messageAlign: 'left',
-                                        confirmButtonText: '立即修改',
-                                        cancelButtonText: '取消',
-                                      })
-                                      .then(() => {
-                                        this.$router.push({
-                                          path: '/storeDetail',
-                                          query: {
-                                            id: val.storeId,
-                                            type: 'address',
-                                            storeAddressId: val.storeAddressId,
-                                          },
-                                        });
-                                      });
-                                  } else {
-                                    this.$dialog.confirm({
-                                      title: '系统提示',
-                                      message: '已经达到最大修改次数',
-                                      messageAlign: 'left',
-                                      confirmButtonText: '确定',
-                                    });
-                                  }
-                                } else if (response.data.updateAddress == 2) {
-                                  // 1.非金牌店铺,非同城店铺 位置偏差过大 重置经纬度
-                                  this.resetCoord(res, val, location, PointSumval);
-                                  return;
-                                }
-                              } else {
-                                // 门店编码校验门店地址通过 进入拜访
-                                this.toSuishenbangOutstoreVisit(res, val, location, PointSumval);
-                              }
-                            });
-                          },
-                          fail: function () {
-                            loading1.clear();
-                            that.$dialog.alert({
-                              message: 'GPS未开启',
-                            });
-                          },
-                        });
-                      });
-                      wx.error(function (res) {
-                        loading1.clear();
-                        that.$dialog
-                          .alert({
-                            message: '定位失败,请开启企微定位权限',
-                          })
-                          .then(() => {});
-                      });
-                    } else {
-                      loading1.clear();
-                    }
-                  });
               }
             }
           }
@@ -938,6 +780,92 @@ export default {
         }
       });
     },
+    checkStoreAddressByStoreCodeFun(val, location, res) {
+      checkStoreAddressByStoreCode({
+        storeCode: val.storeCode,
+        lon: location.lon,
+        lat: location.lat,
+      }).then((response) => {
+        if (val.lat == '' || val.lat == null) {
+          this.lat = location.lat;
+          this.lon = location.lon;
+        } else {
+          this.lat = val.lat;
+          this.lon = val.lon;
+        }
+        let PointSum = this.twoPointSum(this.lat, this.lon, location.lat, location.lon).toFixed(2);
+        let PointSumval = this.twoPointSum(
+          location.lat,
+          location.lon,
+          location.lat,
+          location.lon
+        ).toFixed(2);
+        // GZ:工装店铺 直接进入拜访
+        if (localStorage.getItem('postType') == 'GZ') {
+          localStorage.setItem('startTime', new Date());
+          localStorage.setItem('ORGName', val.deptName);
+          localStorage.setItem('chainNameR', val.storeName);
+          this.toSuishenbangOutstoreVisit(res, val, location, PointSumval);
+          return;
+        }
+        // 门店编码校验门店地址不通过
+        if (response.code != 200) {
+          // updateAddress : ,1:同城AB+金牌,去修改地址;2:非金牌店铺,非同城店铺偏差过大不允许拜访,可以重置定位;0非金牌店铺,非同城店铺 位置信息不存在 可以继续拜访
+          if (response.data.updateAddress == 0) {
+            // 非金牌店铺,非同城店铺 位置信息不存在 可以继续拜访
+            this.$dialog
+              .confirm({
+                confirmButtonText: '确定拜访',
+                cancelButtonText: '取消拜访',
+                title: '系统提示',
+                message:
+                  '该客户没有经纬度,此次拜访会保存定位点作为客户经纬度,下次拜访时判断是否偏差过大。',
+                closeOnClickOverlay: true,
+              })
+              .then(() => {
+                this.toSuishenbangOutstoreVisit(res, val, location, PointSumval);
+              });
+          } else if (response.data.updateAddress == 1) {
+            // 同城AB+金牌,去修改地址
+            // addressUpdateTimesOver: true=已经达到最大次数,不让修改; false=没有达到可以修改
+            if (!response.data.addressUpdateTimesOver) {
+              this.$dialog
+                .confirm({
+                  title: '系统提示',
+                  message: response.msg + '请立即修改后再拜访',
+                  messageAlign: 'left',
+                  confirmButtonText: '立即修改',
+                  cancelButtonText: '取消',
+                })
+                .then(() => {
+                  this.$router.push({
+                    path: '/storeDetail',
+                    query: {
+                      id: val.storeId,
+                      type: 'address',
+                      storeAddressId: val.storeAddressId,
+                    },
+                  });
+                });
+            } else {
+              this.$dialog.confirm({
+                title: '系统提示',
+                message: '已经达到最大修改次数',
+                messageAlign: 'left',
+                confirmButtonText: '确定',
+              });
+            }
+          } else if (response.data.updateAddress == 2) {
+            // 1.非金牌店铺,非同城店铺 位置偏差过大 重置经纬度
+            this.resetCoord(res, val, location, PointSumval);
+            return;
+          }
+        } else {
+          // 门店编码校验门店地址通过 进入拜访
+          this.toSuishenbangOutstoreVisit(res, val, location, PointSumval);
+        }
+      });
+    },
     // 重置经纬度
     resetCoord(res, val, location, PointSumval) {
       this.$dialog
@@ -953,8 +881,8 @@ export default {
             storeId: val.storeId,
             lat: location.lat,
             lon: location.lon,
-          }).then((res) => {
-            if (res.code == 200) {
+          }).then((response) => {
+            if (response.code == 200) {
               this.$dialog
                 .alert({
                   title: '系统提示',
@@ -967,10 +895,11 @@ export default {
               localStorage.setItem('ORGName', val.deptName);
               localStorage.setItem('chainNameR', val.storeName);
             } else {
-              this.$toast(res.msg);
+              this.$toast(response.msg);
             }
           });
-        });
+        })
+        .catch(() => {});
     },
     // 进入拜访 router.push
     toSuishenbangOutstoreVisit(res, val, location, PointSumval) {

ファイルの差分が大きいため隠しています
+ 707 - 567
src/views/deviceWithin/storeVisit.vue