@conecli/cone-render 0.10.1-shop-beta.43 → 0.10.1-shop-beta.44

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
  objectToUrlEncode,
3
2
  isH5AndJingGouMini,
4
3
  isAscfApp,
5
4
  public jingGouMiniState: boolean;
6
5
  private isH5OpenToWxapp: boolean;
7
6
  constructor(opt) {
8
7
  super(opt);
9
8
  this.jingGouMiniState = false;
10
9
  this.getConfig(opt);
11
10
  console.log('window.shopGlobalSwitch:', JSON.stringify(window.shopGlobalSwitch));
12
11
  this.isH5OpenToWxapp = window.shopGlobalSwitch?.openMobileShopToWxApp == 'true';
13
12
  this.init();
14
13
  }
15
14
  getConfig(opt) {
16
15
  return Object.assign(this, {}, defaultConfig, super.getConfig(opt), opt);
17
16
  }
18
17
 
19
18
 
20
19
  async init() {
21
20
  if (window.isJingGouMiniViewState) {
22
21
  this.jingGouMiniState = true;
23
22
  } else {
24
23
  console.log('初始化进行小程序环境检查, 当前是否是京购小程序里的H5', isH5AndJingGouMini);
25
24
  if ((isH5AndJingGouMini || isAscfApp) && this.isH5OpenToWxapp) {
26
25
  console.log('进入了 isH5AndJingGouMini && this.isH5OpenToWxapp 的if');
27
26
  this.jingGouMiniState = true;
28
27
  window.isJingGouMiniViewState = true;
29
28
  console.log('进入了 iwx?.miniProgram then 但是没有继续跳转的逻辑 ');
30
29
  global.info.isJingGouMiniViewState = true;
31
30
  } else {
32
31
  console.log('进入了 isH5AndJingGouMini && this.isH5OpenToWxapp 的esle');
33
32
  }
34
33
  }
35
34
  }
36
35
 
37
36
  jdJumpToMiniPage(pageUrl, logEventInfo, type = 'navigateTo') {
38
37
  this.jdNavigateToNative(
39
38
  pageUrl,
40
39
  logEventInfo,
41
40
  () => {
42
41
  console.log('JD.wxappext.goto');
43
42
  if (window?.wx && window?.wx?.miniProgram[type]) {
44
43
  wx?.miniProgram[type]({
45
44
  url: pageUrl,
46
45
  });
47
46
  } else if (window?.has && window?.has.ascfweb && window?.has.ascfweb[type]) {
48
47
  has.ascfweb[type]({
49
48
  url: pageUrl,
50
49
  });
51
50
  }
52
51
  },
53
52
  () => {
54
53
  console.log('JD.wxappext.goto2');
55
54
  if (window?.wx && window?.wx?.miniProgram[type]) {
56
55
  wx?.miniProgram[type]({
57
56
  url: pageUrl,
58
57
  });
59
58
  } else if (window?.has && window?.has.ascfweb && window?.has.ascfweb[type]) {
60
59
  has.ascfweb[type]({
61
60
  url: pageUrl,
62
61
  });
63
62
  }
64
63
  },
65
64
  );
66
65
  }
67
66
 
68
67
  jdJumpToTabAllProduct(shopId, venderId, logEventInfo = {}) {
69
68
  console.log('web.wxapp.ts - jdJumpToTabAllProduct');
70
69
  if (typeof shopId === 'undefined') shopId = global.info.queryInfo.shopId;
71
70
  if (typeof venderId === 'undefined') venderId = global.info.queryInfo.venderId;
72
71
  if (this.jingGouMiniState) {
73
72
  const param = {
74
73
  shopId,
75
74
  venderId,
76
75
  tabActive: SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PRODUCT],
77
76
  };
78
77
  const url = `${this.jumpMiniPath.shopx}?${objectToUrlEncode(param)}`;
79
78
  this.jdJumpToMiniPage(url, logEventInfo);
80
79
  } else {
81
80
  super.jdJumpToTabAllProduct(shopId, venderId, logEventInfo);
82
81
  }
83
82
  }
84
83
 
85
84
  jdJumpToTopTabBase(type, shopInfo = {}) {
86
85
  const getInfo = Object.assign(
87
86
  {},
88
87
  {
89
88
  shopId: global.info.queryInfo.shopId,
90
89
  venderId: global.info.queryInfo.venderId,
91
90
  },
92
91
  shopInfo,
93
92
  );
94
93
  if (this.jingGouMiniState) {
95
94
  const { shopId, venderId, ...otherInfo } = getInfo;
96
95
  const param = {
97
96
  shopId,
98
97
  venderId,
99
98
  tabActive: type,
100
99
  };
101
100
  const url = `${this.jumpMiniPath.shopx}?${objectToUrlEncode(param)}`;
102
101
  this.jdJumpToMiniPage(url, otherInfo);
103
102
  } else {
104
103
  super.jdJumpToTopTabBase(type, shopInfo);
105
104
  }
106
105
  }
107
106
 
108
107
  jdJumpToWeb(url, logEventInfo) {
109
108
  console.log('web.wxapp.ts - jdJumpToWeb', url);
110
109
  console.log('jingGouMiniState', this.jingGouMiniState);
111
110
  if (this.jingGouMiniState) {
112
111
  const encodeUrl = `${this.jumpMiniPath.h5}?encode_url=${encodeURIComponent(url)}`;
113
112
  this.jdJumpToMiniPage(encodeUrl, logEventInfo);
114
113
  } else {
115
114
  super.jdJumpToWeb(url, logEventInfo);
116
115
  }
117
116
  }
118
117
 
119
118
  jdJumpToWebInner(url, logEventInfo) {
120
119
  super.jdJumpToWeb(url, logEventInfo);
121
120
  }
122
121
 
123
122
  jdJumpToProduct(skuIds, logEventInfo) {
124
123
  if (this.jingGouMiniState) {
125
124
  const detailUrl = `${this.jumpMiniPath.detail}?sku=${skuIds}`;
126
125
  this.jdJumpToMiniPage(detailUrl, logEventInfo);
127
126
  } else {
128
127
  super.jdJumpToProduct(skuIds, logEventInfo);
129
128
  }
130
129
  }
131
130
 
132
131
  jdJumpSkuInfoToProduct(skuInfo: any = {}, logEventInfo) {
133
132
  const getSkuId = skuInfo?.skuId;
134
133
  this.jdJumpToProduct(getSkuId, logEventInfo);
135
134
  }
136
135
 
137
136
  jdJumpToCartPage(logEventInfo) {
138
137
  console.log('跳转到购物车页面', logEventInfo);
139
138
  }
140
139
 
141
140
  jdJumpToShopHome(shopInfo) {
142
141
  console.log('[降级H5] jdJumpToShopHome web.wxapp', shopInfo);
143
142
  console.log(
144
143
  'global.info.queryInfo.shopId',
145
144
  global.info.queryInfo.shopId,
146
145
  global.info.queryInfo.venderId,
147
146
  );
148
147
  const currentShopInfo = {
149
148
  shopId: global.info.queryInfo.shopId,
150
149
  venderId: global.info.queryInfo.venderId,
151
150
  };
152
151
  const restParams =
153
152
  (shopInfo?.shopId && shopInfo.shopId !== currentShopInfo.shopId) ||
154
153
  (shopInfo?.venderId && shopInfo.venderId !== currentShopInfo.venderId)
155
154
  ? {}
156
155
  : currentShopInfo;
157
156
  const getInfo = Object.assign({}, restParams, shopInfo);
158
157
  const { type = 'navigateTo', ...otherShopInfo } = getInfo;
159
158
  if (this.jingGouMiniState) {
160
159
  let shopUrl = `${this.jumpMiniPath.shopx}${window.location.search}`;
161
160
  if (
162
161
  /(\/shop\/(samCenter|samCard))|(\/sale\/home)|(\/favorite)/.test(window.location.pathname)
163
162
  ) {
164
163
  shopUrl = `${this.jumpMiniPath.shopx}?${objectToUrlEncode(
165
164
  this.getShopIdsInfo(otherShopInfo),
166
165
  )}`;
167
166
  }
168
167
  this.jdJumpToMiniPage(shopUrl, otherShopInfo, type);
169
168
  } else {
170
169
  super.jdJumpToShopHome(otherShopInfo);
171
170
  }
172
171
  }
173
172
 
174
173
  jdJumpToShopCategory(params) {
175
174
  console.log('[降级H5] jdJumpToShopCategory web.wxapp');
176
175
  const { type = 'navigateTo', ...otherShopInfo } = params;
177
176
  console.log('获取分类跳转参数', params);
178
177
  if (this.jingGouMiniState) {
179
178
  this.jdJumpToTopTabBase('classify', otherShopInfo);
180
179
  } else {
181
180
  super.jdJumpToShopCategory(otherShopInfo);
182
181
  }
183
182
  }
184
183
 
185
184
  jdJumpToLive(liveInfo, logEventInfo = {}) {
186
185
  if (liveInfo?.liveId) {
187
186
  if (this.jingGouMiniState && liveInfo?.openWxappToLiveRoom) {
188
187
  this.jdJumpToMiniPage(`${this.jumpMiniPath.jdLive}?liveId=${liveInfo.liveId}&origin=473`, {
189
188
  logEventInfo,
190
189
  });
191
190
  } else {
192
191
  this.jdJumpToWeb(
193
192
  `${this.jumpWebUrl.mLive}/${liveInfo.liveId}?${
194
193
  this.jingGouMiniState ? 'origin=0&appid=jdgw' : 'origin=30'
195
194
  }`,
196
195
  logEventInfo,
197
196
  );
198
197
  }
199
198
  }
200
199
  }
201
200
 
202
201
  jdJumpToShopLight(shopInfo) {
203
202
  if (this.jingGouMiniState) {
204
203
  this.jdJumpToMiniPage(
205
204
  `${this.jumpMiniPath.shopLight}?${objectToUrlEncode(
206
205
  this.getShopIdOrVenderIdParams(shopInfo),
207
206
  )}`,
208
207
  {
209
208
  ...shopInfo,
210
209
  },
211
210
  );
212
211
  } else {
213
212
  this.jdNavigateToNative(
214
213
  `${this.jumpWebUrl.shopLight}?${objectToUrlEncode(
215
214
  this.getShopIdOrVenderIdParams(shopInfo),
216
215
  )}`,
217
216
  {
218
217
  ...shopInfo,
219
218
  },
220
219
  );
221
220
  }
222
221
  }
223
222
  jdJumpToCouponSearchProductList(couponId, logEventInfo = {}) {
224
223
  if (this.jingGouMiniState) {
225
224
  const detailUrl = `${this.jumpMiniPath.searchCoupon}?batch=${couponId}`;
226
225
  this.jdJumpToMiniPage(detailUrl, logEventInfo);
227
226
  } else {
228
227
  super.jdJumpToCouponSearchProductList(couponId, logEventInfo);
229
228
  }
230
229
  }
231
230
  jdJumpToOrderList(orderType, logEventInfo = {}) {
232
231
  if (this.jingGouMiniState) {
233
232
  const detailUrl = `${this.jumpMiniPath.orderList}?orderType=${orderType}&source=shopx`;
234
233
  this.jdJumpToMiniPage(detailUrl, logEventInfo);
235
234
  } else {
236
235
  super.jdJumpToOrderList(orderType, logEventInfo);
237
236
  }
238
237
  }
238
+ import global from '../common';
239
239
  objectToUrlEncode,
240
240
  isH5AndJingGouMini,
241
241
  isAscfApp,
242
242
  public jingGouMiniState: boolean;
243
243
  private isH5OpenToWxapp: boolean;
244
244
  constructor(opt) {
245
245
  super(opt);
246
246
  this.jingGouMiniState = false;
247
247
  this.getConfig(opt);
248
248
  console.log('window.shopGlobalSwitch:', JSON.stringify(window.shopGlobalSwitch));
249
249
  this.isH5OpenToWxapp = window.shopGlobalSwitch?.openMobileShopToWxApp == 'true';
250
250
  this.init();
251
251
  }
252
252
  getConfig(opt) {
253
253
  return Object.assign(this, {}, defaultConfig, super.getConfig(opt), opt);
254
254
  }
255
255
 
256
256
 
257
257
  async init() {
258
258
  if (window.isJingGouMiniViewState) {
259
259
  this.jingGouMiniState = true;
260
260
  } else {
261
261
  console.log('初始化进行小程序环境检查, 当前是否是京购小程序里的H5', isH5AndJingGouMini);
262
262
  if ((isH5AndJingGouMini || isAscfApp) && this.isH5OpenToWxapp) {
263
263
  console.log('进入了 isH5AndJingGouMini && this.isH5OpenToWxapp 的if');
264
264
  this.jingGouMiniState = true;
265
265
  window.isJingGouMiniViewState = true;
266
266
  console.log('进入了 iwx?.miniProgram then 但是没有继续跳转的逻辑 ');
267
267
  global.info.isJingGouMiniViewState = true;
268
268
  } else {
269
269
  console.log('进入了 isH5AndJingGouMini && this.isH5OpenToWxapp 的esle');
270
270
  }
271
271
  }
272
272
  }
273
273
 
274
274
  jdJumpToMiniPage(pageUrl, logEventInfo, type = 'navigateTo') {
275
275
  this.jdNavigateToNative(
276
276
  pageUrl,
277
277
  logEventInfo,
278
278
  () => {
279
279
  console.log('JD.wxappext.goto');
280
280
  if (window?.wx && window?.wx?.miniProgram[type]) {
281
281
  wx?.miniProgram[type]({
282
282
  url: pageUrl,
283
283
  });
284
284
  } else if (window?.has && window?.has.ascfweb && window?.has.ascfweb[type]) {
285
285
  has.ascfweb[type]({
286
286
  url: pageUrl,
287
287
  });
288
288
  }
289
289
  },
290
290
  () => {
291
291
  console.log('JD.wxappext.goto2');
292
292
  if (window?.wx && window?.wx?.miniProgram[type]) {
293
293
  wx?.miniProgram[type]({
294
294
  url: pageUrl,
295
295
  });
296
296
  } else if (window?.has && window?.has.ascfweb && window?.has.ascfweb[type]) {
297
297
  has.ascfweb[type]({
298
298
  url: pageUrl,
299
299
  });
300
300
  }
301
301
  },
302
302
  );
303
303
  }
304
304
 
305
305
  jdJumpToTabAllProduct(shopId, venderId, logEventInfo = {}) {
306
306
  console.log('web.wxapp.ts - jdJumpToTabAllProduct');
307
307
  if (typeof shopId === 'undefined') shopId = global.info.queryInfo.shopId;
308
308
  if (typeof venderId === 'undefined') venderId = global.info.queryInfo.venderId;
309
309
  if (this.jingGouMiniState) {
310
310
  const param = {
311
311
  shopId,
312
312
  venderId,
313
313
  tabActive: SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PRODUCT],
314
314
  };
315
315
  const url = `${this.jumpMiniPath.shopx}?${objectToUrlEncode(param)}`;
316
316
  this.jdJumpToMiniPage(url, logEventInfo);
317
317
  } else {
318
318
  super.jdJumpToTabAllProduct(shopId, venderId, logEventInfo);
319
319
  }
320
320
  }
321
321
 
322
322
  jdJumpToTopTabBase(type, shopInfo = {}) {
323
323
  const getInfo = Object.assign(
324
324
  {},
325
325
  {
326
326
  shopId: global.info.queryInfo.shopId,
327
327
  venderId: global.info.queryInfo.venderId,
328
328
  },
329
329
  shopInfo,
330
330
  );
331
331
  if (this.jingGouMiniState) {
332
332
  const { shopId, venderId, ...otherInfo } = getInfo;
333
333
  const param = {
334
334
  shopId,
335
335
  venderId,
336
336
  tabActive: type,
337
337
  };
338
338
  const url = `${this.jumpMiniPath.shopx}?${objectToUrlEncode(param)}`;
339
339
  this.jdJumpToMiniPage(url, otherInfo);
340
340
  } else {
341
341
  super.jdJumpToTopTabBase(type, shopInfo);
342
342
  }
343
343
  }
344
344
 
345
345
  jdJumpToWeb(url, logEventInfo) {
346
346
  console.log('web.wxapp.ts - jdJumpToWeb', url);
347
347
  console.log('jingGouMiniState', this.jingGouMiniState);
348
348
  if (this.jingGouMiniState) {
349
349
  const encodeUrl = `${this.jumpMiniPath.h5}?encode_url=${encodeURIComponent(url)}`;
350
350
  this.jdJumpToMiniPage(encodeUrl, logEventInfo);
351
351
  } else {
352
352
  super.jdJumpToWeb(url, logEventInfo);
353
353
  }
354
354
  }
355
355
 
356
356
  jdJumpToWebInner(url, logEventInfo) {
357
357
  super.jdJumpToWeb(url, logEventInfo);
358
358
  }
359
359
 
360
360
  jdJumpToProduct(skuIds, logEventInfo) {
361
361
  if (this.jingGouMiniState) {
362
362
  const detailUrl = `${this.jumpMiniPath.detail}?sku=${skuIds}`;
363
363
  this.jdJumpToMiniPage(detailUrl, logEventInfo);
364
364
  } else {
365
365
  super.jdJumpToProduct(skuIds, logEventInfo);
366
366
  }
367
367
  }
368
368
 
369
369
  jdJumpSkuInfoToProduct(skuInfo: any = {}, logEventInfo) {
370
370
  const getSkuId = skuInfo?.skuId;
371
371
  this.jdJumpToProduct(getSkuId, logEventInfo);
372
372
  }
373
373
 
374
374
  jdJumpToCartPage(logEventInfo) {
375
375
  console.log('跳转到购物车页面', logEventInfo);
376
376
  }
377
377
 
378
378
  jdJumpToShopHome(shopInfo) {
379
379
  console.log('[降级H5] jdJumpToShopHome web.wxapp', shopInfo);
380
380
  console.log(
381
381
  'global.info.queryInfo.shopId',
382
382
  global.info.queryInfo.shopId,
383
383
  global.info.queryInfo.venderId,
384
384
  );
385
385
  const currentShopInfo = {
386
386
  shopId: global.info.queryInfo.shopId,
387
387
  venderId: global.info.queryInfo.venderId,
388
388
  };
389
389
  const restParams =
390
390
  (shopInfo?.shopId && shopInfo.shopId !== currentShopInfo.shopId) ||
391
391
  (shopInfo?.venderId && shopInfo.venderId !== currentShopInfo.venderId)
392
392
  ? {}
393
393
  : currentShopInfo;
394
394
  const getInfo = Object.assign({}, restParams, shopInfo);
395
395
  const { type = 'navigateTo', ...otherShopInfo } = getInfo;
396
396
  if (this.jingGouMiniState) {
397
397
  let shopUrl = `${this.jumpMiniPath.shopx}${window.location.search}`;
398
398
  if (
399
399
  /(\/shop\/(samCenter|samCard))|(\/sale\/home)|(\/favorite)/.test(window.location.pathname)
400
400
  ) {
401
401
  shopUrl = `${this.jumpMiniPath.shopx}?${objectToUrlEncode(
402
402
  this.getShopIdsInfo(otherShopInfo),
403
403
  )}`;
404
404
  }
405
405
  this.jdJumpToMiniPage(shopUrl, otherShopInfo, type);
406
406
  } else {
407
407
  super.jdJumpToShopHome(otherShopInfo);
408
408
  }
409
409
  }
410
410
 
411
411
  jdJumpToShopCategory(params) {
412
412
  console.log('[降级H5] jdJumpToShopCategory web.wxapp');
413
413
  const { type = 'navigateTo', ...otherShopInfo } = params;
414
414
  console.log('获取分类跳转参数', params);
415
415
  if (this.jingGouMiniState) {
416
416
  this.jdJumpToTopTabBase('classify', otherShopInfo);
417
417
  } else {
418
418
  super.jdJumpToShopCategory(otherShopInfo);
419
419
  }
420
420
  }
421
421
 
422
422
  jdJumpToLive(liveInfo, logEventInfo = {}) {
423
423
  if (liveInfo?.liveId) {
424
424
  if (this.jingGouMiniState && liveInfo?.openWxappToLiveRoom) {
425
425
  this.jdJumpToMiniPage(`${this.jumpMiniPath.jdLive}?liveId=${liveInfo.liveId}&origin=473`, {
426
426
  logEventInfo,
427
427
  });
428
428
  } else {
429
429
  this.jdJumpToWeb(
430
430
  `${this.jumpWebUrl.mLive}/${liveInfo.liveId}?${
431
431
  this.jingGouMiniState ? 'origin=0&appid=jdgw' : 'origin=30'
432
432
  }`,
433
433
  logEventInfo,
434
434
  );
435
435
  }
436
436
  }
437
437
  }
438
438
 
439
439
  jdJumpToShopLight(shopInfo) {
440
440
  if (this.jingGouMiniState) {
441
441
  this.jdJumpToMiniPage(
442
442
  `${this.jumpMiniPath.shopLight}?${objectToUrlEncode(
443
443
  this.getShopIdOrVenderIdParams(shopInfo),
444
444
  )}`,
445
445
  {
446
446
  ...shopInfo,
447
447
  },
448
448
  );
449
449
  } else {
450
450
  this.jdNavigateToNative(
451
451
  `${this.jumpWebUrl.shopLight}?${objectToUrlEncode(
452
452
  this.getShopIdOrVenderIdParams(shopInfo),
453
453
  )}`,
454
454
  {
455
455
  ...shopInfo,
456
456
  },
457
457
  );
458
458
  }
459
459
  }
460
460
  jdJumpToCouponSearchProductList(couponId, logEventInfo = {}) {
461
461
  if (this.jingGouMiniState) {
462
462
  const detailUrl = `${this.jumpMiniPath.searchCoupon}?batch=${couponId}`;
463
463
  this.jdJumpToMiniPage(detailUrl, logEventInfo);
464
464
  } else {
465
465
  super.jdJumpToCouponSearchProductList(couponId, logEventInfo);
466
466
  }
467
467
  }
468
468
  jdJumpToOrderList(orderType, logEventInfo = {}) {
469
469
  if (this.jingGouMiniState) {
470
470
  const detailUrl = `${this.jumpMiniPath.orderList}?orderType=${orderType}&source=shopx`;
471
471
  this.jdJumpToMiniPage(detailUrl, logEventInfo);
472
472
  } else {
473
473
  super.jdJumpToOrderList(orderType, logEventInfo);
474
474
  }
475
475
  }
476
476
 
477
477
  jdJumpBack(logEventInfo) {
478
478
  if (this.jingGouMiniState) {
479
479
  this.jdJumpToMiniPage('', logEventInfo, 'navigateBack');
480
480
  } else {
481
481
  super.jdJumpBack(logEventInfo);
482
482
  }
483
483
  }