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

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
  SHOW_BACK_TOTOP: 'showBackToTop',
895
895
  OPEN: 'open',
896
896
  CLOSE: 'close',
897
897
  JOIN_MEMBER_SUCCESS: 'joinMemberSuccess',
898
898
  h5BaseDataChange: 'h5BaseDataChange',
899
899
  type = Message_Type.NATIVE_PAGE_READ,
900
900
  sendData: null | object = null,
901
901
  callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
902
902
  console.log(
903
903
  '初始化nativePageRegisterMessage-isAppStowShop-type-sendData-isJdApp-isH5AndJdShopView',
904
904
  isAppStowShop,
905
905
  type,
906
906
  sendData,
907
907
  isJdApp,
908
908
  isH5AndJdShopView,
909
909
  callBackName,
910
910
  );
911
911
  if (isJdApp) {
912
912
  const getCallBackName = `window.${callBackName}`;
913
913
  let getRouterParam = {
914
914
  type,
915
915
  callBackName: getCallBackName,
916
916
  };
917
917
  if (!isAppStowShop) {
918
918
  getRouterParam['newHomePage'] = true;
919
919
  }
920
920
  if (sendData) {
921
921
  getRouterParam = Object.assign({}, getRouterParam, sendData);
922
922
  }
923
923
  if (isIosDevice) {
924
924
  const routerURL = isAppStowShop
925
925
  ? 'router://JDBDecorationPlatformModule/wrtNative'
926
926
  : 'router://JDShopModule/wrtNative';
927
927
  if (versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) >= 0) {
928
928
  callRouterIOS({
929
929
  routerURL,
930
930
  routerParam: getRouterParam,
931
931
  });
932
932
  } else {
933
933
  window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
934
934
  method: 'callRouterModuleWithParams',
935
935
  params: {
936
936
  routerURL,
937
937
  serialize: '1',
938
938
  routerParam: JSON.stringify(getRouterParam),
939
939
  callBackName: getCallBackName,
940
940
  callBackId: `${callBackName}Ios`,
941
941
  },
942
942
  });
943
943
  }
944
944
  } else if (isAndroidDevice) {
945
945
  if (type === Message_Type.NATIVE_MOBILE_CONFIG && jdAppVersionCompare('13.2.8') >= 0) {
946
946
  callRouterAndroid({
947
947
  routerURL: 'router://JDJShopModule/wrtNative',
948
948
  routerParam: getRouterParam,
949
949
  });
950
950
  } else {
951
951
  window?.JDJshop?.wrtNative(
952
952
  JSON.stringify({
953
953
  routerParam: JSON.stringify(getRouterParam),
954
954
  serialize: '1',
955
955
  callBackName: getCallBackName,
956
956
  callBackId: `${callBackName}Android`,
957
957
  }),
958
958
  );
959
959
  }
960
960
  } else if (isJdAndHarmonyDevice) {
961
961
  const plugin = 'JdShopPlugin';
962
962
  const action = type;
963
963
  const params = {
964
964
  routerURL: '',
965
965
  routerParam: getRouterParam,
966
966
  };
967
967
  window.XWebView &&
968
968
  window.XWebView.callNative(
969
969
  plugin,
970
970
  action,
971
971
  JSON.stringify(params),
972
972
  getCallBackName,
973
973
  `${callBackName}HarmonyOS`,
974
974
  );
975
975
  }
976
976
  return true;
977
977
  }
978
978
  return false;
979
979
  if (isJdApp) {
980
980
  if (isIosDevice) {
981
981
  window?.webkit?.messageHandlers?.MobileNavi?.postMessage({
982
982
  method: 'close',
983
983
  });
984
984
  } else if (isAndroidDevice) {
985
985
  window?.XView && window?.XView.close();
986
986
  } else if (isJdAndHarmonyDevice) {
987
987
  !isInLiveroomChannel && nativeClosePopWebView();
988
988
  if (isInLiveroomChannel && window?.JDLiveAppJS) {
989
989
  window?.JDLiveAppJS?.handleJs(
990
990
  JSON.stringify([
991
991
  {
992
992
  action: 'closeWeb',
993
993
  params: {},
994
994
  },
995
995
  ]),
996
996
  );
997
997
  } else {
998
998
  window?.XWebView?.callNative &&
999
999
  window.XWebView.callNative(
1000
1000
  'JDXViewPlugin',
1001
1001
  'closeLayer2',
1002
1002
  JSON.stringify({}),
1003
1003
  'shopxCloseXview',
1004
1004
  '1',
1005
1005
  );
1006
1006
  }
1007
1007
  }
1008
1008
  }
1009
1009
  console.log('showToastByRouter:', title, showType);
1010
1010
  if (isJdApp) {
1011
1011
  const routerParam = {
1012
1012
  message: title,
1013
1013
  iconType: showType,
1014
1014
  duration,
1015
1015
  };
1016
1016
  if (isIosDevice) {
1017
1017
  callRouterIOS({
1018
1018
  routerURL: 'router://JDShopModule/showToast',
1019
1019
  routerParam,
1020
1020
  });
1021
1021
  } else if (isAndroidDevice) {
1022
1022
  callRouterAndroid({
1023
1023
  routerURL: 'router://JDJShopModule/showToast',
1024
1024
  routerParam,
1025
1025
  });
1026
1026
  } else if (isJdAndHarmonyDevice) {
1027
1027
  const getHarmonyVersion = window?.shopGlobalSwitch?.useNativeHarmonyToastVersion;
1028
1028
  if (
1029
1029
  getHarmonyVersion &&
1030
1030
  jdAppVersionCompare(getHarmonyVersion) >= 0 &&
1031
1031
  !isInJdShopView &&
1032
1032
  window?.jmfe?.callRouter
1033
1033
  ) {
1034
1034
  const params = {
1035
1035
  routerURL: 'router://JDJShopxModule/showToast',
1036
1036
  routerParam: routerParam,
1037
1037
  sync: '',
1038
1038
  };
1039
1039
  window.jmfe.callRouter(params).then((res) => {
1040
1040
  console.log('鸿蒙调用toast成功', res);
1041
1041
  });
1042
1042
  } else {
1043
1043
  const plugin = 'JdShopPlugin';
1044
1044
  const action = 'showToast';
1045
1045
  const params = {
1046
1046
  routerURL: 'router://JDJShopModule/showToast',
1047
1047
  routerParam: routerParam,
1048
1048
  };
1049
1049
  window.XWebView && window.XWebView.callNative(plugin, action, JSON.stringify(params));
1050
1050
  }
1051
1051
  }
1052
1052
  }
1053
1053
  console.log('nativePageLoadReady called');
1054
1054
  Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1055
1055
  Message_Type.NATIVE_INFO_DATA
1056
1056
  ] = async (data: any) => {
1057
1057
  console.log('nativePageLoadReady callBack:', callBack, ', data:', data);
1058
1058
  callBack && callBack(data);
1059
1059
  };
1060
1060
  nativePageGetMessageInitCallBack();
1061
1061
  nativePageRegisterMessage(
1062
1062
  Message_Type.NATIVE_PAGE_READ,
1063
1063
  sendData,
1064
1064
  Message_CallBack_Name.MESSAGE_HOME_INIT,
1065
1065
  );
1066
1066
  return nativePageRegisterMessage(
1067
1067
  Message_Type.NATIVE_PAGE_FINISH,
1068
1068
  null,
1069
1069
  Message_CallBack_Name.MESSAGE_HOME_INIT,
1070
1070
  );
1071
1071
  callBack &&
1072
1072
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1073
1073
  Message_Type.NATIVE_GET_SCROLL_TOP
1074
1074
  ] = callBack);
1075
1075
  return nativePageRegisterMessage(
1076
1076
  Message_Type.NATIVE_GET_SCROLL_TOP,
1077
1077
  null,
1078
1078
  Message_CallBack_Name.MESSAGE_HOME_INIT,
1079
1079
  );
1080
1080
  callBack &&
1081
1081
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1082
1082
  Message_Type.NATIVE_TO_SCROLL_TOP
1083
1083
  ] = callBack);
1084
1084
  nativePageRegisterMessage(
1085
1085
  Message_Type.NATIVE_TO_SCROLL_TOP,
1086
1086
  {
1087
1087
  data: {
1088
1088
  scrollTop,
1089
1089
  },
1090
1090
  },
1091
1091
  Message_CallBack_Name.MESSAGE_HOME_INIT,
1092
1092
  );
1093
1093
  Taro.eventCenter.trigger(TaroEventType.LUXURY_INFORM_CHANGE_HEIGHT, data);
1094
1094
  Taro.eventCenter.trigger(TaroEventType.SHOP_FOLLOW_STATE_REGISTER, data);
1095
1095
  Taro.eventCenter.trigger(TaroEventType.IMMERSIVEHEADER_STATE_CHANGE, data);
1096
1096
  configName: string,
1097
1097
  isBeforePageReady: boolean,
1098
1098
  return new Promise((resolve, reject) => {
1099
1099
  if (!isJdApp) {
1100
1100
  reject({
1101
1101
  code: -1,
1102
1102
  message: 'getMPaasConfigByNative 只在松果APP店铺内部调用有效。',
1103
1103
  });
1104
1104
  return;
1105
1105
  }
1106
1106
  if (
1107
1107
  isIosDevice &&
1108
1108
  isBeforePageReady &&
1109
1109
  versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) < 0
1110
1110
  ) {
1111
1111
  reject({
1112
1112
  code: -2,
1113
1113
  message: `在nativePageLoadReady之前调用,低于v${MPAAS_CONFIG_APP_VERSION}不会有返回,兜底处理`,
1114
1114
  });
1115
1115
  return;
1116
1116
  }
1117
1117
  Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1118
1118
  Message_Type.NATIVE_MOBILE_CONFIG
1119
1119
  ] = (data: any) => {
1120
1120
  const configData = isAndroidDevice ? data : data?.data;
1121
1121
  const res = JSONParse(configData);
1122
1122
  resolve(res);
1123
1123
  };
1124
1124
  nativePageGetMessageInitCallBack();
1125
1125
  nativePageRegisterMessage(
1126
1126
  Message_Type.NATIVE_MOBILE_CONFIG,
1127
1127
  {
1128
1128
  data: {
1129
1129
  space: isIosDevice ? 'JDCDSHOP' : 'JDShop',
1130
1130
  configName,
1131
1131
  },
1132
1132
  },
1133
1133
  Message_CallBack_Name.MESSAGE_HOME_INIT,
1134
1134
  );
1135
1135
  });
1136
1136
  bussinessKey: string,
1137
1137
  isBeforePageReady: boolean,
1138
1138
  if (!bussinessKey) {
1139
1139
  return null;
1140
1140
  }
1141
1141
  if (!isJdApp) {
1142
1142
  return null;
1143
1143
  }
1144
1144
  const CACHED_MPAAS_KEY = `mpaas_${CONFIG_NAME}`;
1145
1145
  const CACHED_MPAAS_KEY_HELPER = `${CACHED_MPAAS_KEY}_helper`;
1146
1146
  let configData = window[CACHED_MPAAS_KEY];
1147
1147
  if (configData == null) {
1148
1148
  configData = await getMPaasConfigByNative(CONFIG_NAME, isBeforePageReady).catch((e) => {
1149
1149
  console.log('getMPaasConfigByNative error:', e);
1150
1150
  return null;
1151
1151
  });
1152
1152
  window[CACHED_MPAAS_KEY_HELPER] = {};
1153
1153
  window[CACHED_MPAAS_KEY] = configData;
1154
1154
  }
1155
1155
  if (configData) {
1156
1156
  const originData = configData[bussinessKey];
1157
1157
  const hasParse = window[CACHED_MPAAS_KEY_HELPER][bussinessKey];
1158
1158
  try {
1159
1159
  if (hasParse || ['object', 'boolean', 'number'].includes(typeof originData)) {
1160
1160
  return originData;
1161
1161
  } else {
1162
1162
  window[CACHED_MPAAS_KEY_HELPER][bussinessKey] = true;
1163
1163
  const parseData = JSON.parse(configData[bussinessKey]);
1164
1164
  configData[bussinessKey] = parseData;
1165
1165
  return parseData;
1166
1166
  }
1167
1167
  } catch (e) {
1168
1168
  return originData;
1169
1169
  }
1170
1170
  }
1171
1171
  return null;
1172
1172
  nativePageRegisterMessage(Message_Type.NATIVE_CLOSE_SCROLL_MESSAGE);
1173
1173
  if (isJdAndAndroidDevice) {
1174
1174
  callBack &&
1175
1175
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1176
1176
  Message_Type.NATIVE_HOME_PAGING_ENABLE
1177
1177
  ] = callBack);
1178
1178
  nativePageRegisterMessage(Message_Type.NATIVE_HOME_PAGING_ENABLE, {
1179
1179
  data: {
1180
1180
  enable: enable,
1181
1181
  },
1182
1182
  });
1183
1183
  }
1184
1184
  if (isJdAndAndroidDevice) {
1185
1185
  callBack &&
1186
1186
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1187
1187
  Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP
1188
1188
  ] = callBack);
1189
1189
  nativePageRegisterMessage(Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP);
1190
1190
  }
1191
1191
  SUCCESS: 'success',
1192
1192
  FAIL: 'fail',
1193
1193
  NORMAL: 'normal',
1194
1194
  SUCCESS: 2,
1195
1195
  FAIL: 3,
1196
1196
  NORMAL: 1,
1197
1197
  SUCCESS: 2,
1198
1198
  FAIL: 3,
1199
1199
  NORMAL: 1,
1200
1200
  [ToastIosType.NORMAL]: ToastType.NORMAL,
1201
1201
  [ToastIosType.SUCCESS]: ToastType.SUCCESS,
1202
1202
  [ToastIosType.FAIL]: ToastType.FAIL,
1203
1203
  if (isShowNewRouterToast) {
1204
1204
  const changeShowType = isJdAndIosDevice
1205
1205
  ? toastIosTypeToNewToastType[showType] || showType
1206
1206
  : showType;
1207
1207
  showToastByRouter(title, changeShowType, duration * 1000);
1208
1208
  } else {
1209
1209
  nativePageRegisterMessage(Message_Type.NATIVE_SHOW_TOAST, {
1210
1210
  data: {
1211
1211
  message: title,
1212
1212
  iconType: showType,
1213
1213
  duration,
1214
1214
  },
1215
1215
  });
1216
1216
  }
1217
1217
  routerURL,
1218
1218
  routerParam,
1219
1219
  callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
1220
1220
  isSync = false,
1221
1221
  const getCallBackName = `window.${callBackName}`;
1222
1222
  const params = {
1223
1223
  routerURL,
1224
1224
  serialize: '1',
1225
1225
  routerParam,
1226
1226
  callBackName: getCallBackName,
1227
1227
  callBackId: `${callBackName}Ios`,
1228
1228
  };
1229
1229
  console.log(
1230
1230
  'callRouterIOS routerURL:',
1231
1231
  routerURL,
1232
1232
  ',routerParam:',
1233
1233
  routerParam,
1234
1234
  'params',
1235
1235
  params,
1236
1236
  'isSync',
1237
1237
  isSync,
1238
1238
  );
1239
1239
  window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
1240
1240
  method: isSync ? 'callSyncRouterModuleWithParams' : 'callRouterModuleWithParams',
1241
1241
  params: JSON.stringify(params),
1242
1242
  });
1243
1243
  routerURL,
1244
1244
  routerParam,
1245
1245
  callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
1246
1246
  isSync = false,
1247
1247
  hasJdRouter = true,
1248
1248
  console.log(
1249
1249
  'callRouterAndroid routerURL:',
1250
1250
  routerURL,
1251
1251
  ',routerParam:',
1252
1252
  routerParam,
1253
1253
  'isSync',
1254
1254
  isSync,
1255
1255
  );
1256
1256
  const getCallBackName = `window.${callBackName}`;
1257
1257
  routerParam?.data &&
1258
1258
  typeof routerParam?.data === 'object' &&
1259
1259
  (routerParam.data = JSON.stringify(routerParam?.data));
1260
1260
  var params = {
1261
1261
  serialize: '1',
1262
1262
  routerURL,
1263
1263
  routerParam,
1264
1264
  callBackName: getCallBackName,
1265
1265
  callBackId: `${callBackName}Android`,
1266
1266
  };
1267
1267
  hasJdRouter && (params['jdRouter'] = '1');
1268
1268
  isSync
1269
1269
  ? window?.JDAppUnite?.callSyncRouterModuleWithParams(JSON.stringify(params))
1270
1270
  : window?.JDAppUnite?.callRouterModuleWithParams(JSON.stringify(params));
1271
1271
  pluginName,
1272
1272
  action,
1273
1273
  routerParam,
1274
1274
  callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
1275
1275
  isSync = false,
1276
1276
  const getCallBackName = `window.${callBackName}`;
1277
1277
  const params = {
1278
1278
  routerURL: '',
1279
1279
  routerParam: routerParam,
1280
1280
  };
1281
1281
  const outBridgeType = ['getLastAddress', 'getAddress'];
1282
1282
  console.log(
1283
1283
  'callRouterHarmony pluginName:',
1284
1284
  pluginName,
1285
1285
  'action',
1286
1286
  action,
1287
1287
  ',routerParam:',
1288
1288
  routerParam,
1289
1289
  'params',
1290
1290
  params,
1291
1291
  'isSync',
1292
1292
  isSync,
1293
1293
  );
1294
1294
  window?.XWebView?.callNative(
1295
1295
  pluginName,
1296
1296
  action,
1297
1297
  outBridgeType.includes(action) ? JSON.stringify(routerParam) : JSON.stringify(params),
1298
1298
  getCallBackName,
1299
1299
  `${callBackName}HarmonyOS`,
1300
1300
  );
1301
1301
  callRouterHarmony,
1302
1302
  callBack &&
1303
1303
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1304
1304
  Message_Type.NATIVE_SHOW_DIALOG
1305
1305
  ] = callBack);
1306
1306
  return nativePageRegisterMessage(Message_Type.NATIVE_SHOW_DIALOG, {
1307
1307
  data: params,
1308
1308
  });
1309
1309
  if (!isJdApp) {
1310
1310
  return;
1311
1311
  }
1312
1312
  if (!window[Message_CallBack_Name.MESSAGE_HOME_INIT]) {
1313
1313
  window[Message_CallBack_Name.MESSAGE_HOME_INIT] = (messageData) => {
1314
1314
  try {
1315
1315
  console.log('message2native 接收消息:', JSON.stringify(messageData));
1316
1316
  console.log('接收到原生通知返回的原始数据nativePageGetMessageInitCallBack', messageData);
1317
1317
  const getMessageJsonData = JSONParse(messageData);
1318
1318
  const { status } = getMessageJsonData;
1319
1319
  if (status == '0') {
1320
1320
  const { type, data } = getMessageJsonData?.data;
1321
1321
  const getSendJsonData = JSONParse(data);
1322
1322
  switch (type) {
1323
1323
  case Message_Type.NATIVE_INFO_DATA:
1324
1324
  case Message_Type.NATIVE_PAGE_FINISH:
1325
1325
  case Message_Type.NATIVE_GET_SCROLL_TOP:
1326
1326
  case Message_Type.NATIVE_TO_SCROLL_TOP:
1327
1327
  case Message_Type.NATIVE_CLOSE_SCROLL_MESSAGE:
1328
1328
  case Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP:
1329
1329
  case Message_Type.NATIVE_MOBILE_CONFIG:
1330
1330
  case Message_Type.NATIVE_GET_SHOP_FOLLOW_STATE:
1331
1331
  case Message_Type.GET_ENTER_SHOP_OPEN_APP:
1332
1332
  const getTypeCallBack =
1333
1333
  Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][type];
1334
1334
  if (getTypeCallBack) {
1335
1335
  const isCallBackFunc = typeof getTypeCallBack === 'function';
1336
1336
  console.log('接收到原生通知 NATIVE_SHOPSTOW_SEND getSendJsonData', getSendJsonData);
1337
1337
  isCallBackFunc && getTypeCallBack(getSendJsonData);
1338
1338
  }
1339
1339
  break;
1340
1340
  case Message_Type.GET_COLOR_API_DATA:
1341
1341
  const combinType = `${type}_${getSendJsonData.functionId}`;
1342
1342
  const getcombinTypeCallBack =
1343
1343
  Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1344
1344
  combinType
1345
1345
  ];
1346
1346
  if (getcombinTypeCallBack) {
1347
1347
  const isCallBackFunc = typeof getcombinTypeCallBack === 'function';
1348
1348
  console.log('接收到原生通知 NATIVE_SHOPSTOW_SEND getSendJsonData', getSendJsonData);
1349
1349
  if (
1350
1350
  (isAndroidDevice || isIosDevice) &&
1351
1351
  getSendJsonData.functionData &&
1352
1352
  typeof getSendJsonData.functionData === 'string'
1353
1353
  ) {
1354
1354
  getSendJsonData.functionData = JSONParse(getSendJsonData.functionData);
1355
1355
  }
1356
1356
  isCallBackFunc && getcombinTypeCallBack(getSendJsonData);
1357
1357
  }
1358
1358
  break;
1359
1359
  case Message_Type.NATIVE_SHOW_DIALOG:
1360
1360
  const showDialogCallBack =
1361
1361
  Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][type];
1362
1362
  if (showDialogCallBack) {
1363
1363
  const isCallBackFunc = typeof showDialogCallBack === 'function';
1364
1364
  console.log(
1365
1365
  `获取${type}类型数据数据type isCallBackFunc getMessageJsonData `,
1366
1366
  type,
1367
1367
  isCallBackFunc,
1368
1368
  getMessageJsonData,
1369
1369
  );
1370
1370
  isCallBackFunc && showDialogCallBack(getMessageJsonData?.data);
1371
1371
  }
1372
1372
  break;
1373
1373
  case Message_Type.NATIVE_PAGE_SCROLL:
1374
1374
  taroEventSendPageScrollInfo(data);
1375
1375
  break;
1376
1376
  case Message_Type.NATIVE_PAGE_SCROLL_END:
1377
1377
  taroEventSendPageScrollEndInfo(data);
1378
1378
  break;
1379
1379
  case Message_Type.NATIVE_H5_SEND_MSG_TO_H5:
1380
1380
  console.log('接收到原生通知 NATIVE_H5_SEND_MSG_TO_H5', data);
1381
1381
  taroEventH5SendMsgToH5(getSendJsonData);
1382
1382
  break;
1383
1383
  case Message_Type.UPDATE_NATIVE_DATA:
1384
1384
  taroEventUpdateNativeData(getSendJsonData);
1385
1385
  break;
1386
1386
  case Message_Type.H5_TO_SCROLL_TOP:
1387
1387
  taroEventH5ToScrollTop();
1388
1388
  break;
1389
1389
  case Message_Type.NATIVE_SHOPSTOW_SEND:
1390
1390
  console.log('接收到原生通知 NATIVE_SHOPSTOW_SEND', messageData);
1391
1391
  console.log('接收到原生通知 NATIVE_SHOPSTOW_SEND getSendJsonData', getSendJsonData);
1392
1392
  taroEventShopStowSend(getSendJsonData);
1393
1393
  break;
1394
1394
  case Message_Type.LUXURY_INFORM_CHANGE_HEIGHT:
1395
1395
  taroEventSendImmersionStatus(data);
1396
1396
  break;
1397
1397
  case Message_Type.NATIVE_IMMERSIVEHEADER_STATE_CHANGE:
1398
1398
  taroEventSendImmersiveHeaderChange(data);
1399
1399
  break;
1400
1400
  case Message_Type.SHOP_FOLLOW_STATE_REGISTER:
1401
1401
  taroEventSendShopFollowStateChange(data);
1402
1402
  break;
1403
1403
  default:
1404
1404
  }
1405
1405
  } else {
1406
1406
  console.log('传递数据获取异常', getMessageJsonData);
1407
1407
  }
1408
1408
  } catch (e) {
1409
1409
  console.log('获取转换异常结果', e);
1410
1410
  }
1411
1411
  };
1412
1412
  }
1413
1413
  console.warn('🚀 ~~ JumpTabBarInCurrentShop() ~~ params:', params);
1414
1414
  nativePageRegisterMessage(Message_Type.NATIVE_JUMP_TAB_BAR, {
1415
1415
  data: params,
1416
1416
  });
1417
1417
  nativePageRegisterMessage(Message_Type.NATIVE_OPEN_FLOAT, {
1418
1418
  data: params,
1419
1419
  });
1420
1420
  const changeData = {
1421
1421
  type: NATIVE_POP_WEBVIEW_TYPE.OPEN,
1422
1422
  height: DEFAULT_POP_WEBVIEW_HEIGHT,
1423
1423
  };
1424
1424
  if (isChangeDefaultPopViewHeight && !params?.height) {
1425
1425
  changeData.height = Math.round(window.screen.height * 0.8);
1426
1426
  changeData.borderRadius = 12;
1427
1427
  }
1428
1428
  nativePageRegisterMessage(Message_Type.NATIVE_POP_WEBVIEW, {
1429
1429
  data: {
1430
1430
  ...changeData,
1431
1431
  ...params,
1432
1432
  },
1433
1433
  });
1434
1434
  nativePageRegisterMessage(Message_Type.NATIVE_POP_WEBVIEW, {
1435
1435
  data: {
1436
1436
  type: NATIVE_POP_WEBVIEW_TYPE.CLOSE,
1437
1437
  ...params,
1438
1438
  },
1439
1439
  });
1440
1440
  Taro.eventCenter.off(TaroEventType.JOIN_MEMBER_SUCCESS);
1441
1441
  console.log('popWebview关闭');
1442
1442
  nativePageRegisterMessage(Message_Type.NATIVE_H5_SEND_MSG_TO_H5, {
1443
1443
  data: params,
1444
1444
  });
1445
1445
  nativePageRegisterMessage(Message_Type.NATIVE_PUSH_NATIVE_PAGE, {
1446
1446
  data: params,
1447
1447
  });
1448
1448
  window &&
1449
1449
  (window.location.href = `xview://search?request={"action":"${Message_Type.NAVTIVE_FLOAT_READY}"}`);
1450
1450
  const { displayHeight, offSetY } = res;
1451
1451
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return;
1452
1452
  if (isIosDevice) return res;
1453
1453
  if (isAndroidDevice) {
1454
1454
  const deviceRatio = window.devicePixelRatio;
1455
1455
  const cssDisplayHeight = Math.ceil(displayHeight / deviceRatio);
1456
1456
  const cssOffsetY = Math.ceil(offSetY / deviceRatio);
1457
1457
  return {
1458
1458
  displayHeight: cssDisplayHeight,
1459
1459
  offSetY: cssOffsetY,
1460
1460
  };
1461
1461
  }
1462
1462
  nativePageRegisterMessage(Message_Type.NATIVE_UPDATE_PAGE_INFO, {
1463
1463
  data: params,
1464
1464
  });
1465
1465
  nativePageRegisterMessage(Message_Type.NATIVE_TO_BUYER_SHOW_DETAIL, {
1466
1466
  data: params,
1467
1467
  });
1468
1468
  nativePageRegisterMessage(Message_Type.NATIVE_TO_HIDE_JD_SHOP_HEADER, {
1469
1469
  data: params,
1470
1470
  });
1471
1471
  nativePageRegisterMessage(Message_Type.NATIVE_TO_SHOW_CART_BTN, {
1472
1472
  data: params,
1473
1473
  });
1474
1474
  nativePageRegisterMessage(Message_Type.SHOP_FOLLOW_STATE_REGISTER, {
1475
1475
  data: params,
1476
1476
  });
1477
1477
  callBack &&
1478
1478
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1479
1479
  Message_Type.NATIVE_GET_SHOP_FOLLOW_STATE
1480
1480
  ] = callBack);
1481
1481
  nativePageRegisterMessage(Message_Type.NATIVE_GET_SHOP_FOLLOW_STATE, {
1482
1482
  data: {},
1483
1483
  });
1484
1484
  nativePageRegisterMessage(Message_Type.SHOP_FOLLOW_STATE_SYNC, {
1485
1485
  data: {
1486
1486
  followed: followState,
1487
1487
  },
1488
1488
  });
1489
1489
  nativePageRegisterMessage(Message_Type.H5_TO_NATIVE_LIVE_RESERVE_STATE, {
1490
1490
  data: params,
1491
1491
  });
1492
1492
  Taro.eventCenter.on('SEND_MSG_TO_NATIVE', (key, params) => {
1493
1493
  nativePageRegisterMessage(key, {
1494
1494
  data: params,
1495
1495
  });
1496
1496
  });
1497
1497
  nativePageRegisterMessage(Message_Type.H5_TO_NATIVE_SCROLL_TO_TOP, {
1498
1498
  data: params,
1499
1499
  });
1500
1500
  functionid: string;
1501
1501
  callBack &&
1502
1502
  params.functionid &&
1503
1503
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1504
1504
  Message_Type.GET_COLOR_API_DATA + '_' + params.functionid
1505
1505
  ] = callBack);
1506
1506
  nativePageRegisterMessage(Message_Type.GET_COLOR_API_DATA, {
1507
1507
  data: params.functionid,
1508
1508
  });
1509
1509
  callBack &&
1510
1510
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1511
1511
  Message_Type.GET_ENTER_SHOP_OPEN_APP
1512
1512
  ] = callBack);
1513
1513
  nativePageRegisterMessage(Message_Type.GET_ENTER_SHOP_OPEN_APP, {});
1514
1514
  callBack &&
1515
1515
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1516
1516
  Message_Type.NEED_REFRESH_PRODUCT
1517
1517
  ] = callBack);
1518
1518
  nativePageRegisterMessage(Message_Type.NEED_REFRESH_PRODUCT, {});
1519
1519
  callBack &&
1520
1520
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1521
1521
  Message_Type.DO_FOLLOW
1522
1522
  ] = callBack);
1523
1523
  nativePageRegisterMessage(Message_Type.DO_FOLLOW, params);
1524
1524
  callBack &&
1525
1525
  (Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
1526
1526
  Message_Type.FOLLOW_STATE_CHANGED
1527
1527
  ] = callBack);
1528
1528
  nativePageRegisterMessage(Message_Type.FOLLOW_STATE_CHANGED, {});
1529
1529
  nativePageRegisterMessage(Message_Type.SHOW_BACK_TOTOP, {
1530
1530
  data: isShow,
1531
1531
  });