@conecli/cone-render 0.10.1-beta.2 → 0.10.1-beta.4

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