@conecli/cone-render 0.8.32 → 0.8.33

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