@tmsfe/tms-core 0.0.127 → 0.0.129
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/runtime/index.js +10 -4
- package/src/runtime/login.ts +24 -3
package/package.json
CHANGED
package/src/runtime/index.js
CHANGED
|
@@ -96,7 +96,10 @@ const login = async () => {
|
|
|
96
96
|
*/
|
|
97
97
|
async function setPaypointAuth(param = {}) {
|
|
98
98
|
const request = getRequestInstnce();
|
|
99
|
-
const userInfo = await
|
|
99
|
+
const [userInfo, mycarPubOpenId] = await Promise.all([
|
|
100
|
+
getLoginInfo(),
|
|
101
|
+
getMycarPubOpenId(),
|
|
102
|
+
]);
|
|
100
103
|
|
|
101
104
|
const req = {
|
|
102
105
|
traceSource: param.traceSource || 1, // 请求类型
|
|
@@ -106,7 +109,7 @@ async function setPaypointAuth(param = {}) {
|
|
|
106
109
|
subAppId: param.appId || 'wx735359beafd78b9f', // 默认使用我的车的小程序号发布号发布
|
|
107
110
|
appId: param.wechaId || 'wx29d15d946a7f2351', // 默认使用我的车的公众号id
|
|
108
111
|
...userInfo,
|
|
109
|
-
openId:
|
|
112
|
+
openId: mycarPubOpenId,
|
|
110
113
|
};
|
|
111
114
|
|
|
112
115
|
const res = await request.post('paypoint/setpayauth', req);
|
|
@@ -173,7 +176,10 @@ async function getPermissionList(param = {}) {
|
|
|
173
176
|
*/
|
|
174
177
|
async function terminatePaypointPermisson(param = {}) {
|
|
175
178
|
const request = getRequestInstnce();
|
|
176
|
-
const userInfo = await
|
|
179
|
+
const [userInfo, mycarPubOpenId] = await Promise.all([
|
|
180
|
+
getLoginInfo(),
|
|
181
|
+
getMycarPubOpenId(),
|
|
182
|
+
]);
|
|
177
183
|
|
|
178
184
|
const data = {
|
|
179
185
|
traceSource: param.traceSource || 1, // 请求来源
|
|
@@ -185,7 +191,7 @@ async function terminatePaypointPermisson(param = {}) {
|
|
|
185
191
|
reason: param.reason || '其他',
|
|
186
192
|
serviceId: param.serviceId,
|
|
187
193
|
...userInfo,
|
|
188
|
-
openId:
|
|
194
|
+
openId: mycarPubOpenId,
|
|
189
195
|
};
|
|
190
196
|
|
|
191
197
|
const res = await request.post('paypoint/terminatePaypointPermisson', data);
|
package/src/runtime/login.ts
CHANGED
|
@@ -82,7 +82,12 @@ async function login() {
|
|
|
82
82
|
// @ts-ignore
|
|
83
83
|
const { trafficEntrence: registerSource, scene: sceneId } = getOpenAppTrafficData();
|
|
84
84
|
|
|
85
|
-
userData = await getApp().tms.createRequest({ withAuth: false }).post('user/login', {
|
|
85
|
+
userData = await getApp().tms.createRequest({ withAuth: false }).post('user/login', {
|
|
86
|
+
code,
|
|
87
|
+
sceneId,
|
|
88
|
+
registerSource,
|
|
89
|
+
apiVer: 1, // 1表示不需要再去请求mycarPubOpenId,能快100ms
|
|
90
|
+
});
|
|
86
91
|
} catch (e) {
|
|
87
92
|
console.error(e); // eslint-disable-line
|
|
88
93
|
}
|
|
@@ -156,12 +161,28 @@ let getMycarPubOpenIdProm;
|
|
|
156
161
|
* 获取失败时,返回rejected Promise,rejected数据为错误对象
|
|
157
162
|
*/
|
|
158
163
|
const getMycarPubOpenId = () => {
|
|
159
|
-
if (getMycarPubOpenIdProm) {
|
|
164
|
+
if (getMycarPubOpenIdProm) {
|
|
165
|
+
return getMycarPubOpenIdProm;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const { appEnv } = getApp().tms.getEnvInfo();
|
|
169
|
+
// 优先用缓存的,正式环境跟测试环境的不一样
|
|
170
|
+
const key = `tms.pubOpenId.${appEnv}`;
|
|
171
|
+
const pubOpenId = wx.getStorageSync(key);
|
|
172
|
+
if (pubOpenId) {
|
|
173
|
+
getMycarPubOpenIdProm = Promise.resolve(pubOpenId);
|
|
160
174
|
return getMycarPubOpenIdProm;
|
|
161
175
|
}
|
|
162
176
|
|
|
177
|
+
// 从接口请求
|
|
163
178
|
getMycarPubOpenIdProm = getOaPubOpenId('mycar')
|
|
164
|
-
.then(
|
|
179
|
+
.then((pubOpenId) => {
|
|
180
|
+
if (pubOpenId) {
|
|
181
|
+
wx.setStorageSync(key, pubOpenId);
|
|
182
|
+
return pubOpenId;
|
|
183
|
+
}
|
|
184
|
+
return Promise.reject(new Error('No mycarPubOpenId found'));
|
|
185
|
+
})
|
|
165
186
|
.catch((e) => {
|
|
166
187
|
getMycarPubOpenIdProm = null;
|
|
167
188
|
return Promise.reject(e);
|