Browse Source

no message

zhujindu 11 months ago
parent
commit
19691ace3e
1 changed files with 56 additions and 170 deletions
  1. 56 170
      src/views/deviceOutside/index.vue

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

@@ -1463,6 +1463,8 @@ export default {
         positionDesc: '',
         accuracy: res.accuracy,
       });
+      // 进入拜访之前先刷新页面
+      this.onSearch();
       this.$router.push({
         path: '/suishenbangOutstoreVisit',
         query: {
@@ -1809,178 +1811,62 @@ export default {
             localStorage.setItem('chainNameR', val.storeName);
           } 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);
+                  let PointSum = this.twoPointSum(
+                    TXisBD.lat,
+                    TXisBD.lon,
+                    TXisBD.lat,
+                    TXisBD.lon
+                  ).toFixed(2);
+                  // 先刷新页面
+                  this.onSearch();
+                  this.$router.push({
+                    path: '/outabnormalVisit',
+                    query: {
+                      storeId: val.storeId,
+                      rdId: val.rdId,
+                      lat: this.lat,
+                      lon: this.lon,
+                      visitId: val.visitId,
+                      pageType: 'out',
+                      visitModel: localStorage.getItem('postType') != 'GZ' ? '5' : '3',
+                      storeCode: val.storeCode,
+                      tabVal: this.tabVal,
+                      latNew: TXisBD.lat,
+                      lonNew: TXisBD.lon,
+                      PointSum: PointSum,
+                      marklat: resData.latitude,
+                      marklon: resData.longitude,
+                    },
+                  });
+                  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,
+                  });
+                  localStorage.setItem('startTime', new Date());
+                  localStorage.setItem('ORGName', val.deptName);
+                  localStorage.setItem('chainNameR', val.storeName);
                 })
-                .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(() => {
-                              // this.$router.go(-1);
-                            });
-                        } 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;
-                          } else {
-                            that.lat = val.lat;
-                            that.lon = val.lon;
-                          }
-                          let PointSum = that
-                            .twoPointSum(that.lat, that.lon, location.lat, location.lon)
-                            .toFixed(2);
-
-                          if (PointSum > 500 && localStorage.getItem('postType') != 'GZ') {
-                            that.$dialog
-                              .confirm({
-                                confirmButtonText: '确定',
-                                cancelButtonText: '取消',
-                                title: '系统提示',
-                                message: '定位距离偏差大',
-                                closeOnClickOverlay: true,
-                              })
-                              .then(() => {
-                                that.$router.push({
-                                  path: '/outabnormalVisit',
-                                  query: {
-                                    storeId: val.storeId,
-                                    rdId: val.rdId,
-                                    lat: that.lat,
-                                    lon: that.lon,
-                                    visitId: val.visitId,
-                                    pageType: 'out',
-                                    visitModel: '5',
-                                    storeCode: val.storeCode,
-                                    tabVal: that.tabVal,
-                                    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);
-                              })
-                              .catch(() => {
-                                // that.abnormalVisit(val)
-                              });
-                          } else {
-                            that.$router.push({
-                              path: '/outabnormalVisit',
-                              query: {
-                                storeId: val.storeId,
-                                rdId: val.rdId,
-                                lat: that.lat,
-                                lon: that.lon,
-                                visitId: val.visitId,
-                                pageType: 'out',
-                                visitModel: '3',
-                                storeCode: val.storeCode,
-                                tabVal: that.tabVal,
-                                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: '定位失败,请开启企微定位权限',
-                        })
-                        .then(() => {});
-                    });
-                  } else {
-                    loading1.clear();
-                    this.$toast.fail(dataList.msg);
-                  }
+                .catch((error) => {
+                  this.$dialog.alert({
+                    message: error,
+                  });
                 });
-              localStorage.setItem('startTime', new Date());
-              localStorage.setItem('ORGName', val.deptName);
-              localStorage.setItem('chainNameR', val.storeName);
             }
           }
         } else {