ipanel-rnapp-ajb-base 1.0.21 → 1.0.23
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 +180 -166
- package/app/api/ipanelCloudApi.js +210 -208
- package/app/assets/img/launch_bg_panyu.png +0 -0
- package/app/assets/img/launch_logo_panyu.png +0 -0
- package/app/assets/img/launch_text_panyu.png +0 -0
- package/app/assets/img/login_bg_new.png +0 -0
- package/app/base.js +69 -62
- package/app/components/common/LoginType/protocol.js +66 -44
- package/app/screens/BaseScreen.js +111 -108
- package/app/screens/CommonScreens/DeviceFeedbackScreen/index.js +99 -83
- package/app/screens/LoginScreen/index.js +193 -170
- package/app/screens/LoginScreen/indexNew.js +414 -368
- package/app/screens/RegisteCountScreen/index.js +494 -468
- package/app/screens/SbkScreen.js +149 -7
- package/app/utils/applyPermissions.js +4 -2
- package/app/utils/common.js +94 -93
- package/app/utils/config.js +15 -15
- package/package.json +2 -2
package/app/screens/SbkScreen.js
CHANGED
|
@@ -1,19 +1,161 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import {
|
|
3
|
+
StyleSheet,
|
|
4
|
+
View,
|
|
5
|
+
Text,
|
|
6
|
+
ScrollView,
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import { Icon, Button } from "@rneui/themed";
|
|
10
|
+
|
|
11
|
+
const { storage, replace } = global.base;
|
|
12
|
+
|
|
13
|
+
const SbkPage = ({ navigation }) => {
|
|
14
|
+
const [activeAddr, setActiveAddr] = useState({});
|
|
15
|
+
const [addressList, setAddressList] = useState([]);
|
|
16
|
+
const [addrSelectorVisible, setAddrSelectorVisible] = useState(false);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
initAddressList();
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
const initAddressList = async () => {
|
|
23
|
+
const activeAddr = await storage.get("activeAddr");
|
|
24
|
+
const addressList = await storage.get("addressList");
|
|
25
|
+
|
|
26
|
+
setActiveAddr(activeAddr);
|
|
27
|
+
setAddressList(addressList);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const handleSwitchAddr = () => {
|
|
31
|
+
setAddrSelectorVisible(true);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const handleSelectAddr = async (addr) => {
|
|
35
|
+
console.log(addr);
|
|
36
|
+
setActiveAddr(addr);
|
|
37
|
+
await storage.set("activeAddr", addr);
|
|
38
|
+
setAddrSelectorVisible(false);
|
|
39
|
+
};
|
|
40
|
+
const handleLogout = async () => {
|
|
41
|
+
await storage.set("accessToken", null);
|
|
42
|
+
await storage.set("refreshToken", null);
|
|
43
|
+
await storage.set("homedAccessToken", null);
|
|
44
|
+
replace("Login", {
|
|
45
|
+
skip: true,
|
|
46
|
+
});
|
|
47
|
+
};
|
|
3
48
|
|
|
4
|
-
const SbkScreen = () => {
|
|
5
49
|
return (
|
|
6
50
|
<View style={styles.container}>
|
|
7
|
-
<
|
|
51
|
+
<View style={styles.container}>
|
|
52
|
+
<View
|
|
53
|
+
style={{
|
|
54
|
+
marginBottom: 20,
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<Text style={[styles.welcomeText, { color: "orange" }]}>
|
|
58
|
+
声必可专用页面
|
|
59
|
+
</Text>
|
|
60
|
+
</View>
|
|
61
|
+
{addressList.length > 0 ? (
|
|
62
|
+
<View>
|
|
63
|
+
<Text style={styles.welcomeText}>
|
|
64
|
+
当前家庭:{activeAddr.address_name}{" "}
|
|
65
|
+
<Text
|
|
66
|
+
style={[styles.switchAddrBtn, styles.welcomeText]}
|
|
67
|
+
onPress={handleSwitchAddr}
|
|
68
|
+
>
|
|
69
|
+
切换
|
|
70
|
+
</Text>
|
|
71
|
+
</Text>
|
|
72
|
+
</View>
|
|
73
|
+
) : (
|
|
74
|
+
<Text>暂无家庭</Text>
|
|
75
|
+
)}
|
|
76
|
+
</View>
|
|
77
|
+
{addrSelectorVisible ? (
|
|
78
|
+
<View style={styles.addrSelector}>
|
|
79
|
+
<ScrollView style={styles.addrSelectorScrollView}>
|
|
80
|
+
{addressList.map((item, index) => (
|
|
81
|
+
<TouchableOpacity
|
|
82
|
+
key={index}
|
|
83
|
+
onPress={() => handleSelectAddr(item)}
|
|
84
|
+
>
|
|
85
|
+
<Text
|
|
86
|
+
style={[
|
|
87
|
+
styles.addrSelectorText,
|
|
88
|
+
item.address_id === activeAddr.address_id &&
|
|
89
|
+
styles.activeAddrText,
|
|
90
|
+
]}
|
|
91
|
+
>
|
|
92
|
+
{item.address_name}
|
|
93
|
+
</Text>
|
|
94
|
+
</TouchableOpacity>
|
|
95
|
+
))}
|
|
96
|
+
</ScrollView>
|
|
97
|
+
</View>
|
|
98
|
+
) : null}
|
|
99
|
+
|
|
100
|
+
<Icon
|
|
101
|
+
containerStyle={styles.exitBtn}
|
|
102
|
+
type="ionicon"
|
|
103
|
+
name="exit-outline"
|
|
104
|
+
color="#00aced"
|
|
105
|
+
size={30}
|
|
106
|
+
onPress={handleLogout}
|
|
107
|
+
/>
|
|
8
108
|
</View>
|
|
9
109
|
);
|
|
10
110
|
};
|
|
11
111
|
|
|
12
112
|
const styles = StyleSheet.create({
|
|
13
113
|
container: {
|
|
14
|
-
|
|
15
|
-
|
|
114
|
+
flex: 1,
|
|
115
|
+
alignItems: "center",
|
|
116
|
+
justifyContent: "center",
|
|
117
|
+
backgroundColor: "#F2F2F2",
|
|
118
|
+
},
|
|
119
|
+
previewBtn: {
|
|
120
|
+
height: 70,
|
|
121
|
+
},
|
|
122
|
+
previewBtnStyle: {
|
|
123
|
+
fontSize: 18,
|
|
124
|
+
},
|
|
125
|
+
welcomeText: {
|
|
126
|
+
fontSize: 26,
|
|
127
|
+
},
|
|
128
|
+
switchAddrBtn: {
|
|
129
|
+
// 蓝色文本样式
|
|
130
|
+
color: "#00aced",
|
|
131
|
+
},
|
|
132
|
+
exitBtn: {
|
|
133
|
+
position: "absolute",
|
|
134
|
+
top: 40,
|
|
135
|
+
right: 20,
|
|
136
|
+
},
|
|
137
|
+
addrSelector: {
|
|
138
|
+
position: "absolute",
|
|
139
|
+
top: 0,
|
|
140
|
+
bottom: 0,
|
|
141
|
+
left: 0,
|
|
142
|
+
right: 0,
|
|
143
|
+
alignItems: "center",
|
|
144
|
+
justifyContent: "center",
|
|
145
|
+
backgroundColor: "#fff",
|
|
146
|
+
zIndex: 2,
|
|
147
|
+
},
|
|
148
|
+
addrSelectorScrollView: {
|
|
149
|
+
marginVertical: 30,
|
|
150
|
+
paddingHorizontal: 30,
|
|
151
|
+
},
|
|
152
|
+
addrSelectorText: {
|
|
153
|
+
fontSize: 30,
|
|
154
|
+
lineHeight: 50,
|
|
155
|
+
},
|
|
156
|
+
activeAddrText: {
|
|
157
|
+
color: "#00aced",
|
|
16
158
|
},
|
|
17
159
|
});
|
|
18
160
|
|
|
19
|
-
export default
|
|
161
|
+
export default SbkPage;
|
|
@@ -78,15 +78,17 @@ const requestPermissions = async (
|
|
|
78
78
|
const permissionsMap = await PermissionsAndroid.requestMultiple(
|
|
79
79
|
permissions,
|
|
80
80
|
);
|
|
81
|
+
console.log(permissionsMap)
|
|
81
82
|
const permissionsResults = Object.values(permissionsMap);
|
|
83
|
+
console.log(permissionsResults)
|
|
82
84
|
if (
|
|
83
85
|
permissionsResults.every(
|
|
84
86
|
item => item === PermissionsAndroid.RESULTS.GRANTED,
|
|
85
87
|
)
|
|
86
88
|
) {
|
|
87
89
|
console.log('成功申请权限');
|
|
88
|
-
await storage.set(`neverAskAgainPermission${type}`, null);
|
|
89
|
-
return true;
|
|
90
|
+
await storage.set(`neverAskAgainPermission${type}`, type==='audio'?true:null);
|
|
91
|
+
return type==='audio'?'getRight':true;
|
|
90
92
|
} else if (
|
|
91
93
|
permissionsResults.some(
|
|
92
94
|
item => item === PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN,
|
package/app/utils/common.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {Alert, NativeModules, Platform} from
|
|
2
|
-
import Geolocation from
|
|
3
|
-
import UUIDGenerator from
|
|
1
|
+
import { Alert, NativeModules, Platform } from "react-native";
|
|
2
|
+
import Geolocation from "react-native-geolocation-service";
|
|
3
|
+
import UUIDGenerator from "react-native-uuid-generator";
|
|
4
4
|
|
|
5
|
-
const appName = NativeModules?.RNToNativeEmitter?.appName
|
|
5
|
+
const appName = NativeModules?.RNToNativeEmitter?.appName;
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
homedGet,
|
|
@@ -13,55 +13,55 @@ import {
|
|
|
13
13
|
getUserInfo,
|
|
14
14
|
getAccessToken,
|
|
15
15
|
refreshToken,
|
|
16
|
-
} from
|
|
17
|
-
import storage from
|
|
18
|
-
import eventBus, {EVENTS} from
|
|
19
|
-
import applyPermissions from
|
|
20
|
-
import {replace} from
|
|
16
|
+
} from "../api";
|
|
17
|
+
import storage from "../storage";
|
|
18
|
+
import eventBus, { EVENTS } from "../eventBus";
|
|
19
|
+
import applyPermissions from "./applyPermissions";
|
|
20
|
+
import { replace } from "./RootNavigation";
|
|
21
21
|
|
|
22
22
|
async function updateHomedToken() {
|
|
23
|
-
const accountData = await storage.get(
|
|
24
|
-
const activeAddr = await storage.get(
|
|
23
|
+
const accountData = await storage.get("accountData");
|
|
24
|
+
const activeAddr = await storage.get("activeAddr");
|
|
25
25
|
const res = await getUserInfo();
|
|
26
26
|
const userList = res.result?.user_list || [];
|
|
27
27
|
const currentUser = userList.find(
|
|
28
|
-
item => item.user_id === accountData?.user.user_id
|
|
28
|
+
(item) => item.user_id === accountData?.user.user_id
|
|
29
29
|
);
|
|
30
30
|
const bindList = currentUser?.bind_list || [];
|
|
31
|
-
console.log(bindList,
|
|
32
|
-
const homedConfig = bindList.find(item => item.third_type ===
|
|
33
|
-
let domain = activeAddr?.domain ||
|
|
34
|
-
// if (appName
|
|
31
|
+
console.log(bindList, "bindList");
|
|
32
|
+
const homedConfig = bindList.find((item) => item.third_type === "homed");
|
|
33
|
+
let domain = activeAddr?.domain || "homed.tv";
|
|
34
|
+
// if (!["禺乐慧家", "悦慧家"].includes(appName)) {
|
|
35
35
|
// domain = 'homed.tv'
|
|
36
36
|
// }
|
|
37
|
-
console.log(domain,
|
|
37
|
+
console.log(domain, "domain");
|
|
38
38
|
if (homedConfig && domain) {
|
|
39
39
|
const tokenRes = await getAccessToken(
|
|
40
40
|
{
|
|
41
41
|
userName: homedConfig.third_id,
|
|
42
42
|
deviceType: 1,
|
|
43
43
|
},
|
|
44
|
-
domain
|
|
45
|
-
).catch(err => {});
|
|
46
|
-
console.log(tokenRes,
|
|
44
|
+
domain
|
|
45
|
+
).catch((err) => {});
|
|
46
|
+
console.log(tokenRes, "tokenRes");
|
|
47
47
|
if (tokenRes && tokenRes.ret === 0) {
|
|
48
48
|
// 如果能获取到homed token,说明当前登录的家庭成员开通(绑定)了homed业务
|
|
49
|
-
await storage.set(
|
|
49
|
+
await storage.set("homedAccessToken", tokenRes.access_token);
|
|
50
50
|
const userListRes = await getUserList({}).catch(() => {});
|
|
51
51
|
if (userListRes?.ret === 0) {
|
|
52
52
|
const list = userListRes.user_list || [];
|
|
53
53
|
await storage.set(
|
|
54
|
-
|
|
55
|
-
list.filter(item => item.user_id !== userListRes.bind_user_id)
|
|
54
|
+
"homedHomeMembers",
|
|
55
|
+
list.filter((item) => item.user_id !== userListRes.bind_user_id)
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
} else {
|
|
59
59
|
// global.toast.showToast(tokenRes?.ret_message || '获取homedtoken失败');
|
|
60
60
|
// 置空
|
|
61
|
-
await storage.set(
|
|
61
|
+
await storage.set("homedAccessToken", "");
|
|
62
62
|
}
|
|
63
63
|
} else {
|
|
64
|
-
await storage.set(
|
|
64
|
+
await storage.set("homedAccessToken", "");
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// const params = {
|
|
@@ -95,7 +95,7 @@ async function updateHomedToken() {
|
|
|
95
95
|
// 初始化当前运营商对应的homed游客账号
|
|
96
96
|
// TODO 在用户个人信息切换运营商后需要同步调用该函数初始化新的运营商的homed游客账号及token
|
|
97
97
|
async function initOperatorHomedTouristAccount(opHomedConfig) {
|
|
98
|
-
await storage.set(
|
|
98
|
+
await storage.set("operatorHomedConfig", opHomedConfig);
|
|
99
99
|
|
|
100
100
|
await homedGet(
|
|
101
101
|
`https://access.${opHomedConfig.domain}/account/user/register`,
|
|
@@ -104,10 +104,10 @@ async function initOperatorHomedTouristAccount(opHomedConfig) {
|
|
|
104
104
|
groupid: opHomedConfig.touristGroupId,
|
|
105
105
|
accounttype: 1,
|
|
106
106
|
iconid: 1,
|
|
107
|
-
pwd:
|
|
108
|
-
}
|
|
109
|
-
).catch(e => {
|
|
110
|
-
console.log(
|
|
107
|
+
pwd: "1bbd886460827015e5d605ed44252251", // md5("11111111")
|
|
108
|
+
}
|
|
109
|
+
).catch((e) => {
|
|
110
|
+
console.log("Error: homed游客注册请求失败", e);
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
await updateHomedTouristToken();
|
|
@@ -115,7 +115,7 @@ async function initOperatorHomedTouristAccount(opHomedConfig) {
|
|
|
115
115
|
|
|
116
116
|
// 更新homed游客token
|
|
117
117
|
async function updateHomedTouristToken() {
|
|
118
|
-
const opHomedConfig = await storage.get(
|
|
118
|
+
const opHomedConfig = await storage.get("operatorHomedConfig");
|
|
119
119
|
|
|
120
120
|
const result = await homedGet(
|
|
121
121
|
`https://access.${opHomedConfig.domain}/account/login`,
|
|
@@ -124,17 +124,17 @@ async function updateHomedTouristToken() {
|
|
|
124
124
|
account: opHomedConfig.touristUsername,
|
|
125
125
|
devicetype: 3,
|
|
126
126
|
accounttype: 2,
|
|
127
|
-
pwd:
|
|
128
|
-
}
|
|
129
|
-
).catch(e => {
|
|
130
|
-
console.log(
|
|
127
|
+
pwd: "1bbd886460827015e5d605ed44252251", // md5("11111111")
|
|
128
|
+
}
|
|
129
|
+
).catch((e) => {
|
|
130
|
+
console.log("Error: homed游客登录请求失败", e);
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
if (result && result.ret === 0) {
|
|
134
|
-
console.log(
|
|
135
|
-
await storage.set(
|
|
134
|
+
console.log("homedTouristAccessToken:", result.access_token);
|
|
135
|
+
await storage.set("homedTouristAccessToken", result.access_token);
|
|
136
136
|
} else {
|
|
137
|
-
await storage.set(
|
|
137
|
+
await storage.set("homedTouristAccessToken", "");
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -150,8 +150,8 @@ async function getCurrentPosition() {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
async function getUserLocation() {
|
|
153
|
-
if (Platform.OS ===
|
|
154
|
-
await Geolocation.requestAuthorization(
|
|
153
|
+
if (Platform.OS === "ios") {
|
|
154
|
+
await Geolocation.requestAuthorization("whenInUse");
|
|
155
155
|
return getCurrentPosition();
|
|
156
156
|
} else {
|
|
157
157
|
// try {
|
|
@@ -175,28 +175,28 @@ async function getUserLocation() {
|
|
|
175
175
|
try {
|
|
176
176
|
return getCurrentPosition();
|
|
177
177
|
} catch (e) {
|
|
178
|
-
throw new Error(
|
|
178
|
+
throw new Error("Location permission not granted!!!!");
|
|
179
179
|
}
|
|
180
180
|
} else {
|
|
181
|
-
throw new Error(
|
|
181
|
+
throw new Error("Location permission not granted!!!!");
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
const MSG_TYPES = {
|
|
187
|
-
TEXT:
|
|
188
|
-
IMAGE:
|
|
189
|
-
VOICE:
|
|
190
|
-
VIDEO:
|
|
191
|
-
EVENT:
|
|
192
|
-
TEMPLATE:
|
|
187
|
+
TEXT: "text",
|
|
188
|
+
IMAGE: "image",
|
|
189
|
+
VOICE: "voice",
|
|
190
|
+
VIDEO: "video",
|
|
191
|
+
EVENT: "event",
|
|
192
|
+
TEMPLATE: "template",
|
|
193
193
|
};
|
|
194
194
|
|
|
195
195
|
const MSG_EVENT_TYPES = {
|
|
196
|
-
GEO:
|
|
197
|
-
PUSH_WEATHER:
|
|
198
|
-
SET_DEVICE_TIMING_CONTROL:
|
|
199
|
-
CANCEL_DEVICE_TIMING_CONTROL:
|
|
196
|
+
GEO: "geo", // 上报地理位置信息
|
|
197
|
+
PUSH_WEATHER: "push_weather", // 请求云端推送天气消息
|
|
198
|
+
SET_DEVICE_TIMING_CONTROL: "set_device_timing_control", // 设置一个设备控制任务(notify task)
|
|
199
|
+
CANCEL_DEVICE_TIMING_CONTROL: "cancel_device_timing_control", // 取消某个设备控制任务(delete task)
|
|
200
200
|
};
|
|
201
201
|
|
|
202
202
|
// 快速构成智能客服消息对象
|
|
@@ -210,20 +210,21 @@ async function genMsg(type, msgType, payload) {
|
|
|
210
210
|
const baseMsg = {
|
|
211
211
|
MsgType: msgType,
|
|
212
212
|
[payloadKey]: payload,
|
|
213
|
-
MsgId: id.replace(/-/g,
|
|
213
|
+
MsgId: id.replace(/-/g, ""),
|
|
214
|
+
SessionId: global.base.messageManager.sessionId,
|
|
214
215
|
};
|
|
215
|
-
const activeAddr = await storage.get(
|
|
216
|
-
const accountData = await storage.get(
|
|
216
|
+
const activeAddr = await storage.get("activeAddr");
|
|
217
|
+
const accountData = await storage.get("accountData");
|
|
217
218
|
|
|
218
|
-
if (type ===
|
|
219
|
+
if (type === "send") {
|
|
219
220
|
// 当前用户发出
|
|
220
221
|
baseMsg.FromUserId = accountData.user.user_id;
|
|
221
222
|
baseMsg.FromAddrId = activeAddr.address_id;
|
|
222
|
-
baseMsg.ToUserId =
|
|
223
|
+
baseMsg.ToUserId = "client";
|
|
223
224
|
baseMsg.ToAddrId = activeAddr.address_id;
|
|
224
|
-
} else if (type ===
|
|
225
|
+
} else if (type === "get") {
|
|
225
226
|
// 当前用户收到
|
|
226
|
-
baseMsg.FromUserId =
|
|
227
|
+
baseMsg.FromUserId = "client";
|
|
227
228
|
baseMsg.FromAddrId = activeAddr.address_id;
|
|
228
229
|
baseMsg.ToUserId = accountData.user.user_id;
|
|
229
230
|
baseMsg.ToAddrId = activeAddr.address_id;
|
|
@@ -235,13 +236,13 @@ async function genMsg(type, msgType, payload) {
|
|
|
235
236
|
function preZero(num, digit = 2) {
|
|
236
237
|
num = num.toString();
|
|
237
238
|
while (num.length < digit) {
|
|
238
|
-
num =
|
|
239
|
+
num = "0" + num;
|
|
239
240
|
}
|
|
240
241
|
return num;
|
|
241
242
|
}
|
|
242
243
|
|
|
243
244
|
function isDef(val) {
|
|
244
|
-
return typeof val !==
|
|
245
|
+
return typeof val !== "undefined";
|
|
245
246
|
}
|
|
246
247
|
|
|
247
248
|
// 商城客服消息对象
|
|
@@ -251,10 +252,10 @@ async function shopGenMsg(
|
|
|
251
252
|
inputText,
|
|
252
253
|
seq_id,
|
|
253
254
|
recver_id,
|
|
254
|
-
conversation_id =
|
|
255
|
+
conversation_id = "ipanel"
|
|
255
256
|
) {
|
|
256
257
|
// todo 检查入参格式
|
|
257
|
-
const accountData = await storage.get(
|
|
258
|
+
const accountData = await storage.get("accountData");
|
|
258
259
|
if (type === 1000) {
|
|
259
260
|
// 发消息
|
|
260
261
|
const client_msg_id = generate_uuid();
|
|
@@ -266,9 +267,9 @@ async function shopGenMsg(
|
|
|
266
267
|
nick_name: accountData?.user?.nickname, // 发送方 zhanghaoyy
|
|
267
268
|
face_url: accountData?.user?.icon_url
|
|
268
269
|
? `${ACCOUNT_SERVICE}/icon?file=${
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
:
|
|
270
|
+
accountData?.user?.icon_url
|
|
271
|
+
}&time=${new Date().getTime()}`
|
|
272
|
+
: "",
|
|
272
273
|
message_prop: message_prop,
|
|
273
274
|
message_data: inputText,
|
|
274
275
|
};
|
|
@@ -276,8 +277,8 @@ async function shopGenMsg(
|
|
|
276
277
|
id: seq_id,
|
|
277
278
|
type: 1000, // 1000 request 2000 response
|
|
278
279
|
ecode: 0,
|
|
279
|
-
emessage:
|
|
280
|
-
route:
|
|
280
|
+
emessage: "",
|
|
281
|
+
route: "message_post",
|
|
281
282
|
data: JSON.stringify(params),
|
|
282
283
|
};
|
|
283
284
|
return proto;
|
|
@@ -286,16 +287,16 @@ async function shopGenMsg(
|
|
|
286
287
|
|
|
287
288
|
// 协议
|
|
288
289
|
const generate_uuid = () => {
|
|
289
|
-
return
|
|
290
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
290
291
|
var r = (Math.random() * 16) | 0,
|
|
291
|
-
v = c ===
|
|
292
|
+
v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
292
293
|
return v.toString(16);
|
|
293
294
|
});
|
|
294
295
|
};
|
|
295
296
|
|
|
296
297
|
// APP大数据上报:https://git.ipanel.cn/1/wdoc/?p=YjM4MmY1MW.2【iPanelCloud后台管理工作组/ipanel_collect_report_data_doc】
|
|
297
298
|
async function appReport(tag, extraData = {}) {
|
|
298
|
-
const token = await storage.get(
|
|
299
|
+
const token = await storage.get("accessToken");
|
|
299
300
|
if (!token) {
|
|
300
301
|
return;
|
|
301
302
|
}
|
|
@@ -304,7 +305,7 @@ async function appReport(tag, extraData = {}) {
|
|
|
304
305
|
return;
|
|
305
306
|
}
|
|
306
307
|
|
|
307
|
-
const accountData = await storage.get(
|
|
308
|
+
const accountData = await storage.get("accountData");
|
|
308
309
|
|
|
309
310
|
const data = {
|
|
310
311
|
upTime: Date.now(),
|
|
@@ -312,52 +313,52 @@ async function appReport(tag, extraData = {}) {
|
|
|
312
313
|
userId: accountData?.user?.user_id,
|
|
313
314
|
accountId: accountData?.account?.account_id,
|
|
314
315
|
appTermType:
|
|
315
|
-
Platform.OS ===
|
|
316
|
+
Platform.OS === "ios"
|
|
316
317
|
? 2020 // IOS设备应用
|
|
317
|
-
: Platform.OS ===
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
: Platform.OS === "android"
|
|
319
|
+
? 2010 // Android设备应用
|
|
320
|
+
: 2000, // 无法确定Android还是IOS,报2000
|
|
320
321
|
...extraData,
|
|
321
322
|
};
|
|
322
323
|
|
|
323
|
-
const res = await reportBigData(tag, appID, data).catch(err => {
|
|
324
|
-
console.log(
|
|
324
|
+
const res = await reportBigData(tag, appID, data).catch((err) => {
|
|
325
|
+
console.log("reportBigData", err);
|
|
325
326
|
});
|
|
326
|
-
console.log(
|
|
327
|
+
console.log("reportBigData", tag, res);
|
|
327
328
|
}
|
|
328
329
|
|
|
329
330
|
const checkToken = async () => {
|
|
330
|
-
const access_token = await storage.get(
|
|
331
|
-
const refresh_token = await storage.get(
|
|
331
|
+
const access_token = await storage.get("accessToken");
|
|
332
|
+
const refresh_token = await storage.get("refreshToken");
|
|
332
333
|
|
|
333
334
|
const logout = () => {
|
|
334
|
-
Alert.alert(
|
|
335
|
+
Alert.alert("登录过期,请重新登录!", "", [
|
|
335
336
|
{
|
|
336
|
-
text:
|
|
337
|
+
text: "好",
|
|
337
338
|
onPress: async () => {
|
|
338
|
-
await storage.set(
|
|
339
|
-
await storage.set(
|
|
340
|
-
await storage.set(
|
|
341
|
-
replace(
|
|
339
|
+
await storage.set("accessToken", null);
|
|
340
|
+
await storage.set("refreshToken", null);
|
|
341
|
+
await storage.set("homedAccessToken", null);
|
|
342
|
+
replace("Login");
|
|
342
343
|
},
|
|
343
344
|
},
|
|
344
345
|
]);
|
|
345
346
|
};
|
|
346
347
|
|
|
347
|
-
return new Promise(async resolve => {
|
|
348
|
+
return new Promise(async (resolve) => {
|
|
348
349
|
try {
|
|
349
|
-
const accountType = await storage.get(
|
|
350
|
+
const accountType = await storage.get("accountType");
|
|
350
351
|
const res = await refreshToken(
|
|
351
352
|
{
|
|
352
353
|
access_token,
|
|
353
354
|
refresh_token,
|
|
354
355
|
},
|
|
355
|
-
accountType
|
|
356
|
+
accountType
|
|
356
357
|
);
|
|
357
358
|
if (res.code === 0) {
|
|
358
|
-
console.log(
|
|
359
|
-
await storage.set(
|
|
360
|
-
await storage.set(
|
|
359
|
+
console.log("刷新token", res);
|
|
360
|
+
await storage.set("accessToken", res.result.access_token);
|
|
361
|
+
await storage.set("refreshToken", res.result.refresh_token);
|
|
361
362
|
resolve(true);
|
|
362
363
|
} else {
|
|
363
364
|
resolve(false);
|
package/app/utils/config.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {NativeModules} from
|
|
1
|
+
import { NativeModules } from "react-native";
|
|
2
2
|
|
|
3
3
|
// dev/alpha/release
|
|
4
|
-
const envVersion = NativeModules?.RNToNativeEmitter?.serverCluster ||
|
|
4
|
+
const envVersion = NativeModules?.RNToNativeEmitter?.serverCluster || "alpha";
|
|
5
5
|
// NativeModules?.RNToNativeEmitter?.serverCluster || 'dev'; /*本地测试*/
|
|
6
6
|
// `ipanelcloud`域名(因APP是`开发版`、`测试版`或`正式版`而不同)
|
|
7
7
|
// NativeModules.RNToNativeEmitter.appName = '禺乐慧家'
|
|
8
8
|
const appName = NativeModules?.RNToNativeEmitter?.appName;
|
|
9
9
|
const packageName = NativeModules?.RNToNativeEmitter?.packageName;
|
|
10
10
|
|
|
11
|
-
console.log(
|
|
12
|
-
console.log(
|
|
11
|
+
console.log("当前app名称", appName);
|
|
12
|
+
console.log("当前app包名", packageName);
|
|
13
13
|
|
|
14
14
|
let IPANEL_CLOUD_DOMAIN;
|
|
15
|
-
if (appName
|
|
16
|
-
IPANEL_CLOUD_DOMAIN =
|
|
15
|
+
if (["禺乐慧家", "悦慧家"].includes(appName)) {
|
|
16
|
+
IPANEL_CLOUD_DOMAIN = "szjtyfw.panyu.gd.cn";
|
|
17
17
|
} else {
|
|
18
18
|
switch (envVersion) {
|
|
19
|
-
case
|
|
20
|
-
IPANEL_CLOUD_DOMAIN =
|
|
19
|
+
case "release":
|
|
20
|
+
IPANEL_CLOUD_DOMAIN = "ipanelcloud.ipanel.cn"; // 正式集群
|
|
21
21
|
break;
|
|
22
|
-
case
|
|
23
|
-
IPANEL_CLOUD_DOMAIN =
|
|
22
|
+
case "dev":
|
|
23
|
+
IPANEL_CLOUD_DOMAIN = "dev.ipanelcloud2.ipanel.cn"; // 开发集群
|
|
24
24
|
break;
|
|
25
25
|
default: // alpha
|
|
26
|
-
IPANEL_CLOUD_DOMAIN =
|
|
26
|
+
IPANEL_CLOUD_DOMAIN = "ipanelcloud2.ipanel.cn"; // 测试集群
|
|
27
27
|
break;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -33,17 +33,17 @@ const config = {
|
|
|
33
33
|
IPANEL_CLOUD_BASE_URI: `https://${IPANEL_CLOUD_DOMAIN}:50443`,
|
|
34
34
|
IPANEL_CLOUD_WSS_URI: `wss://${IPANEL_CLOUD_DOMAIN}:50443`,
|
|
35
35
|
IPANEL_CLOUD_BASE_ADG_URI:
|
|
36
|
-
envVersion ===
|
|
36
|
+
envVersion === "dev"
|
|
37
37
|
? `http://${IPANEL_CLOUD_DOMAIN}:50080`
|
|
38
38
|
: `https://${IPANEL_CLOUD_DOMAIN}:50443`,
|
|
39
39
|
// 禺乐慧家模块版本相关api跟着公司alpha走
|
|
40
|
-
PANYU_MODULE_VERSION_URI:
|
|
40
|
+
PANYU_MODULE_VERSION_URI: "https://ipanelcloud2.ipanel.cn:50443",
|
|
41
41
|
|
|
42
42
|
// 模拟配置本地测试用的app版本号,用于模拟执行一些依赖app版本的逻辑
|
|
43
|
-
LOCALTEST_APP_VERSION:
|
|
43
|
+
LOCALTEST_APP_VERSION: "9.9.9",
|
|
44
44
|
|
|
45
45
|
// 模拟配置本地测试用的appName,用于模拟加载不同APP的模块,当前支持"爱家宝"、"安电工"
|
|
46
|
-
LOCALTEST_APP_NAME:
|
|
46
|
+
LOCALTEST_APP_NAME: "禺乐慧家",
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
export default config;
|