@conecli/cone-render 0.10.1-shop-beta.27 → 0.10.1-shop-beta.28

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