@conecli/cone-render 0.8.22-beta.2 → 0.8.23

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 +0,0 @@
1
- import { JdJumpJdApp } from './jdJumpJdApp'
2
  reportClick,
3
1
  reportToCart,
4
2
  routerInfo: {
5
3
  params: {},
6
4
  },
7
5
  nativeEvent: null,
8
6
  jumpConfig: {
9
7
  venderId: null,
10
8
  shopId: null,
11
9
  sourceValue: '',
12
10
  sourceType: 'App-H5',
13
11
  activityType: 'shopx',
14
12
  moduleId: 'none',
15
13
  entrance: 'none',
16
14
  },
17
15
  logPageParamStr: '',
18
16
  public logPageId: string
19
17
  public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig
20
18
  constructor(opt = {}) {
21
19
  console.log("jdb加载==========")
22
20
  super(opt)
23
21
  this.getConfig(opt)
24
22
  }
25
23
 
26
24
  jdJumpConfigUrl(detail, logEventInfo = {}) {
27
25
  const { configDataType, configDataValue } = detail
28
26
  switch (configDataType) {
29
27
  case LinkConfigType.CONFIG_TYPE_SKU_LIST:
30
28
  this.jdJumpToProduct({
31
29
  ...configDataValue,
32
30
  skuId: configDataValue.skuIds,
33
31
  }, logEventInfo)
34
32
  break
35
33
  default:
36
34
  }
37
35
  }
38
36
 
39
37
  jdJumpToProduct(skuParams, logEventInfo) {
40
38
  if(typeof skuParams !== 'object') {
41
39
  console.error('万商app跳转商品详情参数需要对象,详情请查看文档')
42
40
  return
43
41
  }
44
42
 
45
43
  let { skuId, bMallTag = "1", skuUniformBizInfo } = skuParams
46
44
  skuId = skuId.toString().trim()
47
45
  this.jdNavigateToNative({
48
46
  category: 'jump',
49
47
  des: 'skudetail',
50
48
  param: {
51
49
  skuId: skuId,
52
50
  bMallTag: bMallTag,
53
51
  skuUniformBizInfo
54
52
  },
55
53
  logEventInfo,
56
54
  })
57
55
  }
58
56
  jdNavigateToNative(
59
57
  console.log("otherParams", otherParams)
60
58
  const paramsStr = JSON.stringify(otherParams)
61
59
  console.log(
62
60
  '跳转web jdb open协议',
63
61
  `${url}?params=${paramsStr}`,
64
62
  )
65
63
  console.log('catch', e)
66
64
  clickEventLog(
67
65
  getConfig(opt = {}) {
68
66
  return Object.assign(this, {}, defaultConfig, opt)
69
67
  }
@@ -1 +0,0 @@
1
- const getUserInfo = () => {
2
  let result = {}
3
1
  try {
4
2
  result = JSON.parse(
5
3
  window.WebViewCommon && window.WebViewCommon.getUserInfo(),
6
4
  )
7
5
  } catch {}
8
6
  return result
9
7
  buId: userInfo?.data?.buId,
10
8
  process.env.NODE_ENV === 'development'
11
9
  ? {
12
10
  apolloId: '48ee955b0fb04d19b9f9fe8cb73d387f',
13
11
  apolloSecret: '0d9c76ee66b0487da4e17d3cf1d7af7a',
14
12
  }
15
13
  : {
16
14
  apolloId: '80c46fd06e4442998609d9f6a4ab96f0',
17
15
  apolloSecret: 'f36bef08bcba4683b409732095793fb2',
18
16
  }
19
17
  if (typeof window.crypto === 'object') {
20
18
  if (typeof (window.crypto as any).randomUUID === 'function') {
21
19
  return (window.crypto as any).randomUUID()
22
20
  }
23
21
  if (
24
22
  typeof (window.crypto as any).getRandomValues === 'function' &&
25
23
  typeof Uint8Array === 'function'
26
24
  ) {
27
25
  const callback = (c) => {
28
26
  const num = Number(c)
29
27
  return (
30
28
  num ^
31
29
  ((window.crypto as any).getRandomValues(new Uint8Array(1))[0] &
32
30
  (15 >> (num / 4)))
33
31
  ).toString(16)
34
32
  }
35
33
  return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, callback)
36
34
  }
37
35
  }
38
36
  let timestamp = new Date().getTime()
39
37
  let perforNow =
40
38
  (typeof window.performance !== 'undefined' &&
41
39
  window.performance.now &&
42
40
  window.performance.now() * 1000) ||
43
41
  0
44
42
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
45
43
  let random = Math.random() * 16
46
44
  if (timestamp > 0) {
47
45
  random = (timestamp + random) % 16 | 0
48
46
  timestamp = Math.floor(timestamp / 16)
49
47
  } else {
50
48
  random = (perforNow + random) % 16 | 0
51
49
  perforNow = Math.floor(perforNow / 16)
52
50
  }
53
51
  return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16)
54
52
  })
55
53
  let params = {
56
54
  uniformBizInfo: {
57
55
  tenantId: 1024,
58
56
  ua: 1,
59
57
  buId: commonParam.buId || 377,
60
58
  bMallTag: bMallTag,
61
59
  },
62
60
  commonParam: {
63
61
  pid: 100,
64
62
  verticalCode: 'cn_retail_bmall',
65
63
  ua: 1,
66
64
  language: 'zh',
67
65
  },
68
66
  operations: [{ TheSkus: [{ Id: skuId, num: num || 1 }] }],
69
67
  apolloId: APOLLO.apolloId,
70
68
  apolloSecret: APOLLO.apolloSecret,
71
69
  client: 'H5',
72
70
  verticalTag: 'cn_retail_bmall',
73
71
  carttype: bMallTag == 1 ? 21 : 22,
74
72
  bMallTag: bMallTag,
75
73
  traceId: getUuid(),
76
74
  noResponse: true,
77
75
  }
78
76
  if (skuUuid) {
79
77
  params.operations[0].TheSkus[0].skuUuid = skuUuid
80
78
  }
81
79
  if (window?.siteTransResult?.gridInfoList) {
82
80
  params = {
83
81
  ...params,
84
82
  cartLocationList: [
85
83
  {
86
84
  gridInfos:
87
85
  window?.siteTransResult?.gridInfoList &&
88
86
  JSON.parse(window?.siteTransResult?.gridInfoList),
89
87
  areaIdSet:
90
88
  window?.siteTransResult?.area &&
91
89
  window?.siteTransResult?.area?.split('-'),
92
90
  },
93
91
  ],
94
92
  }
95
93
  }
96
94
  return params
@@ -1 +0,0 @@
1
- import Taro from '@tarojs/taro'
2
  SHOP_COLOR_APPID,
3
1
  JshopxColorFunctionIdList,
4
2
  PagesColorFunctionIdList,
5
3
  JSHOPX_COLOR_APPID,
6
4
  PAGES_COLOR_APPID,
7
5
  PAGES_DOMAIN,
8
6
  B2BColorFunctionIdList,
9
7
  B2B_COLOR_APPID,
10
8
  cookiesStr: '',
11
9
  requestHeaderContentType: {
12
10
  jsonHeader: {
13
11
  'content-type': 'application/json;charset=utf-8',
14
12
  },
15
13
  formDataHeader: {
16
14
  'content-type': 'application/x-www-form-urlencoded',
17
15
  },
18
16
  },
19
17
  requestBaseParam: {
20
18
  data: null,
21
19
  header: {
22
20
  'content-type': 'application/json;charset=utf-8',
23
21
  },
24
22
  },
25
23
  timeOut: 7000,
26
24
  apiClientParams: {
27
25
  appid: SHOP_COLOR_APPID,
28
26
  clientVersion:
29
27
  isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
30
28
  client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : 'wh5',
31
29
  area: '1_72_2799_0',
32
30
  uuid: UUID,
33
31
  },
34
32
  public addressFetchInfo: {
35
33
  reqState: boolean
36
34
  promiseInstance: null | Promise<any>
37
35
  }
38
36
  public getPromotionConfig: {
39
37
  projectId: null | string | number
40
38
  pageId: null | string | number
41
39
  }
42
40
  public resInfo: ServiceInterFace.HttpRequestInfo
43
41
  public api: ServiceInterFace.HttpApi
44
42
  public isPageDomain: boolean
45
43
  constructor(opt) {
46
44
  this._init()
47
45
  this.addressFetchInfo = {
48
46
  reqState: false,
49
47
  promiseInstance: null,
50
48
  }
51
49
  this.getPromotionConfig = {
52
50
  projectId: null,
53
51
  pageId: null,
54
52
  }
55
53
  this._userAreaUpdateListen()
56
54
  this.resInfo = this._getResConfig(opt)
57
55
  this.api = api
58
56
  this.isPageDomain = window.location.hostname === PAGES_DOMAIN
59
57
  }
60
58
  _init(): void {
61
59
  httpInterceptors.forEach((item) => {
62
60
  Taro.addInterceptor((chain) => item(chain))
63
61
  })
64
62
  }
65
63
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
66
64
  return Object.assign({}, DefaultConfig, opt)
67
65
  }
68
66
 
69
67
  _userAreaUpdateListen() {
70
68
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
71
69
  this.updateApiClientParamsResInfo({
72
70
  area,
73
71
  })
74
72
  })
75
73
  }
76
74
  updateApiClientParamsResInfo(opt = {}) {
77
75
  this.resInfo.apiClientParams = {
78
76
  ...this.resInfo.apiClientParams,
79
77
  ...opt,
80
78
  }
81
79
  }
82
80
 
83
81
  _paramsSign(data) {
84
82
  return Promise.resolve(data)
85
83
  }
86
84
 
87
85
  checkFunctionIdToReturnAppId(functionId) {
88
86
  if (JshopxColorFunctionIdList.includes(functionId)) {
89
87
  return JSHOPX_COLOR_APPID
90
88
  } else if (
91
89
  this.isPageDomain &&
92
90
  PagesColorFunctionIdList.includes(functionId)
93
91
  ) {
94
92
  return PAGES_COLOR_APPID
95
93
  } else if (B2BColorFunctionIdList.includes(functionId)) {
96
94
  return B2B_COLOR_APPID
97
95
  } else {
98
96
  return SHOP_COLOR_APPID
99
97
  }
100
98
  }
101
99
 
102
100
  gatewayReq(
103
101
  functionId: string,
104
102
  bodyParams = {},
105
103
  clientParams = {},
106
104
  ): Promise<any> {
107
105
  if (
108
106
  functionId === 'receiveShopCoupon' &&
109
107
  ((isH5 && window.isJingGouMiniViewState) || isWxMinAndWxapp)
110
108
  ) {
111
109
  clientParams = Object.assign(
112
110
  {},
113
111
  {
114
112
  loginType: '1',
115
113
  loginWQBiz: WXAPP_BIZ_KEY,
116
114
  },
117
115
  clientParams,
118
116
  )
119
117
  }
120
118
  const apiClientParams = Object.assign(
121
119
  {},
122
120
  this.resInfo.apiClientParams,
123
121
  clientParams,
124
122
  )
125
123
  apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId)
126
124
  const getReqData = {
127
125
  functionId: functionId,
128
126
  body: JSON.stringify(bodyParams),
129
127
  t: Date.now(),
130
128
  ...apiClientParams,
131
129
  }
132
130
  return http
133
131
  .request({
134
132
  url: this.api.apiFunc,
135
133
  data: getReqData,
136
134
  method: 'GET',
137
135
  })
138
136
  .then((res: ServiceInterFace.RequestPromiseRes) => {
139
137
  const { statusCode, data } = res
140
138
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
141
139
  ok: true,
142
140
  }
143
141
  if (statusCode === 200 && data) {
144
142
  const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
145
143
  ? Number(res.data.code)
146
144
  : -1
147
145
  const subCode = Object.prototype.hasOwnProperty.call(
148
146
  res.data,
149
147
  'subCode',
150
148
  )
151
149
  ? Number(res.data.subCode)
152
150
  : -1
153
151
  if (
154
152
  data.success === true ||
155
153
  data.isSuccess ||
156
154
  resCode === 0 ||
157
155
  resCode === 200 ||
158
156
  subCode === 0
159
157
  ) {
160
158
  changeRes = {
161
159
  result: Object.prototype.hasOwnProperty.call(data, 'result')
162
160
  ? data.result
163
161
  : Object.prototype.hasOwnProperty.call(data, 'data')
164
162
  ? data.data
165
163
  : data,
166
164
  code: data.code || 200,
167
165
  ok: true,
168
166
  source: data,
169
167
  }
170
168
  return changeRes
171
169
  } else {
172
170
  changeRes = {
173
171
  ...data,
174
172
  ok: false,
175
173
  statusCode: res.statusCode,
176
174
  }
177
175
  return changeRes
178
176
  }
179
177
  } else {
180
178
  changeRes = {
181
179
  ...data,
182
180
  ok: false,
183
181
  statusCode: res.statusCode,
184
182
  }
185
183
  return changeRes
186
184
  }
187
185
  })
188
186
  .catch((res) => {
189
187
  return {
190
188
  ...res,
191
189
  ok: false,
192
190
  } as ServiceInterFace.RequestResponseFormatRes
193
191
  })
194
192
  }
195
193
 
196
194
  async receiveCoupon(param = {}, clientParams) {
197
195
  return await this.gatewayReq(
198
196
  'receiveShopCoupon',
199
197
  {
200
198
  operation: '3',
201
199
  ...param,
202
200
  },
203
201
  clientParams,
204
202
  )
205
203
  }
206
204
  bMallGetUserInfo = () => {
207
205
  return userInfo
208
206
  }
209
207
  async bMallAddCart(params = {}) {
210
208
  return await this.gatewayReq('bmall_cartAdd', params, {
211
209
  client: 'H5',
212
210
  })
213
211
  }
214
212
  async bMallChangeCart(params = {}) {
215
213
  return await this.gatewayReq('bmall_cartChange', params, {
216
214
  client: 'H5',
217
215
  })
218
216
  }
219
217
  async bMallRemoveCart(params = {}) {
220
218
  return await this.gatewayReq(
221
219
  'bmall_cartRemove',
222
220
  params,
223
221
  {
224
222
  client: 'H5',
225
223
  },
226
224
  )
227
225
  }
228
226
  async bMallGetOmittedProduct(params = {}) {
229
227
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
230
228
  client: 'H5',
231
229
  })
232
230
  }
233
231
  async bMallAddCartService({ skuId, bMallTag, num }) {
234
232
  const params = getParams({ skuId, bMallTag, num })
235
233
  return await this.bMallAddCart(params)
236
234
  }
237
235
  async bMallGetSkuNumService(bMallTag = 1) {
238
236
  const params = getParams({ bMallTag })
239
237
  delete params.operations
240
238
  return await this.bMallGetOmittedProduct(params)
241
239
  }
242
240
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid }) {
243
241
  let params = getParams({ skuId, bMallTag, num, skuUuid })
244
242
  return await this.bMallRemoveCart(params)
245
243
  }
246
244
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid }) {
247
245
  let params = getParams({ skuId, bMallTag, num, skuUuid })
248
246
  return await this.bMallChangeCart(params)
249
247
  }
250
248
 
251
249
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
252
250
  if (!needRequest && window.bMallCartData) {
253
251
  return window.bMallCartData
254
252
  }
255
253
  const cartData = await this.bMallGetSkuNumService(bMallTag)
256
254
  let items
257
255
  if (cartData.ok && cartData.result) {
258
256
  items = cartData?.result?.items || {}
259
257
  }
260
258
  window.bMallCartData = items
261
259
  return items
262
260
  }
263
261
 
264
262
  async bMallCartHandle(goodItem, num) {
265
263
  try {
266
264
  const {
267
265
  skuUuid,
268
266
  limitUpper,
269
267
  limitLower,
270
268
  } = goodItem
271
269
  let cartNum = Number(num)
272
270
  if (limitLower && cartNum && cartNum < limitLower) {
273
271
  cartNum = limitLower
274
272
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
275
273
  cartNum = limitUpper
276
274
  }
277
275
  if (skuUuid && cartNum > 0) {
278
276
  return this.bMallChangeCartService({
279
277
  ...goodItem,
280
278
  skuUuid,
281
279
  num: cartNum,
282
280
  })
283
281
  } else if (!skuUuid && cartNum > 0) {
284
282
  return this.bMallAddCartService({ ...goodItem, num: cartNum })
285
283
  } else if (skuUuid && !cartNum) {
286
284
  return this.bMallRemoveCartService({
287
285
  ...goodItem,
288
286
  skuUuid,
289
287
  num: cartNum,
290
288
  })
291
289
  } else {
292
290
  console.error('参数不全')
293
291
  return false
294
292
  }
295
293
  } catch (e) {
296
294
  console.error(e)
297
295
  }
298
296
  }