ipanel-rnapp-ajb-base 1.0.30 → 1.0.31
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/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`,
|
|
@@ -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 = {
|
|
@@ -59,6 +62,8 @@ function HomedLoginIndex(props) {
|
|
|
59
62
|
});
|
|
60
63
|
console.log("qrdata", qrdata);
|
|
61
64
|
|
|
65
|
+
global.loading.showLoading("正在登录...");
|
|
66
|
+
|
|
62
67
|
// 绑定 & 登录
|
|
63
68
|
const accountData = await storage.get("accountData");
|
|
64
69
|
const activeAddr = await storage.get("activeAddr");
|
|
@@ -75,37 +80,57 @@ function HomedLoginIndex(props) {
|
|
|
75
80
|
user_id: accountData?.user.user_id,
|
|
76
81
|
};
|
|
77
82
|
|
|
78
|
-
//
|
|
83
|
+
// 扫码绑定
|
|
79
84
|
const result = await deviceReportThird(params);
|
|
80
85
|
if (result && result.code === 0) {
|
|
81
86
|
global.toast.showToast("绑定成功");
|
|
82
87
|
await updateAddrFromNetwork();
|
|
83
88
|
await updateHomedToken();
|
|
84
89
|
|
|
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",
|
|
90
|
+
// 扫码登录
|
|
91
|
+
try {
|
|
92
|
+
const mobileRelationLoginParams = {
|
|
93
|
+
deviceno: qrdata.deviceno,
|
|
94
|
+
deviceid: "2" + qrdata.deviceid, // 给个假id,手机端走后门,免确认直接登录
|
|
95
|
+
userid: qrdata.userid,
|
|
96
|
+
devicetype: "3",
|
|
97
|
+
isforce: "1",
|
|
98
|
+
businessplatform: Platform.OS === "ios" ? 1 : 0,
|
|
101
99
|
};
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
const homedLoginResult = await mobileRelationLogin(
|
|
101
|
+
mobileRelationLoginParams
|
|
102
|
+
).catch((err) => {
|
|
103
|
+
console.log("mobileRelationLogin Err:", err);
|
|
104
|
+
});
|
|
105
|
+
if (homedLoginResult && homedLoginResult.ret === 0) {
|
|
106
|
+
console.log("homedLoginResult", homedLoginResult);
|
|
107
|
+
await storage.set("homedLoginResult", homedLoginResult);
|
|
108
|
+
// 保存登录参数,以便后续自动登录,自动登录前要先判断当前cloud用户是否已经绑定homed用户(即开通homed业务)
|
|
109
|
+
await storage.set(
|
|
110
|
+
"mobileRelationLoginParams",
|
|
111
|
+
mobileRelationLoginParams
|
|
112
|
+
);
|
|
113
|
+
global.toast.showToast("登录成功");
|
|
114
|
+
// 登录成功后跳转回目标页面
|
|
115
|
+
const backParams = {
|
|
116
|
+
loginResult: "success",
|
|
117
|
+
};
|
|
118
|
+
if (route.params?.redirectScreenName) {
|
|
119
|
+
navigation.navigate(
|
|
120
|
+
route.params.redirectScreenName,
|
|
121
|
+
backParams
|
|
122
|
+
);
|
|
123
|
+
} else {
|
|
124
|
+
navigation.goBack(backParams);
|
|
125
|
+
}
|
|
104
126
|
} else {
|
|
105
|
-
|
|
127
|
+
global.toast.showToast(
|
|
128
|
+
"登录失败:" +
|
|
129
|
+
(homedLoginResult ? homedLoginResult.message : "接口异常")
|
|
130
|
+
);
|
|
106
131
|
}
|
|
107
|
-
}
|
|
108
|
-
global.toast.showToast("
|
|
132
|
+
} catch (e) {
|
|
133
|
+
global.toast.showToast("登录异常");
|
|
109
134
|
}
|
|
110
135
|
} else {
|
|
111
136
|
console.error("绑定用户失败", result);
|
|
@@ -114,6 +139,7 @@ function HomedLoginIndex(props) {
|
|
|
114
139
|
} else {
|
|
115
140
|
global.toast.showToast("二维码数据不合法");
|
|
116
141
|
}
|
|
142
|
+
global.loading.hideLoading();
|
|
117
143
|
};
|
|
118
144
|
};
|
|
119
145
|
|
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
|
|