gxd-uni-library-editx 1.0.23 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gxd-uni-library-editx",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "private": false,
5
5
  "description": "聚福宝基础插件专用库",
6
6
  "main": "index.js",
@@ -77,13 +77,13 @@
77
77
  //微信参数
78
78
  isWx: false,
79
79
  time: 0,
80
-
80
+
81
81
  location: {},
82
82
  baiduCount: 0, //baidu API 加载次数
83
83
  backed: false,
84
84
  initBaidu: false,
85
85
  uiBaiduAk: '',
86
-
86
+
87
87
  failStatus: false,
88
88
  timeStatus: null,
89
89
  permanentSave: 'xd-user-permanent-location-config',
@@ -92,7 +92,7 @@
92
92
  }
93
93
  },
94
94
  created() {
95
-
95
+
96
96
  //#ifdef H5
97
97
  //微信环境定位
98
98
  if(isWechat()) {
@@ -100,7 +100,7 @@
100
100
  this.init();
101
101
  return
102
102
  }
103
-
103
+
104
104
  //百度定位
105
105
  this.uiBaiduAk = this.baiduAk || this.$settings.baiduAk;
106
106
  if(this.baidu){
@@ -112,7 +112,7 @@
112
112
  this.init();
113
113
  }
114
114
  }
115
-
115
+
116
116
  //默认
117
117
  else{
118
118
  this.init();
@@ -127,11 +127,11 @@
127
127
  methods:{
128
128
  ...mapMutations(['setLocationInfo']),
129
129
  ...mapActions(['getH5WxAuthorize']),
130
-
130
+
131
131
  getLocationData(){
132
132
  return storage.get(this.locationStorageKey);
133
133
  },
134
-
134
+
135
135
  /**
136
136
  * @description 火星转百度坐标
137
137
  * @param lng
@@ -143,7 +143,7 @@
143
143
  let PI = 3.1415926535897932384626;
144
144
  let a = 6378245.0;
145
145
  let ee = 0.00669342162296594323;
146
-
146
+
147
147
  lat = +lat;
148
148
  lng = +lng;
149
149
  let z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI);
@@ -152,7 +152,7 @@
152
152
  let bd_lat = z * Math.sin(theta) + 0.006;
153
153
  return {longitude: bd_lng, latitude:bd_lat}
154
154
  },
155
-
155
+
156
156
  wxLocation(){
157
157
  //被拒绝之后不在启动授权功能
158
158
  if(storage.get(this.rejectSave) === true) {
@@ -164,12 +164,12 @@
164
164
  this.handleBaiduInit(null);
165
165
  return
166
166
  }
167
-
167
+
168
168
  //启动微信授权功能
169
169
  this.getH5WxAuthorize({jsApiList: ['openLocation', 'getLocation']})
170
170
  .then(({jwxSDK}) => {
171
171
  this.$xdLog.setProject('Location.jwxSDK.init', 'Location.jwxSDK.init');
172
-
172
+
173
173
  //pc端端微信环境直接返回
174
174
  if(isPlatform().isPc ||
175
175
  (jwxSDK && typeof jwxSDK.getLocation !== 'function')
@@ -181,7 +181,10 @@
181
181
  this.handleBaiduInit(null);
182
182
  return
183
183
  }
184
-
184
+
185
+ let time = null;
186
+ let isReturn = false;
187
+
185
188
  //手机端微信环境
186
189
  jwxSDK.getLocation({
187
190
  type: 'gcj02',
@@ -199,9 +202,23 @@
199
202
  this.handleBaiduInit(this.location);
200
203
  },
201
204
  fail: (e) => {
205
+
206
+ //已超时返回
207
+ if(isReturn) {
208
+ time = null;
209
+ return;
210
+ }
211
+
212
+ //比超时返回快
213
+ if(time) {
214
+ clearTimeout(time);
215
+ time=null;
216
+ }
217
+
202
218
  this.$xdLog.setProject('Location.wx.api.fail', {
203
219
  lng: null,
204
- lat: null
220
+ lat: null,
221
+ error:e
205
222
  });
206
223
  this.handleBaiduInit(null)
207
224
  },
@@ -214,6 +231,17 @@
214
231
  this.handleBaiduInit(null)
215
232
  }
216
233
  });
234
+
235
+ //超时处理
236
+ time = setTimeout(()=>{
237
+ this.$xdLog.setProject('Location.wx.api.fail.timeout', {
238
+ lng: null,
239
+ lat: null,
240
+ error:'fail.timeout'
241
+ });
242
+ this.handleBaiduInit(null);
243
+ isReturn = true;
244
+ }, 5000)
217
245
  })
218
246
  .catch(res => {
219
247
  this.$xdLog.setProject('Location.wx.jwxSDK.fail', {
@@ -223,7 +251,7 @@
223
251
  this.handleBaiduInit(null)
224
252
  });
225
253
  },
226
-
254
+
227
255
  /**
228
256
  * @description 主要针对百度定位超时进行返回操作
229
257
  */
@@ -236,7 +264,7 @@
236
264
  }, 10000)
237
265
  }
238
266
  },
239
-
267
+
240
268
  init(){
241
269
  if(this.getLocationData() !== null){
242
270
  this.$xdLog.setProject('Location.cache', this.getLocationData());
@@ -252,7 +280,7 @@
252
280
  }
253
281
  return;
254
282
  }
255
-
283
+
256
284
  //百度定位
257
285
  if(this.isWx === false) {
258
286
  // 没有定位信息并且超时5秒
@@ -263,7 +291,7 @@
263
291
 
264
292
  handleDone(){
265
293
  this.setLocationInfo(this.location);
266
-
294
+
267
295
  //超过5秒就不走这里的逻辑
268
296
  if(this.failStatus === false) {
269
297
  this.$xdLog.setProject('Location.done', this.location);