ipanel-rnapp-ajb-base 1.0.39 → 1.0.40
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/base.js +31 -8
- package/app/hooks/useMessageManager.js +124 -40
- package/app/screens/CommonScreens/BossScreen/index.js +64 -39
- package/app/utils/common.js +8 -0
- package/package.json +3 -3
package/app/base.js
CHANGED
|
@@ -60,8 +60,9 @@ global.base.messageManager = {
|
|
|
60
60
|
* }
|
|
61
61
|
*/
|
|
62
62
|
},
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
addrMsgDataUpdateTimer: null,
|
|
64
|
+
ws: null,
|
|
65
|
+
connectStatus: undefined,
|
|
65
66
|
sessionId: "",
|
|
66
67
|
|
|
67
68
|
getAddrMsgList: function (addrId) {
|
|
@@ -72,6 +73,10 @@ global.base.messageManager = {
|
|
|
72
73
|
|
|
73
74
|
// 用户读取的最新一条消息
|
|
74
75
|
readLatestMsg: function (msg) {
|
|
76
|
+
if (msg.FromUserId !== "cloud") {
|
|
77
|
+
// 只针对云端消息设置已读
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
75
80
|
if (global.base.messageManager.addrMsgData[msg.FromAddrId]) {
|
|
76
81
|
if (
|
|
77
82
|
global.base.messageManager.addrMsgData[msg.FromAddrId]
|
|
@@ -83,10 +88,10 @@ global.base.messageManager = {
|
|
|
83
88
|
msg.MsgId;
|
|
84
89
|
|
|
85
90
|
// 更新本地存储
|
|
86
|
-
clearTimeout(global.base.messageManager.
|
|
87
|
-
global.base.messageManager.
|
|
91
|
+
clearTimeout(global.base.messageManager.addrMsgDataUpdateTimer);
|
|
92
|
+
global.base.messageManager.addrMsgDataUpdateTimer = setTimeout(() => {
|
|
88
93
|
storage.set("addrMsgData", global.base.messageManager.addrMsgData);
|
|
89
|
-
},
|
|
94
|
+
}, 300);
|
|
90
95
|
|
|
91
96
|
eventBus.emit(EVENTS.MESSAGE.UNREAD_COUNT_UPDATE);
|
|
92
97
|
}
|
|
@@ -114,7 +119,7 @@ global.base.messageManager = {
|
|
|
114
119
|
},
|
|
115
120
|
|
|
116
121
|
isConnected: function () {
|
|
117
|
-
return !!global.base.messageManager.
|
|
122
|
+
return !!global.base.messageManager.ws;
|
|
118
123
|
},
|
|
119
124
|
|
|
120
125
|
setSessionId: function (sid) {
|
|
@@ -123,8 +128,8 @@ global.base.messageManager = {
|
|
|
123
128
|
|
|
124
129
|
sendMessage: async function (message) {
|
|
125
130
|
console.log("ws.send", message);
|
|
126
|
-
global.base.messageManager.
|
|
127
|
-
global.base.messageManager.
|
|
131
|
+
global.base.messageManager.ws &&
|
|
132
|
+
global.base.messageManager.ws.send(JSON.stringify(message));
|
|
128
133
|
eventBus.emit(EVENTS.MESSAGE.ADD, message);
|
|
129
134
|
},
|
|
130
135
|
|
|
@@ -147,6 +152,24 @@ global.base.messageManager = {
|
|
|
147
152
|
await storage.set("addrMsgData", global.base.messageManager.addrMsgData);
|
|
148
153
|
},
|
|
149
154
|
|
|
155
|
+
removeMsg(msgId) {
|
|
156
|
+
const addrMsgData = global.base.messageManager.addrMsgData;
|
|
157
|
+
|
|
158
|
+
for (let addrId in addrMsgData) {
|
|
159
|
+
const msgData = addrMsgData[addrId];
|
|
160
|
+
const msgIdx = msgData.messages.findIndex((msg) => msg.MsgId === msgId);
|
|
161
|
+
if (msgIdx !== -1) {
|
|
162
|
+
msgData.messages.splice(msgIdx, 1);
|
|
163
|
+
// 更新本地存储
|
|
164
|
+
clearTimeout(global.base.messageManager.addrMsgDataUpdateTimer);
|
|
165
|
+
global.base.messageManager.addrMsgDataUpdateTimer = setTimeout(() => {
|
|
166
|
+
storage.set("addrMsgData", addrMsgData);
|
|
167
|
+
}, 300);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
|
|
150
173
|
genMsg,
|
|
151
174
|
MSG_TYPES,
|
|
152
175
|
MSG_EVENT_TYPES,
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback, useRef } from "react";
|
|
2
|
-
import { PermissionsAndroid, Platform } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { format } from "date-fns";
|
|
5
|
-
|
|
6
2
|
import storage from "../storage";
|
|
7
3
|
import eventBus, { EVENTS } from "../eventBus";
|
|
8
4
|
import config from "../utils/config";
|
|
9
|
-
import { MSG_TYPES, genMsg } from "../utils/common";
|
|
5
|
+
import { MSG_TYPES, genMsg, CONNECT_STATUS } from "../utils/common";
|
|
10
6
|
import applyPermissions from "../utils/applyPermissions";
|
|
11
7
|
|
|
12
|
-
let
|
|
8
|
+
let wsInstance = null;
|
|
13
9
|
|
|
14
10
|
let tryConnectTimes = 0;
|
|
11
|
+
let isReConnecting = false;
|
|
12
|
+
const MAX_CONNECT_TIMES = 7;
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* 智能客服中心JS
|
|
@@ -82,26 +80,48 @@ let aiModel = "CUSTOMER_SERVICE";
|
|
|
82
80
|
|
|
83
81
|
let storageTimer;
|
|
84
82
|
|
|
83
|
+
// 缓存正在发送中的消息,MsgId->Msg,当消息发送成功或发送失败时,需要将其从缓存中删除
|
|
84
|
+
const pendingMsgMap = {};
|
|
85
|
+
|
|
85
86
|
const UseMessageManager = () => {
|
|
86
|
-
const ws = useRef(null);
|
|
87
87
|
const connectedAddressId = useRef(null);
|
|
88
88
|
|
|
89
89
|
const sendMessage = useCallback((msg) => {
|
|
90
|
-
|
|
90
|
+
// 给用户发送的消息追加Status字段,此时消息是“未发送态”,如果未连接且重连失败,则将状态改为“发送失败态”
|
|
91
|
+
// 然后先直接把正在发送的消息显示出来,待消息发送成功或失败时再更新消息状态
|
|
92
|
+
msg.Status = "pending";
|
|
93
|
+
eventBus.emit(EVENTS.MESSAGE.ADD, msg);
|
|
94
|
+
|
|
95
|
+
if (wsInstance) {
|
|
91
96
|
console.log("ws.send");
|
|
92
|
-
|
|
93
|
-
eventBus.emit(EVENTS.MESSAGE.ADD, msg);
|
|
97
|
+
wsInstance.send(JSON.stringify(msg));
|
|
94
98
|
} else {
|
|
95
99
|
// 未连接,触发重连
|
|
96
100
|
reConnect(() => {
|
|
97
101
|
console.log("ws.send");
|
|
98
|
-
|
|
99
|
-
eventBus.emit(EVENTS.MESSAGE.ADD, msg);
|
|
102
|
+
wsInstance.send(JSON.stringify(msg));
|
|
100
103
|
});
|
|
101
104
|
}
|
|
102
105
|
}, []);
|
|
103
106
|
|
|
104
107
|
const connectMsgServer = async (connectSuccessCallback) => {
|
|
108
|
+
if (
|
|
109
|
+
global.base.messageManager.connectStatus === CONNECT_STATUS.CONNECTING ||
|
|
110
|
+
(global.base.messageManager.connectStatus === CONNECT_STATUS.CONNECTED &&
|
|
111
|
+
wsInstance &&
|
|
112
|
+
wsInstance.readyState < 2)
|
|
113
|
+
) {
|
|
114
|
+
console.log(
|
|
115
|
+
`useMessageManager connectMsgServer skipped, connectStatus=${global.base.messageManager.connectStatus}, ws.readyState=${wsInstance?.readyState}`
|
|
116
|
+
);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
global.base.messageManager.connectStatus = CONNECT_STATUS.CONNECTING;
|
|
120
|
+
eventBus.emit(
|
|
121
|
+
EVENTS.MESSAGE.CONNECT_STATUS_CHANGE,
|
|
122
|
+
global.base.messageManager.connectStatus
|
|
123
|
+
);
|
|
124
|
+
|
|
105
125
|
console.log("connectMsgServer start");
|
|
106
126
|
const token = await storage.get("accessToken");
|
|
107
127
|
const accountData = await storage.get("accountData");
|
|
@@ -135,35 +155,71 @@ const UseMessageManager = () => {
|
|
|
135
155
|
}
|
|
136
156
|
|
|
137
157
|
// 缓存全局智能客服websocket连接
|
|
138
|
-
global.base.messageManager.wsRef = ws;
|
|
139
158
|
global.base.messageManager.connectMsgServer = connectMsgServer;
|
|
140
159
|
|
|
141
160
|
const url = `${wsUrl}?${connectParams.join("&")}`;
|
|
142
161
|
console.log("useMessageManager ws url:", url);
|
|
143
162
|
|
|
144
|
-
|
|
145
|
-
|
|
163
|
+
wsInstance = new WebSocket(url);
|
|
164
|
+
global.base.messageManager.ws = wsInstance;
|
|
165
|
+
wsInstance.onopen = () => {
|
|
146
166
|
console.log("useMessageManager ws open");
|
|
147
|
-
connectStatus =
|
|
167
|
+
global.base.messageManager.connectStatus = CONNECT_STATUS.CONNECTED;
|
|
148
168
|
tryConnectTimes = 0;
|
|
149
|
-
|
|
169
|
+
isReConnecting = false;
|
|
170
|
+
eventBus.emit(
|
|
171
|
+
EVENTS.MESSAGE.CONNECT_STATUS_CHANGE,
|
|
172
|
+
global.base.messageManager.connectStatus
|
|
173
|
+
);
|
|
150
174
|
eventBus.emit(EVENTS.MESSAGE.UNREAD_COUNT_UPDATE);
|
|
151
175
|
|
|
152
176
|
connectSuccessCallback && connectSuccessCallback();
|
|
153
177
|
};
|
|
154
|
-
|
|
178
|
+
wsInstance.onmessage = ({ data }) => {
|
|
179
|
+
// 处理来自云端的消息
|
|
155
180
|
try {
|
|
156
181
|
const msg = JSON.parse(data);
|
|
157
|
-
if (msg.MsgType === "chat" && msg.Chat.type === "tool_call_begin") {
|
|
158
|
-
const toolCallId = msg.Chat.payload.tool_calls[0].id;
|
|
159
|
-
const messages = global.base.messageManager.getAddrMsgList(
|
|
160
|
-
activeAddr.address_id
|
|
161
|
-
);
|
|
162
182
|
|
|
183
|
+
const messages = global.base.messageManager.getAddrMsgList(
|
|
184
|
+
activeAddr.address_id
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
// 用户每发送一条消息到云端,云端都会响应一条确认事件消息,用于更新该消息的本地MsgId为服务器生成的ID
|
|
188
|
+
if (
|
|
189
|
+
msg.MsgType === MSG_TYPES.EVENT &&
|
|
190
|
+
msg.Event.Type === "user_msg_received"
|
|
191
|
+
) {
|
|
192
|
+
const targetMsg = messages.find(
|
|
193
|
+
(item) => item.MsgId === msg.Event.Data.MsgId // 本地产生的ID
|
|
194
|
+
);
|
|
195
|
+
if (targetMsg) {
|
|
196
|
+
targetMsg.MsgId = msg.MsgId; // 服务器产生的ID
|
|
197
|
+
targetMsg.CreateTime = msg.CreateTime;
|
|
198
|
+
// 将消息从“未发送态”修改为“已发送态”(即删除Status字段)
|
|
199
|
+
delete targetMsg.Status;
|
|
200
|
+
delete pendingMsgMap[msg.Event.Data.MsgId];
|
|
201
|
+
|
|
202
|
+
// 避免频繁写入本地存储,在ios可能会导致闪退
|
|
203
|
+
clearTimeout(storageTimer);
|
|
204
|
+
storageTimer = setTimeout(() => {
|
|
205
|
+
storage.set(
|
|
206
|
+
"addrMsgData",
|
|
207
|
+
global.base.messageManager.addrMsgData
|
|
208
|
+
);
|
|
209
|
+
}, 300);
|
|
210
|
+
}
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
// AI大模型工具消息合并处理
|
|
214
|
+
if (
|
|
215
|
+
msg.MsgType === MSG_TYPES.CHAT &&
|
|
216
|
+
msg.Chat.type === "tool_call_begin"
|
|
217
|
+
) {
|
|
218
|
+
const toolCallId = msg.Chat.payload.tool_calls[0].id;
|
|
163
219
|
if (
|
|
164
220
|
messages.find(
|
|
165
221
|
(msg) =>
|
|
166
|
-
msg.MsgType ===
|
|
222
|
+
msg.MsgType === MSG_TYPES.CHAT &&
|
|
167
223
|
msg.Chat.type === "end" &&
|
|
168
224
|
msg.Chat.payload.message.tool_calls &&
|
|
169
225
|
msg.Chat.payload.message.tool_calls[0].id === toolCallId
|
|
@@ -178,20 +234,28 @@ const UseMessageManager = () => {
|
|
|
178
234
|
console.log("msg不合法", e);
|
|
179
235
|
}
|
|
180
236
|
};
|
|
181
|
-
|
|
237
|
+
wsInstance.onerror = (err) => {
|
|
182
238
|
console.log("useMessageManager ws onerror", err);
|
|
183
|
-
connectStatus =
|
|
184
|
-
eventBus.emit(
|
|
239
|
+
global.base.messageManager.connectStatus = CONNECT_STATUS.DISCONNECTED;
|
|
240
|
+
eventBus.emit(
|
|
241
|
+
EVENTS.MESSAGE.CONNECT_STATUS_CHANGE,
|
|
242
|
+
global.base.messageManager.connectStatus
|
|
243
|
+
);
|
|
185
244
|
};
|
|
186
|
-
|
|
245
|
+
wsInstance.onclose = (event) => {
|
|
187
246
|
console.log("useMessageManager ws onclose", event);
|
|
188
247
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
248
|
+
wsInstance = null;
|
|
249
|
+
global.base.messageManager.ws = null;
|
|
250
|
+
global.base.messageManager.connectStatus = CONNECT_STATUS.DISCONNECTED;
|
|
251
|
+
eventBus.emit(
|
|
252
|
+
EVENTS.MESSAGE.CONNECT_STATUS_CHANGE,
|
|
253
|
+
global.base.messageManager.connectStatus
|
|
254
|
+
);
|
|
192
255
|
|
|
193
256
|
// 触发重连
|
|
194
257
|
setTimeout(() => {
|
|
258
|
+
isReConnecting = false;
|
|
195
259
|
reConnect(connectSuccessCallback);
|
|
196
260
|
}, 1000);
|
|
197
261
|
};
|
|
@@ -202,22 +266,38 @@ const UseMessageManager = () => {
|
|
|
202
266
|
|
|
203
267
|
// 正常主动关闭连接,重置重连次数
|
|
204
268
|
tryConnectTimes = 0;
|
|
269
|
+
isReConnecting = false;
|
|
205
270
|
|
|
206
|
-
|
|
207
|
-
|
|
271
|
+
if (wsInstance) {
|
|
272
|
+
wsInstance.close();
|
|
273
|
+
}
|
|
208
274
|
};
|
|
209
275
|
|
|
210
276
|
const reConnect = async (connectSuccessCallback) => {
|
|
277
|
+
if (isReConnecting) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
isReConnecting = true;
|
|
211
281
|
console.log("useMessageManager reConnect", tryConnectTimes);
|
|
212
|
-
if (tryConnectTimes <
|
|
282
|
+
if (tryConnectTimes < MAX_CONNECT_TIMES) {
|
|
213
283
|
// 重连ws
|
|
214
284
|
tryConnectTimes++;
|
|
215
285
|
connectMsgServer(connectSuccessCallback);
|
|
216
286
|
} else {
|
|
217
287
|
// 重连N次ws失败,不再重试。等用户自己进入智能客服页面或者发送消息时触发重连
|
|
218
288
|
tryConnectTimes = 0;
|
|
219
|
-
connectStatus =
|
|
220
|
-
|
|
289
|
+
global.base.messageManager.connectStatus = CONNECT_STATUS.DISCONNECTED;
|
|
290
|
+
isReConnecting = false;
|
|
291
|
+
eventBus.emit(
|
|
292
|
+
EVENTS.MESSAGE.CONNECT_STATUS_CHANGE,
|
|
293
|
+
global.base.messageManager.connectStatus
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
// 所有正在发送的消息全部失败,然后清空pendingMsgMap缓存
|
|
297
|
+
Object.keys(pendingMsgMap).forEach((MsgId) => {
|
|
298
|
+
pendingMsgMap[MsgId].Status = "fail";
|
|
299
|
+
delete pendingMsgMap[MsgId];
|
|
300
|
+
});
|
|
221
301
|
}
|
|
222
302
|
};
|
|
223
303
|
|
|
@@ -295,6 +375,11 @@ const UseMessageManager = () => {
|
|
|
295
375
|
useEffect(() => {
|
|
296
376
|
// 新增并显示一条消息
|
|
297
377
|
const onMessageAdd = (msg) => {
|
|
378
|
+
if (msg.MsgType === MSG_TYPES.EVENT) {
|
|
379
|
+
// 事件消息不持久化保存,也不渲染
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
|
|
298
383
|
if (!global.base.messageManager.addrMsgData[msg.FromAddrId]) {
|
|
299
384
|
global.base.messageManager.addrMsgData[msg.FromAddrId] = {
|
|
300
385
|
messages: [],
|
|
@@ -341,8 +426,6 @@ const UseMessageManager = () => {
|
|
|
341
426
|
}
|
|
342
427
|
};
|
|
343
428
|
|
|
344
|
-
connectStatus = -1;
|
|
345
|
-
eventBus.emit(EVENTS.MESSAGE.CONNECT_STATUS_CHANGE, connectStatus);
|
|
346
429
|
// requestCameraPermission();
|
|
347
430
|
connectMsgServer();
|
|
348
431
|
|
|
@@ -470,8 +553,9 @@ const UseMessageManager = () => {
|
|
|
470
553
|
aiModel = model;
|
|
471
554
|
|
|
472
555
|
// 触发重新连接
|
|
473
|
-
|
|
474
|
-
|
|
556
|
+
if (wsInstance) {
|
|
557
|
+
wsInstance.close();
|
|
558
|
+
}
|
|
475
559
|
};
|
|
476
560
|
|
|
477
561
|
return {
|
|
@@ -15,11 +15,15 @@ export default ({ navigation, route }) => {
|
|
|
15
15
|
}, []);
|
|
16
16
|
const init = async () => {
|
|
17
17
|
const accountData = await storage.get("accountData");
|
|
18
|
+
console.log("init", accountData, "accountData");
|
|
18
19
|
const binding = 1; // 1:绑定,0:解绑.
|
|
19
20
|
const redirect_uri =
|
|
20
21
|
"https://ipanelcloud2.ipanel.cn:50443/iapp/ajbstatic/bind_boss_account/"; // 绑定后跳转地址
|
|
21
22
|
const state2 = generateRandomString(8);
|
|
22
23
|
setState(state2);
|
|
24
|
+
console.log(
|
|
25
|
+
`https://boss.ipanel.cn/ipanelTask/api/cas_open/isport/Isport_cloud_mall_c/binding?agentid=133&oauth2_id=72d2453f689fc99548187dca4b922a5b&redirect_uri=${redirect_uri}&open_id=${accountData.user?.user_id}&binding=${binding}&scope=snsapi_privateinfo&response_type=code&state=${state2}`
|
|
26
|
+
);
|
|
23
27
|
setUri(
|
|
24
28
|
`https://boss.ipanel.cn/ipanelTask/api/cas_open/isport/Isport_cloud_mall_c/binding?agentid=133&oauth2_id=72d2453f689fc99548187dca4b922a5b&redirect_uri=${redirect_uri}&open_id=${accountData.user?.user_id}&binding=${binding}&scope=snsapi_privateinfo&response_type=code&state=${state2}`
|
|
25
29
|
);
|
|
@@ -38,7 +42,7 @@ export default ({ navigation, route }) => {
|
|
|
38
42
|
global.loading.hideLoading("正在绑定...");
|
|
39
43
|
if (res.code === 0) {
|
|
40
44
|
global.toast.showToast("绑定成功");
|
|
41
|
-
get_user_info();
|
|
45
|
+
await get_user_info();
|
|
42
46
|
// navigation.goBack();
|
|
43
47
|
} else {
|
|
44
48
|
navigation.goBack();
|
|
@@ -49,28 +53,33 @@ export default ({ navigation, route }) => {
|
|
|
49
53
|
};
|
|
50
54
|
|
|
51
55
|
const get_user_info = async () => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
try {
|
|
57
|
+
const res = await getUserInfo();
|
|
58
|
+
console.log(res, "getUserInfo");
|
|
59
|
+
if (
|
|
60
|
+
res?.code === 0 &&
|
|
61
|
+
res.result?.user_list &&
|
|
62
|
+
res.result?.user_list.length
|
|
63
|
+
) {
|
|
64
|
+
// const accountData = await storage.get('accountData');
|
|
65
|
+
// accountData.user.bind_list = res.result?.user_list[0].bind_list;
|
|
66
|
+
// await storage.set('accountData', accountData);
|
|
67
|
+
// const bossData = accountData.user.bind_list
|
|
68
|
+
const bossData = res.result?.user_list[0].bind_list.filter(item => {
|
|
69
|
+
return item.third_type === "boss";
|
|
70
|
+
});
|
|
71
|
+
console.log(bossData[0]);
|
|
72
|
+
if (bossData[0]) {
|
|
73
|
+
await storage.set("bossData", bossData[0]);
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
if (module === "shop") {
|
|
77
|
+
await get_assets();
|
|
78
|
+
} else {
|
|
79
|
+
navigation.goBack();
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error("get_user_info error:", error);
|
|
74
83
|
navigation.goBack();
|
|
75
84
|
}
|
|
76
85
|
};
|
|
@@ -86,7 +95,8 @@ export default ({ navigation, route }) => {
|
|
|
86
95
|
if (appID) {
|
|
87
96
|
params.appid = appID;
|
|
88
97
|
}
|
|
89
|
-
|
|
98
|
+
try {
|
|
99
|
+
const res = await getAssets(params);
|
|
90
100
|
if (res?.code === 0) {
|
|
91
101
|
if (
|
|
92
102
|
res?.result &&
|
|
@@ -97,12 +107,15 @@ export default ({ navigation, route }) => {
|
|
|
97
107
|
return item.currency === 20000;
|
|
98
108
|
});
|
|
99
109
|
if (current.length) {
|
|
100
|
-
storage.set("isportData", current[0]);
|
|
110
|
+
await storage.set("isportData", current[0]);
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
113
|
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error("get_assets error:", error);
|
|
116
|
+
} finally {
|
|
104
117
|
navigation.goBack();
|
|
105
|
-
}
|
|
118
|
+
}
|
|
106
119
|
};
|
|
107
120
|
|
|
108
121
|
const generateRandomString = length => {
|
|
@@ -120,20 +133,32 @@ export default ({ navigation, route }) => {
|
|
|
120
133
|
<View style={{ flex: 1 }}>
|
|
121
134
|
<ScreenBackHeader title="BOSS登录" />
|
|
122
135
|
<View style={{ flex: 1 }}>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
{!!uri && (
|
|
137
|
+
<WebView
|
|
138
|
+
bounces={false}
|
|
139
|
+
javaScriptEnabled={true}
|
|
140
|
+
useWebKit={true}
|
|
141
|
+
source={{
|
|
142
|
+
uri: uri,
|
|
143
|
+
headers: { "Cache-Control": "no-store" },
|
|
144
|
+
}}
|
|
145
|
+
incognito={true}
|
|
146
|
+
onMessage={onMessage}
|
|
147
|
+
onLoadStart={() => global.loading.showLoading()}
|
|
148
|
+
onLoadEnd={() => global.loading.hideLoading()}
|
|
149
|
+
onError={e => {
|
|
150
|
+
console.log("加载错误:", e.nativeEvent.description);
|
|
151
|
+
global.loading.hideLoading();
|
|
152
|
+
}}
|
|
153
|
+
// iOS 特定修复
|
|
154
|
+
// onShouldStartLoadWithRequest={request => {
|
|
155
|
+
// if (request.url.startsWith('file://')) {
|
|
156
|
+
// return true; // 允许加载本地文件
|
|
157
|
+
// }
|
|
158
|
+
// return true;
|
|
159
|
+
// }}
|
|
160
|
+
/>
|
|
161
|
+
)}
|
|
137
162
|
</View>
|
|
138
163
|
</View>
|
|
139
164
|
);
|
package/app/utils/common.js
CHANGED
|
@@ -263,6 +263,7 @@ const MSG_TYPES = {
|
|
|
263
263
|
VIDEO: "video",
|
|
264
264
|
EVENT: "event",
|
|
265
265
|
TEMPLATE: "template",
|
|
266
|
+
CHAT: "chat",
|
|
266
267
|
};
|
|
267
268
|
|
|
268
269
|
const MSG_EVENT_TYPES = {
|
|
@@ -452,6 +453,12 @@ const checkToken = async () => {
|
|
|
452
453
|
});
|
|
453
454
|
};
|
|
454
455
|
|
|
456
|
+
const CONNECT_STATUS = {
|
|
457
|
+
CONNECTING: -1,
|
|
458
|
+
CONNECTED: 0,
|
|
459
|
+
DISCONNECTED: 1,
|
|
460
|
+
};
|
|
461
|
+
|
|
455
462
|
export {
|
|
456
463
|
updateHomedToken,
|
|
457
464
|
initOperatorHomedTouristAccount,
|
|
@@ -465,4 +472,5 @@ export {
|
|
|
465
472
|
appReport,
|
|
466
473
|
checkToken,
|
|
467
474
|
updateApartmentToken,
|
|
475
|
+
CONNECT_STATUS,
|
|
468
476
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ipanel-rnapp-ajb-base",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"ipanelVersion": "1.0.
|
|
3
|
+
"version": "1.0.40",
|
|
4
|
+
"ipanelVersion": "1.0.529",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"keywords": [
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"postinstall": "node bin/local-dev.js"
|
|
15
15
|
}
|
|
16
|
-
}
|
|
16
|
+
}
|