@conecli/cone-render 0.10.1-shop3.76 → 0.10.1-shop3.79

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 global from '../common';
2
1
  BUSINESS_TYPE,
3
2
  SHOP_MENU_ID_TYPE,
4
3
  SHOP_MENU_ID_NAME,
5
4
  SECTION_HOME_TAB_TYPE,
6
5
  SECTION_HOME_TAB_NAME_TYPE,
7
6
  LogPageIdInfo,
8
7
  LogPnameInfo,
9
8
  PcShopSpmA,
10
9
  PcShopSpmBforMap,
11
10
  routerInfo: {
12
11
  params: {},
13
12
  },
14
13
  nativeEvent: null,
15
14
  jumpConfig: {
16
15
  venderId: null,
17
16
  shopId: null,
18
17
  sourceValue: '',
19
18
  sourceType: 'M-H5',
20
19
  activityType: 'shopx',
21
20
  moduleId: 'none',
22
21
  entrance: 'none',
23
22
  },
24
23
  logPageParamStr: '',
25
24
  new Promise((resolve, reject) => {
26
25
  if (window.spmPV) {
27
26
  resolve(true);
28
27
  } else {
29
28
  if (isReportReadyError) {
30
29
  reject(false);
31
30
  } else {
32
31
  ready('spmPV', 3000)
33
32
  .then(() => {
34
33
  isReportReadyError = false;
35
34
  resolve(true);
36
35
  })
37
36
  .catch(() => {
38
37
  isReportReadyError = true;
39
38
  reject(false);
40
39
  });
41
40
  }
42
41
  }
43
42
  });
44
43
  public logPageId: string;
45
44
  public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig;
46
45
  getConfig(opt) {
47
46
  return Object.assign(this, {}, defaultConfig, opt);
48
47
  }
49
48
  updateInfo(routerInfo, logPname = LogPnameInfo.HOME, pageId = LogPageIdInfo.APP) {
50
49
  this.routerInfo = routerInfo;
51
50
  this.logPname = logPname;
52
51
  this.jumpConfig = Object.assign(
53
52
  {},
54
53
  this.jumpConfig,
55
54
  filterUrlQueryData(routerInfo?.params || {}),
56
55
  );
57
56
  this.logPageId = pageId;
58
57
  }
59
58
 
60
59
  jdNavigateToNative(
61
60
  url: string,
62
61
  params: {
63
62
  logEventInfo?: object;
64
63
  } = {},
65
64
  successBack?: Function | undefined,
66
65
  failBack?: Function | undefined,
67
66
  ) {
68
67
  const { logEventInfo } = params;
69
68
  const getEparam = logEventInfo || params;
70
69
  console.log(`url:::::::${url}`);
71
70
  global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE &&
72
71
  this.clickEventLog(getEparam)
73
72
  .then(() => {
74
73
  typeof successBack === 'function' ? successBack(url) : (window.open(url, '_blank'));
75
74
  })
76
75
  .catch(() => {
77
76
  typeof failBack === 'function' && failBack(url);
78
77
  });
79
78
  }
80
79
 
81
80
  reportInfoPv(
82
81
  pageId = LogPageIdInfo.APP,
83
82
  opt: {
84
83
  pageParam?: any;
85
84
  } = {},
86
85
  ): Promise<any> {
87
86
  console.log('web.pc.ts - reportInfoPv', pageId, opt);
88
87
  return new Promise((resolve, reject) => {
89
88
  const { pageParam } = opt;
90
89
  const pageParamStr = typeof pageParam === 'object' ? JSON.stringify(pageParam) : pageParam;
91
90
  getReportObjReadyPromise()
92
91
  .then(() => {
93
92
  window.spmPV({
94
93
  spm: `${PcShopSpmA}.${PcShopSpmBforMap[pageId]}`,
95
94
  page_id: pageId,
96
95
  page_param: pageParamStr,
97
96
  });
98
97
  resolve(true);
99
98
  })
100
99
  .catch((e) => {
101
100
  reject(e);
102
101
  });
103
102
  }).catch((err) => {
104
103
  console.log('pc sgm 浏览pv埋点上报异常', err);
105
104
  });
106
105
  }
107
106
 
108
107
  clickEventLog(opts): Promise<any> {
109
108
  console.log('web.pc.ts - clickEventLog opts: ', opts);
110
109
  return new Promise((resolve, reject) => {
111
110
  const { spmAll, spmCd, pageId, pageParam, ...otherParam } = opts;
112
111
  const pageParamStr = typeof pageParam === 'object' ? JSON.stringify(pageParam) : pageParam;
113
112
  getReportObjReadyPromise()
114
113
  .then(() => {
115
114
  window.spmLog({
116
115
  spm: spmAll ? spmAll : `${PcShopSpmA}.${PcShopSpmBforMap[pageId]}.${spmCd}`,
117
116
  biz_type: '',
118
117
  page_id: pageId,
119
118
  event_param: '',
120
119
  json_param: pageParamStr,
121
120
  t1: '',
122
121
  t2: '',
123
122
  p0: '',
124
123
  ...otherParam,
125
124
  });
126
125
  resolve(true);
127
126
  })
128
127
  .catch((e) => {
129
128
  reject(e);
130
129
  });
131
130
  }).catch((err) => {
132
131
  console.log('pc sgm 点击埋点上报异常', err);
133
132
  });
134
133
  }
135
134
 
136
135
  exposureEventLog(opts): Promise<any> {
137
136
  console.log('web.pc.ts - exposureEventLog opts: ', opts);
138
137
  return new Promise((resolve, reject) => {
139
138
  const { spmAll, spmCd, pageId, pageParam, ...otherParam } = opts;
140
139
  const pageParamStr = typeof pageParam === 'object' ? JSON.stringify(pageParam) : pageParam;
141
140
  getReportObjReadyPromise()
142
141
  .then(() => {
143
142
  window.spmExposure({
144
143
  spm: spmAll ? spmAll : `${PcShopSpmA}.${PcShopSpmBforMap[pageId]}.${spmCd}`,
145
144
  biz_type: '',
146
145
  page_id: pageId,
147
146
  event_param: '',
148
147
  json_param: pageParamStr,
149
148
  t1: '',
150
149
  t2: '',
151
150
  p0: '',
152
151
  ...otherParam,
153
152
  });
154
153
  resolve(true);
155
154
  })
156
155
  .catch((e) => {
157
156
  reject(e);
158
157
  });
159
158
  }).catch((err) => {
160
159
  console.log('pc sgm 曝光埋点上报异常', err);
161
160
  });
162
161
  }
163
162
 
164
163
  jdJumpToProduct(skuIds, logEventInfo) {
165
164
  skuIds = skuIds.toString().trim();
166
165
  const getSkuId = skuIds.indexOf(',') !== -1 ? skuIds.split(',')[0] : skuIds;
167
166
  let url = `${this.jumpWebUrl.pcDetail}${getSkuId}.html`;
168
167
  this.jdNavigateToNative(url, logEventInfo);
169
168
  }
170
169
 
171
170
  jdJumpSkuInfoToProduct(skuInfo: any = {}, logEventInfo) {
172
171
  const getSkuId = skuInfo?.skuId;
173
172
  this.jdJumpToProduct(getSkuId, logEventInfo);
174
173
  }
175
174
 
176
175
  jdJumpToShopHome(shopInfo: JumpEventReportInterFace.ShopIdsInfo = {}) {
177
176
  const currentShopInfo = {
178
177
  shopId: global.info.queryInfo.shopId,
179
178
  venderId: global.info.queryInfo.venderId,
180
179
  };
181
180
  const restParams =
182
181
  (shopInfo?.shopId && shopInfo.shopId !== currentShopInfo.shopId) ||
183
182
  (shopInfo?.venderId && shopInfo.venderId !== currentShopInfo.venderId)
184
183
  ? {}
185
184
  : currentShopInfo;
186
185
  const getInfo = Object.assign({}, restParams, shopInfo);
187
186
  let url = `${this.jumpWebUrl.pages}/index-${global.info.queryInfo.shopId}.html`;
188
187
  this.jdNavigateToNative(url, {
189
188
  ...getInfo,
190
189
  });
191
190
  }
192
191
 
193
192
  getPcSearchUrl = (cateId) => {
194
193
  const flag = document.querySelector('#JSHOP_CHANNEL_FLAG')?.value;
195
194
  const appId =
196
195
  document.querySelector('#J_AppId')?.value ||
197
196
  document.querySelector('#pageInstance_appId')?.value;
198
197
  return flag === 'yao'
199
198
  ? this.jumpWebUrl.pages + '/view_shop_search-' + appId + '.html'
200
199
  : this.jumpWebUrl.pages + '/view_search-' + appId + '-' + cateId + '-99-1-20-1.html';
201
200
  };
202
201
 
203
202
  jdJumpToShopSearch(shopInfo) {
204
203
  const getInfo = Object.assign(
205
204
  {},
206
205
  {
207
206
  shopId: global.info.queryInfo.shopId,
208
207
  venderId: global.info.queryInfo.venderId,
209
208
  },
210
209
  shopInfo,
211
210
  );
212
211
  const { categoryId } = getInfo;
213
212
  const url = `${this.getPcSearchUrl(categoryId)}`;
214
213
  this.jdJumpToWeb(url, getInfo);
215
214
  }
216
215
 
217
216
  jdJumpToTabAllProduct(shopId, venderId, logEventInfo = {}) {
218
217
  console.log('web.base.ts - jdJumpToTabAllProduct');
219
218
  if (typeof shopId === 'undefined') shopId = global.info.queryInfo.shopId;
220
219
  if (typeof venderId === 'undefined') venderId = global.info.queryInfo.venderId;
221
220
  const url = `${this.jumpWebUrl.pages}/index-${shopId}.html`;
222
221
  this.jdJumpToWeb(url, logEventInfo);
223
222
  }
224
223
 
225
224
  jdJumpToCouponSearchProductList(couponId, logEventInfo = {}) {
226
225
  const url = `${this.jumpWebUrl.couponSearch}?couponbatch=${couponId}&sceneval=2`;
227
226
  this.jdJumpToWeb(url, logEventInfo);
228
227
  }
228
+ import global from '../common';
229
229
  BUSINESS_TYPE,
230
230
  SHOP_MENU_ID_TYPE,
231
231
  SHOP_MENU_ID_NAME,
232
232
  SECTION_HOME_TAB_TYPE,
233
233
  SECTION_HOME_TAB_NAME_TYPE,
234
234
  LogPageIdInfo,
235
235
  LogPnameInfo,
236
236
  PcShopSpmA,
237
237
  PcShopSpmBforMap,
238
238
  routerInfo: {
239
239
  params: {},
240
240
  },
241
241
  nativeEvent: null,
242
242
  jumpConfig: {
243
243
  venderId: null,
244
244
  shopId: null,
245
245
  sourceValue: '',
246
246
  sourceType: 'M-H5',
247
247
  activityType: 'shopx',
248
248
  moduleId: 'none',
249
249
  entrance: 'none',
250
250
  },
251
251
  logPageParamStr: '',
252
252
  new Promise((resolve, reject) => {
253
253
  if (window.spmPV) {
254
254
  resolve(true);
255
255
  } else {
256
256
  if (isReportReadyError) {
257
257
  reject(false);
258
258
  } else {
259
259
  ready('spmPV', 3000)
260
260
  .then(() => {
261
261
  isReportReadyError = false;
262
262
  resolve(true);
263
263
  })
264
264
  .catch(() => {
265
265
  isReportReadyError = true;
266
266
  reject(false);
267
267
  });
268
268
  }
269
269
  }
270
270
  });
271
271
  public logPageId: string;
272
272
  public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig;
273
273
  getConfig(opt) {
274
274
  return Object.assign(this, {}, defaultConfig, opt);
275
275
  }
276
276
  updateInfo(routerInfo, logPname = LogPnameInfo.HOME, pageId = LogPageIdInfo.APP) {
277
277
  this.routerInfo = routerInfo;
278
278
  this.logPname = logPname;
279
279
  this.jumpConfig = Object.assign(
280
280
  {},
281
281
  this.jumpConfig,
282
282
  filterUrlQueryData(routerInfo?.params || {}),
283
283
  );
284
284
  this.logPageId = pageId;
285
285
  }
286
286
 
287
287
  jdNavigateToNative(
288
288
  url: string,
289
289
  params: {
290
290
  logEventInfo?: object;
291
291
  } = {},
292
292
  successBack?: Function | undefined,
293
293
  failBack?: Function | undefined,
294
294
  ) {
295
295
  const { logEventInfo } = params;
296
296
  const getEparam = logEventInfo || params;
297
297
  console.log(`url:::::::${url}`);
298
298
  global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE &&
299
299
  this.clickEventLog(getEparam)
300
300
  .then(() => {
301
301
  typeof successBack === 'function' ? successBack(url) : window.open(url, '_blank');
302
302
  })
303
303
  .catch(() => {
304
304
  typeof failBack === 'function' && failBack(url);
305
305
  });
306
306
  }
307
307
 
308
308
  reportInfoPv(
309
309
  pageId = LogPageIdInfo.APP,
310
310
  opt: {
311
311
  pageParam?: any;
312
312
  } = {},
313
313
  ): Promise<any> {
314
314
  console.log('web.pc.ts - reportInfoPv', pageId, opt);
315
315
  return new Promise((resolve, reject) => {
316
316
  const { pageParam } = opt;
317
317
  const pageParamStr = typeof pageParam === 'object' ? JSON.stringify(pageParam) : pageParam;
318
318
  getReportObjReadyPromise()
319
319
  .then(() => {
320
320
  window.spmPV({
321
321
  spm: `${PcShopSpmA}.${PcShopSpmBforMap[pageId]}`,
322
322
  page_id: pageId,
323
323
  page_param: pageParamStr,
324
324
  });
325
325
  resolve(true);
326
326
  })
327
327
  .catch((e) => {
328
328
  reject(e);
329
329
  });
330
330
  }).catch((err) => {
331
331
  console.log('pc sgm 浏览pv埋点上报异常', err);
332
332
  });
333
333
  }
334
334
 
335
335
  clickEventLog(opts): Promise<any> {
336
336
  console.log('web.pc.ts - clickEventLog opts: ', opts);
337
337
  return new Promise((resolve, reject) => {
338
338
  const { spmAll, spmCd, pageId, pageParam, ...otherParam } = opts;
339
339
  const pageParamStr = typeof pageParam === 'object' ? JSON.stringify(pageParam) : pageParam;
340
340
  getReportObjReadyPromise()
341
341
  .then(() => {
342
342
  window.spmLog({
343
343
  spm: spmAll ? spmAll : `${PcShopSpmA}.${PcShopSpmBforMap[pageId]}.${spmCd}`,
344
344
  biz_type: '',
345
345
  page_id: pageId,
346
346
  event_param: '',
347
347
  json_param: pageParamStr,
348
348
  t1: '',
349
349
  t2: '',
350
350
  p0: '',
351
351
  ...otherParam,
352
352
  });
353
353
  resolve(true);
354
354
  })
355
355
  .catch((e) => {
356
356
  reject(e);
357
357
  });
358
358
  }).catch((err) => {
359
359
  console.log('pc sgm 点击埋点上报异常', err);
360
360
  });
361
361
  }
362
362
 
363
363
  exposureEventLog(opts): Promise<any> {
364
364
  console.log('web.pc.ts - exposureEventLog opts: ', opts);
365
365
  return new Promise((resolve, reject) => {
366
366
  const { spmAll, spmCd, pageId, pageParam, ...otherParam } = opts;
367
367
  const pageParamStr = typeof pageParam === 'object' ? JSON.stringify(pageParam) : pageParam;
368
368
  getReportObjReadyPromise()
369
369
  .then(() => {
370
370
  window.spmExposure({
371
371
  spm: spmAll ? spmAll : `${PcShopSpmA}.${PcShopSpmBforMap[pageId]}.${spmCd}`,
372
372
  biz_type: '',
373
373
  page_id: pageId,
374
374
  event_param: '',
375
375
  json_param: pageParamStr,
376
376
  t1: '',
377
377
  t2: '',
378
378
  p0: '',
379
379
  ...otherParam,
380
380
  });
381
381
  resolve(true);
382
382
  })
383
383
  .catch((e) => {
384
384
  reject(e);
385
385
  });
386
386
  }).catch((err) => {
387
387
  console.log('pc sgm 曝光埋点上报异常', err);
388
388
  });
389
389
  }
390
390
 
391
391
  jdJumpToProduct(skuIds, logEventInfo) {
392
392
  skuIds = skuIds.toString().trim();
393
393
  const getSkuId = skuIds.indexOf(',') !== -1 ? skuIds.split(',')[0] : skuIds;
394
394
  let url = `${this.jumpWebUrl.pcDetail}${getSkuId}.html`;
395
395
  this.jdNavigateToNative(url, logEventInfo);
396
396
  }
397
397
 
398
398
  jdJumpSkuInfoToProduct(skuInfo: any = {}, logEventInfo) {
399
399
  const getSkuId = skuInfo?.skuId;
400
400
  this.jdJumpToProduct(getSkuId, logEventInfo);
401
401
  }
402
402
 
403
403
  jdJumpToShopHome(shopInfo: JumpEventReportInterFace.ShopIdsInfo = {}) {
404
404
  const currentShopInfo = {
405
405
  shopId: global.info.queryInfo.shopId,
406
406
  venderId: global.info.queryInfo.venderId,
407
407
  };
408
408
  const restParams =
409
409
  (shopInfo?.shopId && shopInfo.shopId !== currentShopInfo.shopId) ||
410
410
  (shopInfo?.venderId && shopInfo.venderId !== currentShopInfo.venderId)
411
411
  ? {}
412
412
  : currentShopInfo;
413
413
  const getInfo = Object.assign({}, restParams, shopInfo);
414
414
  let url = `${this.jumpWebUrl.pages}/index-${getInfo.shopId}.html`;
415
415
  this.jdNavigateToNative(url, {
416
416
  ...getInfo,
417
417
  });
418
418
  }
419
419
 
420
420
  getPcSearchUrl = (cateId) => {
421
421
  const flag = document.querySelector('#JSHOP_CHANNEL_FLAG')?.value;
422
422
  const appId =
423
423
  document.querySelector('#J_AppId')?.value ||
424
424
  document.querySelector('#pageInstance_appId')?.value;
425
425
  return flag === 'yao'
426
426
  ? this.jumpWebUrl.pages + '/view_shop_search-' + appId + '.html'
427
427
  : this.jumpWebUrl.pages + '/view_search-' + appId + '-' + cateId + '-99-1-20-1.html';
428
428
  };
429
429
 
430
430
  jdJumpToShopSearch(shopInfo) {
431
431
  const getInfo = Object.assign(
432
432
  {},
433
433
  {
434
434
  shopId: global.info.queryInfo.shopId,
435
435
  venderId: global.info.queryInfo.venderId,
436
436
  },
437
437
  shopInfo,
438
438
  );
439
439
  const { categoryId } = getInfo;
440
440
  const url = `${this.getPcSearchUrl(categoryId)}`;
441
441
  this.jdJumpToWeb(url, getInfo);
442
442
  }
443
443
 
444
444
  jdJumpToTabAllProduct(shopId, venderId, logEventInfo = {}) {
445
445
  console.log('web.base.ts - jdJumpToTabAllProduct');
446
446
  if (typeof shopId === 'undefined') shopId = global.info.queryInfo.shopId;
447
447
  if (typeof venderId === 'undefined') venderId = global.info.queryInfo.venderId;
448
448
  const url = `${this.jumpWebUrl.pages}/index-${shopId}.html`;
449
449
  this.jdJumpToWeb(url, logEventInfo);
450
450
  }
451
451
 
452
452
  jdJumpToCouponSearchProductList(couponId, logEventInfo = {}) {
453
453
  const url = `${this.jumpWebUrl.couponSearch}?couponbatch=${couponId}&sceneval=2`;
454
454
  this.jdJumpToWeb(url, logEventInfo);
455
455
  }