@tmsfe/tms-core 0.0.125 → 0.0.126
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 +1 -1
- package/src/request.js +24 -0
- package/src/runtime/login.ts +4 -1
package/package.json
CHANGED
package/src/request.js
CHANGED
|
@@ -30,6 +30,29 @@ const seriesParam = (param) => {
|
|
|
30
30
|
return series.join('');
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
let uuid = '';
|
|
34
|
+
|
|
35
|
+
// 生成用户唯一id,方便追踪未登录接口
|
|
36
|
+
const getTmsUUID = () => {
|
|
37
|
+
if (uuid) {
|
|
38
|
+
return uuid;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const key = 'tms.user.uuid';
|
|
42
|
+
uuid = wx.getStorageSync(key);
|
|
43
|
+
if (!uuid) {
|
|
44
|
+
const str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
45
|
+
uuid = str.replace(/[xy]/g, (c) => {
|
|
46
|
+
const r = (Math.random() * 16) | 0;
|
|
47
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
48
|
+
return v.toString(16);
|
|
49
|
+
});
|
|
50
|
+
wx.setStorageSync(key, uuid);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return uuid;
|
|
54
|
+
}
|
|
55
|
+
|
|
33
56
|
/**
|
|
34
57
|
* 用于对request请求对象做签名
|
|
35
58
|
* @private
|
|
@@ -70,6 +93,7 @@ const composeParam = async (param = {}, withAuth = true, baseParam = {}) => {
|
|
|
70
93
|
timestamp,
|
|
71
94
|
seqId,
|
|
72
95
|
wxAppId,
|
|
96
|
+
tmsUUID: getTmsUUID(),
|
|
73
97
|
},
|
|
74
98
|
{ ...baseParam },
|
|
75
99
|
{ ...paramsWithAuth },
|
package/src/runtime/login.ts
CHANGED
|
@@ -44,7 +44,10 @@ const loginFn = async () => {
|
|
|
44
44
|
if (!wx.tmsLoginPromise) {
|
|
45
45
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
46
46
|
wx.tmsLoginPromise = new Promise(async (resolve) => {
|
|
47
|
-
let userInfo = {
|
|
47
|
+
let userInfo = {
|
|
48
|
+
// todo: 临时加代码用于分析问题
|
|
49
|
+
token: 'tms-login-fail',
|
|
50
|
+
} as any;
|
|
48
51
|
try {
|
|
49
52
|
let userData = await login();
|
|
50
53
|
if (userData.errCode === 10 || !userData.resData.userInfo || !userData.resData.userInfo.uid) {
|