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

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