@conecli/cone-render 0.8.23 → 0.8.25-beta.0

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 { JdJumpJdApp } from './jdJumpJdApp'
2
1
  case LinkConfigType.CONFIG_TYPE_CATEGORY_PAGE:
2
+ import { JdJumpJdApp } from './jdJumpJdApp'
3
3
  reportClick,
4
4
  reportPV,
5
5
  reportToCart,
6
6
  routerInfo: {
7
7
  params: {},
8
8
  },
9
9
  nativeEvent: null,
10
10
  jumpConfig: {
11
11
  venderId: null,
12
12
  shopId: null,
13
13
  sourceValue: '',
14
14
  sourceType: 'App-H5',
15
15
  activityType: 'shopx',
16
16
  moduleId: 'none',
17
17
  entrance: 'none',
18
18
  },
19
19
  logPageParamStr: '',
20
20
  public logPageId: string
21
21
  public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig
22
22
  constructor(opt = {}) {
23
23
  super(opt)
24
24
  this.getConfig(opt)
25
25
  }
26
26
  getConfig(opt = {}) {
27
27
  return Object.assign(this, {}, defaultConfig, opt)
28
28
  }
29
29
  updateInfo(
30
30
  routerInfo,
31
31
  logPname = LogPnameInfo.HOME,
32
32
  pageId = LogPageIdInfo.APP,
33
33
  ) {
34
34
  this.logPageId = pageId
35
35
  this.routerInfo = routerInfo
36
36
  this.jumpConfig = Object.assign({}, this.jumpConfig, routerInfo.params)
37
37
  this.logPname = logPname
38
38
  }
39
39
  reportInfoPv(
40
40
  pageId = LogPageIdInfo.APP,
41
41
  opt: {
42
42
  pageParam?: any
43
43
  } = {},
44
44
  ) {
45
45
  const { pageParam } = opt
46
46
  this.logPageParamStr = pageParam
47
47
  ? pageParam
48
48
  : this.creatParamToLogStr(this.jumpConfig)
49
49
  .replace(/moduleId/, 'JumpmoduleID')
50
50
  .replace(/entrance/, 'Jumpentrance')
51
51
  reportPV({
52
52
  pageId,
53
53
  pageParam: this.logPageParamStr,
54
54
  ...opt,
55
55
  })
56
56
  }
57
57
 
58
58
  jdJumpToWeb(
59
59
  url,
60
60
  logEventInfo,
61
61
  successBack?: Function | undefined,
62
62
  failBack?: Function | undefined,
63
63
  ) {
64
64
  if (this.isOpenJdAppUrl(url)) {
65
65
  const getOpenAppParams = this.jdOpenAppParams(url)
66
66
  console.log(
67
67
  'jd web 获取自定义openApp链接解析后的参数结果',
68
68
  getOpenAppParams,
69
69
  )
70
70
  if (getOpenAppParams) {
71
71
  this.jdNavigateToNative(
72
72
  Object.assign({}, getOpenAppParams, {
73
73
  logEventInfo,
74
74
  }),
75
75
  )
76
76
  }
77
77
  } else {
78
78
  super.jdJumpToWeb(
79
79
  url,
80
80
  {
81
81
  ...logEventInfo,
82
82
  },
83
83
  successBack,
84
84
  failBack,
85
85
  )
86
86
  }
87
87
  }
88
88
 
89
89
  jdJumpToWebInner(url, logEventInfo) {
90
90
  this.jdJumpToWeb(url, logEventInfo)
91
91
  }
92
92
 
93
93
  jdJumpConfigUrl(detail, logEventInfo = {}) {
94
94
  const { configDataType, configDataValue } = detail
95
95
  switch (configDataType) {
96
96
  case LinkConfigType.CONFIG_TYPE_CATEGORY_PAGE:
97
97
  this.jdJumpToShopCategory({
98
98
  ...configDataValue,
99
99
  logEventInfo,
100
100
  })
101
101
  break
102
102
  case LinkConfigType.CONFIG_TYPE_SKU_LIST:
103
103
  this.jdJumpToProduct(configDataValue.skuIds, logEventInfo)
104
104
  break
105
105
  case LinkConfigType.CONFIG_TYPE_COUPON_LIST:
106
106
  this.jdJumpToWeb(
107
107
  `${this.jumpWebUrl.shopCoupon}?couponType=1&shopId=${global.info.queryInfo.shopId}&venderId=${global.info.queryInfo.venderId}`,
108
108
  {},
109
109
  )
110
110
  break
111
111
  case LinkConfigType.CONFIG_TYPE_CATEGORY:
112
112
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
113
113
  const getShopSearchParams = this.jdOpenAppParams(
114
114
  configDataValue.clickUrl,
115
115
  )
116
116
  console.log(
117
117
  'jd web 获取店铺分类链接解析后的参数结果',
118
118
  getShopSearchParams,
119
119
  )
120
120
  getShopSearchParams &&
121
121
  this.jdJumpToShopSearch(
122
122
  Object.assign({}, getShopSearchParams, {
123
123
  logEventInfo,
124
124
  }),
125
125
  )
126
126
  } else {
127
127
  this.jdJumpToShopSearch(
128
128
  configDataValue['cid']
129
129
  ? Object.assign(
130
130
  {},
131
131
  {
132
132
  shopId: global.info.queryInfo.shopId,
133
133
  categoryId: configDataValue.cid,
134
134
  searchType: '5',
135
135
  logEventInfo,
136
136
  },
137
137
  )
138
138
  : {
139
139
  shopId: global.info.queryInfo.shopId,
140
140
  logEventInfo,
141
141
  },
142
142
  )
143
143
  }
144
144
  break
145
145
  case LinkConfigType.CONFIG_TYPE_MEMBER:
146
146
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
147
147
  const getShopMemberParams = this.jdOpenAppParams(
148
148
  configDataValue.clickUrl,
149
149
  )
150
150
  getShopMemberParams &&
151
151
  this.jdJumpToShopMember(
152
152
  Object.assign({}, getShopMemberParams, {
153
153
  logEventInfo,
154
154
  }),
155
155
  )
156
156
  } else {
157
157
  this.jdJumpToShopMember({
158
158
  shopId: global.info.queryInfo.shopId,
159
159
  venderId: configDataValue.shopDetail,
160
160
  logEventInfo,
161
161
  })
162
162
  }
163
163
  break
164
164
  case LinkConfigType.CONFIG_TYPE_SHOP_ACTIVITY:
165
165
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
166
166
  const getShopActivityParams = this.jdOpenAppParams(
167
167
  configDataValue.clickUrl,
168
168
  )
169
169
  getShopActivityParams &&
170
170
  this.jdJumpToShopActivity(
171
171
  Object.assign({}, getShopActivityParams, {
172
172
  logEventInfo,
173
173
  }),
174
174
  )
175
175
  } else if (configDataValue['projectId']) {
176
176
  this.jdJumpToShopActivity({
177
177
  projectId: configDataValue['projectId'],
178
178
  configDataValue,
179
179
  logEventInfo,
180
180
  })
181
181
  }
182
182
  break
183
183
  case LinkConfigType.CONFIG_TYPE_CUSTOM_LINK:
184
184
  case LinkConfigType.CONFIG_TYPE_FINANCE_COUPON: {
185
185
  const _url = configDataValue.linkUrl
186
186
  if (
187
187
  _url.indexOf('to=') === -1 &&
188
188
  _url.indexOf(`${domain.mshop.replace(/https?:/, '')}/?shopId=`) !== -1
189
189
  ) {
190
190
  const _shopId = _url.match(/\d+/g)[0]
191
191
  this.jdJumpToShopHome({
192
192
  shopId: `${_shopId}`,
193
193
  logEventInfo,
194
194
  })
195
195
  } else if (this.isOpenJdAppUrl(_url)) {
196
196
  const getOpenAppParams = this.jdOpenAppParams(_url)
197
197
  console.log('jd web 获取自定义链接解析后的参数结果', getOpenAppParams)
198
198
  if (getOpenAppParams) {
199
199
  this.jdNavigateToNative(
200
200
  Object.assign({}, getOpenAppParams, {
201
201
  logEventInfo,
202
202
  }),
203
203
  )
204
204
  }
205
205
  } else {
206
206
  this.jdJumpToWeb(_url, logEventInfo)
207
207
  }
208
208
  break
209
209
  }
210
210
  case LinkConfigType.CONFIG_TYPE_JSHOP_DETAIL:
211
211
  this.jdJumpToShopDetail({
212
212
  venderId: global.info.queryInfo.venderId,
213
213
  shopId: global.info.queryInfo.shopId,
214
214
  logEventInfo,
215
215
  })
216
216
  break
217
217
  case LinkConfigType.CONFIG_TYPE_SHOP_HOME:
218
218
  this.jdJumpToShopHome({
219
219
  ...configDataValue,
220
220
  logEventInfo,
221
221
  })
222
222
  break
223
223
  case LinkConfigType.CONFIG_TYPE_ANCHOR_POINT:
224
224
  break
225
225
  case LinkConfigType.CONFIG_TYPE_SHOPPING_GUIDE:
226
226
  if (this.isOpenJdAppUrl(configDataValue.clickUrl)) {
227
227
  const getShoppingGuideParams = this.jdOpenAppParams(
228
228
  configDataValue.clickUrl,
229
229
  )
230
230
  getShoppingGuideParams &&
231
231
  this.jdJumpToShopActivity(
232
232
  Object.assign({}, getShoppingGuideParams, {
233
233
  logEventInfo,
234
234
  }),
235
235
  )
236
236
  }
237
237
  break
238
238
  case LinkConfigType.CONFIG_TYPE_MINI_PROGRAM: {
239
239
  const linkUrl = decodeURIComponent(configDataValue?.linkUrl || '')
240
240
  const search = linkUrl.match(/\?.+/)
241
241
  if (search) {
242
242
  const miniQueryData: JumpEventReportInterFace.LinkMiniParams =
243
243
  parseQueryUrlString(linkUrl)
244
244
  try {
245
245
  miniQueryData.param = JSON.parse(<string>miniQueryData?.param)
246
246
  } catch (e) {
247
247
  console.warn('解析小程序 param 错误:', miniQueryData.param)
248
248
  }
249
249
  this.jdJumpToMiniProgram(miniQueryData)
250
250
  } else {
251
251
  console.warn('小程序地址错误:', linkUrl)
252
252
  }
253
253
  break
254
254
  }
255
255
  default:
256
256
  }
257
257
  }
258
258
 
259
259
  jdNavigateToNative(
260
260
  params: {},
261
261
  url = 'openapp.jdmobile://virtual',
262
262
  successBack?: Function | null,
263
263
  failBack?: Function | null,
264
264
  ) {
265
265
  console.log('[降级H5] jdNavigateToNative web.jd:', params)
266
266
  const getResParams: JumpEventReportInterFace.JdMiniJumpParams =
267
267
  Object.assign(
268
268
  {},
269
269
  {
270
270
  sourceValue: 'sourceValue_jshopModuleWeb',
271
271
  sourceType: 'sourceType_jshopModuleWeb',
272
272
  param: {},
273
273
  },
274
274
  params,
275
275
  )
276
276
  const { logEventInfo, ...otherParams } = getResParams
277
277
  console.log(
278
278
  'jd web 获取open协议参数 jdNavigateToNative params: ',
279
279
  getResParams,
280
280
  )
281
281
  console.log('logEventInfo params: ', logEventInfo)
282
282
  global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE &&
283
283
  this.clickEventLog(logEventInfo || getResParams)
284
284
  .then(() => {
285
285
  if (typeof successBack == 'function') {
286
286
  successBack(getResParams)
287
287
  } else {
288
288
  try {
289
289
  const paramsStr = JSON.stringify(otherParams)
290
290
  console.log('跳转web jd open协议', `${url}?params=${paramsStr}`)
291
291
  window.location.href = `${url}?params=${paramsStr}`
292
292
  } catch (e) {
293
293
  console.log('跳转异常', e)
294
294
  }
295
295
  }
296
296
  })
297
297
  .catch(() => {
298
298
  typeof failBack == 'function' && failBack(getResParams)
299
299
  })
300
300
  }
301
301
 
302
302
  clickEventLog(
303
303
  opts: JumpEventReportInterFace.OptEventLogParams = {},
304
304
  reportKey = 'click',
305
305
  ) {
306
306
  const { eventId, jsonParam, eventLevel = 3, ...otherParams } = opts
307
307
  if (eventId && jsonParam) {
308
308
  const { etModelInfo, logBaseInfo } = jsonParam
309
309
  const webLogParams = {
310
310
  eid: eventId,
311
311
  elevel: eventLevel,
312
312
  jsonParam: JSON.stringify(logBaseInfo || jsonParam),
313
313
  etModel: JSON.stringify(etModelInfo || {}),
314
314
  pageId: this.logPageId,
315
315
  pageParam: this.logPageParamStr,
316
316
  ...otherParams,
317
317
  }
318
318
  return /click|exposure/.test(reportKey)
319
319
  ? reportClick(webLogParams)
320
320
  : reportToCart(opts)
321
321
  } else {
322
322
  console.log('暂无埋点参数eventId和eventParam')
323
323
  return Promise.resolve(false)
324
324
  }
325
325
  }
326
326
 
327
327
  exposureEventLog(opts) {
328
328
  return global.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE
329
329
  ? this.clickEventLog(
330
330
  {
331
331
  ...opts,
332
332
  exposureState: true,
333
333
  },
334
334
  'exposure',
335
335
  )
336
336
  : Promise.resolve(false)
337
337
  }
@@ -1 +1 @@
1
- import global from '../common'
2
1
  console.log('window.shopGlobalSwitch:', JSON.stringify(window.shopGlobalSwitch))
3
2
  console.log('进入了 isH5AndJingGouMini && this.isH5OpenToWxapp 的if')
4
3
  this.jingGouMiniState = true
5
4
  window.isJingGouMiniViewState = true
6
5
  console.log('进入了 iwx?.miniProgram then 但是没有继续跳转的逻辑 ')
7
6
  global.info.isJingGouMiniViewState = true
8
7
  console.log('进入了 isH5AndJingGouMini && this.isH5OpenToWxapp 的esle')
9
8
  }
9
+ import global from '../common'
10
10
  objectToUrlEncode,
11
11
  parseQueryUrlString,
12
12
  isH5AndJingGouMini,
13
13
  public jingGouMiniState: boolean
14
14
  private isH5OpenToWxapp: boolean
15
15
  constructor(opt) {
16
16
  super(opt)
17
17
  this.jingGouMiniState = false
18
18
  this.getConfig(opt)
19
19
  console.log(
20
20
  'window.shopGlobalSwitch:',
21
21
  JSON.stringify(window.shopGlobalSwitch),
22
22
  )
23
23
  this.isH5OpenToWxapp =
24
24
  window.shopGlobalSwitch?.openMobileShopToWxApp == 'true'
25
25
  this.init()
26
26
  }
27
27
  getConfig(opt) {
28
28
  return Object.assign(this, {}, defaultConfig, super.getConfig(opt), opt)
29
29
  }
30
30
 
31
31
 
32
32
  async init() {
33
33
  if (window.isJingGouMiniViewState) {
34
34
  this.jingGouMiniState = true
35
35
  } else {
36
36
  console.log(
37
37
  '初始化进行小程序环境检查, 当前是否是京购小程序里的H5',
38
38
  isH5AndJingGouMini,
39
39
  )
40
40
  if (isH5AndJingGouMini && this.isH5OpenToWxapp) {
41
41
  console.log('进入了 isH5AndJingGouMini && this.isH5OpenToWxapp 的if')
42
42
  this.jingGouMiniState = true
43
43
  window.isJingGouMiniViewState = true
44
44
  console.log('进入了 iwx?.miniProgram then 但是没有继续跳转的逻辑 ')
45
45
  global.info.isJingGouMiniViewState = true
46
46
  } else {
47
47
  console.log('进入了 isH5AndJingGouMini && this.isH5OpenToWxapp 的esle')
48
48
  }
49
49
  }
50
50
  }
51
51
 
52
52
  jdJumpToMiniPage(pageUrl, logEventInfo, type = 'navigateTo') {
53
53
  this.jdNavigateToNative(
54
54
  pageUrl,
55
55
  logEventInfo,
56
56
  () => {
57
57
  wx?.miniProgram[type] &&
58
58
  wx?.miniProgram[type]({
59
59
  url: pageUrl,
60
60
  })
61
61
  },
62
62
  () => {
63
63
  wx?.miniProgram[type] &&
64
64
  wx?.miniProgram[type]({
65
65
  url: pageUrl,
66
66
  })
67
67
  },
68
68
  )
69
69
  }
70
70
 
71
71
  jdJumpToWeb(url, logEventInfo) {
72
72
  if (this.jingGouMiniState) {
73
73
  const encodeUrl = `${
74
74
  this.jumpMiniPath.h5
75
75
  }?encode_url=${encodeURIComponent(url)}`
76
76
  this.jdJumpToMiniPage(encodeUrl, logEventInfo)
77
77
  } else {
78
78
  super.jdJumpToWeb(url, logEventInfo)
79
79
  }
80
80
  }
81
81
 
82
82
  jdJumpToWebInner(url, logEventInfo) {
83
83
  super.jdJumpToWeb(url, logEventInfo)
84
84
  }
85
85
 
86
86
  jdJumpToProduct(skuIds, logEventInfo) {
87
87
  if (this.jingGouMiniState) {
88
88
  const detailUrl = `${this.jumpMiniPath.detail}?sku=${skuIds}`
89
89
  this.jdJumpToMiniPage(detailUrl, logEventInfo)
90
90
  } else {
91
91
  super.jdJumpToProduct(skuIds, logEventInfo)
92
92
  }
93
93
  }
94
94
 
95
95
  jdJumpToShopHome(params) {
96
96
  console.log('[降级H5] jdJumpToShopHome web.wxapp')
97
97
  const { type = 'navigateTo', ...otherShopInfo } = params
98
98
  if (this.jingGouMiniState) {
99
99
  let shopUrl = `${this.jumpMiniPath.shopx}${window.location.search}`
100
100
  if (/\/shop\/(samCenter|samCard)/.test(window.location.pathname)) {
101
101
  shopUrl = `${this.jumpMiniPath.shopx}?${objectToUrlEncode(
102
102
  this.getShopIdsInfo(otherShopInfo),
103
103
  )}`
104
104
  }
105
105
  this.jdJumpToMiniPage(shopUrl, otherShopInfo, type)
106
106
  } else {
107
107
  super.jdJumpToShopHome(otherShopInfo)
108
108
  }
109
109
  }
110
110
 
111
111
  jdJumpToShopCategory(params) {
112
112
  console.log('[降级H5] jdJumpToShopCategory web.wxapp')
113
113
  const { type = 'navigateTo', ...otherShopInfo } = params
114
114
  if (this.jingGouMiniState) {
115
115
  let shopUrl = `${this.jumpMiniPath.shopx}${window.location.search}`
116
116
  this.jdJumpToMiniPage(shopUrl, otherShopInfo, type)
117
117
  } else {
118
118
  super.jdJumpToShopCategory(otherShopInfo)
119
119
  }
120
120
  }
121
121
 
122
122
  jdJumpToLive(liveInfo, logEventInfo = {}) {
123
123
  if (liveInfo?.liveId) {
124
124
  this.jdJumpToWeb(
125
125
  `${this.jumpWebUrl.mLive}/${liveInfo?.liveId}?${
126
126
  this.jingGouMiniState ? 'origin=0&appid=jdgw' : 'origin=30'
127
127
  }`,
128
128
  logEventInfo,
129
129
  )
130
130
  }
131
131
  }
132
132
 
133
133
  jdJumpToShopLight(shopInfo) {
134
134
  if (this.jingGouMiniState) {
135
135
  this.jdJumpToMiniPage(
136
136
  `${this.jumpMiniPath.shopLight}?${objectToUrlEncode(
137
137
  this.getShopIdOrVenderIdParams(shopInfo),
138
138
  )}`,
139
139
  {
140
140
  ...shopInfo,
141
141
  },
142
142
  )
143
143
  } else {
144
144
  this.jdNavigateToNative(
145
145
  `${this.jumpWebUrl.shopLight}?${objectToUrlEncode(
146
146
  this.getShopIdOrVenderIdParams(shopInfo),
147
147
  )}`,
148
148
  {
149
149
  ...shopInfo,
150
150
  },
151
151
  )
152
152
  }
153
153
  }
154
154
  jdJumpToCouponSearchProductList(couponId, logEventInfo = {}) {
155
155
  if (this.jingGouMiniState) {
156
156
  const detailUrl = `${this.jumpMiniPath.searchCoupon}?batch=${couponId}`
157
157
  this.jdJumpToMiniPage(detailUrl, logEventInfo)
158
158
  } else {
159
159
  super.jdJumpToCouponSearchProductList(couponId, logEventInfo)
160
160
  }
161
161
  }
@@ -1 +1 @@
1
- import * as device from './device'
1
+ import * as device from './device'
2
2
  device,
3
3
  environment,
4
4
  jump,
5
5
  storage,
6
6
  util,
7
7
  moduleUtil,
8
8
  track,
9
9
  trackPromise,
10
10
  global,
11
11
  http,
12
12
  shopMember,
13
13
  userToken,
14
14
  TokenPlatform,
@@ -1 +1 @@
1
- export const getDataDefine = (floorData, name = "") => {
2
1
  if (floorData) {
3
2
  if (name) {
4
3
  return floorData?.dsConfig?.editProperty?.dataDefines?.find(item => item.name === name)?.nodeText ?? {}
5
4
  }
6
5
  else {
7
6
  return floorData?.dsConfig?.editProperty?.dataDefines ?? []
8
7
  }
9
8
  }
10
9
  return {}
10
+ export const getDataDefine = (floorData, name = '') => {
11
11
  if (floorData) {
12
12
  const dataDefines = floorData?.dsConfig?.editProperty?.dataDefines ?? []
13
13
  if (name) {
14
14
  return dataDefines.find((item) => item.name === name)?.nodeText ?? {}
15
15
  } else {
16
16
  return dataDefines
17
17
  }
18
18
  }
19
19
  return {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conecli/cone-render",
3
- "version": "0.8.23",
3
+ "version": "0.8.25-beta.0",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist/"