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

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
  Taro.showToast({
383
382
  title: "日志上报完毕,触发回调",
384
383
  })
385
384
  resolve(true);
386
385
  }
387
386
  }
388
387
  console.log('Taro.JDMTA',Taro.JDMTA,"Taro.JDMTA[reportKey]",Taro.JDMTA[reportKey],"getReportData",getReportData)
389
388
  Taro.JDMTA.click(getReportData).then(res => {
390
389
  console.log("埋点上报成功",res)
391
390
  })
392
391
  resolve(true);
393
392
  });
394
393
  } else {
395
394
  console.log('暂无埋点参数eventId和eventParam');
396
395
  return Promise.resolve(false);
397
396
  }
398
397
  }
399
398
  reportPV(opts){
400
399
  const { pageId, pageParam, isSend = true } = opts;
401
400
  isSend && Taro.JDMTA.pv({
402
401
  page_id: pageId,
403
402
  page_name: "",
404
403
  page_param: pageParam
405
404
  })
406
405
  }
407
406
 
408
407
  exposureEventLog(opts) {
409
408
  return global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE
410
409
  ? this.clickEventLog(
411
410
  {
412
411
  ...opts,
413
412
  exposureState: true,
414
413
  },
415
414
  'exposure',
416
415
  )
417
416
  : Promise.resolve(false);
418
417
  }
418
+ import Taro from '@tarojs/taro';
419
419
  parseQueryUrlString,
420
420
  routerInfo: {
421
421
  params: {},
422
422
  },
423
423
  nativeEvent: null,
424
424
  jumpConfig: {
425
425
  venderId: null,
426
426
  shopId: null,
427
427
  sourceValue: '',
428
428
  sourceType: 'App-H5',
429
429
  activityType: 'shopx',
430
430
  moduleId: 'none',
431
431
  entrance: 'none',
432
432
  },
433
433
  logPageParamStr: '',
434
434
  public logPageId: string;
435
435
  public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig;
436
436
  constructor(opt = {}) {
437
437
  super(opt);
438
438
  this.getConfig(opt);
439
439
  }
440
440
  getConfig(opt = {}) {
441
441
  return Object.assign(this, {}, defaultConfig, opt);
442
442
  }
443
443
  updateInfo(routerInfo, logPname = LogPnameInfo.HOME, pageId = LogPageIdInfo.APP) {
444
444
  this.logPageId = pageId;
445
445
  this.routerInfo = routerInfo;
446
446
  this.jumpConfig = Object.assign({}, this.jumpConfig, routerInfo.params);
447
447
  this.logPname = logPname;
448
448
  }
449
449
  reportInfoPv(
450
450
  pageId = LogPageIdInfo.APP,
451
451
  opt: {
452
452
  pageParam?: any;
453
453
  } = {},
454
454
  ) {
455
455
  const { pageParam } = opt;
456
456
  this.logPageParamStr = pageParam
457
457
  ? pageParam
458
458
  : this.creatParamToLogStr(this.jumpConfig)
459
459
  .replace(/moduleId/, 'JumpmoduleID')
460
460
  .replace(/entrance/, 'Jumpentrance');
461
461
  this.reportPV({
462
462
  pageId,
463
463
  pageParam: this.logPageParamStr,
464
464
  ...opt,
465
465
  });
466
466
  }
467
467
 
468
468
  jdJumpToDongDongChatGroup(groupId, source = '4') {
469
469
  this.jdNavigateToNative({
470
470
  category: 'jump',
471
471
  des: 'dongdong_group_chat',
472
472
  source: source,
473
473
  groupId: `${groupId}`,
474
474
  });
475
475
  }
476
476
 
477
477
  jdJumpToWeb(
478
478
  url,
479
479
  logEventInfo,
480
480
  successBack?: functionType | undefined,
481
481
  failBack?: functionType | undefined,
482
482
  ) {
483
483
  console.log('jd web', this.isOpenJdAppUrl(url), url);
484
484
  if (this.isOpenJdAppUrl(url)) {
485
485
  const getOpenAppParams = this.jdOpenAppParams(url);
486
486
  console.log('jd web 获取自定义openApp链接解析后的参数结果', getOpenAppParams);
487
487
  if (getOpenAppParams) {
488
488
  this.jdNavigateToNative(
489
489
  Object.assign({}, getOpenAppParams, {
490
490
  logEventInfo,
491
491
  }),
492
492
  );
493
493
  }
494
494
  } else {
495
495
  let _getLastUrl = url;
496
496
  if (/shop\.m\.jd\.com|pages\.jd\.com/.test(_getLastUrl)) {
497
497
  const getUrlSearchParamState = _getLastUrl.indexOf('?') !== -1;
498
498
  if (!/jwebprog=0/.test(_getLastUrl)) {
499
499
  _getLastUrl = `${_getLastUrl}${getUrlSearchParamState ? '&' : '?'}jwebprog=0`;
500
500
  }
501
501
  if (global.info.sysInfo?.isJdTabletDevice && !/device=tablet/.test(_getLastUrl)) {
502
502
  _getLastUrl = `${_getLastUrl}${getUrlSearchParamState ? '&' : '?'}device=tablet`;
503
503
  }
504
504
  }
505
505
  super.jdJumpToWeb(
506
506
  _getLastUrl,
507
507
  {
508
508
  ...logEventInfo,
509
509
  },
510
510
  successBack,
511
511
  failBack,
512
512
  );
513
513
  }
514
514
  }
515
515
 
516
516
  jdJumpToWebInner(url, logEventInfo) {
517
517
  this.jdJumpToWeb(url, logEventInfo);
518
518
  }
519
519
 
520
520
  jdJumpConfigUrl(detail, logEventInfo = {}) {
521
521
  const { configDataType, configDataValue } = detail;
522
522
  switch (configDataType) {
523
523
  case LinkConfigType.CONFIG_TYPE_CATEGORY_PAGE:
524
524
  this.jdJumpToShopCategory({
525
525
  ...configDataValue,
526
526
  logEventInfo,
527
527
  });
528
528
  break;
529
529
  case LinkConfigType.CONFIG_TYPE_SKU_LIST:
530
530
  if (logEventInfo?.jsonParam?.logBaseInfo?.mInfo) {
531
531
  logEventInfo.jsonParam.logBaseInfo.mInfo.skuid = configDataValue.skuIds;
532
532
  }
533
533
  this.jdJumpToProduct(configDataValue.skuIds, logEventInfo);
534
534
  break;
535
535
  case LinkConfigType.CONFIG_TYPE_COUPON_LIST:
536
536
  this.jdJumpToWeb(
537
537
  `${this.jumpWebUrl.shopCoupon}?couponType=1&shopId=${global.info.queryInfo.shopId}&venderId=${global.info.queryInfo.venderId}`,
538
538
  {},
539
539
  );
540
540
  break;
541
541
  case LinkConfigType.CONFIG_TYPE_CATEGORY:
542
542
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
543
543
  const getShopSearchParams = this.jdOpenAppParams(configDataValue.clickUrl);
544
544
  console.log('jd web 获取店铺分类链接解析后的参数结果', getShopSearchParams);
545
545
  getShopSearchParams &&
546
546
  this.jdJumpToShopSearch(
547
547
  Object.assign({}, getShopSearchParams, {
548
548
  logEventInfo,
549
549
  }),
550
550
  );
551
551
  } else {
552
552
  this.jdJumpToShopSearch(
553
553
  configDataValue['cid']
554
554
  ? Object.assign(
555
555
  {},
556
556
  {
557
557
  shopId: global.info.queryInfo.shopId,
558
558
  categoryId: configDataValue.cid,
559
559
  searchType: '5',
560
560
  logEventInfo,
561
561
  },
562
562
  )
563
563
  : {
564
564
  shopId: global.info.queryInfo.shopId,
565
565
  logEventInfo,
566
566
  },
567
567
  );
568
568
  }
569
569
  break;
570
570
  case LinkConfigType.CONFIG_TYPE_MEMBER:
571
571
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
572
572
  const getShopMemberParams = this.jdOpenAppParams(configDataValue.clickUrl);
573
573
  getShopMemberParams &&
574
574
  this.jdJumpToShopMember(
575
575
  Object.assign({}, getShopMemberParams, {
576
576
  logEventInfo,
577
577
  }),
578
578
  );
579
579
  } else {
580
580
  this.jdJumpToShopMember({
581
581
  shopId: global.info.queryInfo.shopId,
582
582
  venderId: configDataValue.shopDetail,
583
583
  logEventInfo,
584
584
  });
585
585
  }
586
586
  break;
587
587
  case LinkConfigType.CONFIG_TYPE_SHOP_ACTIVITY:
588
588
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
589
589
  const getShopActivityParams = this.jdOpenAppParams(configDataValue.clickUrl);
590
590
  getShopActivityParams &&
591
591
  this.jdJumpToShopActivity(
592
592
  Object.assign({}, getShopActivityParams, {
593
593
  logEventInfo,
594
594
  }),
595
595
  );
596
596
  } else if (configDataValue['projectId']) {
597
597
  this.jdJumpToShopActivity({
598
598
  projectId: configDataValue['projectId'],
599
599
  configDataValue,
600
600
  logEventInfo,
601
601
  });
602
602
  }
603
603
  break;
604
604
  case LinkConfigType.CONFIG_TYPE_CUSTOM_LINK:
605
605
  case LinkConfigType.CONFIG_TYPE_FINANCE_COUPON: {
606
606
  const _url = configDataValue.linkUrl;
607
607
  if (
608
608
  _url.indexOf('to=') === -1 &&
609
609
  _url.indexOf(`${domain.mshop.replace(/https?:/, '')}/?shopId=`) !== -1
610
610
  ) {
611
611
  const _shopId = _url.match(/\d+/g)[0];
612
612
  this.jdJumpToShopHome({
613
613
  shopId: `${_shopId}`,
614
614
  logEventInfo,
615
615
  });
616
616
  } else if (this.isOpenJdAppUrl(_url)) {
617
617
  const getOpenAppParams = this.jdOpenAppParams(_url);
618
618
  console.log('jd web 获取自定义链接解析后的参数结果', getOpenAppParams);
619
619
  if (getOpenAppParams) {
620
620
  let _changeOpenAppParams = getOpenAppParams;
621
621
  const { operation, ...otherOpenAppParams } = getOpenAppParams;
622
622
  if (operation && operation === 'jumpTabInner') {
623
623
  _changeOpenAppParams = otherOpenAppParams;
624
624
  }
625
625
  this.jdNavigateToNative(
626
626
  Object.assign({}, _changeOpenAppParams, {
627
627
  logEventInfo,
628
628
  }),
629
629
  );
630
630
  }
631
631
  } else {
632
632
  this.jdJumpToWeb(_url, logEventInfo);
633
633
  }
634
634
  break;
635
635
  }
636
636
  case LinkConfigType.CONFIG_TYPE_JSHOP_DETAIL:
637
637
  this.jdJumpToShopDetail({
638
638
  venderId: global.info.queryInfo.venderId,
639
639
  shopId: global.info.queryInfo.shopId,
640
640
  logEventInfo,
641
641
  });
642
642
  break;
643
643
  case LinkConfigType.CONFIG_TYPE_SHOP_HOME:
644
644
  this.jdJumpToShopHome({
645
645
  ...configDataValue,
646
646
  logEventInfo,
647
647
  });
648
648
  break;
649
649
  case LinkConfigType.CONFIG_TYPE_ANCHOR_POINT:
650
650
  break;
651
651
  case LinkConfigType.CONFIG_TYPE_SHOPPING_GUIDE:
652
652
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
653
653
  const getShoppingGuideParams = this.jdOpenAppParams(configDataValue.clickUrl);
654
654
  getShoppingGuideParams &&
655
655
  this.jdJumpToShopActivity(
656
656
  Object.assign({}, getShoppingGuideParams, {
657
657
  logEventInfo,
658
658
  }),
659
659
  );
660
660
  }
661
661
  break;
662
662
  case LinkConfigType.CONFIG_TYPE_MINI_PROGRAM: {
663
663
  const linkUrl = decodeURIComponent(configDataValue?.linkUrl || '');
664
664
  const search = linkUrl.match(/\?.+/);
665
665
  if (search) {
666
666
  const miniQueryData: JumpEventReportInterFace.LinkMiniParams =
667
667
  parseQueryUrlString(linkUrl);
668
668
  try {
669
669
  miniQueryData.param = JSON.parse(miniQueryData?.param);
670
670
  } catch (e) {
671
671
  console.warn('解析小程序 param 错误:', miniQueryData);
672
672
  }
673
673
  this.jdJumpToMiniProgram(miniQueryData);
674
674
  } else {
675
675
  console.warn('小程序地址错误:', linkUrl);
676
676
  }
677
677
  break;
678
678
  }
679
679
  case LinkConfigType.CONFIG_TYPE_SHOP_SEARCH: {
680
680
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
681
681
  const getShopSearchParams = this.jdOpenAppParams(configDataValue.clickUrl);
682
682
  console.log('jd web 获取店铺结果落地页链接解析后的参数结果', getShopSearchParams);
683
683
  getShopSearchParams &&
684
684
  this.jdJumpToShopSearch(
685
685
  Object.assign({}, getShopSearchParams, {
686
686
  logEventInfo,
687
687
  }),
688
688
  );
689
689
  } else {
690
690
  this.jdJumpToWeb(configDataValue.clickUrl, logEventInfo);
691
691
  }
692
692
  break;
693
693
  }
694
694
  default:
695
695
  }
696
696
  }
697
697
 
698
698
  jdNavigateToNative(
699
699
  params: object,
700
700
  url = 'openapp.jdmobile://virtual',
701
701
  successBack?: functionType | null,
702
702
  failBack?: functionType | null,
703
703
  ) {
704
704
  const getResParams: JumpEventReportInterFace.JdMiniJumpParams = Object.assign(
705
705
  {},
706
706
  {
707
707
  sourceValue: 'sourceValue_jshopModuleWeb',
708
708
  sourceType: 'sourceType_jshopModuleWeb',
709
709
  param: {},
710
710
  },
711
711
  params,
712
712
  );
713
713
  const { logEventInfo, ...otherParams } = getResParams;
714
714
  console.log('[taro dynamic] jdNavigateToNative jd:', params,"融合后的参数getResParams",getResParams,'logEventInfo params: ', logEventInfo);
715
715
  global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE &&
716
716
  this.clickEventLog(logEventInfo || getResParams).then((res) => {
717
717
  console.log('收到埋点回调,跳转taro dynamic jd 回调结果',res);
718
718
  if (typeof successBack === 'function') {
719
719
  successBack(getResParams);
720
720
  } else {
721
721
  try {
722
722
  const paramsStr = JSON.stringify(otherParams);
723
723
  console.log('跳转taro dynamic jd open协议', `${url}?params=${paramsStr}`);
724
724
  Taro.JDNavigate.navigateTo({
725
725
  url: `${url}?params=${paramsStr}`,
726
726
  }).then(res => {
727
727
  console.log('跳转taro dynamic jd open协议 成功',res);
728
728
  })
729
729
  } catch (e) {
730
730
  console.log('跳转异常', e);
731
731
  }
732
732
  }
733
733
  })
734
734
  .catch(() => {
735
735
  typeof failBack === 'function' && failBack(getResParams);
736
736
  });
737
737
  }
738
738
 
739
739
  clickEventLog(opts: JumpEventReportInterFace.OptEventLogParams = {}, reportKey = 'click') {
740
740
  const { eventId, jsonParam, eventLevel = 3, ...otherParams } = opts;
741
741
  if (eventId && jsonParam) {
742
742
  const { etModelInfo, logBaseInfo } = jsonParam;
743
743
  let getJsonParam = {};
744
744
  if (etModelInfo && logBaseInfo) {
745
745
  getJsonParam = logBaseInfo;
746
746
  } else {
747
747
  if (Array.isArray(jsonParam)) {
748
748
  getJsonParam = jsonParam;
749
749
  } else {
750
750
  getJsonParam = Object.assign(
751
751
  {},
752
752
  {
753
753
  shopid: global.info.queryInfo?.shopId,
754
754
  },
755
755
  jsonParam,
756
756
  );
757
757
  }
758
758
  }
759
759
  if (
760
760
  reportKey === 'exposure' &&
761
761
  /^TerminatorNew/.test(eventId) &&
762
762
  !Array.isArray(getJsonParam)
763
763
  ) {
764
764
  getJsonParam = [getJsonParam];
765
765
  }
766
766
  console.log("eventId",eventId, "jsonParam", jsonParam, "getJsonParam",getJsonParam)
767
767
  const webLogParams = {
768
768
  isExpo: reportKey === 'exposure',
769
769
  eid: eventId,
770
770
  elevel: eventLevel,
771
771
  jsonParam: JSON.stringify(getJsonParam),
772
772
  etModel: JSON.stringify(etModelInfo || {}),
773
773
  pageId: this.logPageId,
774
774
  pageParam: this.logPageParamStr,
775
775
  ...otherParams,
776
776
  };
777
777
  console.log(
778
778
  `jdapp内,taro动态化---埋点参数对象-${reportKey}`,
779
779
  webLogParams,
780
780
  )
781
781
  return new Promise((resolve) => {
782
782
  const {
783
783
  eid,
784
784
  jsonParam,
785
785
  pageParam,
786
786
  pageId = 'TerminatorNew_All',
787
787
  } = webLogParams;
788
788
  const getReportData = {
789
789
  event_id: eid,
790
790
  page_id: pageId,
791
791
  page_name: "",
792
792
  page_param: pageParam,
793
793
  json_param: jsonParam,
794
794
  event_param:"",
795
795
  next_page_name:"",
796
796
  params:{},
797
797
  complete: () => {
798
798
  console.log('日志上报完毕,触发回调')
799
799
  resolve(true);
800
800
  }
801
801
  }
802
802
  console.log('Taro.JDMTA',Taro.JDMTA,"Taro.JDMTA[reportKey]",Taro.JDMTA[reportKey],"getReportData",getReportData)
803
803
  Taro.JDMTA.click(getReportData).then(res => {
804
804
  console.log("埋点上报成功",res)
805
805
  })
806
806
  resolve(true);
807
807
  });
808
808
  } else {
809
809
  console.log('暂无埋点参数eventId和eventParam');
810
810
  return Promise.resolve(false);
811
811
  }
812
812
  }
813
813
  reportPV(opts){
814
814
  const { pageId, pageParam, isSend = true } = opts;
815
815
  isSend && Taro.JDMTA.pv({
816
816
  page_id: pageId,
817
817
  page_name: "",
818
818
  page_param: pageParam
819
819
  })
820
820
  }
821
821
 
822
822
  exposureEventLog(opts) {
823
823
  return global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE
824
824
  ? this.clickEventLog(
825
825
  {
826
826
  ...opts,
827
827
  exposureState: true,
828
828
  },
829
829
  'exposure',
830
830
  )
831
831
  : Promise.resolve(false);
832
832
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conecli/cone-render",
3
- "version": "0.10.1-shop-beta.13",
3
+ "version": "0.10.1-shop-beta.14",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist/"