@tmsfe/tms-core 0.0.9 → 0.0.13
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/dist/index.js +10 -39
- package/package.json +4 -2
- package/src/location/base.ts +11 -4
- package/src/report.js +0 -20
package/dist/index.js
CHANGED
|
@@ -543,6 +543,8 @@ function getWxLocation(type = defaultLocationType) {
|
|
|
543
543
|
});
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
|
+
// 是否开启监听位置变更
|
|
547
|
+
let isListenerLocation = false;
|
|
546
548
|
/**
|
|
547
549
|
* @class Location
|
|
548
550
|
* @classdesc 基于微信api,封装location相关的接口。 包括监听位置变化, 获取用户位置信息
|
|
@@ -550,11 +552,14 @@ function getWxLocation(type = defaultLocationType) {
|
|
|
550
552
|
*/
|
|
551
553
|
class LocationBase {
|
|
552
554
|
/**
|
|
553
|
-
* @private
|
|
555
|
+
* @private 开启监听位置变更,要在授权之后才能开启
|
|
554
556
|
*/
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
557
|
+
listenerLocation() {
|
|
558
|
+
if (!isListenerLocation) {
|
|
559
|
+
isListenerLocation = true;
|
|
560
|
+
wx.onLocationChange(this.subscribeLocationChnage);
|
|
561
|
+
wx.startLocationUpdate({});
|
|
562
|
+
}
|
|
558
563
|
}
|
|
559
564
|
/**
|
|
560
565
|
* 获取用户当前位置(经纬度)
|
|
@@ -604,6 +609,7 @@ class LocationBase {
|
|
|
604
609
|
getWxLocationPromise(showModalWhenCloseAuth, type, content = '', showCancel = true) {
|
|
605
610
|
return new Promise((resolve, reject) => {
|
|
606
611
|
getWxLocation(type).then((res) => {
|
|
612
|
+
this.listenerLocation();
|
|
607
613
|
userLocationCache$1 = res;
|
|
608
614
|
// 更新用户状态 -- todo
|
|
609
615
|
updateLocStatus(true);
|
|
@@ -1476,41 +1482,6 @@ const startListenApp = () => {
|
|
|
1476
1482
|
// onHide时立即上报,并清除定时器
|
|
1477
1483
|
report(true, true);
|
|
1478
1484
|
});
|
|
1479
|
-
/**
|
|
1480
|
-
* 监听小程序路由切换事件
|
|
1481
|
-
*/
|
|
1482
|
-
|
|
1483
|
-
if (!wx.onAppRoute) {
|
|
1484
|
-
cache({
|
|
1485
|
-
26: 'H',
|
|
1486
|
-
27: 'H100',
|
|
1487
|
-
40: 'notReport'
|
|
1488
|
-
}, true);
|
|
1489
|
-
wx.reportAnalytics('onapproute_not_support', {
|
|
1490
|
-
mp_version: getMiniProgramVersion()
|
|
1491
|
-
});
|
|
1492
|
-
return;
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
wx.onAppRoute(res => {
|
|
1496
|
-
const {
|
|
1497
|
-
path,
|
|
1498
|
-
query,
|
|
1499
|
-
openType
|
|
1500
|
-
} = res || {};
|
|
1501
|
-
cache({
|
|
1502
|
-
26: 'H',
|
|
1503
|
-
27: 'H100',
|
|
1504
|
-
38: path,
|
|
1505
|
-
39: JSON.stringify(query),
|
|
1506
|
-
40: openType
|
|
1507
|
-
});
|
|
1508
|
-
wx.reportAnalytics('page_show', {
|
|
1509
|
-
path,
|
|
1510
|
-
query: JSON.stringify(query),
|
|
1511
|
-
opentype: openType
|
|
1512
|
-
});
|
|
1513
|
-
});
|
|
1514
1485
|
};
|
|
1515
1486
|
|
|
1516
1487
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmsfe/tms-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "tms运行时框架",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
"rollup": "^2.6.1",
|
|
35
35
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
36
36
|
"rollup-plugin-terser": "^6.1.0",
|
|
37
|
-
"rollup-plugin-typescript2": "0.27.0"
|
|
37
|
+
"rollup-plugin-typescript2": "0.27.0",
|
|
38
|
+
"rollup-plugin-replace": "^2.2.0",
|
|
39
|
+
"typescript": "^4.5.2"
|
|
38
40
|
},
|
|
39
41
|
"author": "tms·web",
|
|
40
42
|
"gitHead": "72bf52451594b49a1c9f78edbad5956d414a66ca"
|
package/src/location/base.ts
CHANGED
|
@@ -29,6 +29,9 @@ function getWxLocation(type: string = defaultLocationType): Promise<WxPostionTyp
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// 是否开启监听位置变更
|
|
33
|
+
let isListenerLocation = false;
|
|
34
|
+
|
|
32
35
|
/**
|
|
33
36
|
* @class Location
|
|
34
37
|
* @classdesc 基于微信api,封装location相关的接口。 包括监听位置变化, 获取用户位置信息
|
|
@@ -36,11 +39,14 @@ function getWxLocation(type: string = defaultLocationType): Promise<WxPostionTyp
|
|
|
36
39
|
*/
|
|
37
40
|
class LocationBase {
|
|
38
41
|
/**
|
|
39
|
-
* @private
|
|
42
|
+
* @private 开启监听位置变更,要在授权之后才能开启
|
|
40
43
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
listenerLocation() {
|
|
45
|
+
if (!isListenerLocation) {
|
|
46
|
+
isListenerLocation = true;
|
|
47
|
+
wx.onLocationChange(this.subscribeLocationChnage);
|
|
48
|
+
wx.startLocationUpdate({});
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
/**
|
|
@@ -95,6 +101,7 @@ class LocationBase {
|
|
|
95
101
|
public getWxLocationPromise(showModalWhenCloseAuth: boolean, type: string, content = '', showCancel = true) {
|
|
96
102
|
return new Promise((resolve, reject) => {
|
|
97
103
|
getWxLocation(type).then((res: WxPostionType) => {
|
|
104
|
+
this.listenerLocation();
|
|
98
105
|
userLocationCache = res;
|
|
99
106
|
// 更新用户状态 -- todo
|
|
100
107
|
updateLocStatus(true);
|
package/src/report.js
CHANGED
|
@@ -409,26 +409,6 @@ const startListenApp = () => {
|
|
|
409
409
|
// onHide时立即上报,并清除定时器
|
|
410
410
|
report(true, true);
|
|
411
411
|
});
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* 监听小程序路由切换事件
|
|
415
|
-
*/
|
|
416
|
-
if (!wx.onAppRoute) {
|
|
417
|
-
cache({ 26: 'H', 27: 'H100', 40: 'notReport' }, true);
|
|
418
|
-
wx.reportAnalytics('onapproute_not_support', {
|
|
419
|
-
mp_version: getMiniProgramVersion(),
|
|
420
|
-
});
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
wx.onAppRoute((res) => {
|
|
424
|
-
const { path, query, openType } = res || {};
|
|
425
|
-
cache({ 26: 'H', 27: 'H100', 38: path, 39: JSON.stringify(query), 40: openType });
|
|
426
|
-
wx.reportAnalytics('page_show', {
|
|
427
|
-
path,
|
|
428
|
-
query: JSON.stringify(query),
|
|
429
|
-
opentype: openType,
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
412
|
};
|
|
433
413
|
|
|
434
414
|
export {
|