@conecli/cone-render 0.10.1-shop-beta.21 → 0.10.1-shop-beta.22
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/dist/common/const.ts +1 -1
- package/dist/common/index.h5.ts +1 -1
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.dynamic.module.scss +1 -0
- package/dist/components/base/NetworkDataError/const.ts +1 -1
- package/dist/components/base/NetworkDataError/index.module.scss +6 -6
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/createReportFloorData.ts +1 -1
- package/dist/jumpEventReport/index.jd.ts +1 -1
- package/dist/jumpEventReport/index.weapp.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.pc.ts +1 -1
- package/dist/jumpEventReport/web.tjm.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/language/en_US.json +2 -0
- package/dist/language/zh_CN.json +2 -0
- package/dist/language/zh_HK.json +2 -0
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
1
|
isH5AndJdShopView,
|
|
3
2
|
isJdApp,
|
|
4
3
|
isIosDevice,
|
|
5
4
|
isAndroidDevice,
|
|
6
5
|
isJdAndIosDevice,
|
|
7
6
|
isJdAndAndroidDevice,
|
|
8
7
|
jdAppVersionCompare,
|
|
9
8
|
isAppStowShop,
|
|
10
9
|
isJdAndHarmonyDevice,
|
|
11
10
|
(window.JDJshopViewInfo = {
|
|
12
11
|
androidTouchSlop: 5,
|
|
13
12
|
getAndroidTouchSlopState: false,
|
|
14
13
|
});
|
|
15
14
|
(state) => {
|
|
16
15
|
console.log('document trigger PAGE_DOCUMENT_VISIBILITY_CHANGE state:', state);
|
|
17
16
|
Taro.eventCenter.trigger(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, state ? 0 : 1);
|
|
18
17
|
},
|
|
19
18
|
1500,
|
|
20
19
|
{ leading: false, trailing: true },
|
|
21
20
|
(state) => {
|
|
22
21
|
console.log('IOS Android trigger PAGE_DOCUMENT_VISIBILITY_CHANGE state:', state);
|
|
23
22
|
Taro.eventCenter.trigger(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, state);
|
|
24
23
|
},
|
|
25
24
|
1500,
|
|
26
25
|
{ leading: true, trailing: false },
|
|
27
26
|
if (!isJdApp) {
|
|
28
27
|
if (isH5) {
|
|
29
28
|
|
|
30
29
|
const documentHandleVisibilityChange = () => {
|
|
31
30
|
const state = document.hidden;
|
|
32
31
|
window.startDocumentVisibilityChange && documentThrottledTrigger(state);
|
|
33
32
|
};
|
|
34
33
|
document.removeEventListener('visibilitychange', documentHandleVisibilityChange);
|
|
35
34
|
console.log('每次进入页面先清除浏览器visibilitychange监听事件');
|
|
36
35
|
setTimeout(() => {
|
|
37
36
|
document.addEventListener('visibilitychange', documentHandleVisibilityChange, false);
|
|
38
37
|
window.startDocumentVisibilityChange = true;
|
|
39
38
|
}, 3000);
|
|
40
39
|
}
|
|
41
40
|
} else {
|
|
42
41
|
|
|
43
42
|
!window.webviewVisible &&
|
|
44
43
|
(window.webviewVisible = (state) => {
|
|
45
44
|
window.startDocumentVisibilityChange && webviewThrottledTrigger(state);
|
|
46
45
|
state === 1 && taroEventSendPageScrollInfo();
|
|
47
46
|
});
|
|
48
47
|
setTimeout(() => {
|
|
49
48
|
window.startDocumentVisibilityChange = true;
|
|
50
49
|
}, 3000);
|
|
51
50
|
!window.floatReceiveData && (window.floatReceiveData = () => {});
|
|
52
51
|
}
|
|
53
52
|
MESSAGE_HOME_INIT: 'messageHomeInitPageData',
|
|
54
53
|
[Message_CallBack_Name.MESSAGE_HOME_INIT]: {},
|
|
55
54
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = {
|
|
56
55
|
displayHeight: 1920,
|
|
57
56
|
offSetY: 0,
|
|
58
57
|
};
|
|
59
58
|
if (options) {
|
|
60
59
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = options;
|
|
61
60
|
}
|
|
62
61
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {};
|
|
63
62
|
Taro.eventCenter.trigger(TaroEventType.PAGE_SCROLL, options || latestRes);
|
|
64
63
|
console.log('PageScrollEnd fire');
|
|
65
64
|
Taro.eventCenter.trigger(TaroEventType.PAGE_SCROLL_END, options);
|
|
66
65
|
const { businessType } = options;
|
|
67
66
|
switch (businessType) {
|
|
68
67
|
case H5_MSG_TO_H5_BUSINESSTYPE.JOIN_MEMBER_SUCCESS:
|
|
69
68
|
Taro.eventCenter.trigger(TaroEventType.JOIN_MEMBER_SUCCESS, options);
|
|
70
69
|
break;
|
|
71
70
|
case H5_MSG_TO_H5_BUSINESSTYPE.h5BaseDataChange:
|
|
72
71
|
Taro.eventCenter.trigger(TaroEventType.H5_BASE_DATA_CHANGE_REGISTER, options);
|
|
73
72
|
break;
|
|
74
73
|
default:
|
|
75
74
|
break;
|
|
76
75
|
}
|
|
77
76
|
const { shopHomeExtendInfo } = options;
|
|
78
77
|
if (shopHomeExtendInfo) {
|
|
79
78
|
Taro.eventCenter.trigger(TaroEventType.UPDATE_SHOP_HOME_EXTEND_DATA, shopHomeExtendInfo);
|
|
80
79
|
}
|
|
81
80
|
window && window.scrollTo(0, 0);
|
|
82
81
|
Taro.eventCenter.trigger(TaroEventType.PAGE_INIT_EXPOSURE, options);
|
|
83
82
|
const { action, params } = options;
|
|
84
83
|
console.log('taroEventShopStowSend', options);
|
|
85
84
|
if (action) {
|
|
86
85
|
Taro.eventCenter.trigger(action, params);
|
|
87
86
|
}
|
|
88
87
|
NATIVE_PAGE_READ: 'pageReady',
|
|
89
88
|
NATIVE_PAGE_FINISH: 'pageFinish',
|
|
90
89
|
NATIVE_INFO_DATA: 'nativeInfoData',
|
|
91
90
|
NATIVE_PAGE_SCROLL: 'pageScroll',
|
|
92
91
|
NATIVE_PAGE_SCROLL_END: 'pageScrollEnd',
|
|
93
92
|
NATIVE_GET_SCROLL_TOP: 'nativeGetScrollTop',
|
|
94
93
|
NATIVE_TO_SCROLL_TOP: 'nativeToScrollTop',
|
|
95
94
|
NATIVE_CLOSE_SCROLL_MESSAGE: 'nativeCloseScrollMessage',
|
|
96
95
|
NATIVE_MOBILE_CONFIG: 'getMobileConfig',
|
|
97
96
|
NATIVE_SHOW_TOAST: 'showToast',
|
|
98
97
|
NATIVE_SHOW_DIALOG: 'showDialog',
|
|
99
98
|
NATIVE_PAGE_LAYOUT_CHANGE: 'pageLayoutChange',
|
|
100
99
|
NATIVE_HOME_PAGING_ENABLE: 'homePagingEnable',
|
|
101
100
|
NATIVE_GET_SCALED_TOUCH_SLOP: 'getScaledTouchSlop',
|
|
102
101
|
NATIVE_ADD_CART: 'addCart',
|
|
103
102
|
NATIVE_JUMP_TAB_BAR: 'jumpTabBar',
|
|
104
103
|
NATIVE_OPEN_FLOAT: 'openFloat',
|
|
105
104
|
NATIVE_INJECT_JS_FILE: 'needIsvPackage',
|
|
106
105
|
NAVTIVE_FLOAT_READY: 'floatReady',
|
|
107
106
|
NATIVE_REFRESH_PAGE: 'refreshPage',
|
|
108
107
|
PAGE_PV_PARAM: 'pagePvParam',
|
|
109
108
|
NATIVE_SCORLL_VIEW: 'nativeScrollControl',
|
|
110
109
|
NATIVE_POP_WEBVIEW: 'popWebview',
|
|
111
110
|
NATIVE_H5_SEND_MSG_TO_H5: 'h5SendMsgToH5',
|
|
112
111
|
NATIVE_PUSH_NATIVE_PAGE: 'pushNativePage',
|
|
113
112
|
UPDATE_NATIVE_DATA: 'updateNativeData',
|
|
114
113
|
H5_TO_SCROLL_TOP: 'h5ToScrollTop',
|
|
115
114
|
LUXURY_INFORM_CHANGE_HEIGHT: 'sendImmersionStatus',
|
|
116
115
|
NATIVE_SHOPSTOW_SEND: 'sendMsgToShopStow',
|
|
117
116
|
NATIVE_UPDATE_PAGE_INFO: 'pageCountInfo',
|
|
118
117
|
NATIVE_TO_BUYER_SHOW_DETAIL: 'jumpBuyerShowDetail',
|
|
119
118
|
NATIVE_TO_HIDE_JD_SHOP_HEADER: 'hideNativeHeader',
|
|
120
119
|
NATIVE_TO_SHOW_CART_BTN: 'showCartButton',
|
|
121
120
|
NATIVE_IMMERSIVEHEADER_STATE_CHANGE: 'immersiveHeaderStateChange',
|
|
122
121
|
SHOP_FOLLOW_STATE_REGISTER: 'shopFollowStateRegister',
|
|
123
122
|
SHOP_FOLLOW_STATE_SYNC: 'shopFollowStateSync',
|
|
124
123
|
NATIVE_GET_SHOP_FOLLOW_STATE: 'getShopFollowState',
|
|
125
124
|
H5_TO_NATIVE_LIVE_RESERVE_STATE: 'shopLiveReserveStateSync',
|
|
126
125
|
H5_TO_NATIVE_SCROLL_TO_TOP: 'expertShopScrollToTop',
|
|
127
126
|
OPEN: 'open',
|
|
128
127
|
CLOSE: 'close',
|
|
129
128
|
JOIN_MEMBER_SUCCESS: 'joinMemberSuccess',
|
|
130
129
|
h5BaseDataChange: 'h5BaseDataChange',
|
|
131
130
|
type = Message_Type.NATIVE_PAGE_READ,
|
|
132
131
|
sendData: null | object = null,
|
|
133
132
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
134
133
|
console.log(
|
|
135
134
|
'初始化nativePageRegisterMessage-isAppStowShop-type-sendData-isJdApp-isH5AndJdShopView',
|
|
136
135
|
isAppStowShop,
|
|
137
136
|
type,
|
|
138
137
|
sendData,
|
|
139
138
|
isJdApp,
|
|
140
139
|
isH5AndJdShopView,
|
|
141
140
|
callBackName,
|
|
142
141
|
);
|
|
143
142
|
if (isJdApp) {
|
|
144
143
|
const getCallBackName = `window.${callBackName}`;
|
|
145
144
|
let getRouterParam = {
|
|
146
145
|
type,
|
|
147
146
|
callBackName: getCallBackName,
|
|
148
147
|
};
|
|
149
148
|
if (!isAppStowShop) {
|
|
150
149
|
getRouterParam['newHomePage'] = true;
|
|
151
150
|
}
|
|
152
151
|
if (sendData) {
|
|
153
152
|
getRouterParam = Object.assign({}, getRouterParam, sendData);
|
|
154
153
|
}
|
|
155
154
|
if (isIosDevice) {
|
|
156
155
|
const routerURL = isAppStowShop
|
|
157
156
|
? 'router://JDBDecorationPlatformModule/wrtNative'
|
|
158
157
|
: 'router://JDShopModule/wrtNative';
|
|
159
158
|
if (versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) >= 0) {
|
|
160
159
|
callRouterIOS({
|
|
161
160
|
routerURL,
|
|
162
161
|
routerParam: getRouterParam,
|
|
163
162
|
});
|
|
164
163
|
} else {
|
|
165
164
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
166
165
|
method: 'callRouterModuleWithParams',
|
|
167
166
|
params: {
|
|
168
167
|
routerURL,
|
|
169
168
|
serialize: '1',
|
|
170
169
|
routerParam: JSON.stringify(getRouterParam),
|
|
171
170
|
callBackName: getCallBackName,
|
|
172
171
|
callBackId: `${callBackName}Ios`,
|
|
173
172
|
},
|
|
174
173
|
});
|
|
175
174
|
}
|
|
176
175
|
} else if (isAndroidDevice) {
|
|
177
176
|
if (type === Message_Type.NATIVE_MOBILE_CONFIG && jdAppVersionCompare('13.2.8') >= 0) {
|
|
178
177
|
callRouterAndroid({
|
|
179
178
|
routerURL: 'router://JDJShopModule/wrtNative',
|
|
180
179
|
routerParam: getRouterParam,
|
|
181
180
|
});
|
|
182
181
|
} else {
|
|
183
182
|
window?.JDJshop?.wrtNative(
|
|
184
183
|
JSON.stringify({
|
|
185
184
|
routerParam: JSON.stringify(getRouterParam),
|
|
186
185
|
serialize: '1',
|
|
187
186
|
callBackName: getCallBackName,
|
|
188
187
|
callBackId: `${callBackName}Android`,
|
|
189
188
|
}),
|
|
190
189
|
);
|
|
191
190
|
}
|
|
192
191
|
} else if (isJdAndHarmonyDevice) {
|
|
193
192
|
const plugin = 'JdShopPlugin';
|
|
194
193
|
const action = type;
|
|
195
194
|
const params = {
|
|
196
195
|
routerURL: '',
|
|
197
196
|
routerParam: getRouterParam,
|
|
198
197
|
};
|
|
199
198
|
window.XWebView &&
|
|
200
199
|
window.XWebView.callNative(
|
|
201
200
|
plugin,
|
|
202
201
|
action,
|
|
203
202
|
JSON.stringify(params),
|
|
204
203
|
getCallBackName,
|
|
205
204
|
`${callBackName}HarmonyOS`,
|
|
206
205
|
);
|
|
207
206
|
}
|
|
208
207
|
return true;
|
|
209
208
|
}
|
|
210
209
|
return false;
|
|
211
210
|
if (isJdApp) {
|
|
212
211
|
if (isIosDevice) {
|
|
213
212
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage({
|
|
214
213
|
method: 'close',
|
|
215
214
|
});
|
|
216
215
|
} else if (isAndroidDevice) {
|
|
217
216
|
window?.XView && window?.XView.close();
|
|
218
217
|
} else if (isJdAndHarmonyDevice) {
|
|
219
218
|
nativeClosePopWebView();
|
|
220
219
|
}
|
|
221
220
|
}
|
|
222
221
|
console.log('showToastByRouter:', title, showType);
|
|
223
222
|
if (isJdApp) {
|
|
224
223
|
const routerParam = {
|
|
225
224
|
message: title,
|
|
226
225
|
iconType: showType,
|
|
227
226
|
duration,
|
|
228
227
|
};
|
|
229
228
|
if (isIosDevice) {
|
|
230
229
|
callRouterIOS({
|
|
231
230
|
routerURL: 'router://JDShopModule/showToast',
|
|
232
231
|
routerParam,
|
|
233
232
|
});
|
|
234
233
|
} else if (isAndroidDevice) {
|
|
235
234
|
callRouterAndroid({
|
|
236
235
|
routerURL: 'router://JDJShopModule/showToast',
|
|
237
236
|
routerParam,
|
|
238
237
|
});
|
|
239
238
|
} else if (isJdAndHarmonyDevice) {
|
|
240
239
|
const plugin = 'JdShopPlugin';
|
|
241
240
|
const action = 'showToast';
|
|
242
241
|
const params = {
|
|
243
242
|
routerURL: 'router://JDJShopModule/showToast',
|
|
244
243
|
routerParam: routerParam,
|
|
245
244
|
};
|
|
246
245
|
window.XWebView && window.XWebView.callNative(plugin, action, JSON.stringify(params));
|
|
247
246
|
}
|
|
248
247
|
}
|
|
249
248
|
console.log('nativePageLoadReady called');
|
|
250
249
|
Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
251
250
|
Message_Type.NATIVE_INFO_DATA
|
|
252
251
|
] = async (data: any) => {
|
|
253
252
|
console.log('nativePageLoadReady callBack:', callBack, ', data:', data);
|
|
254
253
|
callBack && callBack(data);
|
|
255
254
|
};
|
|
256
255
|
nativePageGetMessageInitCallBack();
|
|
257
256
|
nativePageRegisterMessage(
|
|
258
257
|
Message_Type.NATIVE_PAGE_READ,
|
|
259
258
|
sendData,
|
|
260
259
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
261
260
|
);
|
|
262
261
|
return nativePageRegisterMessage(
|
|
263
262
|
Message_Type.NATIVE_PAGE_FINISH,
|
|
264
263
|
null,
|
|
265
264
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
266
265
|
);
|
|
267
266
|
callBack &&
|
|
268
267
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
269
268
|
Message_Type.NATIVE_GET_SCROLL_TOP
|
|
270
269
|
] = callBack);
|
|
271
270
|
return nativePageRegisterMessage(
|
|
272
271
|
Message_Type.NATIVE_GET_SCROLL_TOP,
|
|
273
272
|
null,
|
|
274
273
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
275
274
|
);
|
|
276
275
|
callBack &&
|
|
277
276
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
278
277
|
Message_Type.NATIVE_TO_SCROLL_TOP
|
|
279
278
|
] = callBack);
|
|
280
279
|
nativePageRegisterMessage(
|
|
281
280
|
Message_Type.NATIVE_TO_SCROLL_TOP,
|
|
282
281
|
{
|
|
283
282
|
data: {
|
|
284
283
|
scrollTop,
|
|
285
284
|
},
|
|
286
285
|
},
|
|
287
286
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
288
287
|
);
|
|
289
288
|
Taro.eventCenter.trigger(TaroEventType.LUXURY_INFORM_CHANGE_HEIGHT, data);
|
|
290
289
|
Taro.eventCenter.trigger(TaroEventType.SHOP_FOLLOW_STATE_REGISTER, data);
|
|
291
290
|
Taro.eventCenter.trigger(TaroEventType.IMMERSIVEHEADER_STATE_CHANGE, data);
|
|
292
291
|
configName: string,
|
|
293
292
|
isBeforePageReady: boolean,
|
|
294
293
|
return new Promise((resolve, reject) => {
|
|
295
294
|
if (!isJdApp) {
|
|
296
295
|
reject({
|
|
297
296
|
code: -1,
|
|
298
297
|
message: 'getMPaasConfigByNative 只在松果APP店铺内部调用有效。',
|
|
299
298
|
});
|
|
300
299
|
return;
|
|
301
300
|
}
|
|
302
301
|
if (
|
|
303
302
|
isIosDevice &&
|
|
304
303
|
isBeforePageReady &&
|
|
305
304
|
versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) < 0
|
|
306
305
|
) {
|
|
307
306
|
reject({
|
|
308
307
|
code: -2,
|
|
309
308
|
message: `在nativePageLoadReady之前调用,低于v${MPAAS_CONFIG_APP_VERSION}不会有返回,兜底处理`,
|
|
310
309
|
});
|
|
311
310
|
return;
|
|
312
311
|
}
|
|
313
312
|
Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
314
313
|
Message_Type.NATIVE_MOBILE_CONFIG
|
|
315
314
|
] = (data: any) => {
|
|
316
315
|
const configData = isAndroidDevice ? data : data?.data;
|
|
317
316
|
const res = JSONParse(configData);
|
|
318
317
|
resolve(res);
|
|
319
318
|
};
|
|
320
319
|
nativePageGetMessageInitCallBack();
|
|
321
320
|
nativePageRegisterMessage(
|
|
322
321
|
Message_Type.NATIVE_MOBILE_CONFIG,
|
|
323
322
|
{
|
|
324
323
|
data: {
|
|
325
324
|
space: isIosDevice ? 'JDCDSHOP' : 'JDShop',
|
|
326
325
|
configName,
|
|
327
326
|
},
|
|
328
327
|
},
|
|
329
328
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
330
329
|
);
|
|
331
330
|
});
|
|
332
331
|
bussinessKey: string,
|
|
333
332
|
isBeforePageReady: boolean,
|
|
334
333
|
if (!bussinessKey) {
|
|
335
334
|
return null;
|
|
336
335
|
}
|
|
337
336
|
if (!isJdApp) {
|
|
338
337
|
return null;
|
|
339
338
|
}
|
|
340
339
|
const CACHED_MPAAS_KEY = `mpaas_${CONFIG_NAME}`;
|
|
341
340
|
const CACHED_MPAAS_KEY_HELPER = `${CACHED_MPAAS_KEY}_helper`;
|
|
342
341
|
let configData = window[CACHED_MPAAS_KEY];
|
|
343
342
|
if (configData == null) {
|
|
344
343
|
configData = await getMPaasConfigByNative(CONFIG_NAME, isBeforePageReady).catch((e) => {
|
|
345
344
|
console.log('getMPaasConfigByNative error:', e);
|
|
346
345
|
return null;
|
|
347
346
|
});
|
|
348
347
|
window[CACHED_MPAAS_KEY_HELPER] = {};
|
|
349
348
|
window[CACHED_MPAAS_KEY] = configData;
|
|
350
349
|
}
|
|
351
350
|
if (configData) {
|
|
352
351
|
const originData = configData[bussinessKey];
|
|
353
352
|
const hasParse = window[CACHED_MPAAS_KEY_HELPER][bussinessKey];
|
|
354
353
|
try {
|
|
355
354
|
if (hasParse || ['object', 'boolean', 'number'].includes(typeof originData)) {
|
|
356
355
|
return originData;
|
|
357
356
|
} else {
|
|
358
357
|
window[CACHED_MPAAS_KEY_HELPER][bussinessKey] = true;
|
|
359
358
|
const parseData = JSON.parse(configData[bussinessKey]);
|
|
360
359
|
configData[bussinessKey] = parseData;
|
|
361
360
|
return parseData;
|
|
362
361
|
}
|
|
363
362
|
} catch (e) {
|
|
364
363
|
return originData;
|
|
365
364
|
}
|
|
366
365
|
}
|
|
367
366
|
return null;
|
|
368
367
|
nativePageRegisterMessage(Message_Type.NATIVE_CLOSE_SCROLL_MESSAGE);
|
|
369
368
|
if (isJdAndAndroidDevice) {
|
|
370
369
|
callBack &&
|
|
371
370
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
372
371
|
Message_Type.NATIVE_HOME_PAGING_ENABLE
|
|
373
372
|
] = callBack);
|
|
374
373
|
nativePageRegisterMessage(Message_Type.NATIVE_HOME_PAGING_ENABLE, {
|
|
375
374
|
data: {
|
|
376
375
|
enable: enable,
|
|
377
376
|
},
|
|
378
377
|
});
|
|
379
378
|
}
|
|
380
379
|
if (isJdAndAndroidDevice) {
|
|
381
380
|
callBack &&
|
|
382
381
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
383
382
|
Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP
|
|
384
383
|
] = callBack);
|
|
385
384
|
nativePageRegisterMessage(Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP);
|
|
386
385
|
}
|
|
387
386
|
SUCCESS: 'success',
|
|
388
387
|
FAIL: 'fail',
|
|
389
388
|
NORMAL: 'normal',
|
|
390
389
|
SUCCESS: 2,
|
|
391
390
|
FAIL: 3,
|
|
392
391
|
NORMAL: 1,
|
|
393
392
|
SUCCESS: 2,
|
|
394
393
|
FAIL: 3,
|
|
395
394
|
NORMAL: 1,
|
|
396
395
|
[ToastIosType.NORMAL]: ToastType.NORMAL,
|
|
397
396
|
[ToastIosType.SUCCESS]: ToastType.SUCCESS,
|
|
398
397
|
[ToastIosType.FAIL]: ToastType.FAIL,
|
|
399
398
|
if (isShowNewRouterToast) {
|
|
400
399
|
const changeShowType = isJdAndIosDevice
|
|
401
400
|
? toastIosTypeToNewToastType[showType] || showType
|
|
402
401
|
: showType;
|
|
403
402
|
showToastByRouter(title, changeShowType, duration * 1000);
|
|
404
403
|
} else {
|
|
405
404
|
nativePageRegisterMessage(Message_Type.NATIVE_SHOW_TOAST, {
|
|
406
405
|
data: {
|
|
407
406
|
message: title,
|
|
408
407
|
iconType: showType,
|
|
409
408
|
duration,
|
|
410
409
|
},
|
|
411
410
|
});
|
|
412
411
|
}
|
|
413
412
|
routerURL,
|
|
414
413
|
routerParam,
|
|
415
414
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
416
415
|
isSync = false,
|
|
417
416
|
const getCallBackName = `window.${callBackName}`;
|
|
418
417
|
const params = {
|
|
419
418
|
routerURL,
|
|
420
419
|
serialize: '1',
|
|
421
420
|
routerParam,
|
|
422
421
|
callBackName: getCallBackName,
|
|
423
422
|
callBackId: `${callBackName}Ios`,
|
|
424
423
|
};
|
|
425
424
|
console.log(
|
|
426
425
|
'callRouterIOS routerURL:',
|
|
427
426
|
routerURL,
|
|
428
427
|
',routerParam:',
|
|
429
428
|
routerParam,
|
|
430
429
|
'params',
|
|
431
430
|
params,
|
|
432
431
|
'isSync',
|
|
433
432
|
isSync,
|
|
434
433
|
);
|
|
435
434
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
436
435
|
method: isSync ? 'callSyncRouterModuleWithParams' : 'callRouterModuleWithParams',
|
|
437
436
|
params: JSON.stringify(params),
|
|
438
437
|
});
|
|
439
438
|
routerURL,
|
|
440
439
|
routerParam,
|
|
441
440
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
442
441
|
isSync = false,
|
|
443
442
|
hasJdRouter = true,
|
|
444
443
|
console.log(
|
|
445
444
|
'callRouterAndroid routerURL:',
|
|
446
445
|
routerURL,
|
|
447
446
|
',routerParam:',
|
|
448
447
|
routerParam,
|
|
449
448
|
'isSync',
|
|
450
449
|
isSync,
|
|
451
450
|
);
|
|
452
451
|
const getCallBackName = `window.${callBackName}`;
|
|
453
452
|
routerParam?.data &&
|
|
454
453
|
typeof routerParam?.data === 'object' &&
|
|
455
454
|
(routerParam.data = JSON.stringify(routerParam?.data));
|
|
456
455
|
var params = {
|
|
457
456
|
serialize: '1',
|
|
458
457
|
routerURL,
|
|
459
458
|
routerParam,
|
|
460
459
|
callBackName: getCallBackName,
|
|
461
460
|
callBackId: `${callBackName}Android`,
|
|
462
461
|
};
|
|
463
462
|
hasJdRouter && (params['jdRouter'] = '1');
|
|
464
463
|
isSync
|
|
465
464
|
? window?.JDAppUnite?.callSyncRouterModuleWithParams(JSON.stringify(params))
|
|
466
465
|
: window?.JDAppUnite?.callRouterModuleWithParams(JSON.stringify(params));
|
|
467
466
|
pluginName,
|
|
468
467
|
action,
|
|
469
468
|
routerParam,
|
|
470
469
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
471
470
|
isSync = false,
|
|
472
471
|
const getCallBackName = `window.${callBackName}`;
|
|
473
472
|
const params = {
|
|
474
473
|
routerURL: '',
|
|
475
474
|
routerParam: routerParam,
|
|
476
475
|
};
|
|
477
476
|
const outBridgeType = ['getLastAddress', 'getAddress'];
|
|
478
477
|
console.log(
|
|
479
478
|
'callRouterHarmony pluginName:',
|
|
480
479
|
pluginName,
|
|
481
480
|
'action',
|
|
482
481
|
action,
|
|
483
482
|
',routerParam:',
|
|
484
483
|
routerParam,
|
|
485
484
|
'params',
|
|
486
485
|
params,
|
|
487
486
|
'isSync',
|
|
488
487
|
isSync,
|
|
489
488
|
);
|
|
490
489
|
window?.XWebView?.callNative(
|
|
491
490
|
pluginName,
|
|
492
491
|
action,
|
|
493
492
|
outBridgeType.includes(action) ? JSON.stringify(routerParam) : JSON.stringify(params),
|
|
494
493
|
getCallBackName,
|
|
495
494
|
`${callBackName}HarmonyOS`,
|
|
496
495
|
);
|
|
497
496
|
const params = {
|
|
498
497
|
action,
|
|
499
498
|
params: typeof routerParam === 'string' ? routerParam : JSON.stringify(routerParam),
|
|
500
499
|
};
|
|
501
500
|
console.log(
|
|
502
501
|
'callRouterHarmony pluginName:',
|
|
503
502
|
pluginName,
|
|
504
503
|
'action',
|
|
505
504
|
action,
|
|
506
505
|
',routerParam:',
|
|
507
506
|
routerParam,
|
|
508
507
|
'params',
|
|
509
508
|
params,
|
|
510
509
|
'isSync',
|
|
511
510
|
isSync,
|
|
512
511
|
);
|
|
513
512
|
return new Promise(async (resolve, reject) => {
|
|
514
513
|
if (!window?.XBridge) {
|
|
515
514
|
reject({
|
|
516
515
|
status: '-1001',
|
|
517
516
|
data: {},
|
|
518
517
|
msg: 'window.XBridge不存在',
|
|
519
518
|
});
|
|
520
519
|
return;
|
|
521
520
|
}
|
|
522
521
|
if (isSync) {
|
|
523
522
|
try {
|
|
524
523
|
const result = await window?.XBridge?.callNative(pluginName, {
|
|
525
524
|
...params,
|
|
526
525
|
sync: '1',
|
|
527
526
|
});
|
|
528
527
|
console.log('callRouterHarmony同步await', result);
|
|
529
528
|
resolve({
|
|
530
529
|
status: '0',
|
|
531
530
|
data: result,
|
|
532
531
|
msg: '',
|
|
533
532
|
});
|
|
534
533
|
} catch (err) {
|
|
535
534
|
const errMessage = err ? (typeof err === 'string' ? err : err.message || '') : '';
|
|
536
535
|
console.log('callRouterHarmony异步 调用error', err);
|
|
537
536
|
reject({
|
|
538
537
|
status: '-202',
|
|
539
538
|
data: {},
|
|
540
539
|
msg: errMessage || 'XBridge调用异常',
|
|
541
540
|
});
|
|
542
541
|
}
|
|
543
542
|
} else {
|
|
544
543
|
window?.XBridge?.callNative(pluginName, {
|
|
545
544
|
...params,
|
|
546
545
|
success: (res) => {
|
|
547
546
|
console.log('callRouterHarmony异步 调用success', res);
|
|
548
547
|
resolve({
|
|
549
548
|
status: '0',
|
|
550
549
|
data: res,
|
|
551
550
|
msg: '',
|
|
552
551
|
});
|
|
553
552
|
},
|
|
554
553
|
error: (err) => {
|
|
555
554
|
const errMessage = err ? (typeof err === 'string' ? err : err.message || '') : '';
|
|
556
555
|
console.log('callRouterHarmony异步 调用error', err);
|
|
557
556
|
reject({
|
|
558
557
|
status: '-202',
|
|
559
558
|
data: {},
|
|
560
559
|
msg: errMessage || 'XBridge调用异常',
|
|
561
560
|
});
|
|
562
561
|
},
|
|
563
562
|
});
|
|
564
563
|
}
|
|
565
564
|
});
|
|
566
565
|
callBack &&
|
|
567
566
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
568
567
|
Message_Type.NATIVE_SHOW_DIALOG
|
|
569
568
|
] = callBack);
|
|
570
569
|
return nativePageRegisterMessage(Message_Type.NATIVE_SHOW_DIALOG, {
|
|
571
570
|
data: params,
|
|
572
571
|
});
|
|
573
572
|
if (!isJdApp) {
|
|
574
573
|
return;
|
|
575
574
|
}
|
|
576
575
|
if (!window[Message_CallBack_Name.MESSAGE_HOME_INIT]) {
|
|
577
576
|
window[Message_CallBack_Name.MESSAGE_HOME_INIT] = (messageData) => {
|
|
578
577
|
try {
|
|
579
578
|
console.log('接收到原生通知返回的原始数据nativePageGetMessageInitCallBack', messageData);
|
|
580
579
|
const getMessageJsonData = JSONParse(messageData);
|
|
581
580
|
const { status } = getMessageJsonData;
|
|
582
581
|
if (status == '0') {
|
|
583
582
|
const { type, data } = getMessageJsonData?.data;
|
|
584
583
|
const getSendJsonData = JSONParse(data);
|
|
585
584
|
switch (type) {
|
|
586
585
|
case Message_Type.NATIVE_INFO_DATA:
|
|
587
586
|
case Message_Type.NATIVE_PAGE_FINISH:
|
|
588
587
|
case Message_Type.NATIVE_GET_SCROLL_TOP:
|
|
589
588
|
case Message_Type.NATIVE_TO_SCROLL_TOP:
|
|
590
589
|
case Message_Type.NATIVE_CLOSE_SCROLL_MESSAGE:
|
|
591
590
|
case Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP:
|
|
592
591
|
case Message_Type.NATIVE_MOBILE_CONFIG:
|
|
593
592
|
case Message_Type.NATIVE_GET_SHOP_FOLLOW_STATE:
|
|
594
593
|
const getTypeCallBack =
|
|
595
594
|
Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][type];
|
|
596
595
|
if (getTypeCallBack) {
|
|
597
596
|
const isCallBackFunc = typeof getTypeCallBack === 'function';
|
|
598
597
|
console.log('接收到原生通知 NATIVE_SHOPSTOW_SEND getSendJsonData', getSendJsonData);
|
|
599
598
|
isCallBackFunc && getTypeCallBack(getSendJsonData);
|
|
600
599
|
}
|
|
601
600
|
break;
|
|
602
601
|
case Message_Type.NATIVE_SHOW_DIALOG:
|
|
603
602
|
const showDialogCallBack =
|
|
604
603
|
Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][type];
|
|
605
604
|
if (showDialogCallBack) {
|
|
606
605
|
const isCallBackFunc = typeof showDialogCallBack === 'function';
|
|
607
606
|
console.log(
|
|
608
607
|
`获取${type}类型数据数据type isCallBackFunc getMessageJsonData `,
|
|
609
608
|
type,
|
|
610
609
|
isCallBackFunc,
|
|
611
610
|
getMessageJsonData,
|
|
612
611
|
);
|
|
613
612
|
isCallBackFunc && showDialogCallBack(getMessageJsonData?.data);
|
|
614
613
|
}
|
|
615
614
|
break;
|
|
616
615
|
case Message_Type.NATIVE_PAGE_SCROLL:
|
|
617
616
|
taroEventSendPageScrollInfo(data);
|
|
618
617
|
break;
|
|
619
618
|
case Message_Type.NATIVE_PAGE_SCROLL_END:
|
|
620
619
|
taroEventSendPageScrollEndInfo(data);
|
|
621
620
|
break;
|
|
622
621
|
case Message_Type.NATIVE_H5_SEND_MSG_TO_H5:
|
|
623
622
|
console.log('接收到原生通知 NATIVE_H5_SEND_MSG_TO_H5', data);
|
|
624
623
|
taroEventH5SendMsgToH5(getSendJsonData);
|
|
625
624
|
break;
|
|
626
625
|
case Message_Type.UPDATE_NATIVE_DATA:
|
|
627
626
|
taroEventUpdateNativeData(getSendJsonData);
|
|
628
627
|
break;
|
|
629
628
|
case Message_Type.H5_TO_SCROLL_TOP:
|
|
630
629
|
taroEventH5ToScrollTop();
|
|
631
630
|
break;
|
|
632
631
|
case Message_Type.NATIVE_SHOPSTOW_SEND:
|
|
633
632
|
console.log('接收到原生通知 NATIVE_SHOPSTOW_SEND', messageData);
|
|
634
633
|
console.log('接收到原生通知 NATIVE_SHOPSTOW_SEND getSendJsonData', getSendJsonData);
|
|
635
634
|
taroEventShopStowSend(getSendJsonData);
|
|
636
635
|
break;
|
|
637
636
|
case Message_Type.LUXURY_INFORM_CHANGE_HEIGHT:
|
|
638
637
|
taroEventSendImmersionStatus(data);
|
|
639
638
|
break;
|
|
640
639
|
case Message_Type.NATIVE_IMMERSIVEHEADER_STATE_CHANGE:
|
|
641
640
|
taroEventSendImmersiveHeaderChange(data);
|
|
642
641
|
break;
|
|
643
642
|
case Message_Type.SHOP_FOLLOW_STATE_REGISTER:
|
|
644
643
|
taroEventSendShopFollowStateChange(data);
|
|
645
644
|
break;
|
|
646
645
|
default:
|
|
647
646
|
}
|
|
648
647
|
} else {
|
|
649
648
|
console.log('传递数据获取异常', getMessageJsonData);
|
|
650
649
|
}
|
|
651
650
|
} catch (e) {
|
|
652
651
|
console.log('获取转换异常结果', e);
|
|
653
652
|
}
|
|
654
653
|
};
|
|
655
654
|
}
|
|
656
655
|
console.warn('🚀 ~~ JumpTabBarInCurrentShop() ~~ params:', params);
|
|
657
656
|
nativePageRegisterMessage(Message_Type.NATIVE_JUMP_TAB_BAR, {
|
|
658
657
|
data: params,
|
|
659
658
|
});
|
|
660
659
|
nativePageRegisterMessage(Message_Type.NATIVE_OPEN_FLOAT, {
|
|
661
660
|
data: params,
|
|
662
661
|
});
|
|
663
662
|
const changeData = {
|
|
664
663
|
type: NATIVE_POP_WEBVIEW_TYPE.OPEN,
|
|
665
664
|
height: DEFAULT_POP_WEBVIEW_HEIGHT,
|
|
666
665
|
};
|
|
667
666
|
if (isChangeDefaultPopViewHeight && !params?.height) {
|
|
668
667
|
changeData.height = Math.round(window.screen.height * 0.8);
|
|
669
668
|
changeData.borderRadius = 12;
|
|
670
669
|
}
|
|
671
670
|
nativePageRegisterMessage(Message_Type.NATIVE_POP_WEBVIEW, {
|
|
672
671
|
data: {
|
|
673
672
|
...changeData,
|
|
674
673
|
...params,
|
|
675
674
|
},
|
|
676
675
|
});
|
|
677
676
|
nativePageRegisterMessage(Message_Type.NATIVE_POP_WEBVIEW, {
|
|
678
677
|
data: {
|
|
679
678
|
type: NATIVE_POP_WEBVIEW_TYPE.CLOSE,
|
|
680
679
|
...params,
|
|
681
680
|
},
|
|
682
681
|
});
|
|
683
682
|
Taro.eventCenter.off(TaroEventType.JOIN_MEMBER_SUCCESS);
|
|
684
683
|
console.log('popWebview关闭');
|
|
685
684
|
nativePageRegisterMessage(Message_Type.NATIVE_H5_SEND_MSG_TO_H5, {
|
|
686
685
|
data: params,
|
|
687
686
|
});
|
|
688
687
|
nativePageRegisterMessage(Message_Type.NATIVE_PUSH_NATIVE_PAGE, {
|
|
689
688
|
data: params,
|
|
690
689
|
});
|
|
691
690
|
window &&
|
|
692
691
|
(window.location.href = `xview://search?request={"action":"${Message_Type.NAVTIVE_FLOAT_READY}"}`);
|
|
693
692
|
const { displayHeight, offSetY } = res;
|
|
694
693
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return;
|
|
695
694
|
if (isIosDevice) return res;
|
|
696
695
|
if (isAndroidDevice) {
|
|
697
696
|
const deviceRatio = window.devicePixelRatio;
|
|
698
697
|
const cssDisplayHeight = Math.ceil(displayHeight / deviceRatio);
|
|
699
698
|
const cssOffsetY = Math.ceil(offSetY / deviceRatio);
|
|
700
699
|
return {
|
|
701
700
|
displayHeight: cssDisplayHeight,
|
|
702
701
|
offSetY: cssOffsetY,
|
|
703
702
|
};
|
|
704
703
|
}
|
|
705
704
|
nativePageRegisterMessage(Message_Type.NATIVE_UPDATE_PAGE_INFO, {
|
|
706
705
|
data: params,
|
|
707
706
|
});
|
|
708
707
|
nativePageRegisterMessage(Message_Type.NATIVE_TO_BUYER_SHOW_DETAIL, {
|
|
709
708
|
data: params,
|
|
710
709
|
});
|
|
711
710
|
nativePageRegisterMessage(Message_Type.NATIVE_TO_HIDE_JD_SHOP_HEADER, {
|
|
712
711
|
data: params,
|
|
713
712
|
});
|
|
714
713
|
nativePageRegisterMessage(Message_Type.NATIVE_TO_SHOW_CART_BTN, {
|
|
715
714
|
data: params,
|
|
716
715
|
});
|
|
717
716
|
nativePageRegisterMessage(Message_Type.SHOP_FOLLOW_STATE_REGISTER, {
|
|
718
717
|
data: params,
|
|
719
718
|
});
|
|
720
719
|
callBack &&
|
|
721
720
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
722
721
|
Message_Type.NATIVE_GET_SHOP_FOLLOW_STATE
|
|
723
722
|
] = callBack);
|
|
724
723
|
nativePageRegisterMessage(Message_Type.NATIVE_GET_SHOP_FOLLOW_STATE, {
|
|
725
724
|
data: {},
|
|
726
725
|
});
|
|
727
726
|
nativePageRegisterMessage(Message_Type.SHOP_FOLLOW_STATE_SYNC, {
|
|
728
727
|
data: {
|
|
729
728
|
followed: followState,
|
|
730
729
|
},
|
|
731
730
|
});
|
|
732
731
|
nativePageRegisterMessage(Message_Type.H5_TO_NATIVE_LIVE_RESERVE_STATE, {
|
|
733
732
|
data: params,
|
|
734
733
|
});
|
|
735
734
|
Taro.eventCenter.on('SEND_MSG_TO_NATIVE', (key, params) => {
|
|
736
735
|
nativePageRegisterMessage(key, {
|
|
737
736
|
data: params,
|
|
738
737
|
});
|
|
739
738
|
});
|
|
740
739
|
nativePageRegisterMessage(Message_Type.H5_TO_NATIVE_SCROLL_TO_TOP, {
|
|
741
740
|
data: params,
|
|
742
741
|
});
|
|
742
|
+
import Taro from '@tarojs/taro';
|
|
743
743
|
isH5AndJdShopView,
|
|
744
744
|
isJdApp,
|
|
745
745
|
isIosDevice,
|
|
746
746
|
isAndroidDevice,
|
|
747
747
|
isJdAndIosDevice,
|
|
748
748
|
isJdAndAndroidDevice,
|
|
749
749
|
jdAppVersionCompare,
|
|
750
750
|
isAppStowShop,
|
|
751
751
|
isJdAndHarmonyDevice,
|
|
752
752
|
(window.JDJshopViewInfo = {
|
|
753
753
|
androidTouchSlop: 5,
|
|
754
754
|
getAndroidTouchSlopState: false,
|
|
755
755
|
});
|
|
756
756
|
(state) => {
|
|
757
757
|
console.log('document trigger PAGE_DOCUMENT_VISIBILITY_CHANGE state:', state);
|
|
758
758
|
Taro.eventCenter.trigger(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, state ? 0 : 1);
|
|
759
759
|
},
|
|
760
760
|
1500,
|
|
761
761
|
{ leading: false, trailing: true },
|
|
762
762
|
(state) => {
|
|
763
763
|
console.log('IOS Android trigger PAGE_DOCUMENT_VISIBILITY_CHANGE state:', state);
|
|
764
764
|
Taro.eventCenter.trigger(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, state);
|
|
765
765
|
},
|
|
766
766
|
1500,
|
|
767
767
|
{ leading: true, trailing: false },
|
|
768
768
|
if (!isJdApp) {
|
|
769
769
|
if (isH5) {
|
|
770
770
|
|
|
771
771
|
const documentHandleVisibilityChange = () => {
|
|
772
772
|
const state = document.hidden;
|
|
773
773
|
window.startDocumentVisibilityChange && documentThrottledTrigger(state);
|
|
774
774
|
};
|
|
775
775
|
document.removeEventListener('visibilitychange', documentHandleVisibilityChange);
|
|
776
776
|
console.log('每次进入页面先清除浏览器visibilitychange监听事件');
|
|
777
777
|
setTimeout(() => {
|
|
778
778
|
document.addEventListener('visibilitychange', documentHandleVisibilityChange, false);
|
|
779
779
|
window.startDocumentVisibilityChange = true;
|
|
780
780
|
}, 3000);
|
|
781
781
|
}
|
|
782
782
|
} else {
|
|
783
783
|
|
|
784
784
|
!window.webviewVisible &&
|
|
785
785
|
(window.webviewVisible = (state) => {
|
|
786
786
|
if (window.startDocumentVisibilityChange) {
|
|
787
787
|
webviewThrottledTrigger(state);
|
|
788
788
|
} else {
|
|
789
789
|
Taro.eventCenter.trigger(
|
|
790
790
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE_INIT_NOW_TIME,
|
|
791
791
|
state,
|
|
792
792
|
);
|
|
793
793
|
}
|
|
794
794
|
state === 1 && taroEventSendPageScrollInfo();
|
|
795
795
|
});
|
|
796
796
|
setTimeout(() => {
|
|
797
797
|
window.startDocumentVisibilityChange = true;
|
|
798
798
|
}, 3000);
|
|
799
799
|
!window.floatReceiveData && (window.floatReceiveData = () => {});
|
|
800
800
|
}
|
|
801
801
|
MESSAGE_HOME_INIT: 'messageHomeInitPageData',
|
|
802
802
|
[Message_CallBack_Name.MESSAGE_HOME_INIT]: {},
|
|
803
803
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = {
|
|
804
804
|
displayHeight: 1920,
|
|
805
805
|
offSetY: 0,
|
|
806
806
|
};
|
|
807
807
|
if (options) {
|
|
808
808
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = options;
|
|
809
809
|
}
|
|
810
810
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {};
|
|
811
811
|
Taro.eventCenter.trigger(TaroEventType.PAGE_SCROLL, options || latestRes);
|
|
812
812
|
console.log('PageScrollEnd fire');
|
|
813
813
|
Taro.eventCenter.trigger(TaroEventType.PAGE_SCROLL_END, options);
|
|
814
814
|
const { businessType } = options;
|
|
815
815
|
switch (businessType) {
|
|
816
816
|
case H5_MSG_TO_H5_BUSINESSTYPE.JOIN_MEMBER_SUCCESS:
|
|
817
817
|
Taro.eventCenter.trigger(TaroEventType.JOIN_MEMBER_SUCCESS, options);
|
|
818
818
|
break;
|
|
819
819
|
case H5_MSG_TO_H5_BUSINESSTYPE.h5BaseDataChange:
|
|
820
820
|
Taro.eventCenter.trigger(TaroEventType.H5_BASE_DATA_CHANGE_REGISTER, options);
|
|
821
821
|
break;
|
|
822
822
|
default:
|
|
823
823
|
break;
|
|
824
824
|
}
|
|
825
825
|
const { shopHomeExtendInfo } = options;
|
|
826
826
|
if (shopHomeExtendInfo) {
|
|
827
827
|
Taro.eventCenter.trigger(TaroEventType.UPDATE_SHOP_HOME_EXTEND_DATA, shopHomeExtendInfo);
|
|
828
828
|
}
|
|
829
829
|
window && window.scrollTo(0, 0);
|
|
830
830
|
Taro.eventCenter.trigger(TaroEventType.PAGE_INIT_EXPOSURE, options);
|
|
831
831
|
const { action, params } = options;
|
|
832
832
|
console.log('taroEventShopStowSend', options);
|
|
833
833
|
if (action) {
|
|
834
834
|
Taro.eventCenter.trigger(action, params);
|
|
835
835
|
}
|
|
836
836
|
NATIVE_PAGE_READ: 'pageReady',
|
|
837
837
|
NATIVE_PAGE_FINISH: 'pageFinish',
|
|
838
838
|
NATIVE_INFO_DATA: 'nativeInfoData',
|
|
839
839
|
NATIVE_PAGE_SCROLL: 'pageScroll',
|
|
840
840
|
NATIVE_PAGE_SCROLL_END: 'pageScrollEnd',
|
|
841
841
|
NATIVE_GET_SCROLL_TOP: 'nativeGetScrollTop',
|
|
842
842
|
NATIVE_TO_SCROLL_TOP: 'nativeToScrollTop',
|
|
843
843
|
NATIVE_CLOSE_SCROLL_MESSAGE: 'nativeCloseScrollMessage',
|
|
844
844
|
NATIVE_MOBILE_CONFIG: 'getMobileConfig',
|
|
845
845
|
NATIVE_SHOW_TOAST: 'showToast',
|
|
846
846
|
NATIVE_SHOW_DIALOG: 'showDialog',
|
|
847
847
|
NATIVE_PAGE_LAYOUT_CHANGE: 'pageLayoutChange',
|
|
848
848
|
NATIVE_HOME_PAGING_ENABLE: 'homePagingEnable',
|
|
849
849
|
NATIVE_GET_SCALED_TOUCH_SLOP: 'getScaledTouchSlop',
|
|
850
850
|
NATIVE_ADD_CART: 'addCart',
|
|
851
851
|
NATIVE_JUMP_TAB_BAR: 'jumpTabBar',
|
|
852
852
|
NATIVE_OPEN_FLOAT: 'openFloat',
|
|
853
853
|
NATIVE_INJECT_JS_FILE: 'needIsvPackage',
|
|
854
854
|
NAVTIVE_FLOAT_READY: 'floatReady',
|
|
855
855
|
NATIVE_REFRESH_PAGE: 'refreshPage',
|
|
856
856
|
PAGE_PV_PARAM: 'pagePvParam',
|
|
857
857
|
NATIVE_SCORLL_VIEW: 'nativeScrollControl',
|
|
858
858
|
NATIVE_POP_WEBVIEW: 'popWebview',
|
|
859
859
|
NATIVE_H5_SEND_MSG_TO_H5: 'h5SendMsgToH5',
|
|
860
860
|
NATIVE_PUSH_NATIVE_PAGE: 'pushNativePage',
|
|
861
861
|
UPDATE_NATIVE_DATA: 'updateNativeData',
|
|
862
862
|
H5_TO_SCROLL_TOP: 'h5ToScrollTop',
|
|
863
863
|
LUXURY_INFORM_CHANGE_HEIGHT: 'sendImmersionStatus',
|
|
864
864
|
NATIVE_SHOPSTOW_SEND: 'sendMsgToShopStow',
|
|
865
865
|
NATIVE_UPDATE_PAGE_INFO: 'pageCountInfo',
|
|
866
866
|
NATIVE_TO_BUYER_SHOW_DETAIL: 'jumpBuyerShowDetail',
|
|
867
867
|
NATIVE_TO_HIDE_JD_SHOP_HEADER: 'hideNativeHeader',
|
|
868
868
|
NATIVE_TO_SHOW_CART_BTN: 'showCartButton',
|
|
869
869
|
NATIVE_IMMERSIVEHEADER_STATE_CHANGE: 'immersiveHeaderStateChange',
|
|
870
870
|
SHOP_FOLLOW_STATE_REGISTER: 'shopFollowStateRegister',
|
|
871
871
|
SHOP_FOLLOW_STATE_SYNC: 'shopFollowStateSync',
|
|
872
872
|
NATIVE_GET_SHOP_FOLLOW_STATE: 'getShopFollowState',
|
|
873
873
|
H5_TO_NATIVE_LIVE_RESERVE_STATE: 'shopLiveReserveStateSync',
|
|
874
874
|
H5_TO_NATIVE_SCROLL_TO_TOP: 'expertShopScrollToTop',
|
|
875
875
|
OPEN: 'open',
|
|
876
876
|
CLOSE: 'close',
|
|
877
877
|
JOIN_MEMBER_SUCCESS: 'joinMemberSuccess',
|
|
878
878
|
h5BaseDataChange: 'h5BaseDataChange',
|
|
879
879
|
type = Message_Type.NATIVE_PAGE_READ,
|
|
880
880
|
sendData: null | object = null,
|
|
881
881
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
882
882
|
console.log(
|
|
883
883
|
'初始化nativePageRegisterMessage-isAppStowShop-type-sendData-isJdApp-isH5AndJdShopView',
|
|
884
884
|
isAppStowShop,
|
|
885
885
|
type,
|
|
886
886
|
sendData,
|
|
887
887
|
isJdApp,
|
|
888
888
|
isH5AndJdShopView,
|
|
889
889
|
callBackName,
|
|
890
890
|
);
|
|
891
891
|
if (isJdApp) {
|
|
892
892
|
const getCallBackName = `window.${callBackName}`;
|
|
893
893
|
let getRouterParam = {
|
|
894
894
|
type,
|
|
895
895
|
callBackName: getCallBackName,
|
|
896
896
|
};
|
|
897
897
|
if (!isAppStowShop) {
|
|
898
898
|
getRouterParam['newHomePage'] = true;
|
|
899
899
|
}
|
|
900
900
|
if (sendData) {
|
|
901
901
|
getRouterParam = Object.assign({}, getRouterParam, sendData);
|
|
902
902
|
}
|
|
903
903
|
if (isIosDevice) {
|
|
904
904
|
const routerURL = isAppStowShop
|
|
905
905
|
? 'router://JDBDecorationPlatformModule/wrtNative'
|
|
906
906
|
: 'router://JDShopModule/wrtNative';
|
|
907
907
|
if (versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) >= 0) {
|
|
908
908
|
callRouterIOS({
|
|
909
909
|
routerURL,
|
|
910
910
|
routerParam: getRouterParam,
|
|
911
911
|
});
|
|
912
912
|
} else {
|
|
913
913
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
914
914
|
method: 'callRouterModuleWithParams',
|
|
915
915
|
params: {
|
|
916
916
|
routerURL,
|
|
917
917
|
serialize: '1',
|
|
918
918
|
routerParam: JSON.stringify(getRouterParam),
|
|
919
919
|
callBackName: getCallBackName,
|
|
920
920
|
callBackId: `${callBackName}Ios`,
|
|
921
921
|
},
|
|
922
922
|
});
|
|
923
923
|
}
|
|
924
924
|
} else if (isAndroidDevice) {
|
|
925
925
|
if (type === Message_Type.NATIVE_MOBILE_CONFIG && jdAppVersionCompare('13.2.8') >= 0) {
|
|
926
926
|
callRouterAndroid({
|
|
927
927
|
routerURL: 'router://JDJShopModule/wrtNative',
|
|
928
928
|
routerParam: getRouterParam,
|
|
929
929
|
});
|
|
930
930
|
} else {
|
|
931
931
|
window?.JDJshop?.wrtNative(
|
|
932
932
|
JSON.stringify({
|
|
933
933
|
routerParam: JSON.stringify(getRouterParam),
|
|
934
934
|
serialize: '1',
|
|
935
935
|
callBackName: getCallBackName,
|
|
936
936
|
callBackId: `${callBackName}Android`,
|
|
937
937
|
}),
|
|
938
938
|
);
|
|
939
939
|
}
|
|
940
940
|
} else if (isJdAndHarmonyDevice) {
|
|
941
941
|
const plugin = 'JdShopPlugin';
|
|
942
942
|
const action = type;
|
|
943
943
|
const params = {
|
|
944
944
|
routerURL: '',
|
|
945
945
|
routerParam: getRouterParam,
|
|
946
946
|
};
|
|
947
947
|
window.XWebView &&
|
|
948
948
|
window.XWebView.callNative(
|
|
949
949
|
plugin,
|
|
950
950
|
action,
|
|
951
951
|
JSON.stringify(params),
|
|
952
952
|
getCallBackName,
|
|
953
953
|
`${callBackName}HarmonyOS`,
|
|
954
954
|
);
|
|
955
955
|
}
|
|
956
956
|
return true;
|
|
957
957
|
}
|
|
958
958
|
return false;
|
|
959
959
|
if (isJdApp) {
|
|
960
960
|
if (isIosDevice) {
|
|
961
961
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage({
|
|
962
962
|
method: 'close',
|
|
963
963
|
});
|
|
964
964
|
} else if (isAndroidDevice) {
|
|
965
965
|
window?.XView && window?.XView.close();
|
|
966
966
|
} else if (isJdAndHarmonyDevice) {
|
|
967
967
|
nativeClosePopWebView();
|
|
968
968
|
}
|
|
969
969
|
}
|
|
970
970
|
console.log('showToastByRouter:', title, showType);
|
|
971
971
|
if (isJdApp) {
|
|
972
972
|
const routerParam = {
|
|
973
973
|
message: title,
|
|
974
974
|
iconType: showType,
|
|
975
975
|
duration,
|
|
976
976
|
};
|
|
977
977
|
if (isIosDevice) {
|
|
978
978
|
callRouterIOS({
|
|
979
979
|
routerURL: 'router://JDShopModule/showToast',
|
|
980
980
|
routerParam,
|
|
981
981
|
});
|
|
982
982
|
} else if (isAndroidDevice) {
|
|
983
983
|
callRouterAndroid({
|
|
984
984
|
routerURL: 'router://JDJShopModule/showToast',
|
|
985
985
|
routerParam,
|
|
986
986
|
});
|
|
987
987
|
} else if (isJdAndHarmonyDevice) {
|
|
988
988
|
const plugin = 'JdShopPlugin';
|
|
989
989
|
const action = 'showToast';
|
|
990
990
|
const params = {
|
|
991
991
|
routerURL: 'router://JDJShopModule/showToast',
|
|
992
992
|
routerParam: routerParam,
|
|
993
993
|
};
|
|
994
994
|
window.XWebView && window.XWebView.callNative(plugin, action, JSON.stringify(params));
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
997
|
console.log('nativePageLoadReady called');
|
|
998
998
|
Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
999
999
|
Message_Type.NATIVE_INFO_DATA
|
|
1000
1000
|
] = async (data: any) => {
|
|
1001
1001
|
console.log('nativePageLoadReady callBack:', callBack, ', data:', data);
|
|
1002
1002
|
callBack && callBack(data);
|
|
1003
1003
|
};
|
|
1004
1004
|
nativePageGetMessageInitCallBack();
|
|
1005
1005
|
nativePageRegisterMessage(
|
|
1006
1006
|
Message_Type.NATIVE_PAGE_READ,
|
|
1007
1007
|
sendData,
|
|
1008
1008
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
1009
1009
|
);
|
|
1010
1010
|
return nativePageRegisterMessage(
|
|
1011
1011
|
Message_Type.NATIVE_PAGE_FINISH,
|
|
1012
1012
|
null,
|
|
1013
1013
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
1014
1014
|
);
|
|
1015
1015
|
callBack &&
|
|
1016
1016
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
1017
1017
|
Message_Type.NATIVE_GET_SCROLL_TOP
|
|
1018
1018
|
] = callBack);
|
|
1019
1019
|
return nativePageRegisterMessage(
|
|
1020
1020
|
Message_Type.NATIVE_GET_SCROLL_TOP,
|
|
1021
1021
|
null,
|
|
1022
1022
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
1023
1023
|
);
|
|
1024
1024
|
callBack &&
|
|
1025
1025
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
1026
1026
|
Message_Type.NATIVE_TO_SCROLL_TOP
|
|
1027
1027
|
] = callBack);
|
|
1028
1028
|
nativePageRegisterMessage(
|
|
1029
1029
|
Message_Type.NATIVE_TO_SCROLL_TOP,
|
|
1030
1030
|
{
|
|
1031
1031
|
data: {
|
|
1032
1032
|
scrollTop,
|
|
1033
1033
|
},
|
|
1034
1034
|
},
|
|
1035
1035
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
1036
1036
|
);
|
|
1037
1037
|
Taro.eventCenter.trigger(TaroEventType.LUXURY_INFORM_CHANGE_HEIGHT, data);
|
|
1038
1038
|
Taro.eventCenter.trigger(TaroEventType.SHOP_FOLLOW_STATE_REGISTER, data);
|
|
1039
1039
|
Taro.eventCenter.trigger(TaroEventType.IMMERSIVEHEADER_STATE_CHANGE, data);
|
|
1040
1040
|
configName: string,
|
|
1041
1041
|
isBeforePageReady: boolean,
|
|
1042
1042
|
return new Promise((resolve, reject) => {
|
|
1043
1043
|
if (!isJdApp) {
|
|
1044
1044
|
reject({
|
|
1045
1045
|
code: -1,
|
|
1046
1046
|
message: 'getMPaasConfigByNative 只在松果APP店铺内部调用有效。',
|
|
1047
1047
|
});
|
|
1048
1048
|
return;
|
|
1049
1049
|
}
|
|
1050
1050
|
if (
|
|
1051
1051
|
isIosDevice &&
|
|
1052
1052
|
isBeforePageReady &&
|
|
1053
1053
|
versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) < 0
|
|
1054
1054
|
) {
|
|
1055
1055
|
reject({
|
|
1056
1056
|
code: -2,
|
|
1057
1057
|
message: `在nativePageLoadReady之前调用,低于v${MPAAS_CONFIG_APP_VERSION}不会有返回,兜底处理`,
|
|
1058
1058
|
});
|
|
1059
1059
|
return;
|
|
1060
1060
|
}
|
|
1061
1061
|
Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
1062
1062
|
Message_Type.NATIVE_MOBILE_CONFIG
|
|
1063
1063
|
] = (data: any) => {
|
|
1064
1064
|
const configData = isAndroidDevice ? data : data?.data;
|
|
1065
1065
|
const res = JSONParse(configData);
|
|
1066
1066
|
resolve(res);
|
|
1067
1067
|
};
|
|
1068
1068
|
nativePageGetMessageInitCallBack();
|
|
1069
1069
|
nativePageRegisterMessage(
|
|
1070
1070
|
Message_Type.NATIVE_MOBILE_CONFIG,
|
|
1071
1071
|
{
|
|
1072
1072
|
data: {
|
|
1073
1073
|
space: isIosDevice ? 'JDCDSHOP' : 'JDShop',
|
|
1074
1074
|
configName,
|
|
1075
1075
|
},
|
|
1076
1076
|
},
|
|
1077
1077
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
1078
1078
|
);
|
|
1079
1079
|
});
|
|
1080
1080
|
bussinessKey: string,
|
|
1081
1081
|
isBeforePageReady: boolean,
|
|
1082
1082
|
if (!bussinessKey) {
|
|
1083
1083
|
return null;
|
|
1084
1084
|
}
|
|
1085
1085
|
if (!isJdApp) {
|
|
1086
1086
|
return null;
|
|
1087
1087
|
}
|
|
1088
1088
|
const CACHED_MPAAS_KEY = `mpaas_${CONFIG_NAME}`;
|
|
1089
1089
|
const CACHED_MPAAS_KEY_HELPER = `${CACHED_MPAAS_KEY}_helper`;
|
|
1090
1090
|
let configData = window[CACHED_MPAAS_KEY];
|
|
1091
1091
|
if (configData == null) {
|
|
1092
1092
|
configData = await getMPaasConfigByNative(CONFIG_NAME, isBeforePageReady).catch((e) => {
|
|
1093
1093
|
console.log('getMPaasConfigByNative error:', e);
|
|
1094
1094
|
return null;
|
|
1095
1095
|
});
|
|
1096
1096
|
window[CACHED_MPAAS_KEY_HELPER] = {};
|
|
1097
1097
|
window[CACHED_MPAAS_KEY] = configData;
|
|
1098
1098
|
}
|
|
1099
1099
|
if (configData) {
|
|
1100
1100
|
const originData = configData[bussinessKey];
|
|
1101
1101
|
const hasParse = window[CACHED_MPAAS_KEY_HELPER][bussinessKey];
|
|
1102
1102
|
try {
|
|
1103
1103
|
if (hasParse || ['object', 'boolean', 'number'].includes(typeof originData)) {
|
|
1104
1104
|
return originData;
|
|
1105
1105
|
} else {
|
|
1106
1106
|
window[CACHED_MPAAS_KEY_HELPER][bussinessKey] = true;
|
|
1107
1107
|
const parseData = JSON.parse(configData[bussinessKey]);
|
|
1108
1108
|
configData[bussinessKey] = parseData;
|
|
1109
1109
|
return parseData;
|
|
1110
1110
|
}
|
|
1111
1111
|
} catch (e) {
|
|
1112
1112
|
return originData;
|
|
1113
1113
|
}
|
|
1114
1114
|
}
|
|
1115
1115
|
return null;
|
|
1116
1116
|
nativePageRegisterMessage(Message_Type.NATIVE_CLOSE_SCROLL_MESSAGE);
|
|
1117
1117
|
if (isJdAndAndroidDevice) {
|
|
1118
1118
|
callBack &&
|
|
1119
1119
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
1120
1120
|
Message_Type.NATIVE_HOME_PAGING_ENABLE
|
|
1121
1121
|
] = callBack);
|
|
1122
1122
|
nativePageRegisterMessage(Message_Type.NATIVE_HOME_PAGING_ENABLE, {
|
|
1123
1123
|
data: {
|
|
1124
1124
|
enable: enable,
|
|
1125
1125
|
},
|
|
1126
1126
|
});
|
|
1127
1127
|
}
|
|
1128
1128
|
if (isJdAndAndroidDevice) {
|
|
1129
1129
|
callBack &&
|
|
1130
1130
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
1131
1131
|
Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP
|
|
1132
1132
|
] = callBack);
|
|
1133
1133
|
nativePageRegisterMessage(Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP);
|
|
1134
1134
|
}
|
|
1135
1135
|
SUCCESS: 'success',
|
|
1136
1136
|
FAIL: 'fail',
|
|
1137
1137
|
NORMAL: 'normal',
|
|
1138
1138
|
SUCCESS: 2,
|
|
1139
1139
|
FAIL: 3,
|
|
1140
1140
|
NORMAL: 1,
|
|
1141
1141
|
SUCCESS: 2,
|
|
1142
1142
|
FAIL: 3,
|
|
1143
1143
|
NORMAL: 1,
|
|
1144
1144
|
[ToastIosType.NORMAL]: ToastType.NORMAL,
|
|
1145
1145
|
[ToastIosType.SUCCESS]: ToastType.SUCCESS,
|
|
1146
1146
|
[ToastIosType.FAIL]: ToastType.FAIL,
|
|
1147
1147
|
if (isShowNewRouterToast) {
|
|
1148
1148
|
const changeShowType = isJdAndIosDevice
|
|
1149
1149
|
? toastIosTypeToNewToastType[showType] || showType
|
|
1150
1150
|
: showType;
|
|
1151
1151
|
showToastByRouter(title, changeShowType, duration * 1000);
|
|
1152
1152
|
} else {
|
|
1153
1153
|
nativePageRegisterMessage(Message_Type.NATIVE_SHOW_TOAST, {
|
|
1154
1154
|
data: {
|
|
1155
1155
|
message: title,
|
|
1156
1156
|
iconType: showType,
|
|
1157
1157
|
duration,
|
|
1158
1158
|
},
|
|
1159
1159
|
});
|
|
1160
1160
|
}
|
|
1161
1161
|
routerURL,
|
|
1162
1162
|
routerParam,
|
|
1163
1163
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
1164
1164
|
isSync = false,
|
|
1165
1165
|
const getCallBackName = `window.${callBackName}`;
|
|
1166
1166
|
const params = {
|
|
1167
1167
|
routerURL,
|
|
1168
1168
|
serialize: '1',
|
|
1169
1169
|
routerParam,
|
|
1170
1170
|
callBackName: getCallBackName,
|
|
1171
1171
|
callBackId: `${callBackName}Ios`,
|
|
1172
1172
|
};
|
|
1173
1173
|
console.log(
|
|
1174
1174
|
'callRouterIOS routerURL:',
|
|
1175
1175
|
routerURL,
|
|
1176
1176
|
',routerParam:',
|
|
1177
1177
|
routerParam,
|
|
1178
1178
|
'params',
|
|
1179
1179
|
params,
|
|
1180
1180
|
'isSync',
|
|
1181
1181
|
isSync,
|
|
1182
1182
|
);
|
|
1183
1183
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
1184
1184
|
method: isSync ? 'callSyncRouterModuleWithParams' : 'callRouterModuleWithParams',
|
|
1185
1185
|
params: JSON.stringify(params),
|
|
1186
1186
|
});
|
|
1187
1187
|
routerURL,
|
|
1188
1188
|
routerParam,
|
|
1189
1189
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
1190
1190
|
isSync = false,
|
|
1191
1191
|
hasJdRouter = true,
|
|
1192
1192
|
console.log(
|
|
1193
1193
|
'callRouterAndroid routerURL:',
|
|
1194
1194
|
routerURL,
|
|
1195
1195
|
',routerParam:',
|
|
1196
1196
|
routerParam,
|
|
1197
1197
|
'isSync',
|
|
1198
1198
|
isSync,
|
|
1199
1199
|
);
|
|
1200
1200
|
const getCallBackName = `window.${callBackName}`;
|
|
1201
1201
|
routerParam?.data &&
|
|
1202
1202
|
typeof routerParam?.data === 'object' &&
|
|
1203
1203
|
(routerParam.data = JSON.stringify(routerParam?.data));
|
|
1204
1204
|
var params = {
|
|
1205
1205
|
serialize: '1',
|
|
1206
1206
|
routerURL,
|
|
1207
1207
|
routerParam,
|
|
1208
1208
|
callBackName: getCallBackName,
|
|
1209
1209
|
callBackId: `${callBackName}Android`,
|
|
1210
1210
|
};
|
|
1211
1211
|
hasJdRouter && (params['jdRouter'] = '1');
|
|
1212
1212
|
isSync
|
|
1213
1213
|
? window?.JDAppUnite?.callSyncRouterModuleWithParams(JSON.stringify(params))
|
|
1214
1214
|
: window?.JDAppUnite?.callRouterModuleWithParams(JSON.stringify(params));
|
|
1215
1215
|
pluginName,
|
|
1216
1216
|
action,
|
|
1217
1217
|
routerParam,
|
|
1218
1218
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
1219
1219
|
isSync = false,
|
|
1220
1220
|
const getCallBackName = `window.${callBackName}`;
|
|
1221
1221
|
const params = {
|
|
1222
1222
|
routerURL: '',
|
|
1223
1223
|
routerParam: routerParam,
|
|
1224
1224
|
};
|
|
1225
1225
|
const outBridgeType = ['getLastAddress', 'getAddress'];
|
|
1226
1226
|
console.log(
|
|
1227
1227
|
'callRouterHarmony pluginName:',
|
|
1228
1228
|
pluginName,
|
|
1229
1229
|
'action',
|
|
1230
1230
|
action,
|
|
1231
1231
|
',routerParam:',
|
|
1232
1232
|
routerParam,
|
|
1233
1233
|
'params',
|
|
1234
1234
|
params,
|
|
1235
1235
|
'isSync',
|
|
1236
1236
|
isSync,
|
|
1237
1237
|
);
|
|
1238
1238
|
window?.XWebView?.callNative(
|
|
1239
1239
|
pluginName,
|
|
1240
1240
|
action,
|
|
1241
1241
|
outBridgeType.includes(action) ? JSON.stringify(routerParam) : JSON.stringify(params),
|
|
1242
1242
|
getCallBackName,
|
|
1243
1243
|
`${callBackName}HarmonyOS`,
|
|
1244
1244
|
);
|
|
1245
1245
|
const params = {
|
|
1246
1246
|
action,
|
|
1247
1247
|
params: typeof routerParam === 'string' ? routerParam : JSON.stringify(routerParam),
|
|
1248
1248
|
};
|
|
1249
1249
|
console.log(
|
|
1250
1250
|
'callRouterHarmony pluginName:',
|
|
1251
1251
|
pluginName,
|
|
1252
1252
|
'action',
|
|
1253
1253
|
action,
|
|
1254
1254
|
',routerParam:',
|
|
1255
1255
|
routerParam,
|
|
1256
1256
|
'params',
|
|
1257
1257
|
params,
|
|
1258
1258
|
'isSync',
|
|
1259
1259
|
isSync,
|
|
1260
1260
|
);
|
|
1261
1261
|
return new Promise(async (resolve, reject) => {
|
|
1262
1262
|
if (!window?.XBridge) {
|
|
1263
1263
|
reject({
|
|
1264
1264
|
status: '-1001',
|
|
1265
1265
|
data: {},
|
|
1266
1266
|
msg: 'window.XBridge不存在',
|
|
1267
1267
|
});
|
|
1268
1268
|
return;
|
|
1269
1269
|
}
|
|
1270
1270
|
if (isSync) {
|
|
1271
1271
|
try {
|
|
1272
1272
|
const result = await window?.XBridge?.callNative(pluginName, {
|
|
1273
1273
|
...params,
|
|
1274
1274
|
sync: '1',
|
|
1275
1275
|
});
|
|
1276
1276
|
console.log('callRouterHarmony同步await', result);
|
|
1277
1277
|
resolve({
|
|
1278
1278
|
status: '0',
|
|
1279
1279
|
data: result,
|
|
1280
1280
|
msg: '',
|
|
1281
1281
|
});
|
|
1282
1282
|
} catch (err) {
|
|
1283
1283
|
const errMessage = err ? (typeof err === 'string' ? err : err.message || '') : '';
|
|
1284
1284
|
console.log('callRouterHarmony异步 调用error', err);
|
|
1285
1285
|
reject({
|
|
1286
1286
|
status: '-202',
|
|
1287
1287
|
data: {},
|
|
1288
1288
|
msg: errMessage || 'XBridge调用异常',
|
|
1289
1289
|
});
|
|
1290
1290
|
}
|
|
1291
1291
|
} else {
|
|
1292
1292
|
window?.XBridge?.callNative(pluginName, {
|
|
1293
1293
|
...params,
|
|
1294
1294
|
success: (res) => {
|
|
1295
1295
|
console.log('callRouterHarmony异步 调用success', res);
|
|
1296
1296
|
resolve({
|
|
1297
1297
|
status: '0',
|
|
1298
1298
|
data: res,
|
|
1299
1299
|
msg: '',
|
|
1300
1300
|
});
|
|
1301
1301
|
},
|
|
1302
1302
|
error: (err) => {
|
|
1303
1303
|
const errMessage = err ? (typeof err === 'string' ? err : err.message || '') : '';
|
|
1304
1304
|
console.log('callRouterHarmony异步 调用error', err);
|
|
1305
1305
|
reject({
|
|
1306
1306
|
status: '-202',
|
|
1307
1307
|
data: {},
|
|
1308
1308
|
msg: errMessage || 'XBridge调用异常',
|
|
1309
1309
|
});
|
|
1310
1310
|
},
|
|
1311
1311
|
});
|
|
1312
1312
|
}
|
|
1313
1313
|
});
|
|
1314
1314
|
callBack &&
|
|
1315
1315
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
1316
1316
|
Message_Type.NATIVE_SHOW_DIALOG
|
|
1317
1317
|
] = callBack);
|
|
1318
1318
|
return nativePageRegisterMessage(Message_Type.NATIVE_SHOW_DIALOG, {
|
|
1319
1319
|
data: params,
|
|
1320
1320
|
});
|
|
1321
1321
|
if (!isJdApp) {
|
|
1322
1322
|
return;
|
|
1323
1323
|
}
|
|
1324
1324
|
if (!window[Message_CallBack_Name.MESSAGE_HOME_INIT]) {
|
|
1325
1325
|
window[Message_CallBack_Name.MESSAGE_HOME_INIT] = (messageData) => {
|
|
1326
1326
|
try {
|
|
1327
1327
|
console.log('接收到原生通知返回的原始数据nativePageGetMessageInitCallBack', messageData);
|
|
1328
1328
|
const getMessageJsonData = JSONParse(messageData);
|
|
1329
1329
|
const { status } = getMessageJsonData;
|
|
1330
1330
|
if (status == '0') {
|
|
1331
1331
|
const { type, data } = getMessageJsonData?.data;
|
|
1332
1332
|
const getSendJsonData = JSONParse(data);
|
|
1333
1333
|
switch (type) {
|
|
1334
1334
|
case Message_Type.NATIVE_INFO_DATA:
|
|
1335
1335
|
case Message_Type.NATIVE_PAGE_FINISH:
|
|
1336
1336
|
case Message_Type.NATIVE_GET_SCROLL_TOP:
|
|
1337
1337
|
case Message_Type.NATIVE_TO_SCROLL_TOP:
|
|
1338
1338
|
case Message_Type.NATIVE_CLOSE_SCROLL_MESSAGE:
|
|
1339
1339
|
case Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP:
|
|
1340
1340
|
case Message_Type.NATIVE_MOBILE_CONFIG:
|
|
1341
1341
|
case Message_Type.NATIVE_GET_SHOP_FOLLOW_STATE:
|
|
1342
1342
|
const getTypeCallBack =
|
|
1343
1343
|
Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][type];
|
|
1344
1344
|
if (getTypeCallBack) {
|
|
1345
1345
|
const isCallBackFunc = typeof getTypeCallBack === 'function';
|
|
1346
1346
|
console.log('接收到原生通知 NATIVE_SHOPSTOW_SEND getSendJsonData', getSendJsonData);
|
|
1347
1347
|
isCallBackFunc && getTypeCallBack(getSendJsonData);
|
|
1348
1348
|
}
|
|
1349
1349
|
break;
|
|
1350
1350
|
case Message_Type.NATIVE_SHOW_DIALOG:
|
|
1351
1351
|
const showDialogCallBack =
|
|
1352
1352
|
Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][type];
|
|
1353
1353
|
if (showDialogCallBack) {
|
|
1354
1354
|
const isCallBackFunc = typeof showDialogCallBack === 'function';
|
|
1355
1355
|
console.log(
|
|
1356
1356
|
`获取${type}类型数据数据type isCallBackFunc getMessageJsonData `,
|
|
1357
1357
|
type,
|
|
1358
1358
|
isCallBackFunc,
|
|
1359
1359
|
getMessageJsonData,
|
|
1360
1360
|
);
|
|
1361
1361
|
isCallBackFunc && showDialogCallBack(getMessageJsonData?.data);
|
|
1362
1362
|
}
|
|
1363
1363
|
break;
|
|
1364
1364
|
case Message_Type.NATIVE_PAGE_SCROLL:
|
|
1365
1365
|
taroEventSendPageScrollInfo(data);
|
|
1366
1366
|
break;
|
|
1367
1367
|
case Message_Type.NATIVE_PAGE_SCROLL_END:
|
|
1368
1368
|
taroEventSendPageScrollEndInfo(data);
|
|
1369
1369
|
break;
|
|
1370
1370
|
case Message_Type.NATIVE_H5_SEND_MSG_TO_H5:
|
|
1371
1371
|
console.log('接收到原生通知 NATIVE_H5_SEND_MSG_TO_H5', data);
|
|
1372
1372
|
taroEventH5SendMsgToH5(getSendJsonData);
|
|
1373
1373
|
break;
|
|
1374
1374
|
case Message_Type.UPDATE_NATIVE_DATA:
|
|
1375
1375
|
taroEventUpdateNativeData(getSendJsonData);
|
|
1376
1376
|
break;
|
|
1377
1377
|
case Message_Type.H5_TO_SCROLL_TOP:
|
|
1378
1378
|
taroEventH5ToScrollTop();
|
|
1379
1379
|
break;
|
|
1380
1380
|
case Message_Type.NATIVE_SHOPSTOW_SEND:
|
|
1381
1381
|
console.log('接收到原生通知 NATIVE_SHOPSTOW_SEND', messageData);
|
|
1382
1382
|
console.log('接收到原生通知 NATIVE_SHOPSTOW_SEND getSendJsonData', getSendJsonData);
|
|
1383
1383
|
taroEventShopStowSend(getSendJsonData);
|
|
1384
1384
|
break;
|
|
1385
1385
|
case Message_Type.LUXURY_INFORM_CHANGE_HEIGHT:
|
|
1386
1386
|
taroEventSendImmersionStatus(data);
|
|
1387
1387
|
break;
|
|
1388
1388
|
case Message_Type.NATIVE_IMMERSIVEHEADER_STATE_CHANGE:
|
|
1389
1389
|
taroEventSendImmersiveHeaderChange(data);
|
|
1390
1390
|
break;
|
|
1391
1391
|
case Message_Type.SHOP_FOLLOW_STATE_REGISTER:
|
|
1392
1392
|
taroEventSendShopFollowStateChange(data);
|
|
1393
1393
|
break;
|
|
1394
1394
|
default:
|
|
1395
1395
|
}
|
|
1396
1396
|
} else {
|
|
1397
1397
|
console.log('传递数据获取异常', getMessageJsonData);
|
|
1398
1398
|
}
|
|
1399
1399
|
} catch (e) {
|
|
1400
1400
|
console.log('获取转换异常结果', e);
|
|
1401
1401
|
}
|
|
1402
1402
|
};
|
|
1403
1403
|
}
|
|
1404
1404
|
console.warn('🚀 ~~ JumpTabBarInCurrentShop() ~~ params:', params);
|
|
1405
1405
|
nativePageRegisterMessage(Message_Type.NATIVE_JUMP_TAB_BAR, {
|
|
1406
1406
|
data: params,
|
|
1407
1407
|
});
|
|
1408
1408
|
nativePageRegisterMessage(Message_Type.NATIVE_OPEN_FLOAT, {
|
|
1409
1409
|
data: params,
|
|
1410
1410
|
});
|
|
1411
1411
|
const changeData = {
|
|
1412
1412
|
type: NATIVE_POP_WEBVIEW_TYPE.OPEN,
|
|
1413
1413
|
height: DEFAULT_POP_WEBVIEW_HEIGHT,
|
|
1414
1414
|
};
|
|
1415
1415
|
if (isChangeDefaultPopViewHeight && !params?.height) {
|
|
1416
1416
|
changeData.height = Math.round(window.screen.height * 0.8);
|
|
1417
1417
|
changeData.borderRadius = 12;
|
|
1418
1418
|
}
|
|
1419
1419
|
nativePageRegisterMessage(Message_Type.NATIVE_POP_WEBVIEW, {
|
|
1420
1420
|
data: {
|
|
1421
1421
|
...changeData,
|
|
1422
1422
|
...params,
|
|
1423
1423
|
},
|
|
1424
1424
|
});
|
|
1425
1425
|
nativePageRegisterMessage(Message_Type.NATIVE_POP_WEBVIEW, {
|
|
1426
1426
|
data: {
|
|
1427
1427
|
type: NATIVE_POP_WEBVIEW_TYPE.CLOSE,
|
|
1428
1428
|
...params,
|
|
1429
1429
|
},
|
|
1430
1430
|
});
|
|
1431
1431
|
Taro.eventCenter.off(TaroEventType.JOIN_MEMBER_SUCCESS);
|
|
1432
1432
|
console.log('popWebview关闭');
|
|
1433
1433
|
nativePageRegisterMessage(Message_Type.NATIVE_H5_SEND_MSG_TO_H5, {
|
|
1434
1434
|
data: params,
|
|
1435
1435
|
});
|
|
1436
1436
|
nativePageRegisterMessage(Message_Type.NATIVE_PUSH_NATIVE_PAGE, {
|
|
1437
1437
|
data: params,
|
|
1438
1438
|
});
|
|
1439
1439
|
window &&
|
|
1440
1440
|
(window.location.href = `xview://search?request={"action":"${Message_Type.NAVTIVE_FLOAT_READY}"}`);
|
|
1441
1441
|
const { displayHeight, offSetY } = res;
|
|
1442
1442
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return;
|
|
1443
1443
|
if (isIosDevice) return res;
|
|
1444
1444
|
if (isAndroidDevice) {
|
|
1445
1445
|
const deviceRatio = window.devicePixelRatio;
|
|
1446
1446
|
const cssDisplayHeight = Math.ceil(displayHeight / deviceRatio);
|
|
1447
1447
|
const cssOffsetY = Math.ceil(offSetY / deviceRatio);
|
|
1448
1448
|
return {
|
|
1449
1449
|
displayHeight: cssDisplayHeight,
|
|
1450
1450
|
offSetY: cssOffsetY,
|
|
1451
1451
|
};
|
|
1452
1452
|
}
|
|
1453
1453
|
nativePageRegisterMessage(Message_Type.NATIVE_UPDATE_PAGE_INFO, {
|
|
1454
1454
|
data: params,
|
|
1455
1455
|
});
|
|
1456
1456
|
nativePageRegisterMessage(Message_Type.NATIVE_TO_BUYER_SHOW_DETAIL, {
|
|
1457
1457
|
data: params,
|
|
1458
1458
|
});
|
|
1459
1459
|
nativePageRegisterMessage(Message_Type.NATIVE_TO_HIDE_JD_SHOP_HEADER, {
|
|
1460
1460
|
data: params,
|
|
1461
1461
|
});
|
|
1462
1462
|
nativePageRegisterMessage(Message_Type.NATIVE_TO_SHOW_CART_BTN, {
|
|
1463
1463
|
data: params,
|
|
1464
1464
|
});
|
|
1465
1465
|
nativePageRegisterMessage(Message_Type.SHOP_FOLLOW_STATE_REGISTER, {
|
|
1466
1466
|
data: params,
|
|
1467
1467
|
});
|
|
1468
1468
|
callBack &&
|
|
1469
1469
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
1470
1470
|
Message_Type.NATIVE_GET_SHOP_FOLLOW_STATE
|
|
1471
1471
|
] = callBack);
|
|
1472
1472
|
nativePageRegisterMessage(Message_Type.NATIVE_GET_SHOP_FOLLOW_STATE, {
|
|
1473
1473
|
data: {},
|
|
1474
1474
|
});
|
|
1475
1475
|
nativePageRegisterMessage(Message_Type.SHOP_FOLLOW_STATE_SYNC, {
|
|
1476
1476
|
data: {
|
|
1477
1477
|
followed: followState,
|
|
1478
1478
|
},
|
|
1479
1479
|
});
|
|
1480
1480
|
nativePageRegisterMessage(Message_Type.H5_TO_NATIVE_LIVE_RESERVE_STATE, {
|
|
1481
1481
|
data: params,
|
|
1482
1482
|
});
|
|
1483
1483
|
Taro.eventCenter.on('SEND_MSG_TO_NATIVE', (key, params) => {
|
|
1484
1484
|
nativePageRegisterMessage(key, {
|
|
1485
1485
|
data: params,
|
|
1486
1486
|
});
|
|
1487
1487
|
});
|
|
1488
1488
|
nativePageRegisterMessage(Message_Type.H5_TO_NATIVE_SCROLL_TO_TOP, {
|
|
1489
1489
|
data: params,
|
|
1490
1490
|
});
|