jufubao-third 1.0.21 → 1.0.22-beta10
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/.claude/settings.local.json +12 -0
- package/package.json +1 -1
- package/src/components/JfbThirdPay/WalletMix.js +1 -0
- package/src/components/JfbThirdRideCheckPay/Api.js +18 -0
- package/src/components/JfbThirdRideCheckPay/Attr.js +17 -0
- package/src/components/JfbThirdRideCheckPay/JfbThirdRideCheckPay.vue +217 -0
- package/src/components/JfbThirdRideCheckPay/JfbThirdRideCheckPayLess.less +80 -0
- package/src/components/JfbThirdRideCheckPay/JfbThirdRideCheckPayMixin.js +30 -0
- package/src/components/JfbThirdRideCheckPay/Mock.js +7 -0
- package/src/components/JfbThirdRideCheckPay/cusAttr/advanced.js +28 -0
- package/src/components/JfbThirdRideCheckPay/cusAttr/content.js +27 -0
- package/src/components/JfbThirdRideCheckPay/cusAttr/style.js +7 -0
- package/src/components/JfbThirdRideConfirm/Api.js +37 -0
- package/src/components/JfbThirdRideConfirm/Attr.js +17 -0
- package/src/components/JfbThirdRideConfirm/JfbThirdRideConfirm.vue +527 -0
- package/src/components/JfbThirdRideConfirm/JfbThirdRideConfirmLess.less +80 -0
- package/src/components/JfbThirdRideConfirm/JfbThirdRideConfirmMixin.js +30 -0
- package/src/components/JfbThirdRideConfirm/Mock.js +69 -0
- package/src/components/JfbThirdRideConfirm/cusAttr/advanced.js +7 -0
- package/src/components/JfbThirdRideConfirm/cusAttr/content.js +27 -0
- package/src/components/JfbThirdRideConfirm/cusAttr/style.js +7 -0
- package/src/components/JfbThirdRideGenOrder/Api.js +21 -0
- package/src/components/JfbThirdRideGenOrder/Attr.js +17 -0
- package/src/components/JfbThirdRideGenOrder/JfbThirdRideGenOrder.vue +234 -0
- package/src/components/JfbThirdRideGenOrder/JfbThirdRideGenOrderLess.less +80 -0
- package/src/components/JfbThirdRideGenOrder/JfbThirdRideGenOrderMixin.js +30 -0
- package/src/components/JfbThirdRideGenOrder/Mock.js +11 -0
- package/src/components/JfbThirdRideGenOrder/cusAttr/advanced.js +37 -0
- package/src/components/JfbThirdRideGenOrder/cusAttr/content.js +7 -0
- package/src/components/JfbThirdRideGenOrder/cusAttr/style.js +7 -0
- package/src/components/JfbThirdRideHome/Api.js +44 -0
- package/src/components/JfbThirdRideHome/Attr.js +17 -0
- package/src/components/JfbThirdRideHome/JfbThirdRideHome.vue +831 -0
- package/src/components/JfbThirdRideHome/JfbThirdRideHomeLess.less +80 -0
- package/src/components/JfbThirdRideHome/JfbThirdRideHomeMixin.js +30 -0
- package/src/components/JfbThirdRideHome/Mock.js +13 -0
- package/src/components/JfbThirdRideHome/cusAttr/advanced.js +52 -0
- package/src/components/JfbThirdRideHome/cusAttr/content.js +27 -0
- package/src/components/JfbThirdRideHome/cusAttr/style.js +7 -0
- package/src/components/JfbThirdRideLand/Api.js +58 -0
- package/src/components/JfbThirdRideLand/Attr.js +17 -0
- package/src/components/JfbThirdRideLand/JfbThirdRideLand.vue +256 -0
- package/src/components/JfbThirdRideLand/JfbThirdRideLandLess.less +80 -0
- package/src/components/JfbThirdRideLand/JfbThirdRideLandMixin.js +30 -0
- package/src/components/JfbThirdRideLand/Mock.js +13 -0
- package/src/components/JfbThirdRideLand/cusAttr/advanced.js +22 -0
- package/src/components/JfbThirdRideLand/cusAttr/content.js +60 -0
- package/src/components/JfbThirdRideLand/cusAttr/style.js +109 -0
- package/src/components/JfbThirdRideRecord/Api.js +33 -0
- package/src/components/JfbThirdRideRecord/Attr.js +17 -0
- package/src/components/JfbThirdRideRecord/JfbThirdRideRecord.vue +533 -0
- package/src/components/JfbThirdRideRecord/JfbThirdRideRecordLess.less +80 -0
- package/src/components/JfbThirdRideRecord/JfbThirdRideRecordMixin.js +30 -0
- package/src/components/JfbThirdRideRecord/Mock.js +44 -0
- package/src/components/JfbThirdRideRecord/cusAttr/advanced.js +22 -0
- package/src/components/JfbThirdRideRecord/cusAttr/content.js +27 -0
- package/src/components/JfbThirdRideRecord/cusAttr/style.js +7 -0
- package/src/components/JfbThirdRideStartEnd/Api.js +20 -0
- package/src/components/JfbThirdRideStartEnd/Attr.js +17 -0
- package/src/components/JfbThirdRideStartEnd/JfbThirdRideStartEnd.vue +382 -0
- package/src/components/JfbThirdRideStartEnd/JfbThirdRideStartEndLess.less +80 -0
- package/src/components/JfbThirdRideStartEnd/JfbThirdRideStartEndMixin.js +30 -0
- package/src/components/JfbThirdRideStartEnd/Mock.js +17 -0
- package/src/components/JfbThirdRideStartEnd/cusAttr/advanced.js +22 -0
- package/src/components/JfbThirdRideStartEnd/cusAttr/content.js +27 -0
- package/src/components/JfbThirdRideStartEnd/cusAttr/style.js +7 -0
- package/src/mixins/getCoordinatesMixins.js +407 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
//#ifdef H5
|
|
3
|
+
import {mapActions} from "vuex";
|
|
4
|
+
//#endif
|
|
5
|
+
import {isWechat} from "@/utils/xd.base";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
data(){
|
|
9
|
+
return {
|
|
10
|
+
lastSuccessCoords:null,
|
|
11
|
+
|
|
12
|
+
//#ifdef H5
|
|
13
|
+
jwxCoordinatesSDK:null,
|
|
14
|
+
//#endif
|
|
15
|
+
|
|
16
|
+
// #ifdef MP-WEIXIN
|
|
17
|
+
mpLocationFn:'getFuzzyLocation',
|
|
18
|
+
// #endif
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
created() {
|
|
22
|
+
// #ifdef MP-WEIXIN
|
|
23
|
+
//判断小程序是否使用精准定位
|
|
24
|
+
if(this.$configProject['privacy_interface_list']) {
|
|
25
|
+
this.$configProject['privacy_interface_list'].map(item=>{
|
|
26
|
+
if(item['api_name'] === 'wx.getLocation') {
|
|
27
|
+
this.mpLocationFn = 'getLocation';
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
// #endif
|
|
32
|
+
},
|
|
33
|
+
methods:{
|
|
34
|
+
/**
|
|
35
|
+
* @description 获取位置信息
|
|
36
|
+
* @return {Promise<unknown>}
|
|
37
|
+
*/
|
|
38
|
+
getCoordinates() {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
//#ifdef H5
|
|
41
|
+
if (isWechat()) {
|
|
42
|
+
this.getH5WXLocation().then(res => {
|
|
43
|
+
resolve(res);
|
|
44
|
+
}).catch(err => {
|
|
45
|
+
//微信定位失败,降级到百度定位/原生定位
|
|
46
|
+
this.getH5FallbackLocation(err, resolve, reject);
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//百度定位
|
|
52
|
+
if(this.$settings.baiduAk) {
|
|
53
|
+
this.getBaiduLocation().then(res => {
|
|
54
|
+
resolve(res);
|
|
55
|
+
}).catch(err => {
|
|
56
|
+
reject(err);
|
|
57
|
+
});
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//H5原生定位兜底
|
|
62
|
+
if(window.navigator.geolocation) {
|
|
63
|
+
this.getH5NativeLocation().then(res => {
|
|
64
|
+
resolve(res);
|
|
65
|
+
}).catch(err => {
|
|
66
|
+
reject(err);
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
//所有定位方式均不可用,直接拒绝避免 Promise 悬挂
|
|
71
|
+
reject('当前环境不支持定位');
|
|
72
|
+
// #endif
|
|
73
|
+
|
|
74
|
+
// #ifdef MP-WEIXIN
|
|
75
|
+
this.getWxLocation().then(res => {
|
|
76
|
+
resolve(res);
|
|
77
|
+
}).catch(err => {
|
|
78
|
+
reject(err);
|
|
79
|
+
});
|
|
80
|
+
// #endif
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @description 火星转百度坐标
|
|
87
|
+
* @param lng
|
|
88
|
+
* @param lat
|
|
89
|
+
* @returns {{latitude: *, longitude: *}}
|
|
90
|
+
*/
|
|
91
|
+
gcj02ToBaiduLatAndLng(lng, lat) {
|
|
92
|
+
const X_PI = 3.14159265358979324 * 3000.0 / 180.0;
|
|
93
|
+
const PI = 3.1415926535897932384626;
|
|
94
|
+
const A = 6378245.0;
|
|
95
|
+
const EE = 0.00669342162296594323;
|
|
96
|
+
|
|
97
|
+
lat = +lat;
|
|
98
|
+
lng = +lng;
|
|
99
|
+
let z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * X_PI);
|
|
100
|
+
let theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * X_PI);
|
|
101
|
+
let bd_lng = z * Math.cos(theta) + 0.0065;
|
|
102
|
+
let bd_lat = z * Math.sin(theta) + 0.006;
|
|
103
|
+
return {longitude: bd_lng, latitude:bd_lat}
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @description 通用定位执行器:超时 + 防重复 + 成功缓存 + 失败兜底
|
|
108
|
+
* @param locateFn {Function} 发起定位的函数,接收 {type, success, fail, cancel}
|
|
109
|
+
* @param resolve {Function}
|
|
110
|
+
* @param reject {Function}
|
|
111
|
+
* @param isTargetCoords {Boolean} 是否已是目标坐标系(BD-09),true则跳过 gcj02→bd09 转换
|
|
112
|
+
*/
|
|
113
|
+
locateWithFallback(locateFn, resolve, reject, isTargetCoords = false){
|
|
114
|
+
let done = false;
|
|
115
|
+
let timer = null;
|
|
116
|
+
|
|
117
|
+
//统一收尾:成功保存坐标,失败/超时兜底返回上次成功坐标
|
|
118
|
+
const finish = (isSuccess, val) => {
|
|
119
|
+
if (done) return;
|
|
120
|
+
done = true;
|
|
121
|
+
clearTimeout(timer);
|
|
122
|
+
if (isSuccess) {
|
|
123
|
+
this.lastSuccessCoords = val;
|
|
124
|
+
resolve(val);
|
|
125
|
+
} else if (this.lastSuccessCoords) {
|
|
126
|
+
resolve(this.lastSuccessCoords);
|
|
127
|
+
} else {
|
|
128
|
+
reject(val);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
//5秒超时设置
|
|
133
|
+
timer = setTimeout(() => {
|
|
134
|
+
finish(false, '定位超时');
|
|
135
|
+
}, 5000);
|
|
136
|
+
|
|
137
|
+
//发起定位
|
|
138
|
+
locateFn({
|
|
139
|
+
type: 'gcj02',
|
|
140
|
+
success: (res) => {
|
|
141
|
+
const lng = Number(res.longitude);
|
|
142
|
+
const lat = Number(res.latitude);
|
|
143
|
+
//坐标有效性校验,避免 NaN 进入缓存
|
|
144
|
+
if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
|
|
145
|
+
finish(false, '定位坐标无效');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const coords = isTargetCoords
|
|
149
|
+
? {longitude: lng, latitude: lat}
|
|
150
|
+
: this.gcj02ToBaiduLatAndLng(lng, lat);
|
|
151
|
+
coords.accuracy = res.accuracy !== undefined ? res.accuracy : null;
|
|
152
|
+
finish(true, coords);
|
|
153
|
+
},
|
|
154
|
+
fail: () => finish(false, '定位失败'),
|
|
155
|
+
cancel: () => finish(false, '定位取消')
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
//#ifdef H5
|
|
161
|
+
...mapActions(['getH5WxAuthorize']),
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @description 初始化微信定位信息
|
|
165
|
+
* @return {Promise<unknown>}
|
|
166
|
+
*/
|
|
167
|
+
initH5WXLocation(){
|
|
168
|
+
return new Promise((resolve, reject) => {
|
|
169
|
+
//已经初始化
|
|
170
|
+
if(this.jwxCoordinatesSDK !== null){
|
|
171
|
+
resolve(this.jwxCoordinatesSDK );
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
//未初始化,10s授权超时兜底,避免 Promise 悬挂
|
|
175
|
+
let authorizeTimer = setTimeout(() => {
|
|
176
|
+
reject('微信授权超时');
|
|
177
|
+
}, 10000);
|
|
178
|
+
this.getH5WxAuthorize({jsApiList: ['openLocation', 'getLocation']})
|
|
179
|
+
.then(({jwxSDK}) => {
|
|
180
|
+
clearTimeout(authorizeTimer);
|
|
181
|
+
this.jwxCoordinatesSDK = jwxSDK;
|
|
182
|
+
resolve(jwxSDK)
|
|
183
|
+
})
|
|
184
|
+
.catch(res => {
|
|
185
|
+
clearTimeout(authorizeTimer);
|
|
186
|
+
reject('微信授权失败')
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @description 微信环境获取位置
|
|
193
|
+
*/
|
|
194
|
+
getH5WXLocation(){
|
|
195
|
+
return new Promise((resolve, reject) => {
|
|
196
|
+
this.initH5WXLocation()
|
|
197
|
+
.then(jwxSDK => {
|
|
198
|
+
this.locateWithFallback((opts) => jwxSDK.getLocation(opts), resolve, reject);
|
|
199
|
+
})
|
|
200
|
+
.catch(err => reject(err));
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @description 微信H5定位失败后的降级定位(百度 → 原生)
|
|
206
|
+
* @param originErr 原始错误信息
|
|
207
|
+
* @param resolve {Function}
|
|
208
|
+
* @param reject {Function}
|
|
209
|
+
*/
|
|
210
|
+
getH5FallbackLocation(originErr, resolve, reject){
|
|
211
|
+
if(this.$settings.baiduAk) {
|
|
212
|
+
this.getBaiduLocation()
|
|
213
|
+
.then(resolve)
|
|
214
|
+
.catch(() => {
|
|
215
|
+
if(window.navigator.geolocation) {
|
|
216
|
+
this.getH5NativeLocation().then(resolve).catch(() => reject(originErr || '定位失败'));
|
|
217
|
+
} else {
|
|
218
|
+
reject(originErr || '定位失败');
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
} else if(window.navigator.geolocation) {
|
|
222
|
+
this.getH5NativeLocation().then(resolve).catch(() => reject(originErr || '定位失败'));
|
|
223
|
+
} else {
|
|
224
|
+
reject(originErr || '定位失败');
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @description 加载百度地图JS SDK(v3.0 经典版)
|
|
230
|
+
* @description 已加载直接复用;加载中复用缓存 Promise,避免重复创建 script 下载 SDK
|
|
231
|
+
* @returns {Promise<BMap>}
|
|
232
|
+
*/
|
|
233
|
+
loadBaiduMapSDK(){
|
|
234
|
+
//已加载完成,直接复用
|
|
235
|
+
if (window.BMap && !window.BMap._preloader) {
|
|
236
|
+
return Promise.resolve(window.BMap);
|
|
237
|
+
}
|
|
238
|
+
//加载中,复用同一个 Promise
|
|
239
|
+
if (window.BMap && window.BMap._preloader) {
|
|
240
|
+
return window.BMap._preloader;
|
|
241
|
+
}
|
|
242
|
+
const ak = this.$settings.baiduAk;
|
|
243
|
+
if (!ak) {
|
|
244
|
+
return Promise.reject('百度AK未配置');
|
|
245
|
+
}
|
|
246
|
+
//未加载:创建加载流程,缓存 Promise 供并发调用复用
|
|
247
|
+
window.BMap = window.BMap || {};
|
|
248
|
+
window.BMap._preloader = new Promise((resolve, reject) => {
|
|
249
|
+
//10s加载超时兜底,避免回调不触发导致 Promise 悬挂
|
|
250
|
+
let sdkTimer = setTimeout(() => {
|
|
251
|
+
delete window._initBaiduMap;
|
|
252
|
+
window.BMap._preloader = null;
|
|
253
|
+
window.BMap = null;
|
|
254
|
+
reject('百度地图SDK加载超时');
|
|
255
|
+
}, 10000);
|
|
256
|
+
|
|
257
|
+
//百度地图SDK加载回调
|
|
258
|
+
window._initBaiduMap = () => {
|
|
259
|
+
clearTimeout(sdkTimer);
|
|
260
|
+
window.BMap._preloader = null;
|
|
261
|
+
delete window._initBaiduMap;
|
|
262
|
+
resolve(window.BMap);
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
//创建script标签加载百度地图SDK
|
|
266
|
+
const script = document.createElement('script');
|
|
267
|
+
script.src = `https://api.map.baidu.com/api?v=3.0&ak=${ak}&callback=_initBaiduMap`;
|
|
268
|
+
script.onerror = () => {
|
|
269
|
+
clearTimeout(sdkTimer);
|
|
270
|
+
window.BMap._preloader = null;
|
|
271
|
+
window.BMap = null;
|
|
272
|
+
delete window._initBaiduMap;
|
|
273
|
+
reject('百度地图SDK加载失败');
|
|
274
|
+
};
|
|
275
|
+
document.head.appendChild(script);
|
|
276
|
+
});
|
|
277
|
+
return window.BMap._preloader;
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* @description 百度定位(BMap.Geolocation,返回 BD-09 坐标)
|
|
282
|
+
*/
|
|
283
|
+
getBaiduLocation(){
|
|
284
|
+
return new Promise((resolve, reject) => {
|
|
285
|
+
this.loadBaiduMapSDK()
|
|
286
|
+
.then(BMap => {
|
|
287
|
+
//百度返回 bd09,isTargetCoords=true 跳过 gcj02→bd09 转换
|
|
288
|
+
this.locateWithFallback((opts) => {
|
|
289
|
+
const geolocation = new BMap.Geolocation();
|
|
290
|
+
geolocation.getCurrentPosition(
|
|
291
|
+
(location) => opts.success({
|
|
292
|
+
longitude: location.point.lng,
|
|
293
|
+
latitude: location.point.lat,
|
|
294
|
+
accuracy: location.accuracy
|
|
295
|
+
}),
|
|
296
|
+
(err) => opts.fail && opts.fail(err)
|
|
297
|
+
);
|
|
298
|
+
}, resolve, reject, true);
|
|
299
|
+
})
|
|
300
|
+
.catch(err => reject(err));
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @description 获取H5原生位置(navigator.geolocation,WGS-84 → GCJ-02 → BD-09)
|
|
306
|
+
*/
|
|
307
|
+
getH5NativeLocation(){
|
|
308
|
+
return new Promise((resolve, reject) => {
|
|
309
|
+
this.locateWithFallback((opts) => {
|
|
310
|
+
window.navigator.geolocation.getCurrentPosition(
|
|
311
|
+
(pos) => {
|
|
312
|
+
//WGS-84 转 GCJ-02,交由执行器再转 BD-09
|
|
313
|
+
const gcj02 = this.wgs84ToGcj02LatAndLng(pos.coords.longitude, pos.coords.latitude);
|
|
314
|
+
gcj02.accuracy = pos.coords.accuracy !== undefined ? pos.coords.accuracy : null;
|
|
315
|
+
opts.success(gcj02);
|
|
316
|
+
},
|
|
317
|
+
(err) => opts.fail && opts.fail(err),
|
|
318
|
+
{ enableHighAccuracy: true, timeout: 10000, maximumAge: 0 }
|
|
319
|
+
);
|
|
320
|
+
}, resolve, reject);
|
|
321
|
+
});
|
|
322
|
+
},
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* @description WGS-84 转 GCJ-02(火星坐标)
|
|
326
|
+
* @param lng {Number} 经度
|
|
327
|
+
* @param lat {Number} 纬度
|
|
328
|
+
* @returns {{longitude: *, latitude: *}}
|
|
329
|
+
*/
|
|
330
|
+
wgs84ToGcj02LatAndLng(lng, lat) {
|
|
331
|
+
const PI = 3.1415926535897932384626;
|
|
332
|
+
const a = 6378245.0;
|
|
333
|
+
const ee = 0.00669342162296594323;
|
|
334
|
+
|
|
335
|
+
//中国境外无需偏移,直接返回
|
|
336
|
+
if (lng < 72.004 || lng > 137.8347 || lat < 0.8293 || lat > 55.8271) {
|
|
337
|
+
return {longitude: lng, latitude: lat};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const transformLat = (x, y) => {
|
|
341
|
+
let ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
|
|
342
|
+
ret += (20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0 / 3.0;
|
|
343
|
+
ret += (20.0 * Math.sin(y * PI) + 40.0 * Math.sin(y / 3.0 * PI)) * 2.0 / 3.0;
|
|
344
|
+
ret += (160.0 * Math.sin(y / 12.0 * PI) + 320.0 * Math.sin(y * PI / 30.0)) * 2.0 / 3.0;
|
|
345
|
+
return ret;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const transformLng = (x, y) => {
|
|
349
|
+
let ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
|
|
350
|
+
ret += (20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0 / 3.0;
|
|
351
|
+
ret += (20.0 * Math.sin(x * PI) + 40.0 * Math.sin(x / 3.0 * PI)) * 2.0 / 3.0;
|
|
352
|
+
ret += (150.0 * Math.sin(x / 12.0 * PI) + 300.0 * Math.sin(x / 30.0 * PI)) * 2.0 / 3.0;
|
|
353
|
+
return ret;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
let dLat = transformLat(lng - 105.0, lat - 35.0);
|
|
357
|
+
let dLng = transformLng(lng - 105.0, lat - 35.0);
|
|
358
|
+
const radLat = lat / 180.0 * PI;
|
|
359
|
+
let magic = Math.sin(radLat);
|
|
360
|
+
magic = 1 - ee * magic * magic;
|
|
361
|
+
const sqrtMagic = Math.sqrt(magic);
|
|
362
|
+
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * PI);
|
|
363
|
+
dLng = (dLng * 180.0) / (a / sqrtMagic * Math.cos(radLat) * PI);
|
|
364
|
+
return {longitude: lng + dLng, latitude: lat + dLat};
|
|
365
|
+
},
|
|
366
|
+
//#endif
|
|
367
|
+
|
|
368
|
+
// #ifdef MP-WEIXIN
|
|
369
|
+
/**
|
|
370
|
+
* @description 小程序获取位置
|
|
371
|
+
* @description 根据 mpLocationFn 选择调用 getFuzzyLocation(模糊,无需授权) 或 getLocation(精确,需授权)
|
|
372
|
+
*/
|
|
373
|
+
getWxLocation(){
|
|
374
|
+
return new Promise((resolve, reject) => {
|
|
375
|
+
const locationFn = this.mpLocationFn || 'getFuzzyLocation';
|
|
376
|
+
|
|
377
|
+
const doLocate = () => {
|
|
378
|
+
this.locateWithFallback((opts) => uni[locationFn](opts), resolve, reject);
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
//精确 getLocation 需要 scope.userLocation 授权
|
|
382
|
+
if (locationFn === 'getLocation') {
|
|
383
|
+
uni.getSetting({
|
|
384
|
+
success: (res) => {
|
|
385
|
+
if (res.authSetting['scope.userLocation']) {
|
|
386
|
+
doLocate();
|
|
387
|
+
} else {
|
|
388
|
+
uni.authorize({
|
|
389
|
+
scope: 'scope.userLocation',
|
|
390
|
+
success: doLocate,
|
|
391
|
+
fail: () => reject('定位权限被拒绝')
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
fail: () => reject('获取授权设置失败')
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
//getFuzzyLocation 模糊定位,无需授权
|
|
400
|
+
doLocate();
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
},
|
|
404
|
+
// #endif
|
|
405
|
+
|
|
406
|
+
}
|
|
407
|
+
}
|