Browse Source

异常拜访问题修改

zhujindu 11 months ago
parent
commit
9983332895
1 changed files with 44 additions and 156 deletions
  1. 44 156
      src/views/deviceWithin/index.vue

+ 44 - 156
src/views/deviceWithin/index.vue

@@ -1280,164 +1280,52 @@ export default {
             localStorage.setItem('ORGName', val.deptName);
             localStorage.setItem('ORGName', val.deptName);
             localStorage.setItem('chainNameR', val.storeName);
             localStorage.setItem('chainNameR', val.storeName);
           } else {
           } else {
-            if (this.flag) {
-              this.flag = false;
-              this.timer = null;
-              this.timer = setTimeout(() => {
-                this.flag = true;
-              }, 2000);
-              let loading1 = this.$toast.loading({
-                duration: 0,
-                message: '定位中...',
-                forbidClick: true,
-              });
-              let url = window.location.href;
-              let that = this;
-              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,
+            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);
+                console.log('异常拜访=' + this.lat);
+                console.log('异常拜访=' + this.lon);
+                this.$router.push({
+                  path: '/abnormalVisit',
+                  query: {
+                    storeId: val.storeId,
+                    rdId: val.rdId,
+                    lat: this.lat,
+                    lon: this.lon,
+                    visitModel: localStorage.getItem('postType') != 'GZ' ? '5' : '3',
+                    visitId: val.visitId,
+                    genDate: val.genDate,
+                    storeCode: val.storeCode,
+                    latNew: location.lat,
+                    lonNew: location.lon,
+                    PointSum: PointSum,
+                    marklat: resData.latitude,
+                    marklon: resData.longitude,
                   },
                   },
-                })
-                .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: '定位失败,请开启企微定位权限',
-                          });
-                        } 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(function () {
-                      wx.getLocation({
-                        type: 'gcj02',
-                        success: function (res) {
-                          flat = false;
-                          loading1.clear();
-                          var location = that.CJ02BD(res.latitude, res.longitude);
-                          if (val.lat == '' || val.lat == null) {
-                            that.lat = location.lat;
-                            that.lon = location.lon;
-                          }
-                          let PointSum = that
-                            .twoPointSum(that.lat, that.lon, location.lat, location.lon)
-                            .toFixed(2);
-                          console.log('异常拜访=' + that.lat);
-                          console.log('异常拜访=' + that.lon);
-                          if (PointSum > 500 && localStorage.getItem('postType') != 'GZ') {
-                            // that.$dialog
-                            //   .confirm({
-                            //     confirmButtonText: '确定',
-                            //     cancelButtonText: '取消',
-                            //     title: '系统提示',
-                            //     message: '定位距离偏差大',
-                            //     closeOnClickOverlay: true,
-                            //   })
-                            //   .then(() => {
-                            that.dialogms = false;
-                            that.$router.push({
-                              path: '/abnormalVisit',
-                              query: {
-                                storeId: val.storeId,
-                                rdId: val.rdId,
-                                lat: that.lat,
-                                lon: that.lon,
-                                visitModel: '5',
-                                visitId: val.visitId,
-                                genDate: val.genDate,
-                                storeCode: val.storeCode,
-                                latNew: location.lat,
-                                lonNew: location.lon,
-                                PointSum: PointSum,
-                                marklat: res.latitude,
-                                marklon: res.longitude,
-                              },
-                            });
-                            localStorage.setItem('startTime', new Date());
-                            localStorage.setItem('ORGName', val.deptName);
-                            localStorage.setItem('chainNameR', val.storeName);
-                            // });
-                          } else {
-                            that.$router.push({
-                              path: '/abnormalVisit',
-                              query: {
-                                storeId: val.storeId,
-                                rdId: val.rdId,
-                                lat: that.lat,
-                                lon: that.lon,
-                                visitModel: '3',
-                                visitId: val.visitId,
-                                genDate: val.genDate,
-                                storeCode: val.storeCode,
-                                latNew: location.lat,
-                                lonNew: location.lon,
-                                PointSum: PointSum,
-                                marklat: res.latitude,
-                                marklon: res.longitude,
-                              },
-                            });
-                            localStorage.setItem('startTime', new Date());
-                            localStorage.setItem('ORGName', val.deptName);
-                            localStorage.setItem('chainNameR', val.storeName);
-                          }
-                          addVisitsPosition({
-                            storeId: val.storeId,
-                            visitsId: '',
-                            lon: res.longitude,
-                            lat: res.latitude,
-                            sourceLon: location.lon,
-                            sourceLat: location.lat,
-                            positionDesc: '',
-                            accuracy: res.accuracy,
-                          });
-                        },
-                        fail: function () {
-                          loading1.clear();
-                          that.$dialog
-                            .alert({
-                              message: 'GPS未开启',
-                            })
-                            .then(() => {
-                              // that.abnormalVisit(val)
-                            });
-                        },
-                      });
-                    });
-                    wx.error(function (res) {
-                      loading1.clear();
-                      that.$dialog.alert({
-                        message: '定位失败,请开启企微定位权限',
-                      });
-                    });
-                  } else {
-                    loading1.clear();
-                    this.$toast.fail(dataList.msg);
-                  }
                 });
                 });
-            }
+                localStorage.setItem('startTime', new Date());
+                localStorage.setItem('ORGName', val.deptName);
+                localStorage.setItem('chainNameR', val.storeName);
+                addVisitsPosition({
+                  storeId: val.storeId,
+                  visitsId: '',
+                  lon: resData.longitude,
+                  lat: resData.latitude,
+                  sourceLon: location.lon,
+                  sourceLat: location.lat,
+                  positionDesc: '',
+                  accuracy: resData.accuracy,
+                });
+              })
+              .catch((error) => {
+                this.$dialog.alert({
+                  message: error,
+                });
+              });
           }
           }
         } else {
         } else {
           this.$dialog.alert({
           this.$dialog.alert({