@conecli/cone-render 0.10.1-shop-beta.34 → 0.10.1-shop-beta.36

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