ipanel-rnapp-ajb-base 1.0.11 → 1.0.13
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.
|
@@ -12,23 +12,27 @@ let connectStatus = -1; // -1 连接中 0 连接成功 1连接失败
|
|
|
12
12
|
let tryConnectTimes = 0;
|
|
13
13
|
let seq_id = 0;
|
|
14
14
|
|
|
15
|
+
// let customer_id = ''; // imchat的user_uid
|
|
16
|
+
|
|
17
|
+
// const ishopcs = 'http://192.168.36.241:9101';
|
|
18
|
+
|
|
15
19
|
/**
|
|
16
20
|
* 商城客服中心JS
|
|
17
21
|
*/
|
|
18
22
|
|
|
19
23
|
// 消息记录
|
|
20
|
-
storage.get('shopMessageList').then(msgList => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
24
|
+
// storage.get('shopMessageList').then(msgList => {
|
|
25
|
+
// if (typeof msgList === 'string') {
|
|
26
|
+
// try {
|
|
27
|
+
// msgList = JSON.parse(msgList);
|
|
28
|
+
// } catch (e) {
|
|
29
|
+
// console.log('msgList error', e, msgList);
|
|
30
|
+
// msgList = [];
|
|
31
|
+
// }
|
|
32
|
+
// }
|
|
33
|
+
// // console.log(msgList, '商城客服消息列表msgList');
|
|
34
|
+
// global.base.shopMessageManager.messages = msgList || [];
|
|
35
|
+
// });
|
|
32
36
|
|
|
33
37
|
// 当前是否处于智能客服转人工
|
|
34
38
|
// let isManualCustomServiceActive = false;
|
|
@@ -60,6 +64,27 @@ const ShopMessageManager = () => {
|
|
|
60
64
|
}
|
|
61
65
|
}, []);
|
|
62
66
|
|
|
67
|
+
// 获取im本人user_id
|
|
68
|
+
const getUserUid = () => {
|
|
69
|
+
let proto = {
|
|
70
|
+
id: seq_id,
|
|
71
|
+
type: 1000, // 1000 request 2000 response
|
|
72
|
+
ecode: 0,
|
|
73
|
+
emessage: '',
|
|
74
|
+
route: 'user_uid',
|
|
75
|
+
data: '',
|
|
76
|
+
};
|
|
77
|
+
sendShopImMessage(proto);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// 发送im消息,传参直接发
|
|
81
|
+
const sendShopImMessage = useCallback(params => {
|
|
82
|
+
console.log('发送im消息,传参直接发');
|
|
83
|
+
if (ws.current) {
|
|
84
|
+
ws.current.send(JSON.stringify(params));
|
|
85
|
+
}
|
|
86
|
+
}, []);
|
|
87
|
+
|
|
63
88
|
// 发送消息
|
|
64
89
|
const sendMessage = useCallback(msg => {
|
|
65
90
|
if (ws.current) {
|
|
@@ -96,9 +121,11 @@ const ShopMessageManager = () => {
|
|
|
96
121
|
connectCallback && connectCallback(null); // success
|
|
97
122
|
connectStatus = 0;
|
|
98
123
|
eventBus.emit(EVENTS.SHOPMESSAGE.CONNECT_STATUS_CHANGE, connectStatus);
|
|
124
|
+
getUserUid();
|
|
99
125
|
};
|
|
100
126
|
ws.current.onmessage = ({data}) => {
|
|
101
127
|
const msgData = JSON.parse(data);
|
|
128
|
+
console.log('msgDatamessage', msgData);
|
|
102
129
|
// 2000是接收自己发的消息
|
|
103
130
|
if (msgData.type === 1000) {
|
|
104
131
|
const msg = JSON.parse(msgData?.data);
|
|
@@ -112,6 +139,24 @@ const ShopMessageManager = () => {
|
|
|
112
139
|
// 获取在线用户
|
|
113
140
|
const msg = JSON.parse(msgData?.data);
|
|
114
141
|
eventBus.emit(EVENTS.SHOPMESSAGE.ONLINE_LIST, msg);
|
|
142
|
+
} else if (msgData.type === 2000 && msgData.route === 'user_uid') {
|
|
143
|
+
// 获取user_id
|
|
144
|
+
// customer_id = msgData?.data;
|
|
145
|
+
if (msgData?.data) {
|
|
146
|
+
storage.set('shopImData', {
|
|
147
|
+
customer_id: msgData?.data,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
} else if (
|
|
151
|
+
msgData.type === 2000 &&
|
|
152
|
+
(msgData.route === 'message_list_history' ||
|
|
153
|
+
msgData.route === 'message_list_new')
|
|
154
|
+
) {
|
|
155
|
+
if (msgData?.data) {
|
|
156
|
+
console.log(msgData, 'message_list_new');
|
|
157
|
+
const msgList = JSON.parse(msgData?.data);
|
|
158
|
+
global.base.shopMessageManager.messages = msgList || [];
|
|
159
|
+
}
|
|
115
160
|
}
|
|
116
161
|
};
|
|
117
162
|
ws.current.onerror = err => {
|
|
@@ -216,13 +261,13 @@ const ShopMessageManager = () => {
|
|
|
216
261
|
msg.CreateTime = new Date().getTime();
|
|
217
262
|
console.log(msg, '商城客服msg');
|
|
218
263
|
// console.log(global.base.shopMessageManager.messages, '22');
|
|
219
|
-
global.base.shopMessageManager.messages.push(msg);
|
|
264
|
+
// global.base.shopMessageManager.messages.push(msg);
|
|
220
265
|
|
|
221
266
|
// // save to local 存到本地
|
|
222
|
-
storage.set(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
);
|
|
267
|
+
// storage.set(
|
|
268
|
+
// 'shopMessageList',
|
|
269
|
+
// global.base.shopMessageManager.messages.slice(-100),
|
|
270
|
+
// );
|
|
226
271
|
// storage.remove('shopMessageList');
|
|
227
272
|
|
|
228
273
|
eventBus.emit(EVENTS.SHOPMESSAGE.RENDER, msg);
|
|
@@ -293,6 +338,7 @@ const ShopMessageManager = () => {
|
|
|
293
338
|
|
|
294
339
|
return {
|
|
295
340
|
sendMessage,
|
|
341
|
+
sendShopImMessage,
|
|
296
342
|
getOnlineUser,
|
|
297
343
|
// requestShopManualCustomService,
|
|
298
344
|
// exitShopManualCustomService,
|
|
@@ -167,7 +167,9 @@ function HomeTabScreen({navigation, route}) {
|
|
|
167
167
|
});
|
|
168
168
|
} else {
|
|
169
169
|
// 单业务包开发调试环境
|
|
170
|
-
const component = await global.base.getRemoteComponentByName(
|
|
170
|
+
const component = await global.base.getRemoteComponentByName(
|
|
171
|
+
'__BASE_SINGLETON_MODE_APP__',
|
|
172
|
+
);
|
|
171
173
|
typeof component?.registerStackScreens === 'function' &&
|
|
172
174
|
component.registerStackScreens();
|
|
173
175
|
tabs = [
|
|
@@ -293,11 +295,16 @@ function HomeTabScreen({navigation, route}) {
|
|
|
293
295
|
getManualCustomServiceActiveFlag;
|
|
294
296
|
|
|
295
297
|
// 商城客服
|
|
296
|
-
const {
|
|
297
|
-
|
|
298
|
+
const {
|
|
299
|
+
handleShopTextSubmit,
|
|
300
|
+
handleShopMediaSelect,
|
|
301
|
+
getOnlineUser,
|
|
302
|
+
sendShopImMessage,
|
|
303
|
+
} = ShopMessageManager();
|
|
298
304
|
global.base.shopMessageManager.handleShopTextSubmit = handleShopTextSubmit;
|
|
299
305
|
global.base.shopMessageManager.handleShopMediaSelect = handleShopMediaSelect;
|
|
300
306
|
global.base.shopMessageManager.getOnlineUser = getOnlineUser;
|
|
307
|
+
global.base.shopMessageManager.sendShopImMessage = sendShopImMessage;
|
|
301
308
|
const renderCustomTabBar = props => {
|
|
302
309
|
return <CustomTabBar {...props} />;
|
|
303
310
|
};
|
|
@@ -95,7 +95,35 @@ export default class ScanQRCode extends Component {
|
|
|
95
95
|
//扫码后的操作
|
|
96
96
|
if (data) {
|
|
97
97
|
const routes = getState().routes;
|
|
98
|
-
if (
|
|
98
|
+
if (data.includes('action=redirect')) {
|
|
99
|
+
/**
|
|
100
|
+
* action=redirect 重定向APP页面
|
|
101
|
+
mop=ipanel operatorId(模块运营商,未来有可能废弃)
|
|
102
|
+
m=shop 商城模块
|
|
103
|
+
s=detail screenName
|
|
104
|
+
a/b/c 传给商城模块的参数
|
|
105
|
+
*/
|
|
106
|
+
const querys = data.substring(data.indexOf('?') + 1).split('&');
|
|
107
|
+
const params = {};
|
|
108
|
+
for (let i = 0; i < querys.length; i++) {
|
|
109
|
+
const temp = querys[i].split('=');
|
|
110
|
+
if (temp.length < 2) {
|
|
111
|
+
params[temp[0]] = '';
|
|
112
|
+
} else {
|
|
113
|
+
params[temp[0]] = temp[1];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (params.s) {
|
|
117
|
+
navigate({
|
|
118
|
+
name: params.s,
|
|
119
|
+
params,
|
|
120
|
+
merge: true,
|
|
121
|
+
});
|
|
122
|
+
this.setState({
|
|
123
|
+
scanDone: true,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
} else if (routes[routes.length - 2]) {
|
|
99
127
|
navigate({
|
|
100
128
|
name: sourceRouteName || routes[routes.length - 2].name,
|
|
101
129
|
params: {
|
|
@@ -148,7 +176,35 @@ export default class ScanQRCode extends Component {
|
|
|
148
176
|
//扫码后的操作
|
|
149
177
|
if (data) {
|
|
150
178
|
const routes = getState().routes;
|
|
151
|
-
if (
|
|
179
|
+
if (data.includes('action=redirect')) {
|
|
180
|
+
/**
|
|
181
|
+
* action=redirect 重定向APP页面
|
|
182
|
+
mop=ipanel operatorId(模块运营商,未来有可能废弃)
|
|
183
|
+
m=shop 商城模块
|
|
184
|
+
s=detail screenName
|
|
185
|
+
a/b/c 传给商城模块的参数
|
|
186
|
+
*/
|
|
187
|
+
const querys = data.substring(data.indexOf('?') + 1).split('&');
|
|
188
|
+
const params = {};
|
|
189
|
+
for (let i = 0; i < querys.length; i++) {
|
|
190
|
+
const temp = querys[i].split('=');
|
|
191
|
+
if (temp.length < 2) {
|
|
192
|
+
params[temp[0]] = '';
|
|
193
|
+
} else {
|
|
194
|
+
params[temp[0]] = temp[1];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (params.s) {
|
|
198
|
+
navigate({
|
|
199
|
+
name: params.s,
|
|
200
|
+
params,
|
|
201
|
+
merge: true,
|
|
202
|
+
});
|
|
203
|
+
this.setState({
|
|
204
|
+
scanDone: true,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
} else if (routes[routes.length - 2]) {
|
|
152
208
|
navigate({
|
|
153
209
|
name: sourceRouteName || routes[routes.length - 2].name,
|
|
154
210
|
params: {
|
|
@@ -262,7 +318,7 @@ export default class ScanQRCode extends Component {
|
|
|
262
318
|
}}
|
|
263
319
|
resizeMode="contain"
|
|
264
320
|
/>
|
|
265
|
-
|
|
321
|
+
|
|
266
322
|
<Text style={styles.albumText}>相册</Text>
|
|
267
323
|
</TouchableOpacity>
|
|
268
324
|
</View>
|