@conecli/cone-render 0.10.1-shop3.90 → 0.10.1-shop3.91

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 (wx?.miniProgram[type]) {
44
43
  wx?.miniProgram[type]({
45
44
  url: pageUrl,
46
45
  });
47
46
  } else if (has && has.ascfweb && 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 (wx?.miniProgram[type]) {
56
55
  wx?.miniProgram[type]({
57
56
  url: pageUrl,
58
57
  });
59
58
  } else if (has && has.ascfweb && 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
  }
230
+ import global from '../common';
231
231
  objectToUrlEncode,
232
232
  isH5AndJingGouMini,
233
233
  isAscfApp,
234
234
  public jingGouMiniState: boolean;
235
235
  private isH5OpenToWxapp: boolean;
236
236
  constructor(opt) {
237
237
  super(opt);
238
238
  this.jingGouMiniState = false;
239
239
  this.getConfig(opt);
240
240
  console.log('window.shopGlobalSwitch:', JSON.stringify(window.shopGlobalSwitch));
241
241
  this.isH5OpenToWxapp = window.shopGlobalSwitch?.openMobileShopToWxApp == 'true';
242
242
  this.init();
243
243
  }
244
244
  getConfig(opt) {
245
245
  return Object.assign(this, {}, defaultConfig, super.getConfig(opt), opt);
246
246
  }
247
247
 
248
248
 
249
249
  async init() {
250
250
  if (window.isJingGouMiniViewState) {
251
251
  this.jingGouMiniState = true;
252
252
  } else {
253
253
  console.log('初始化进行小程序环境检查, 当前是否是京购小程序里的H5', isH5AndJingGouMini);
254
254
  if ((isH5AndJingGouMini || isAscfApp) && this.isH5OpenToWxapp) {
255
255
  console.log('进入了 isH5AndJingGouMini && this.isH5OpenToWxapp 的if');
256
256
  this.jingGouMiniState = true;
257
257
  window.isJingGouMiniViewState = true;
258
258
  console.log('进入了 iwx?.miniProgram then 但是没有继续跳转的逻辑 ');
259
259
  global.info.isJingGouMiniViewState = true;
260
260
  } else {
261
261
  console.log('进入了 isH5AndJingGouMini && this.isH5OpenToWxapp 的esle');
262
262
  }
263
263
  }
264
264
  }
265
265
 
266
266
  jdJumpToMiniPage(pageUrl, logEventInfo, type = 'navigateTo') {
267
267
  this.jdNavigateToNative(
268
268
  pageUrl,
269
269
  logEventInfo,
270
270
  () => {
271
271
  console.log('JD.wxappext.goto');
272
272
  if (window?.wx && window?.wx?.miniProgram[type]) {
273
273
  wx?.miniProgram[type]({
274
274
  url: pageUrl,
275
275
  });
276
276
  } else if (window?.has && window?.has.ascfweb && window?.has.ascfweb[type]) {
277
277
  has.ascfweb[type]({
278
278
  url: pageUrl,
279
279
  });
280
280
  }
281
281
  },
282
282
  () => {
283
283
  console.log('JD.wxappext.goto2');
284
284
  if (window?.wx && window?.wx?.miniProgram[type]) {
285
285
  wx?.miniProgram[type]({
286
286
  url: pageUrl,
287
287
  });
288
288
  } else if (window?.has && window?.has.ascfweb && window?.has.ascfweb[type]) {
289
289
  has.ascfweb[type]({
290
290
  url: pageUrl,
291
291
  });
292
292
  }
293
293
  },
294
294
  );
295
295
  }
296
296
 
297
297
  jdJumpToTabAllProduct(shopId, venderId, logEventInfo = {}) {
298
298
  console.log('web.wxapp.ts - jdJumpToTabAllProduct');
299
299
  if (typeof shopId === 'undefined') shopId = global.info.queryInfo.shopId;
300
300
  if (typeof venderId === 'undefined') venderId = global.info.queryInfo.venderId;
301
301
  if (this.jingGouMiniState) {
302
302
  const param = {
303
303
  shopId,
304
304
  venderId,
305
305
  tabActive: SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PRODUCT],
306
306
  };
307
307
  const url = `${this.jumpMiniPath.shopx}?${objectToUrlEncode(param)}`;
308
308
  this.jdJumpToMiniPage(url, logEventInfo);
309
309
  } else {
310
310
  super.jdJumpToTabAllProduct(shopId, venderId, logEventInfo);
311
311
  }
312
312
  }
313
313
 
314
314
  jdJumpToTopTabBase(type, shopInfo = {}) {
315
315
  const getInfo = Object.assign(
316
316
  {},
317
317
  {
318
318
  shopId: global.info.queryInfo.shopId,
319
319
  venderId: global.info.queryInfo.venderId,
320
320
  },
321
321
  shopInfo,
322
322
  );
323
323
  if (this.jingGouMiniState) {
324
324
  const { shopId, venderId, ...otherInfo } = getInfo;
325
325
  const param = {
326
326
  shopId,
327
327
  venderId,
328
328
  tabActive: type,
329
329
  };
330
330
  const url = `${this.jumpMiniPath.shopx}?${objectToUrlEncode(param)}`;
331
331
  this.jdJumpToMiniPage(url, otherInfo);
332
332
  } else {
333
333
  super.jdJumpToTopTabBase(type, shopInfo);
334
334
  }
335
335
  }
336
336
 
337
337
  jdJumpToWeb(url, logEventInfo) {
338
338
  console.log('web.wxapp.ts - jdJumpToWeb', url);
339
339
  console.log('jingGouMiniState', this.jingGouMiniState);
340
340
  if (this.jingGouMiniState) {
341
341
  const encodeUrl = `${this.jumpMiniPath.h5}?encode_url=${encodeURIComponent(url)}`;
342
342
  this.jdJumpToMiniPage(encodeUrl, logEventInfo);
343
343
  } else {
344
344
  super.jdJumpToWeb(url, logEventInfo);
345
345
  }
346
346
  }
347
347
 
348
348
  jdJumpToWebInner(url, logEventInfo) {
349
349
  super.jdJumpToWeb(url, logEventInfo);
350
350
  }
351
351
 
352
352
  jdJumpToProduct(skuIds, logEventInfo) {
353
353
  if (this.jingGouMiniState) {
354
354
  const detailUrl = `${this.jumpMiniPath.detail}?sku=${skuIds}`;
355
355
  this.jdJumpToMiniPage(detailUrl, logEventInfo);
356
356
  } else {
357
357
  super.jdJumpToProduct(skuIds, logEventInfo);
358
358
  }
359
359
  }
360
360
 
361
361
  jdJumpSkuInfoToProduct(skuInfo: any = {}, logEventInfo) {
362
362
  const getSkuId = skuInfo?.skuId;
363
363
  this.jdJumpToProduct(getSkuId, logEventInfo);
364
364
  }
365
365
 
366
366
  jdJumpToCartPage(logEventInfo) {
367
367
  console.log('跳转到购物车页面', logEventInfo);
368
368
  }
369
369
 
370
370
  jdJumpToShopHome(shopInfo) {
371
371
  console.log('[降级H5] jdJumpToShopHome web.wxapp', shopInfo);
372
372
  console.log(
373
373
  'global.info.queryInfo.shopId',
374
374
  global.info.queryInfo.shopId,
375
375
  global.info.queryInfo.venderId,
376
376
  );
377
377
  const currentShopInfo = {
378
378
  shopId: global.info.queryInfo.shopId,
379
379
  venderId: global.info.queryInfo.venderId,
380
380
  };
381
381
  const restParams =
382
382
  (shopInfo?.shopId && shopInfo.shopId !== currentShopInfo.shopId) ||
383
383
  (shopInfo?.venderId && shopInfo.venderId !== currentShopInfo.venderId)
384
384
  ? {}
385
385
  : currentShopInfo;
386
386
  const getInfo = Object.assign({}, restParams, shopInfo);
387
387
  const { type = 'navigateTo', ...otherShopInfo } = getInfo;
388
388
  if (this.jingGouMiniState) {
389
389
  let shopUrl = `${this.jumpMiniPath.shopx}${window.location.search}`;
390
390
  if (
391
391
  /(\/shop\/(samCenter|samCard))|(\/sale\/home)|(\/favorite)/.test(window.location.pathname)
392
392
  ) {
393
393
  shopUrl = `${this.jumpMiniPath.shopx}?${objectToUrlEncode(
394
394
  this.getShopIdsInfo(otherShopInfo),
395
395
  )}`;
396
396
  }
397
397
  this.jdJumpToMiniPage(shopUrl, otherShopInfo, type);
398
398
  } else {
399
399
  super.jdJumpToShopHome(otherShopInfo);
400
400
  }
401
401
  }
402
402
 
403
403
  jdJumpToShopCategory(params) {
404
404
  console.log('[降级H5] jdJumpToShopCategory web.wxapp');
405
405
  const { type = 'navigateTo', ...otherShopInfo } = params;
406
406
  console.log('获取分类跳转参数', params);
407
407
  if (this.jingGouMiniState) {
408
408
  this.jdJumpToTopTabBase('classify', otherShopInfo);
409
409
  } else {
410
410
  super.jdJumpToShopCategory(otherShopInfo);
411
411
  }
412
412
  }
413
413
 
414
414
  jdJumpToLive(liveInfo, logEventInfo = {}) {
415
415
  if (liveInfo?.liveId) {
416
416
  if (this.jingGouMiniState && liveInfo?.openWxappToLiveRoom) {
417
417
  this.jdJumpToMiniPage(`${this.jumpMiniPath.jdLive}?liveId=${liveInfo.liveId}&origin=473`, {
418
418
  logEventInfo,
419
419
  });
420
420
  } else {
421
421
  this.jdJumpToWeb(
422
422
  `${this.jumpWebUrl.mLive}/${liveInfo.liveId}?${
423
423
  this.jingGouMiniState ? 'origin=0&appid=jdgw' : 'origin=30'
424
424
  }`,
425
425
  logEventInfo,
426
426
  );
427
427
  }
428
428
  }
429
429
  }
430
430
 
431
431
  jdJumpToShopLight(shopInfo) {
432
432
  if (this.jingGouMiniState) {
433
433
  this.jdJumpToMiniPage(
434
434
  `${this.jumpMiniPath.shopLight}?${objectToUrlEncode(
435
435
  this.getShopIdOrVenderIdParams(shopInfo),
436
436
  )}`,
437
437
  {
438
438
  ...shopInfo,
439
439
  },
440
440
  );
441
441
  } else {
442
442
  this.jdNavigateToNative(
443
443
  `${this.jumpWebUrl.shopLight}?${objectToUrlEncode(
444
444
  this.getShopIdOrVenderIdParams(shopInfo),
445
445
  )}`,
446
446
  {
447
447
  ...shopInfo,
448
448
  },
449
449
  );
450
450
  }
451
451
  }
452
452
  jdJumpToCouponSearchProductList(couponId, logEventInfo = {}) {
453
453
  if (this.jingGouMiniState) {
454
454
  const detailUrl = `${this.jumpMiniPath.searchCoupon}?batch=${couponId}`;
455
455
  this.jdJumpToMiniPage(detailUrl, logEventInfo);
456
456
  } else {
457
457
  super.jdJumpToCouponSearchProductList(couponId, logEventInfo);
458
458
  }
459
459
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conecli/cone-render",
3
- "version": "0.10.1-shop3.90",
3
+ "version": "0.10.1-shop3.91",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist/"