@conecli/cone-render 0.10.1-shop-beta.59 → 0.10.1-shop-beta.60

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