ipanel-rnapp-ajb-base 1.0.30 → 1.0.32
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/app/App.js +46 -1
- package/app/api/homedApi.js +2 -2
- package/app/api/ipanelCloudApi.js +15 -4
- package/app/assets/img/launch_logo_jilin.png +0 -0
- package/app/assets/img/launch_logo_jilin_bottom1.png +0 -0
- package/app/assets/img/launch_logo_jilin_bottom2.png +0 -0
- package/app/screens/BaseScreen.js +109 -50
- package/app/screens/CommonScreens/HomedLoginScreen/index.js +49 -22
- package/app/screens/LoginScreen/indexNew.js +6 -5
- package/app/utils/common.js +58 -26
- package/package.json +2 -2
package/app/App.js
CHANGED
|
@@ -40,7 +40,7 @@ import storage from "./storage";
|
|
|
40
40
|
|
|
41
41
|
import { navigationRef } from "./utils/RootNavigation";
|
|
42
42
|
import checkLogin from "./hooks/checkLogin";
|
|
43
|
-
import { getModuleVersionInfo } from "./api/";
|
|
43
|
+
import { getModuleVersionInfo, getUserInfo, delThirdId } from "./api/";
|
|
44
44
|
import { appReport } from "./utils/common";
|
|
45
45
|
|
|
46
46
|
// 基础导航页、登录页
|
|
@@ -353,10 +353,55 @@ const App = () => {
|
|
|
353
353
|
}
|
|
354
354
|
);
|
|
355
355
|
|
|
356
|
+
const homedLogOutListener = eventEmitter.addListener(
|
|
357
|
+
"HomedLogout",
|
|
358
|
+
async (data) => {
|
|
359
|
+
console.log("HomedLogout", data);
|
|
360
|
+
|
|
361
|
+
const accountData = await storage.get("accountData");
|
|
362
|
+
// const activeAddr = await storage.get('activeAddr');
|
|
363
|
+
const res = await getUserInfo();
|
|
364
|
+
console.log(res, "HomedLogout getUserInfo");
|
|
365
|
+
const userList = res.result?.user_list || [];
|
|
366
|
+
const currentUser = userList.find(
|
|
367
|
+
(item) => item.user_id === accountData?.user.user_id
|
|
368
|
+
);
|
|
369
|
+
const bindList = currentUser?.bind_list || [];
|
|
370
|
+
console.log(bindList, "HomedLogout bindList");
|
|
371
|
+
const homedConfig = bindList.find(
|
|
372
|
+
(item) => item.third_type === "homed"
|
|
373
|
+
);
|
|
374
|
+
console.log("homedConfig", homedConfig);
|
|
375
|
+
|
|
376
|
+
if (homedConfig) {
|
|
377
|
+
// 解绑当前cloud用户对应的homed用户
|
|
378
|
+
const result = await delThirdId({
|
|
379
|
+
third_type: "homed",
|
|
380
|
+
third_id: homedConfig.third_id,
|
|
381
|
+
user_id: homedConfig.user_id,
|
|
382
|
+
}).catch((err) => {
|
|
383
|
+
console.error(err);
|
|
384
|
+
});
|
|
385
|
+
if (!result || result.code !== 0) {
|
|
386
|
+
console.error("解绑homed用户失败:", result);
|
|
387
|
+
global.toast.showToast("解绑电视用户失败");
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
global.toast.showToast("已解绑电视用户");
|
|
391
|
+
await storage.remove("homedAccessToken");
|
|
392
|
+
await storage.remove("HomedLoginResult");
|
|
393
|
+
} else {
|
|
394
|
+
console.log("当前未绑定homed用户");
|
|
395
|
+
global.toast.showToast("当前没有绑定电视用户,无法解绑");
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
|
|
356
400
|
return () => {
|
|
357
401
|
keyboardDidShowListener.remove();
|
|
358
402
|
keyboardDidHideListener.remove();
|
|
359
403
|
cellularDataStateListener.remove();
|
|
404
|
+
homedLogOutListener.remove();
|
|
360
405
|
};
|
|
361
406
|
}, []);
|
|
362
407
|
|
package/app/api/homedApi.js
CHANGED
|
@@ -44,8 +44,8 @@ export const getAccessToken = async (data, domain) => {
|
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
export const mobileRelationLogin = async (data) => {
|
|
48
|
-
|
|
47
|
+
export const mobileRelationLogin = async (data, domain) => {
|
|
48
|
+
domain = domain || (await global.base.getHomedDomain());
|
|
49
49
|
const host = domain === "pyitv.com" ? 12690 : 80;
|
|
50
50
|
return homedHttp({
|
|
51
51
|
url: `http://access.${domain}:${host}/account/mobile_relation_login`,
|
|
@@ -36,7 +36,7 @@ export const baiduAsr = (cuid, len, speechBase64) => {
|
|
|
36
36
|
|
|
37
37
|
export const getAreaOperatorModules = async (params) => {
|
|
38
38
|
let url = `${
|
|
39
|
-
["禺乐慧家", "悦慧家"].includes(appName)
|
|
39
|
+
["禺乐慧家", "悦慧家", "吉柿果"].includes(appName)
|
|
40
40
|
? config.PANYU_MODULE_VERSION_URI
|
|
41
41
|
: config.IPANEL_CLOUD_BASE_URI
|
|
42
42
|
}/jshomeapp/api/getAreaOperatorModules`;
|
|
@@ -67,7 +67,7 @@ export const getAreaOperatorModules = async (params) => {
|
|
|
67
67
|
|
|
68
68
|
export const getModuleVersionInfo = async (params) => {
|
|
69
69
|
let url = `${
|
|
70
|
-
["禺乐慧家", "悦慧家"].includes(appName)
|
|
70
|
+
["禺乐慧家", "悦慧家", "吉柿果"].includes(appName)
|
|
71
71
|
? config.PANYU_MODULE_VERSION_URI
|
|
72
72
|
: config.IPANEL_CLOUD_BASE_URI
|
|
73
73
|
}/jshomeapp/api/moduleVersionInfo`;
|
|
@@ -165,6 +165,17 @@ export const deviceReportThird = (data) => {
|
|
|
165
165
|
});
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
+
export const delThirdId = (data) => {
|
|
169
|
+
return request({
|
|
170
|
+
url: ACCOUNT_SERVICE,
|
|
171
|
+
method: "POST",
|
|
172
|
+
data: {
|
|
173
|
+
action: "del_third_id",
|
|
174
|
+
...data,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
168
179
|
export const obtainThirdToken = (data) => {
|
|
169
180
|
return request({
|
|
170
181
|
url: ACCOUNT_SERVICE,
|
|
@@ -846,7 +857,7 @@ export const queryCountByName = (data) => {
|
|
|
846
857
|
// 获取图形验证码
|
|
847
858
|
export const getCaptcha = (data) => {
|
|
848
859
|
return request({
|
|
849
|
-
url:
|
|
860
|
+
url: `${config.IPANEL_CLOUD_BASE_URI}/captcha/get`,
|
|
850
861
|
method: "GET",
|
|
851
862
|
data,
|
|
852
863
|
});
|
|
@@ -854,7 +865,7 @@ export const getCaptcha = (data) => {
|
|
|
854
865
|
|
|
855
866
|
// 校验图形验证码
|
|
856
867
|
export const checkCaptcha = (data) => {
|
|
857
|
-
return fetch(
|
|
868
|
+
return fetch(`${config.IPANEL_CLOUD_BASE_URI}/captcha/check`, {
|
|
858
869
|
method: "POST",
|
|
859
870
|
body: data,
|
|
860
871
|
headers: {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
1
|
+
import React, { useState, useEffect, useMemo } from "react";
|
|
2
2
|
import {
|
|
3
3
|
Alert,
|
|
4
4
|
View,
|
|
@@ -154,6 +154,7 @@ function HomeTabScreen({ navigation, route }) {
|
|
|
154
154
|
return {
|
|
155
155
|
name: pack.moduleName,
|
|
156
156
|
component: components[index],
|
|
157
|
+
meta: pack.meta || {},
|
|
157
158
|
options: {
|
|
158
159
|
title: pack.moduleChineseName,
|
|
159
160
|
headerShown: false,
|
|
@@ -243,8 +244,10 @@ function HomeTabScreen({ navigation, route }) {
|
|
|
243
244
|
// 刷新token
|
|
244
245
|
const checkToken = async () => {
|
|
245
246
|
const accountType = await storage.get("accountType");
|
|
246
|
-
const accessTokenKey =
|
|
247
|
-
|
|
247
|
+
const accessTokenKey =
|
|
248
|
+
accountType === "adg" ? "adgAccessToken" : "accessToken";
|
|
249
|
+
const refreshTokenKey =
|
|
250
|
+
accountType === "adg" ? "adgRefreshToken" : "refreshToken";
|
|
248
251
|
const access_token = await storage.get(accessTokenKey);
|
|
249
252
|
const refresh_token = await storage.get(refreshTokenKey);
|
|
250
253
|
const logout = () => {
|
|
@@ -283,6 +286,90 @@ function HomeTabScreen({ navigation, route }) {
|
|
|
283
286
|
}
|
|
284
287
|
};
|
|
285
288
|
|
|
289
|
+
const logoSource = useMemo(() => {
|
|
290
|
+
if (["禺乐慧家", "悦慧家"].includes(appName)) {
|
|
291
|
+
return require("../assets/img/launch_logo_panyu.png");
|
|
292
|
+
} else if (appName === "吉柿果") {
|
|
293
|
+
return require("../assets/img/launch_logo_jilin.png");
|
|
294
|
+
} else {
|
|
295
|
+
return require("../assets/img/launch_logo.png");
|
|
296
|
+
}
|
|
297
|
+
}, []);
|
|
298
|
+
|
|
299
|
+
// 启动页
|
|
300
|
+
const renderLaunch = () => {
|
|
301
|
+
if (appName === "吉柿果") {
|
|
302
|
+
return (
|
|
303
|
+
<View style={styles.loadingView}>
|
|
304
|
+
<Image
|
|
305
|
+
source={logoSource}
|
|
306
|
+
style={{
|
|
307
|
+
width: px(241 * 1.5),
|
|
308
|
+
height: px(310 * 1.5),
|
|
309
|
+
marginBottom: px(80),
|
|
310
|
+
}}
|
|
311
|
+
resizeMode="contain"
|
|
312
|
+
/>
|
|
313
|
+
<ActivityIndicator size="large" />
|
|
314
|
+
<View style={styles.bottomLaunch}>
|
|
315
|
+
<Image
|
|
316
|
+
source={require("../assets/img/launch_logo_jilin_bottom1.png")}
|
|
317
|
+
style={{
|
|
318
|
+
width: px(600),
|
|
319
|
+
height: px(100),
|
|
320
|
+
marginBottom: px(30),
|
|
321
|
+
}}
|
|
322
|
+
resizeMode="contain"
|
|
323
|
+
/>
|
|
324
|
+
<Image
|
|
325
|
+
source={require("../assets/img/launch_logo_jilin_bottom2.png")}
|
|
326
|
+
style={{
|
|
327
|
+
width: px(750),
|
|
328
|
+
height: px(100),
|
|
329
|
+
}}
|
|
330
|
+
resizeMode="contain"
|
|
331
|
+
/>
|
|
332
|
+
</View>
|
|
333
|
+
</View>
|
|
334
|
+
);
|
|
335
|
+
} else {
|
|
336
|
+
return (
|
|
337
|
+
<ImageBackground
|
|
338
|
+
style={styles.loadingView}
|
|
339
|
+
source={
|
|
340
|
+
["禺乐慧家", "悦慧家"].includes(appName)
|
|
341
|
+
? require("../assets/img/launch_bg_panyu.png")
|
|
342
|
+
: require("../assets/img/launch_bg.png")
|
|
343
|
+
}
|
|
344
|
+
>
|
|
345
|
+
<Image
|
|
346
|
+
source={logoSource}
|
|
347
|
+
style={{
|
|
348
|
+
width: px(231),
|
|
349
|
+
height: px(231),
|
|
350
|
+
marginBottom: px(80),
|
|
351
|
+
}}
|
|
352
|
+
resizeMode="contain"
|
|
353
|
+
/>
|
|
354
|
+
<Image
|
|
355
|
+
source={
|
|
356
|
+
["禺乐慧家", "悦慧家"].includes(appName)
|
|
357
|
+
? require("../assets/img/launch_text_panyu.png")
|
|
358
|
+
: require("../assets/img/launch_text.png")
|
|
359
|
+
}
|
|
360
|
+
style={{
|
|
361
|
+
width: px(687),
|
|
362
|
+
height: px(60),
|
|
363
|
+
marginBottom: px(80),
|
|
364
|
+
}}
|
|
365
|
+
resizeMode="contain"
|
|
366
|
+
/>
|
|
367
|
+
<ActivityIndicator size="large" />
|
|
368
|
+
</ImageBackground>
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
|
|
286
373
|
// smartHome专用
|
|
287
374
|
const {
|
|
288
375
|
handleTextSubmit,
|
|
@@ -335,56 +422,19 @@ function HomeTabScreen({ navigation, route }) {
|
|
|
335
422
|
}}
|
|
336
423
|
>
|
|
337
424
|
{tabScreens.map((item, index) => (
|
|
338
|
-
<Tab.Screen
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
425
|
+
<Tab.Screen name={item.name} key={index} options={item.options}>
|
|
426
|
+
{(props) => {
|
|
427
|
+
props.route.params = props.route.params || {};
|
|
428
|
+
// 传递后台配置的模块业务元数据meta
|
|
429
|
+
props.route.params.meta = item.meta || {};
|
|
430
|
+
return <item.component {...props} />;
|
|
431
|
+
}}
|
|
432
|
+
</Tab.Screen>
|
|
344
433
|
))}
|
|
345
434
|
</Tab.Navigator>
|
|
346
435
|
</View>
|
|
347
436
|
) : (
|
|
348
|
-
|
|
349
|
-
style={styles.loadingView}
|
|
350
|
-
source={
|
|
351
|
-
["禺乐慧家", "悦慧家"].includes(appName)
|
|
352
|
-
? require("../assets/img/launch_bg_panyu.png")
|
|
353
|
-
: require("../assets/img/launch_bg.png")
|
|
354
|
-
}
|
|
355
|
-
>
|
|
356
|
-
{/*<Text style={styles.loadingText}>*/}
|
|
357
|
-
{/* 欢迎使用{appName.includes('安电工') ? '安电工' : '爱家宝'}*/}
|
|
358
|
-
{/*</Text>*/}
|
|
359
|
-
{/*<ActivityIndicator size="large" />*/}
|
|
360
|
-
<Image
|
|
361
|
-
source={
|
|
362
|
-
["禺乐慧家", "悦慧家"].includes(appName)
|
|
363
|
-
? require("../assets/img/launch_logo_panyu.png")
|
|
364
|
-
: require("../assets/img/launch_logo.png")
|
|
365
|
-
}
|
|
366
|
-
style={{
|
|
367
|
-
width: px(231),
|
|
368
|
-
height: px(231),
|
|
369
|
-
marginBottom: px(80),
|
|
370
|
-
}}
|
|
371
|
-
resizeMode="contain"
|
|
372
|
-
/>
|
|
373
|
-
<Image
|
|
374
|
-
source={
|
|
375
|
-
["禺乐慧家", "悦慧家"].includes(appName)
|
|
376
|
-
? require("../assets/img/launch_text_panyu.png")
|
|
377
|
-
: require("../assets/img/launch_text.png")
|
|
378
|
-
}
|
|
379
|
-
style={{
|
|
380
|
-
width: px(687),
|
|
381
|
-
height: px(60),
|
|
382
|
-
marginBottom: px(80),
|
|
383
|
-
}}
|
|
384
|
-
resizeMode="contain"
|
|
385
|
-
/>
|
|
386
|
-
<ActivityIndicator size="large" />
|
|
387
|
-
</ImageBackground>
|
|
437
|
+
renderLaunch()
|
|
388
438
|
)}
|
|
389
439
|
</View>
|
|
390
440
|
);
|
|
@@ -395,12 +445,21 @@ const styles = StyleSheet.create({
|
|
|
395
445
|
flex: 1,
|
|
396
446
|
alignItems: "center",
|
|
397
447
|
justifyContent: "center",
|
|
398
|
-
|
|
448
|
+
position: "relative",
|
|
449
|
+
backgroundColor: "#fff",
|
|
399
450
|
},
|
|
400
451
|
loadingText: {
|
|
401
452
|
fontSize: 20,
|
|
402
453
|
marginBottom: 10,
|
|
403
454
|
},
|
|
455
|
+
|
|
456
|
+
bottomLaunch: {
|
|
457
|
+
position: "absolute",
|
|
458
|
+
bottom: px(100),
|
|
459
|
+
left: 0,
|
|
460
|
+
right: 0,
|
|
461
|
+
alignItems: "center",
|
|
462
|
+
},
|
|
404
463
|
});
|
|
405
464
|
|
|
406
465
|
export default HomeTabScreen;
|
|
@@ -30,6 +30,9 @@ function HomedLoginIndex(props) {
|
|
|
30
30
|
const homedAccessToken = await storage.get("homedAccessToken");
|
|
31
31
|
const homedLoginResult = await storage.get("homedLoginResult");
|
|
32
32
|
|
|
33
|
+
console.log("homedAccessToken", homedAccessToken);
|
|
34
|
+
console.log("homedLoginResult", homedLoginResult);
|
|
35
|
+
|
|
33
36
|
if (homedAccessToken && homedLoginResult) {
|
|
34
37
|
// 已登录,自动跳转回去
|
|
35
38
|
const backParams = {
|
|
@@ -41,6 +44,7 @@ function HomedLoginIndex(props) {
|
|
|
41
44
|
navigation.goBack(backParams);
|
|
42
45
|
}
|
|
43
46
|
} else {
|
|
47
|
+
onScanBtnPress();
|
|
44
48
|
setIsCheckingLogin(false);
|
|
45
49
|
}
|
|
46
50
|
// // 临时测试时放开,不要让页面跳回去
|
|
@@ -59,6 +63,8 @@ function HomedLoginIndex(props) {
|
|
|
59
63
|
});
|
|
60
64
|
console.log("qrdata", qrdata);
|
|
61
65
|
|
|
66
|
+
global.loading.showLoading("正在登录...");
|
|
67
|
+
|
|
62
68
|
// 绑定 & 登录
|
|
63
69
|
const accountData = await storage.get("accountData");
|
|
64
70
|
const activeAddr = await storage.get("activeAddr");
|
|
@@ -75,37 +81,57 @@ function HomedLoginIndex(props) {
|
|
|
75
81
|
user_id: accountData?.user.user_id,
|
|
76
82
|
};
|
|
77
83
|
|
|
78
|
-
//
|
|
84
|
+
// 扫码绑定
|
|
79
85
|
const result = await deviceReportThird(params);
|
|
80
86
|
if (result && result.code === 0) {
|
|
81
87
|
global.toast.showToast("绑定成功");
|
|
82
88
|
await updateAddrFromNetwork();
|
|
83
89
|
await updateHomedToken();
|
|
84
90
|
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (homedLoginResult.ret === 0) {
|
|
95
|
-
console.log("homedLoginResult", homedLoginResult);
|
|
96
|
-
await storage.set("homedLoginResult", homedLoginResult);
|
|
97
|
-
global.toast.showToast("登录成功");
|
|
98
|
-
// 登录成功后跳转回目标页面
|
|
99
|
-
const backParams = {
|
|
100
|
-
loginResult: "success",
|
|
91
|
+
// 扫码登录
|
|
92
|
+
try {
|
|
93
|
+
const mobileRelationLoginParams = {
|
|
94
|
+
deviceno: qrdata.deviceno,
|
|
95
|
+
deviceid: "2" + qrdata.deviceid, // 给个假id,手机端走后门,免确认直接登录
|
|
96
|
+
userid: qrdata.userid,
|
|
97
|
+
devicetype: "3",
|
|
98
|
+
isforce: "1",
|
|
99
|
+
businessplatform: Platform.OS === "ios" ? 1 : 0,
|
|
101
100
|
};
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
const homedLoginResult = await mobileRelationLogin(
|
|
102
|
+
mobileRelationLoginParams
|
|
103
|
+
).catch((err) => {
|
|
104
|
+
console.log("mobileRelationLogin Err:", err);
|
|
105
|
+
});
|
|
106
|
+
if (homedLoginResult && homedLoginResult.ret === 0) {
|
|
107
|
+
console.log("homedLoginResult", homedLoginResult);
|
|
108
|
+
await storage.set("homedLoginResult", homedLoginResult);
|
|
109
|
+
// 保存登录参数,以便后续自动登录,自动登录前要先判断当前cloud用户是否已经绑定homed用户(即开通homed业务)
|
|
110
|
+
await storage.set(
|
|
111
|
+
"mobileRelationLoginParams",
|
|
112
|
+
mobileRelationLoginParams
|
|
113
|
+
);
|
|
114
|
+
global.toast.showToast("登录成功");
|
|
115
|
+
// 登录成功后跳转回目标页面
|
|
116
|
+
const backParams = {
|
|
117
|
+
loginResult: "success",
|
|
118
|
+
};
|
|
119
|
+
if (route.params?.redirectScreenName) {
|
|
120
|
+
navigation.navigate(
|
|
121
|
+
route.params.redirectScreenName,
|
|
122
|
+
backParams
|
|
123
|
+
);
|
|
124
|
+
} else {
|
|
125
|
+
navigation.goBack(backParams);
|
|
126
|
+
}
|
|
104
127
|
} else {
|
|
105
|
-
|
|
128
|
+
global.toast.showToast(
|
|
129
|
+
"登录失败:" +
|
|
130
|
+
(homedLoginResult ? homedLoginResult.message : "接口异常")
|
|
131
|
+
);
|
|
106
132
|
}
|
|
107
|
-
}
|
|
108
|
-
global.toast.showToast("
|
|
133
|
+
} catch (e) {
|
|
134
|
+
global.toast.showToast("登录异常");
|
|
109
135
|
}
|
|
110
136
|
} else {
|
|
111
137
|
console.error("绑定用户失败", result);
|
|
@@ -114,6 +140,7 @@ function HomedLoginIndex(props) {
|
|
|
114
140
|
} else {
|
|
115
141
|
global.toast.showToast("二维码数据不合法");
|
|
116
142
|
}
|
|
143
|
+
global.loading.hideLoading();
|
|
117
144
|
};
|
|
118
145
|
};
|
|
119
146
|
|
|
@@ -52,6 +52,7 @@ const errorCodeMap = {
|
|
|
52
52
|
const appName =
|
|
53
53
|
NativeModules?.RNToNativeEmitter?.appName || config.LOCALTEST_APP_NAME;
|
|
54
54
|
|
|
55
|
+
|
|
55
56
|
const envVersion = NativeModules?.RNToNativeEmitter?.serverCluster || "alpha";
|
|
56
57
|
|
|
57
58
|
const packageName = NativeModules?.RNToNativeEmitter?.packageName;
|
|
@@ -176,7 +177,7 @@ function LoginScreen({ navigation, route }) {
|
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
const entranceSelect = await storage.get("entranceSelect");
|
|
179
|
-
if (entranceSelect === "tyygq" && envVersion !== "release") {
|
|
180
|
+
if (entranceSelect === "tyygq" && envVersion !== "release" && !["禺乐慧家", "悦慧家", '吉柿果'].includes(appName)) {
|
|
180
181
|
global.loading.showLoading("正在加载");
|
|
181
182
|
await global.base.navigateModule({
|
|
182
183
|
operatorId: "ipanel",
|
|
@@ -395,8 +396,8 @@ function LoginScreen({ navigation, route }) {
|
|
|
395
396
|
const handleLogin = async () => {
|
|
396
397
|
let adcode;
|
|
397
398
|
let res;
|
|
398
|
-
const appName =
|
|
399
|
-
|
|
399
|
+
// const appName =
|
|
400
|
+
// NativeModules?.RNToNativeEmitter?.appName || config.LOCALTEST_APP_NAME;
|
|
400
401
|
// const appName = '遥控键码库';
|
|
401
402
|
const { deviceModal } = NativeModules?.RNToNativeEmitter || {};
|
|
402
403
|
|
|
@@ -580,8 +581,8 @@ function LoginScreen({ navigation, route }) {
|
|
|
580
581
|
|
|
581
582
|
console.log(activeType);
|
|
582
583
|
console.log(envVersion);
|
|
583
|
-
console.log(9999);
|
|
584
|
-
if (activeType === "ajb" && envVersion !== "release") {
|
|
584
|
+
console.log(9999, appName);
|
|
585
|
+
if (activeType === "ajb" && envVersion !== "release" && !["禺乐慧家", "悦慧家", '吉柿果'].includes(appName)) {
|
|
585
586
|
const entrance = await selectEntrance();
|
|
586
587
|
await storage.set("entranceSelect", entrance);
|
|
587
588
|
if (entrance === "tyygq") {
|
package/app/utils/common.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getUserInfo,
|
|
14
14
|
getAccessToken,
|
|
15
15
|
refreshToken,
|
|
16
|
+
mobileRelationLogin,
|
|
16
17
|
} from "../api";
|
|
17
18
|
import storage from "../storage";
|
|
18
19
|
import eventBus, { EVENTS } from "../eventBus";
|
|
@@ -23,13 +24,14 @@ async function updateHomedToken() {
|
|
|
23
24
|
const accountData = await storage.get("accountData");
|
|
24
25
|
const activeAddr = await storage.get("activeAddr");
|
|
25
26
|
const res = await getUserInfo();
|
|
27
|
+
console.log(res, "getUserInfo");
|
|
26
28
|
const userList = res.result?.user_list || [];
|
|
27
29
|
const currentUser = userList.find(
|
|
28
|
-
item => item.user_id === accountData?.user.user_id
|
|
30
|
+
(item) => item.user_id === accountData?.user.user_id
|
|
29
31
|
);
|
|
30
32
|
const bindList = currentUser?.bind_list || [];
|
|
31
33
|
console.log(bindList, "bindList");
|
|
32
|
-
const homedConfig = bindList.find(item => item.third_type === "homed");
|
|
34
|
+
const homedConfig = bindList.find((item) => item.third_type === "homed");
|
|
33
35
|
let domain = activeAddr?.domain || "homed.tv";
|
|
34
36
|
// if (!["禺乐慧家", "悦慧家"].includes(appName)) {
|
|
35
37
|
// domain = 'homed.tv'
|
|
@@ -38,33 +40,61 @@ async function updateHomedToken() {
|
|
|
38
40
|
domain = "homed.jishimedia.com";
|
|
39
41
|
}
|
|
40
42
|
console.log(domain, "domain");
|
|
43
|
+
// 有homedConfig和domain,说明当前cloud用户已经绑定了homed业务
|
|
41
44
|
if (homedConfig && domain) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
const mobileRelationLoginParams = await storage.get(
|
|
46
|
+
"mobileRelationLoginParams"
|
|
47
|
+
);
|
|
48
|
+
let homedToken = "";
|
|
49
|
+
if (mobileRelationLoginParams) {
|
|
50
|
+
console.log("mobileRelationLoginParams", mobileRelationLoginParams);
|
|
51
|
+
// 未来优先走这个接口去登录homed,拿到并设置 homedLoginResult,以这个作为homed是否登录的判断——jilinHomed & tvShare
|
|
52
|
+
try {
|
|
53
|
+
const homedLoginResult = await mobileRelationLogin(
|
|
54
|
+
mobileRelationLoginParams,
|
|
55
|
+
domain
|
|
56
|
+
).catch((err) => {});
|
|
57
|
+
if (homedLoginResult && homedLoginResult.ret === 0) {
|
|
58
|
+
homedToken = homedLoginResult.access_token;
|
|
59
|
+
await storage.set("homedLoginResult", homedLoginResult);
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.log("mobileRelationLogin Error:", e);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
// 一般不走这个方式了,但还是放着,以防万一
|
|
66
|
+
const tokenRes = await getAccessToken(
|
|
67
|
+
{
|
|
68
|
+
userName: homedConfig.third_id,
|
|
69
|
+
deviceType: 1,
|
|
70
|
+
},
|
|
71
|
+
domain
|
|
72
|
+
).catch((err) => {});
|
|
73
|
+
console.log(tokenRes, "tokenRes");
|
|
74
|
+
if (tokenRes && tokenRes.ret === 0) {
|
|
75
|
+
homedToken = tokenRes.access_token;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (homedToken) {
|
|
51
80
|
// 如果能获取到homed token,说明当前登录的家庭成员开通(绑定)了homed业务
|
|
52
|
-
await storage.set("homedAccessToken",
|
|
81
|
+
await storage.set("homedAccessToken", homedToken);
|
|
53
82
|
const userListRes = await getUserList({}).catch(() => {});
|
|
54
83
|
if (userListRes?.ret === 0) {
|
|
55
84
|
const list = userListRes.user_list || [];
|
|
56
85
|
await storage.set(
|
|
57
86
|
"homedHomeMembers",
|
|
58
|
-
list.filter(item => item.user_id !== userListRes.bind_user_id)
|
|
87
|
+
list.filter((item) => item.user_id !== userListRes.bind_user_id)
|
|
59
88
|
);
|
|
60
89
|
}
|
|
61
90
|
} else {
|
|
62
|
-
// global.toast.showToast(tokenRes?.ret_message || '获取homedtoken失败');
|
|
63
91
|
// 置空
|
|
64
92
|
await storage.set("homedAccessToken", "");
|
|
93
|
+
await storage.remove("homedLoginResult");
|
|
65
94
|
}
|
|
66
95
|
} else {
|
|
67
96
|
await storage.set("homedAccessToken", "");
|
|
97
|
+
await storage.remove("homedLoginResult");
|
|
68
98
|
}
|
|
69
99
|
|
|
70
100
|
// const params = {
|
|
@@ -103,15 +133,15 @@ async function initOperatorHomedTouristAccount(opHomedConfig) {
|
|
|
103
133
|
if (["吉柿果"].includes(appName)) {
|
|
104
134
|
url = `http://access.${opHomedConfig.domain}/account/user/register`;
|
|
105
135
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
136
|
+
await homedGet(url, {
|
|
137
|
+
username: opHomedConfig.touristUsername,
|
|
138
|
+
groupid: opHomedConfig.touristGroupId,
|
|
139
|
+
accounttype: 1,
|
|
140
|
+
iconid: 1,
|
|
141
|
+
pwd: "1bbd886460827015e5d605ed44252251", // md5("11111111")
|
|
142
|
+
}).catch((e) => {
|
|
143
|
+
console.log("Error: homed游客注册请求失败", e);
|
|
144
|
+
});
|
|
115
145
|
|
|
116
146
|
await updateHomedTouristToken();
|
|
117
147
|
}
|
|
@@ -129,7 +159,7 @@ async function updateHomedTouristToken() {
|
|
|
129
159
|
devicetype: 3,
|
|
130
160
|
accounttype: 2,
|
|
131
161
|
pwd: "1bbd886460827015e5d605ed44252251", // md5("11111111")
|
|
132
|
-
}).catch(e => {
|
|
162
|
+
}).catch((e) => {
|
|
133
163
|
console.log("Error: homed游客登录请求失败", e);
|
|
134
164
|
});
|
|
135
165
|
|
|
@@ -332,8 +362,10 @@ async function appReport(tag, extraData = {}) {
|
|
|
332
362
|
|
|
333
363
|
const checkToken = async () => {
|
|
334
364
|
const accountType = await storage.get("accountType");
|
|
335
|
-
const accessTokenKey =
|
|
336
|
-
|
|
365
|
+
const accessTokenKey =
|
|
366
|
+
accountType === "adg" ? "adgAccessToken" : "accessToken";
|
|
367
|
+
const refreshTokenKey =
|
|
368
|
+
accountType === "adg" ? "adgRefreshToken" : "refreshToken";
|
|
337
369
|
const access_token = await storage.get(accessTokenKey);
|
|
338
370
|
const refresh_token = await storage.get(refreshTokenKey);
|
|
339
371
|
|