@conecli/cone-render 0.10.1-shop-beta.14 → 0.10.1-shop-beta.16

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
  parseQueryUrlString,
3
2
  routerInfo: {
4
3
  params: {},
5
4
  },
6
5
  nativeEvent: null,
7
6
  jumpConfig: {
8
7
  venderId: null,
9
8
  shopId: null,
10
9
  sourceValue: '',
11
10
  sourceType: 'App-H5',
12
11
  activityType: 'shopx',
13
12
  moduleId: 'none',
14
13
  entrance: 'none',
15
14
  },
16
15
  logPageParamStr: '',
17
16
  public logPageId: string;
18
17
  public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig;
19
18
  constructor(opt = {}) {
20
19
  super(opt);
21
20
  this.getConfig(opt);
22
21
  }
23
22
  getConfig(opt = {}) {
24
23
  return Object.assign(this, {}, defaultConfig, opt);
25
24
  }
26
25
  updateInfo(routerInfo, logPname = LogPnameInfo.HOME, pageId = LogPageIdInfo.APP) {
27
26
  this.logPageId = pageId;
28
27
  this.routerInfo = routerInfo;
29
28
  this.jumpConfig = Object.assign({}, this.jumpConfig, routerInfo.params);
30
29
  this.logPname = logPname;
31
30
  }
32
31
  reportInfoPv(
33
32
  pageId = LogPageIdInfo.APP,
34
33
  opt: {
35
34
  pageParam?: any;
36
35
  } = {},
37
36
  ) {
38
37
  const { pageParam } = opt;
39
38
  this.logPageParamStr = pageParam
40
39
  ? pageParam
41
40
  : this.creatParamToLogStr(this.jumpConfig)
42
41
  .replace(/moduleId/, 'JumpmoduleID')
43
42
  .replace(/entrance/, 'Jumpentrance');
44
43
  this.reportPV({
45
44
  pageId,
46
45
  pageParam: this.logPageParamStr,
47
46
  ...opt,
48
47
  });
49
48
  }
50
49
 
51
50
  jdJumpToDongDongChatGroup(groupId, source = '4') {
52
51
  this.jdNavigateToNative({
53
52
  category: 'jump',
54
53
  des: 'dongdong_group_chat',
55
54
  source: source,
56
55
  groupId: `${groupId}`,
57
56
  });
58
57
  }
59
58
 
60
59
  jdJumpToWeb(
61
60
  url,
62
61
  logEventInfo,
63
62
  successBack?: functionType | undefined,
64
63
  failBack?: functionType | undefined,
65
64
  ) {
66
65
  console.log('jd web', this.isOpenJdAppUrl(url), url);
67
66
  if (this.isOpenJdAppUrl(url)) {
68
67
  const getOpenAppParams = this.jdOpenAppParams(url);
69
68
  console.log('jd web 获取自定义openApp链接解析后的参数结果', getOpenAppParams);
70
69
  if (getOpenAppParams) {
71
70
  this.jdNavigateToNative(
72
71
  Object.assign({}, getOpenAppParams, {
73
72
  logEventInfo,
74
73
  }),
75
74
  );
76
75
  }
77
76
  } else {
78
77
  let _getLastUrl = url;
79
78
  if (/shop\.m\.jd\.com|pages\.jd\.com/.test(_getLastUrl)) {
80
79
  const getUrlSearchParamState = _getLastUrl.indexOf('?') !== -1;
81
80
  if (!/jwebprog=0/.test(_getLastUrl)) {
82
81
  _getLastUrl = `${_getLastUrl}${getUrlSearchParamState ? '&' : '?'}jwebprog=0`;
83
82
  }
84
83
  if (global.info.sysInfo?.isJdTabletDevice && !/device=tablet/.test(_getLastUrl)) {
85
84
  _getLastUrl = `${_getLastUrl}${getUrlSearchParamState ? '&' : '?'}device=tablet`;
86
85
  }
87
86
  }
88
87
  super.jdJumpToWeb(
89
88
  _getLastUrl,
90
89
  {
91
90
  ...logEventInfo,
92
91
  },
93
92
  successBack,
94
93
  failBack,
95
94
  );
96
95
  }
97
96
  }
98
97
 
99
98
  jdJumpToWebInner(url, logEventInfo) {
100
99
  this.jdJumpToWeb(url, logEventInfo);
101
100
  }
102
101
 
103
102
  jdJumpConfigUrl(detail, logEventInfo = {}) {
104
103
  const { configDataType, configDataValue } = detail;
105
104
  switch (configDataType) {
106
105
  case LinkConfigType.CONFIG_TYPE_CATEGORY_PAGE:
107
106
  this.jdJumpToShopCategory({
108
107
  ...configDataValue,
109
108
  logEventInfo,
110
109
  });
111
110
  break;
112
111
  case LinkConfigType.CONFIG_TYPE_SKU_LIST:
113
112
  if (logEventInfo?.jsonParam?.logBaseInfo?.mInfo) {
114
113
  logEventInfo.jsonParam.logBaseInfo.mInfo.skuid = configDataValue.skuIds;
115
114
  }
116
115
  this.jdJumpToProduct(configDataValue.skuIds, logEventInfo);
117
116
  break;
118
117
  case LinkConfigType.CONFIG_TYPE_COUPON_LIST:
119
118
  this.jdJumpToWeb(
120
119
  `${this.jumpWebUrl.shopCoupon}?couponType=1&shopId=${global.info.queryInfo.shopId}&venderId=${global.info.queryInfo.venderId}`,
121
120
  {},
122
121
  );
123
122
  break;
124
123
  case LinkConfigType.CONFIG_TYPE_CATEGORY:
125
124
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
126
125
  const getShopSearchParams = this.jdOpenAppParams(configDataValue.clickUrl);
127
126
  console.log('jd web 获取店铺分类链接解析后的参数结果', getShopSearchParams);
128
127
  getShopSearchParams &&
129
128
  this.jdJumpToShopSearch(
130
129
  Object.assign({}, getShopSearchParams, {
131
130
  logEventInfo,
132
131
  }),
133
132
  );
134
133
  } else {
135
134
  this.jdJumpToShopSearch(
136
135
  configDataValue['cid']
137
136
  ? Object.assign(
138
137
  {},
139
138
  {
140
139
  shopId: global.info.queryInfo.shopId,
141
140
  categoryId: configDataValue.cid,
142
141
  searchType: '5',
143
142
  logEventInfo,
144
143
  },
145
144
  )
146
145
  : {
147
146
  shopId: global.info.queryInfo.shopId,
148
147
  logEventInfo,
149
148
  },
150
149
  );
151
150
  }
152
151
  break;
153
152
  case LinkConfigType.CONFIG_TYPE_MEMBER:
154
153
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
155
154
  const getShopMemberParams = this.jdOpenAppParams(configDataValue.clickUrl);
156
155
  getShopMemberParams &&
157
156
  this.jdJumpToShopMember(
158
157
  Object.assign({}, getShopMemberParams, {
159
158
  logEventInfo,
160
159
  }),
161
160
  );
162
161
  } else {
163
162
  this.jdJumpToShopMember({
164
163
  shopId: global.info.queryInfo.shopId,
165
164
  venderId: configDataValue.shopDetail,
166
165
  logEventInfo,
167
166
  });
168
167
  }
169
168
  break;
170
169
  case LinkConfigType.CONFIG_TYPE_SHOP_ACTIVITY:
171
170
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
172
171
  const getShopActivityParams = this.jdOpenAppParams(configDataValue.clickUrl);
173
172
  getShopActivityParams &&
174
173
  this.jdJumpToShopActivity(
175
174
  Object.assign({}, getShopActivityParams, {
176
175
  logEventInfo,
177
176
  }),
178
177
  );
179
178
  } else if (configDataValue['projectId']) {
180
179
  this.jdJumpToShopActivity({
181
180
  projectId: configDataValue['projectId'],
182
181
  configDataValue,
183
182
  logEventInfo,
184
183
  });
185
184
  }
186
185
  break;
187
186
  case LinkConfigType.CONFIG_TYPE_CUSTOM_LINK:
188
187
  case LinkConfigType.CONFIG_TYPE_FINANCE_COUPON: {
189
188
  const _url = configDataValue.linkUrl;
190
189
  if (
191
190
  _url.indexOf('to=') === -1 &&
192
191
  _url.indexOf(`${domain.mshop.replace(/https?:/, '')}/?shopId=`) !== -1
193
192
  ) {
194
193
  const _shopId = _url.match(/\d+/g)[0];
195
194
  this.jdJumpToShopHome({
196
195
  shopId: `${_shopId}`,
197
196
  logEventInfo,
198
197
  });
199
198
  } else if (this.isOpenJdAppUrl(_url)) {
200
199
  const getOpenAppParams = this.jdOpenAppParams(_url);
201
200
  console.log('jd web 获取自定义链接解析后的参数结果', getOpenAppParams);
202
201
  if (getOpenAppParams) {
203
202
  let _changeOpenAppParams = getOpenAppParams;
204
203
  const { operation, ...otherOpenAppParams } = getOpenAppParams;
205
204
  if (operation && operation === 'jumpTabInner') {
206
205
  _changeOpenAppParams = otherOpenAppParams;
207
206
  }
208
207
  this.jdNavigateToNative(
209
208
  Object.assign({}, _changeOpenAppParams, {
210
209
  logEventInfo,
211
210
  }),
212
211
  );
213
212
  }
214
213
  } else {
215
214
  this.jdJumpToWeb(_url, logEventInfo);
216
215
  }
217
216
  break;
218
217
  }
219
218
  case LinkConfigType.CONFIG_TYPE_JSHOP_DETAIL:
220
219
  this.jdJumpToShopDetail({
221
220
  venderId: global.info.queryInfo.venderId,
222
221
  shopId: global.info.queryInfo.shopId,
223
222
  logEventInfo,
224
223
  });
225
224
  break;
226
225
  case LinkConfigType.CONFIG_TYPE_SHOP_HOME:
227
226
  this.jdJumpToShopHome({
228
227
  ...configDataValue,
229
228
  logEventInfo,
230
229
  });
231
230
  break;
232
231
  case LinkConfigType.CONFIG_TYPE_ANCHOR_POINT:
233
232
  break;
234
233
  case LinkConfigType.CONFIG_TYPE_SHOPPING_GUIDE:
235
234
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
236
235
  const getShoppingGuideParams = this.jdOpenAppParams(configDataValue.clickUrl);
237
236
  getShoppingGuideParams &&
238
237
  this.jdJumpToShopActivity(
239
238
  Object.assign({}, getShoppingGuideParams, {
240
239
  logEventInfo,
241
240
  }),
242
241
  );
243
242
  }
244
243
  break;
245
244
  case LinkConfigType.CONFIG_TYPE_MINI_PROGRAM: {
246
245
  const linkUrl = decodeURIComponent(configDataValue?.linkUrl || '');
247
246
  const search = linkUrl.match(/\?.+/);
248
247
  if (search) {
249
248
  const miniQueryData: JumpEventReportInterFace.LinkMiniParams =
250
249
  parseQueryUrlString(linkUrl);
251
250
  try {
252
251
  miniQueryData.param = JSON.parse(miniQueryData?.param);
253
252
  } catch (e) {
254
253
  console.warn('解析小程序 param 错误:', miniQueryData);
255
254
  }
256
255
  this.jdJumpToMiniProgram(miniQueryData);
257
256
  } else {
258
257
  console.warn('小程序地址错误:', linkUrl);
259
258
  }
260
259
  break;
261
260
  }
262
261
  case LinkConfigType.CONFIG_TYPE_SHOP_SEARCH: {
263
262
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
264
263
  const getShopSearchParams = this.jdOpenAppParams(configDataValue.clickUrl);
265
264
  console.log('jd web 获取店铺结果落地页链接解析后的参数结果', getShopSearchParams);
266
265
  getShopSearchParams &&
267
266
  this.jdJumpToShopSearch(
268
267
  Object.assign({}, getShopSearchParams, {
269
268
  logEventInfo,
270
269
  }),
271
270
  );
272
271
  } else {
273
272
  this.jdJumpToWeb(configDataValue.clickUrl, logEventInfo);
274
273
  }
275
274
  break;
276
275
  }
277
276
  default:
278
277
  }
279
278
  }
280
279
 
281
280
  jdNavigateToNative(
282
281
  params: object,
283
282
  url = 'openapp.jdmobile://virtual',
284
283
  successBack?: functionType | null,
285
284
  failBack?: functionType | null,
286
285
  ) {
287
286
  const getResParams: JumpEventReportInterFace.JdMiniJumpParams = Object.assign(
288
287
  {},
289
288
  {
290
289
  sourceValue: 'sourceValue_jshopModuleWeb',
291
290
  sourceType: 'sourceType_jshopModuleWeb',
292
291
  param: {},
293
292
  },
294
293
  params,
295
294
  );
296
295
  const { logEventInfo, ...otherParams } = getResParams;
297
296
  console.log('[taro dynamic] jdNavigateToNative jd:', params,"融合后的参数getResParams",getResParams,'logEventInfo params: ', logEventInfo);
298
297
  global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE &&
299
298
  this.clickEventLog(logEventInfo || getResParams).then((res) => {
300
299
  console.log('收到埋点回调,跳转taro dynamic jd 回调结果',res);
301
300
  if (typeof successBack === 'function') {
302
301
  successBack(getResParams);
303
302
  } else {
304
303
  try {
305
304
  const paramsStr = JSON.stringify(otherParams);
306
305
  console.log('跳转taro dynamic jd open协议', `${url}?params=${paramsStr}`);
307
306
  Taro.JDNavigate.navigateTo({
308
307
  url: `${url}?params=${paramsStr}`,
309
308
  }).then(res => {
310
309
  console.log('跳转taro dynamic jd open协议 成功',res);
311
310
  })
312
311
  } catch (e) {
313
312
  console.log('跳转异常', e);
314
313
  }
315
314
  }
316
315
  })
317
316
  .catch(() => {
318
317
  typeof failBack === 'function' && failBack(getResParams);
319
318
  });
320
319
  }
321
320
 
322
321
  clickEventLog(opts: JumpEventReportInterFace.OptEventLogParams = {}, reportKey = 'click') {
323
322
  const { eventId, jsonParam, eventLevel = 3, ...otherParams } = opts;
324
323
  if (eventId && jsonParam) {
325
324
  const { etModelInfo, logBaseInfo } = jsonParam;
326
325
  let getJsonParam = {};
327
326
  if (etModelInfo && logBaseInfo) {
328
327
  getJsonParam = logBaseInfo;
329
328
  } else {
330
329
  if (Array.isArray(jsonParam)) {
331
330
  getJsonParam = jsonParam;
332
331
  } else {
333
332
  getJsonParam = Object.assign(
334
333
  {},
335
334
  {
336
335
  shopid: global.info.queryInfo?.shopId,
337
336
  },
338
337
  jsonParam,
339
338
  );
340
339
  }
341
340
  }
342
341
  if (
343
342
  reportKey === 'exposure' &&
344
343
  /^TerminatorNew/.test(eventId) &&
345
344
  !Array.isArray(getJsonParam)
346
345
  ) {
347
346
  getJsonParam = [getJsonParam];
348
347
  }
349
348
  console.log("eventId",eventId, "jsonParam", jsonParam, "getJsonParam",getJsonParam)
350
349
  const webLogParams = {
351
350
  isExpo: reportKey === 'exposure',
352
351
  eid: eventId,
353
352
  elevel: eventLevel,
354
353
  jsonParam: JSON.stringify(getJsonParam),
355
354
  etModel: JSON.stringify(etModelInfo || {}),
356
355
  pageId: this.logPageId,
357
356
  pageParam: this.logPageParamStr,
358
357
  ...otherParams,
359
358
  };
360
359
  console.log(
361
360
  `jdapp内,taro动态化---埋点参数对象-${reportKey}`,
362
361
  webLogParams,
363
362
  )
364
363
  return new Promise((resolve) => {
365
364
  const {
366
365
  eid,
367
366
  jsonParam,
368
367
  pageParam,
369
368
  pageId = 'TerminatorNew_All',
370
369
  } = webLogParams;
371
370
  const getReportData = {
372
371
  event_id: eid,
373
372
  page_id: pageId,
374
373
  page_name: "",
375
374
  page_param: pageParam,
376
375
  json_param: jsonParam,
377
376
  event_param:"",
378
377
  next_page_name:"",
379
378
  params:{},
380
379
  complete: () => {
381
380
  console.log('日志上报完毕,触发回调')
382
381
  resolve(true);
383
382
  }
384
383
  }
385
384
  console.log('Taro.JDMTA',Taro.JDMTA,"Taro.JDMTA[reportKey]",Taro.JDMTA[reportKey],"getReportData",getReportData)
386
385
  Taro.JDMTA.click(getReportData).then(res => {
387
386
  console.log("埋点上报成功",res)
388
387
  })
389
388
  resolve(true);
390
389
  });
391
390
  } else {
392
391
  console.log('暂无埋点参数eventId和eventParam');
393
392
  return Promise.resolve(false);
394
393
  }
395
394
  }
396
395
  reportPV(opts){
397
396
  const { pageId, pageParam, isSend = true } = opts;
398
397
  isSend && Taro.JDMTA.pv({
399
398
  page_id: pageId,
400
399
  page_name: "",
401
400
  page_param: pageParam
402
401
  })
403
402
  }
404
403
 
405
404
  exposureEventLog(opts) {
406
405
  return global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE
407
406
  ? this.clickEventLog(
408
407
  {
409
408
  ...opts,
410
409
  exposureState: true,
411
410
  },
412
411
  'exposure',
413
412
  )
414
413
  : Promise.resolve(false);
415
414
  }
415
+ import Taro from '@tarojs/taro';
416
416
  parseQueryUrlString,
417
417
  routerInfo: {
418
418
  params: {},
419
419
  },
420
420
  nativeEvent: null,
421
421
  jumpConfig: {
422
422
  venderId: null,
423
423
  shopId: null,
424
424
  sourceValue: '',
425
425
  sourceType: 'App-H5',
426
426
  activityType: 'shopx',
427
427
  moduleId: 'none',
428
428
  entrance: 'none',
429
429
  },
430
430
  logPageParamStr: '',
431
431
  public logPageId: string;
432
432
  public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig;
433
433
  constructor(opt = {}) {
434
434
  super(opt);
435
435
  this.getConfig(opt);
436
436
  }
437
437
  getConfig(opt = {}) {
438
438
  return Object.assign(this, {}, defaultConfig, opt);
439
439
  }
440
440
  updateInfo(routerInfo, logPname = LogPnameInfo.HOME, pageId = LogPageIdInfo.APP) {
441
441
  this.logPageId = pageId;
442
442
  this.routerInfo = routerInfo;
443
443
  this.jumpConfig = Object.assign({}, this.jumpConfig, routerInfo.params);
444
444
  this.logPname = logPname;
445
445
  }
446
446
  reportInfoPv(
447
447
  pageId = LogPageIdInfo.APP,
448
448
  opt: {
449
449
  pageParam?: any;
450
450
  } = {},
451
451
  ) {
452
452
  const { pageParam } = opt;
453
453
  this.logPageParamStr = pageParam
454
454
  ? pageParam
455
455
  : this.creatParamToLogStr(this.jumpConfig)
456
456
  .replace(/moduleId/, 'JumpmoduleID')
457
457
  .replace(/entrance/, 'Jumpentrance');
458
458
  this.reportPV({
459
459
  pageId,
460
460
  pageParam: this.logPageParamStr,
461
461
  ...opt,
462
462
  });
463
463
  }
464
464
 
465
465
  jdJumpToDongDongChatGroup(groupId, source = '4') {
466
466
  this.jdNavigateToNative({
467
467
  category: 'jump',
468
468
  des: 'dongdong_group_chat',
469
469
  source: source,
470
470
  groupId: `${groupId}`,
471
471
  });
472
472
  }
473
473
 
474
474
  jdJumpToWeb(
475
475
  url,
476
476
  logEventInfo,
477
477
  successBack?: functionType | undefined,
478
478
  failBack?: functionType | undefined,
479
479
  ) {
480
480
  console.log('jd web', this.isOpenJdAppUrl(url), url);
481
481
  if (this.isOpenJdAppUrl(url)) {
482
482
  const getOpenAppParams = this.jdOpenAppParams(url);
483
483
  console.log('jd web 获取自定义openApp链接解析后的参数结果', getOpenAppParams);
484
484
  if (getOpenAppParams) {
485
485
  this.jdNavigateToNative(
486
486
  Object.assign({}, getOpenAppParams, {
487
487
  logEventInfo,
488
488
  }),
489
489
  );
490
490
  }
491
491
  } else {
492
492
  let _getLastUrl = url;
493
493
  if (/shop\.m\.jd\.com|pages\.jd\.com/.test(_getLastUrl)) {
494
494
  const getUrlSearchParamState = _getLastUrl.indexOf('?') !== -1;
495
495
  if (!/jwebprog=0/.test(_getLastUrl)) {
496
496
  _getLastUrl = `${_getLastUrl}${getUrlSearchParamState ? '&' : '?'}jwebprog=0`;
497
497
  }
498
498
  if (global.info.sysInfo?.isJdTabletDevice && !/device=tablet/.test(_getLastUrl)) {
499
499
  _getLastUrl = `${_getLastUrl}${getUrlSearchParamState ? '&' : '?'}device=tablet`;
500
500
  }
501
501
  }
502
502
  super.jdJumpToWeb(
503
503
  _getLastUrl,
504
504
  {
505
505
  ...logEventInfo,
506
506
  },
507
507
  successBack,
508
508
  failBack,
509
509
  );
510
510
  }
511
511
  }
512
512
 
513
513
  jdJumpToWebInner(url, logEventInfo) {
514
514
  this.jdJumpToWeb(url, logEventInfo);
515
515
  }
516
516
 
517
517
  jdJumpConfigUrl(detail, logEventInfo = {}) {
518
518
  const { configDataType, configDataValue } = detail;
519
519
  switch (configDataType) {
520
520
  case LinkConfigType.CONFIG_TYPE_CATEGORY_PAGE:
521
521
  this.jdJumpToShopCategory({
522
522
  ...configDataValue,
523
523
  logEventInfo,
524
524
  });
525
525
  break;
526
526
  case LinkConfigType.CONFIG_TYPE_SKU_LIST:
527
527
  if (logEventInfo?.jsonParam?.logBaseInfo?.mInfo) {
528
528
  logEventInfo.jsonParam.logBaseInfo.mInfo.skuid = configDataValue.skuIds;
529
529
  }
530
530
  this.jdJumpToProduct(configDataValue.skuIds, logEventInfo);
531
531
  break;
532
532
  case LinkConfigType.CONFIG_TYPE_COUPON_LIST:
533
533
  this.jdJumpToWeb(
534
534
  `${this.jumpWebUrl.shopCoupon}?couponType=1&shopId=${global.info.queryInfo.shopId}&venderId=${global.info.queryInfo.venderId}`,
535
535
  {},
536
536
  );
537
537
  break;
538
538
  case LinkConfigType.CONFIG_TYPE_CATEGORY:
539
539
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
540
540
  const getShopSearchParams = this.jdOpenAppParams(configDataValue.clickUrl);
541
541
  console.log('jd web 获取店铺分类链接解析后的参数结果', getShopSearchParams);
542
542
  getShopSearchParams &&
543
543
  this.jdJumpToShopSearch(
544
544
  Object.assign({}, getShopSearchParams, {
545
545
  logEventInfo,
546
546
  }),
547
547
  );
548
548
  } else {
549
549
  this.jdJumpToShopSearch(
550
550
  configDataValue['cid']
551
551
  ? Object.assign(
552
552
  {},
553
553
  {
554
554
  shopId: global.info.queryInfo.shopId,
555
555
  categoryId: configDataValue.cid,
556
556
  searchType: '5',
557
557
  logEventInfo,
558
558
  },
559
559
  )
560
560
  : {
561
561
  shopId: global.info.queryInfo.shopId,
562
562
  logEventInfo,
563
563
  },
564
564
  );
565
565
  }
566
566
  break;
567
567
  case LinkConfigType.CONFIG_TYPE_MEMBER:
568
568
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
569
569
  const getShopMemberParams = this.jdOpenAppParams(configDataValue.clickUrl);
570
570
  getShopMemberParams &&
571
571
  this.jdJumpToShopMember(
572
572
  Object.assign({}, getShopMemberParams, {
573
573
  logEventInfo,
574
574
  }),
575
575
  );
576
576
  } else {
577
577
  this.jdJumpToShopMember({
578
578
  shopId: global.info.queryInfo.shopId,
579
579
  venderId: configDataValue.shopDetail,
580
580
  logEventInfo,
581
581
  });
582
582
  }
583
583
  break;
584
584
  case LinkConfigType.CONFIG_TYPE_SHOP_ACTIVITY:
585
585
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
586
586
  const getShopActivityParams = this.jdOpenAppParams(configDataValue.clickUrl);
587
587
  getShopActivityParams &&
588
588
  this.jdJumpToShopActivity(
589
589
  Object.assign({}, getShopActivityParams, {
590
590
  logEventInfo,
591
591
  }),
592
592
  );
593
593
  } else if (configDataValue['projectId']) {
594
594
  this.jdJumpToShopActivity({
595
595
  projectId: configDataValue['projectId'],
596
596
  configDataValue,
597
597
  logEventInfo,
598
598
  });
599
599
  }
600
600
  break;
601
601
  case LinkConfigType.CONFIG_TYPE_CUSTOM_LINK:
602
602
  case LinkConfigType.CONFIG_TYPE_FINANCE_COUPON: {
603
603
  const _url = configDataValue.linkUrl;
604
604
  if (
605
605
  _url.indexOf('to=') === -1 &&
606
606
  _url.indexOf(`${domain.mshop.replace(/https?:/, '')}/?shopId=`) !== -1
607
607
  ) {
608
608
  const _shopId = _url.match(/\d+/g)[0];
609
609
  this.jdJumpToShopHome({
610
610
  shopId: `${_shopId}`,
611
611
  logEventInfo,
612
612
  });
613
613
  } else if (this.isOpenJdAppUrl(_url)) {
614
614
  const getOpenAppParams = this.jdOpenAppParams(_url);
615
615
  console.log('jd web 获取自定义链接解析后的参数结果', getOpenAppParams);
616
616
  if (getOpenAppParams) {
617
617
  let _changeOpenAppParams = getOpenAppParams;
618
618
  const { operation, ...otherOpenAppParams } = getOpenAppParams;
619
619
  if (operation && operation === 'jumpTabInner') {
620
620
  _changeOpenAppParams = otherOpenAppParams;
621
621
  }
622
622
  this.jdNavigateToNative(
623
623
  Object.assign({}, _changeOpenAppParams, {
624
624
  logEventInfo,
625
625
  }),
626
626
  );
627
627
  }
628
628
  } else {
629
629
  this.jdJumpToWeb(_url, logEventInfo);
630
630
  }
631
631
  break;
632
632
  }
633
633
  case LinkConfigType.CONFIG_TYPE_JSHOP_DETAIL:
634
634
  this.jdJumpToShopDetail({
635
635
  venderId: global.info.queryInfo.venderId,
636
636
  shopId: global.info.queryInfo.shopId,
637
637
  logEventInfo,
638
638
  });
639
639
  break;
640
640
  case LinkConfigType.CONFIG_TYPE_SHOP_HOME:
641
641
  this.jdJumpToShopHome({
642
642
  ...configDataValue,
643
643
  logEventInfo,
644
644
  });
645
645
  break;
646
646
  case LinkConfigType.CONFIG_TYPE_ANCHOR_POINT:
647
647
  break;
648
648
  case LinkConfigType.CONFIG_TYPE_SHOPPING_GUIDE:
649
649
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
650
650
  const getShoppingGuideParams = this.jdOpenAppParams(configDataValue.clickUrl);
651
651
  getShoppingGuideParams &&
652
652
  this.jdJumpToShopActivity(
653
653
  Object.assign({}, getShoppingGuideParams, {
654
654
  logEventInfo,
655
655
  }),
656
656
  );
657
657
  }
658
658
  break;
659
659
  case LinkConfigType.CONFIG_TYPE_MINI_PROGRAM: {
660
660
  const linkUrl = decodeURIComponent(configDataValue?.linkUrl || '');
661
661
  const search = linkUrl.match(/\?.+/);
662
662
  if (search) {
663
663
  const miniQueryData: JumpEventReportInterFace.LinkMiniParams =
664
664
  parseQueryUrlString(linkUrl);
665
665
  try {
666
666
  miniQueryData.param = JSON.parse(miniQueryData?.param);
667
667
  } catch (e) {
668
668
  console.warn('解析小程序 param 错误:', miniQueryData);
669
669
  }
670
670
  this.jdJumpToMiniProgram(miniQueryData);
671
671
  } else {
672
672
  console.warn('小程序地址错误:', linkUrl);
673
673
  }
674
674
  break;
675
675
  }
676
676
  case LinkConfigType.CONFIG_TYPE_SHOP_SEARCH: {
677
677
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
678
678
  const getShopSearchParams = this.jdOpenAppParams(configDataValue.clickUrl);
679
679
  console.log('jd web 获取店铺结果落地页链接解析后的参数结果', getShopSearchParams);
680
680
  getShopSearchParams &&
681
681
  this.jdJumpToShopSearch(
682
682
  Object.assign({}, getShopSearchParams, {
683
683
  logEventInfo,
684
684
  }),
685
685
  );
686
686
  } else {
687
687
  this.jdJumpToWeb(configDataValue.clickUrl, logEventInfo);
688
688
  }
689
689
  break;
690
690
  }
691
691
  default:
692
692
  }
693
693
  }
694
694
 
695
695
  jdNavigateToNative(
696
696
  params: object,
697
697
  url = 'openapp.jdmobile://virtual',
698
698
  successBack?: functionType | null,
699
699
  failBack?: functionType | null,
700
700
  ) {
701
701
  const getResParams: JumpEventReportInterFace.JdMiniJumpParams = Object.assign(
702
702
  {},
703
703
  {
704
704
  sourceValue: 'sourceValue_jshopModuleWeb',
705
705
  sourceType: 'sourceType_jshopModuleWeb',
706
706
  param: {},
707
707
  },
708
708
  params,
709
709
  );
710
710
  const { logEventInfo, ...otherParams } = getResParams;
711
711
  console.log('[taro dynamic] jdNavigateToNative jd:', params,"融合后的参数getResParams",getResParams,'logEventInfo params: ', logEventInfo);
712
712
  global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE &&
713
713
  this.clickEventLog(logEventInfo || getResParams).then((res) => {
714
714
  console.log('收到埋点回调,跳转taro dynamic jd 回调结果',res);
715
715
  if (typeof successBack === 'function') {
716
716
  successBack(getResParams);
717
717
  } else {
718
718
  try {
719
719
  const paramsStr = JSON.stringify(otherParams);
720
720
  console.log('跳转taro dynamic jd open协议', `${url}?params=${paramsStr}`);
721
721
  Taro.JDNavigate.navigateTo({
722
722
  url: `${url}?params=${paramsStr}`,
723
723
  }).then(res => {
724
724
  console.log('跳转taro dynamic jd open协议 成功',res);
725
725
  })
726
726
  } catch (e) {
727
727
  console.log('跳转异常', e);
728
728
  }
729
729
  }
730
730
  })
731
731
  .catch(() => {
732
732
  typeof failBack === 'function' && failBack(getResParams);
733
733
  });
734
734
  }
735
735
 
736
736
  clickEventLog(opts: JumpEventReportInterFace.OptEventLogParams = {}, reportKey = 'click') {
737
737
  const { eventId, jsonParam, eventLevel = 3, ...otherParams } = opts;
738
738
  if (eventId && jsonParam) {
739
739
  const { etModelInfo, logBaseInfo } = jsonParam;
740
740
  let getJsonParam = {};
741
741
  if (etModelInfo && logBaseInfo) {
742
742
  getJsonParam = logBaseInfo;
743
743
  } else {
744
744
  if (Array.isArray(jsonParam)) {
745
745
  getJsonParam = jsonParam;
746
746
  } else {
747
747
  getJsonParam = Object.assign(
748
748
  {},
749
749
  {
750
750
  shopid: global.info.queryInfo?.shopId,
751
751
  },
752
752
  jsonParam,
753
753
  );
754
754
  }
755
755
  }
756
756
  if (
757
757
  reportKey === 'exposure' &&
758
758
  /^TerminatorNew/.test(eventId) &&
759
759
  !Array.isArray(getJsonParam)
760
760
  ) {
761
761
  getJsonParam = [getJsonParam];
762
762
  }
763
763
  console.log("eventId",eventId, "jsonParam", jsonParam, "getJsonParam",getJsonParam)
764
764
  const webLogParams = {
765
765
  isExpo: reportKey === 'exposure',
766
766
  eid: eventId,
767
767
  elevel: eventLevel,
768
768
  jsonParam: JSON.stringify(getJsonParam),
769
769
  etModel: JSON.stringify(etModelInfo || {}),
770
770
  pageId: this.logPageId,
771
771
  pageParam: this.logPageParamStr,
772
772
  ...otherParams,
773
773
  };
774
774
  console.log(
775
775
  `jdapp内,taro动态化---埋点参数对象-${reportKey}`,
776
776
  webLogParams,
777
777
  )
778
778
  return new Promise((resolve) => {
779
779
  const {
780
780
  eid,
781
781
  jsonParam,
782
782
  pageParam,
783
783
  pageId = 'TerminatorNew_All',
784
784
  } = webLogParams;
785
785
  const getReportData = {
786
786
  event_id: eid,
787
787
  page_id: pageId,
788
788
  page_name: "",
789
789
  page_param: pageParam,
790
790
  json_param: jsonParam,
791
791
  event_param:"",
792
792
  next_page_name:"",
793
793
  params:{},
794
794
  }
795
795
  console.log('Taro.JDMTA上报前的最终参数getReportData',getReportData)
796
796
  Taro.JDMTA.click(getReportData).then(res => {
797
797
  console.log(`event_id为${eid}的埋点上报成功`,res)
798
798
  resolve(true);
799
799
  }).catch((err) => {
800
800
  resolve(false);
801
801
  console.log(`event_id为${eid}的埋点上报异常`,err)
802
802
  })
803
803
  });
804
804
  } else {
805
805
  console.log('暂无埋点参数eventId和eventParam');
806
806
  return Promise.resolve(false);
807
807
  }
808
808
  }
809
809
  reportPV(opts){
810
810
  const { pageId, pageParam, isSend = true } = opts;
811
811
  isSend && Taro.JDMTA.pv({
812
812
  page_id: pageId,
813
813
  page_name: "",
814
814
  page_param: pageParam
815
815
  })
816
816
  }
817
817
 
818
818
  exposureEventLog(opts) {
819
819
  return global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE
820
820
  ? this.clickEventLog(
821
821
  {
822
822
  ...opts,
823
823
  exposureState: true,
824
824
  },
825
825
  'exposure',
826
826
  )
827
827
  : Promise.resolve(false);
828
828
  }