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

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