@conecli/cone-render 0.8.31 → 0.8.32

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 Taro from '@tarojs/taro'
2
1
  APPID,
3
2
  JshopxColorFunctionIdList,
4
3
  PagesColorFunctionIdList,
5
4
  PAGES_DOMAIN,
6
5
  B2BColorFunctionIdList,
7
6
  MobileVerifyColorList,
8
7
  AppVerifyColorList,
9
8
  JshopxVerifyColorList,
10
9
  BMallVerifyColorList,
11
10
  shopMemberColorFunctionIdList
12
11
  cookiesStr: '',
13
12
  requestHeaderContentType: {
14
13
  jsonHeader: {
15
14
  'content-type': 'application/json;charset=utf-8',
16
15
  },
17
16
  formDataHeader: {
18
17
  'content-type': 'application/x-www-form-urlencoded',
19
18
  },
20
19
  },
21
20
  requestBaseParam: {
22
21
  data: null,
23
22
  header: {
24
23
  'content-type': 'application/json;charset=utf-8',
25
24
  },
26
25
  },
27
26
  timeOut: 7000,
28
27
  apiClientParams: {
29
28
  appid: APPID.SHOP_COLOR_APPID,
30
29
  clientVersion:
31
30
  isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
32
31
  client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : 'wh5',
33
32
  area: '1_72_2799_0',
34
33
  uuid: UUID,
35
34
  },
36
35
  public addressFetchInfo: {
37
36
  reqState: boolean
38
37
  promiseInstance: null | Promise<any>
39
38
  }
40
39
  public getPromotionConfig: {
41
40
  projectId: null | string | number
42
41
  pageId: null | string | number
43
42
  }
44
43
  public resInfo: ServiceInterFace.HttpRequestInfo
45
44
  public api: ServiceInterFace.HttpApi
46
45
  public isPageDomain: boolean
47
46
  public verifyColorList: string[]
48
47
  constructor(opt) {
49
48
  this._init()
50
49
  this.addressFetchInfo = {
51
50
  reqState: false,
52
51
  promiseInstance: null,
53
52
  }
54
53
  this.getPromotionConfig = {
55
54
  projectId: null,
56
55
  pageId: null,
57
56
  }
58
57
  this._userAreaUpdateListen()
59
58
  this.resInfo = this._getResConfig(opt)
60
59
  this.api = api
61
60
  this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false
62
61
  this.verifyColorList = [
63
62
  ...MobileVerifyColorList,
64
63
  ...AppVerifyColorList,
65
64
  ...JshopxVerifyColorList,
66
65
  ...BMallVerifyColorList,
67
66
  ]
68
67
  }
69
68
  _init(): void {
70
69
  httpInterceptors.forEach((item) => {
71
70
  Taro.addInterceptor((chain) => item(chain))
72
71
  })
73
72
  }
74
73
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
75
74
  return Object.assign({}, DefaultConfig, opt)
76
75
  }
77
76
 
78
77
  _userAreaUpdateListen() {
79
78
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
80
79
  this.updateApiClientParamsResInfo({
81
80
  area,
82
81
  })
83
82
  })
84
83
  }
85
84
  updateApiClientParamsResInfo(opt = {}) {
86
85
  this.resInfo.apiClientParams = {
87
86
  ...this.resInfo.apiClientParams,
88
87
  ...opt,
89
88
  }
90
89
  }
91
90
 
92
91
  checkFunctionIdToReturnAppId(functionId) {
93
92
  if (JshopxColorFunctionIdList.includes(functionId)) {
94
93
  return APPID.JSHOPX_COLOR_APPID
95
94
  } else if (
96
95
  this.isPageDomain &&
97
96
  PagesColorFunctionIdList.includes(functionId)
98
97
  ) {
99
98
  return APPID.PAGES_COLOR_APPID
100
99
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
101
100
  return APPID.SHOP_MEMBER_COLOR_APPID
102
101
  }else if (B2BColorFunctionIdList.includes(functionId)) {
103
102
  return APPID.B2B_COLOR_APPID
104
103
  } else {
105
104
  return APPID.SHOP_COLOR_APPID
106
105
  }
107
106
  }
108
107
 
109
108
  gatewayReq(
110
109
  functionId: string,
111
110
  bodyParams = {},
112
111
  clientParams = {},
113
112
  ): Promise<any> {
114
113
  if (
115
114
  functionId === 'receiveShopCoupon' &&
116
115
  ((isH5 && window?.isJingGouMiniViewState) || isWxMinAndWxapp)
117
116
  ) {
118
117
  clientParams = Object.assign(
119
118
  {},
120
119
  {
121
120
  loginType: '1',
122
121
  loginWQBiz: WXAPP_BIZ_KEY,
123
122
  },
124
123
  clientParams,
125
124
  )
126
125
  }
127
126
  const apiClientParams = Object.assign(
128
127
  {},
129
128
  this.resInfo.apiClientParams,
130
129
  clientParams,
131
130
  )
132
131
  typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
133
132
  const isColorVerify = this.verifyColorList.includes(functionId)
134
133
  const getReqData = {
135
134
  functionId: functionId,
136
135
  body: JSON.stringify(bodyParams),
137
136
  t: Date.now(),
138
137
  ...apiClientParams,
139
138
  }
140
139
  return http
141
140
  .request({
142
141
  url: this.api.apiFunc,
143
142
  data: getReqData,
144
143
  isColorVerify,
145
144
  })
146
145
  .then((res: ServiceInterFace.RequestPromiseRes) => {
147
146
  const { statusCode, data } = res
148
147
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
149
148
  ok: true,
150
149
  }
151
150
  if (statusCode === 200 && data) {
152
151
  const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
153
152
  ? Number(res.data.code)
154
153
  : -1
155
154
  const subCode = Object.prototype.hasOwnProperty.call(
156
155
  res.data,
157
156
  'subCode',
158
157
  )
159
158
  ? Number(res.data.subCode)
160
159
  : -1
161
160
  if (
162
161
  data.success === true ||
163
162
  data.isSuccess ||
164
163
  resCode === 0 ||
165
164
  resCode === 200 ||
166
165
  subCode === 0
167
166
  ) {
168
167
  changeRes = {
169
168
  result: Object.prototype.hasOwnProperty.call(data, 'result')
170
169
  ? data.result
171
170
  : Object.prototype.hasOwnProperty.call(data, 'data')
172
171
  ? data.data
173
172
  : data,
174
173
  code: data.code || 200,
175
174
  ok: true,
176
175
  source: data,
177
176
  }
178
177
  return changeRes
179
178
  } else {
180
179
  changeRes = {
181
180
  ...data,
182
181
  ok: false,
183
182
  statusCode: res.statusCode,
184
183
  }
185
184
  return changeRes
186
185
  }
187
186
  } else {
188
187
  changeRes = {
189
188
  ...data,
190
189
  ok: false,
191
190
  statusCode: res.statusCode,
192
191
  }
193
192
  return changeRes
194
193
  }
195
194
  })
196
195
  .catch((res) => {
197
196
  return {
198
197
  ...res,
199
198
  ok: false,
200
199
  } as ServiceInterFace.RequestResponseFormatRes
201
200
  })
202
201
  }
203
202
 
204
203
  async receiveCoupon(param = {}, clientParams) {
205
204
  return await this.gatewayReq(
206
205
  'receiveShopCoupon',
207
206
  {
208
207
  operation: '3',
209
208
  ...param,
210
209
  },
211
210
  clientParams,
212
211
  )
213
212
  }
214
213
 
215
214
  getCustomerCenterDispatch(params = {}) {
216
215
  return this.gatewayReq('customerCenterDispatch', params, {
217
216
  clientVersion: '9.2.0',
218
217
  client: 'H5',
219
218
  uuid: 88888,
220
219
  appid: 'shopmember_m_jd_com',
221
220
  })
222
221
  }
223
222
  bMallGetUserInfo = () => {
224
223
  return getBMallUserInfo()
225
224
  }
226
225
  async bMallAddCart(params = {}) {
227
226
  return await this.gatewayReq('bmall_cartAdd', params, {
228
227
  client: 'H5',
229
228
  clientVersion: '5.5.0'
230
229
  })
231
230
  }
232
231
  async bMallChangeCart(params = {}) {
233
232
  return await this.gatewayReq('bmall_cartChange', params, {
234
233
  client: 'H5',
235
234
  clientVersion: '5.5.0'
236
235
  })
237
236
  }
238
237
  async bMallRemoveCart(params = {}) {
239
238
  return await this.gatewayReq(
240
239
  'bmall_cartRemove',
241
240
  params,
242
241
  {
243
242
  client: 'H5',
244
243
  clientVersion: '5.5.0'
245
244
  },
246
245
  )
247
246
  }
248
247
  async bMallGetOmittedProduct(params = {}) {
249
248
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
250
249
  client: 'H5',
251
250
  clientVersion: '5.5.0'
252
251
  })
253
252
  }
254
253
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
255
254
  const params = await getParams({ ...data, skuId, bMallTag, num })
256
255
  return await this.bMallAddCart(params)
257
256
  }
258
257
  async bMallGetSkuNumService(bMallTag = 1) {
259
258
  const params = await getParams({ bMallTag })
260
259
  delete params.operations
261
260
  return await this.bMallGetOmittedProduct(params)
262
261
  }
263
262
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
264
263
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
265
264
  return await this.bMallRemoveCart(params)
266
265
  }
267
266
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
268
267
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
269
268
  return await this.bMallChangeCart(params)
270
269
  }
271
270
 
272
271
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
273
272
  if (!needRequest && isH5 && window?.bMallCartData) {
274
273
  return window?.bMallCartData
275
274
  }
276
275
  const cartData = await this.bMallGetSkuNumService(bMallTag)
277
276
  let items
278
277
  if (cartData.ok && cartData.result) {
279
278
  items = cartData?.result?.items || {}
280
279
  }
281
280
  if (isH5) {
282
281
  window.bMallCartData = items
283
282
  }
284
283
  return items
285
284
  }
286
285
 
287
286
  async bMallCartHandle(goodItem, num) {
288
287
  try {
289
288
  const {
290
289
  skuUuid,
291
290
  limitUpper,
292
291
  limitLower,
293
292
  } = goodItem
294
293
  let cartNum = Number(num)
295
294
  if (limitLower && cartNum && cartNum < limitLower) {
296
295
  cartNum = limitLower
297
296
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
298
297
  cartNum = limitUpper
299
298
  }
300
299
  if (skuUuid && cartNum > 0) {
301
300
  return this.bMallChangeCartService({
302
301
  ...goodItem,
303
302
  skuUuid,
304
303
  num: cartNum,
305
304
  })
306
305
  } else if (!skuUuid && cartNum > 0) {
307
306
  return this.bMallAddCartService({ ...goodItem, num: cartNum })
308
307
  } else if (skuUuid && !cartNum) {
309
308
  return this.bMallRemoveCartService({
310
309
  ...goodItem,
311
310
  skuUuid,
312
311
  num: cartNum,
313
312
  })
314
313
  } else {
315
314
  console.error('参数不全')
316
315
  return false
317
316
  }
318
317
  } catch (e) {
319
318
  console.error(e)
320
319
  }
321
320
  }
321
+ import Taro from '@tarojs/taro'
322
322
  APPID,
323
323
  JshopxColorFunctionIdList,
324
324
  PagesColorFunctionIdList,
325
325
  PAGES_DOMAIN,
326
326
  B2BColorFunctionIdList,
327
327
  MobileVerifyColorList,
328
328
  AppVerifyColorList,
329
329
  JshopxVerifyColorList,
330
330
  BMallVerifyColorList,
331
331
  shopMemberColorFunctionIdList
332
332
  cookiesStr: '',
333
333
  requestHeaderContentType: {
334
334
  jsonHeader: {
335
335
  'content-type': 'application/json;charset=utf-8',
336
336
  },
337
337
  formDataHeader: {
338
338
  'content-type': 'application/x-www-form-urlencoded',
339
339
  },
340
340
  },
341
341
  requestBaseParam: {
342
342
  data: null,
343
343
  header: {
344
344
  'content-type': 'application/json;charset=utf-8',
345
345
  },
346
346
  },
347
347
  timeOut: 7000,
348
348
  apiClientParams: {
349
349
  clientVersion:
350
350
  isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
351
351
  client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : 'wh5',
352
352
  area: '1_72_2799_0',
353
353
  uuid: UUID,
354
354
  },
355
355
  public addressFetchInfo: {
356
356
  reqState: boolean
357
357
  promiseInstance: null | Promise<any>
358
358
  }
359
359
  public getPromotionConfig: {
360
360
  projectId: null | string | number
361
361
  pageId: null | string | number
362
362
  }
363
363
  public resInfo: ServiceInterFace.HttpRequestInfo
364
364
  public api: ServiceInterFace.HttpApi
365
365
  public isPageDomain: boolean
366
366
  public verifyColorList: string[]
367
367
  constructor(opt) {
368
368
  this._init()
369
369
  this.addressFetchInfo = {
370
370
  reqState: false,
371
371
  promiseInstance: null,
372
372
  }
373
373
  this.getPromotionConfig = {
374
374
  projectId: null,
375
375
  pageId: null,
376
376
  }
377
377
  this._userAreaUpdateListen()
378
378
  this.resInfo = this._getResConfig(opt)
379
379
  this.api = api
380
380
  this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false
381
381
  this.verifyColorList = [
382
382
  ...MobileVerifyColorList,
383
383
  ...AppVerifyColorList,
384
384
  ...JshopxVerifyColorList,
385
385
  ...BMallVerifyColorList,
386
386
  ]
387
387
  }
388
388
  _init(): void {
389
389
  httpInterceptors.forEach((item) => {
390
390
  Taro.addInterceptor((chain) => item(chain))
391
391
  })
392
392
  }
393
393
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
394
394
  return Object.assign({}, DefaultConfig, opt)
395
395
  }
396
396
 
397
397
  _userAreaUpdateListen() {
398
398
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
399
399
  this.updateApiClientParamsResInfo({
400
400
  area,
401
401
  })
402
402
  })
403
403
  }
404
404
  updateApiClientParamsResInfo(opt = {}) {
405
405
  this.resInfo.apiClientParams = {
406
406
  ...this.resInfo.apiClientParams,
407
407
  ...opt,
408
408
  }
409
409
  }
410
410
 
411
411
  checkFunctionIdToReturnAppId(functionId) {
412
412
  if (JshopxColorFunctionIdList.includes(functionId)) {
413
413
  return APPID.JSHOPX_COLOR_APPID
414
414
  } else if (
415
415
  this.isPageDomain &&
416
416
  PagesColorFunctionIdList.includes(functionId)
417
417
  ) {
418
418
  return APPID.PAGES_COLOR_APPID
419
419
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
420
420
  return APPID.SHOP_MEMBER_COLOR_APPID
421
421
  }else if (B2BColorFunctionIdList.includes(functionId)) {
422
422
  return APPID.B2B_COLOR_APPID
423
423
  } else {
424
424
  return APPID.SHOP_COLOR_APPID
425
425
  }
426
426
  }
427
427
 
428
428
  gatewayReq(
429
429
  functionId: string,
430
430
  bodyParams = {},
431
431
  clientParams = {},
432
432
  ): Promise<any> {
433
433
  if (
434
434
  functionId === 'receiveShopCoupon' &&
435
435
  ((isH5 && window?.isJingGouMiniViewState) || isWxMinAndWxapp)
436
436
  ) {
437
437
  clientParams = Object.assign(
438
438
  {},
439
439
  {
440
440
  loginType: '1',
441
441
  loginWQBiz: WXAPP_BIZ_KEY,
442
442
  },
443
443
  clientParams,
444
444
  )
445
445
  }
446
446
  const apiClientParams = Object.assign(
447
447
  {},
448
448
  this.resInfo.apiClientParams,
449
449
  clientParams,
450
450
  )
451
451
  typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
452
452
  const isColorVerify = this.verifyColorList.includes(functionId)
453
453
  const getReqData = {
454
454
  functionId: functionId,
455
455
  body: JSON.stringify(bodyParams),
456
456
  t: Date.now(),
457
457
  ...apiClientParams,
458
458
  }
459
459
  return http
460
460
  .request({
461
461
  url: this.api.apiFunc,
462
462
  data: getReqData,
463
463
  isColorVerify,
464
464
  })
465
465
  .then((res: ServiceInterFace.RequestPromiseRes) => {
466
466
  const { statusCode, data } = res
467
467
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
468
468
  ok: true,
469
469
  }
470
470
  if (statusCode === 200 && data) {
471
471
  const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
472
472
  ? Number(res.data.code)
473
473
  : -1
474
474
  const subCode = Object.prototype.hasOwnProperty.call(
475
475
  res.data,
476
476
  'subCode',
477
477
  )
478
478
  ? Number(res.data.subCode)
479
479
  : -1
480
480
  if (
481
481
  data.success === true ||
482
482
  data.isSuccess ||
483
483
  resCode === 0 ||
484
484
  resCode === 200 ||
485
485
  subCode === 0
486
486
  ) {
487
487
  changeRes = {
488
488
  result: Object.prototype.hasOwnProperty.call(data, 'result')
489
489
  ? data.result
490
490
  : Object.prototype.hasOwnProperty.call(data, 'data')
491
491
  ? data.data
492
492
  : data,
493
493
  code: data.code || 200,
494
494
  ok: true,
495
495
  source: data,
496
496
  }
497
497
  return changeRes
498
498
  } else {
499
499
  changeRes = {
500
500
  ...data,
501
501
  ok: false,
502
502
  statusCode: res.statusCode,
503
503
  }
504
504
  return changeRes
505
505
  }
506
506
  } else {
507
507
  changeRes = {
508
508
  ...data,
509
509
  ok: false,
510
510
  statusCode: res.statusCode,
511
511
  }
512
512
  return changeRes
513
513
  }
514
514
  })
515
515
  .catch((res) => {
516
516
  return {
517
517
  ...res,
518
518
  ok: false,
519
519
  } as ServiceInterFace.RequestResponseFormatRes
520
520
  })
521
521
  }
522
522
 
523
523
  async receiveCoupon(param = {}, clientParams) {
524
524
  return await this.gatewayReq(
525
525
  'receiveShopCoupon',
526
526
  {
527
527
  operation: '3',
528
528
  ...param,
529
529
  },
530
530
  clientParams,
531
531
  )
532
532
  }
533
533
 
534
534
  getCustomerCenterDispatch(params = {}) {
535
535
  return this.gatewayReq('customerCenterDispatch', params, {
536
536
  clientVersion: '9.2.0',
537
537
  client: 'H5',
538
538
  uuid: 88888,
539
539
  appid: 'shopmember_m_jd_com',
540
540
  })
541
541
  }
542
542
  bMallGetUserInfo = () => {
543
543
  return getBMallUserInfo()
544
544
  }
545
545
  async bMallAddCart(params = {}) {
546
546
  return await this.gatewayReq('bmall_cartAdd', params, {
547
547
  client: 'H5',
548
548
  clientVersion: '5.5.0'
549
549
  })
550
550
  }
551
551
  async bMallChangeCart(params = {}) {
552
552
  return await this.gatewayReq('bmall_cartChange', params, {
553
553
  client: 'H5',
554
554
  clientVersion: '5.5.0'
555
555
  })
556
556
  }
557
557
  async bMallRemoveCart(params = {}) {
558
558
  return await this.gatewayReq(
559
559
  'bmall_cartRemove',
560
560
  params,
561
561
  {
562
562
  client: 'H5',
563
563
  clientVersion: '5.5.0'
564
564
  },
565
565
  )
566
566
  }
567
567
  async bMallGetOmittedProduct(params = {}) {
568
568
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
569
569
  client: 'H5',
570
570
  clientVersion: '5.5.0'
571
571
  })
572
572
  }
573
573
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
574
574
  const params = await getParams({ ...data, skuId, bMallTag, num })
575
575
  return await this.bMallAddCart(params)
576
576
  }
577
577
  async bMallGetSkuNumService(bMallTag = 1) {
578
578
  const params = await getParams({ bMallTag })
579
579
  delete params.operations
580
580
  return await this.bMallGetOmittedProduct(params)
581
581
  }
582
582
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
583
583
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
584
584
  return await this.bMallRemoveCart(params)
585
585
  }
586
586
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
587
587
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
588
588
  return await this.bMallChangeCart(params)
589
589
  }
590
590
 
591
591
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
592
592
  if (!needRequest && isH5 && window?.bMallCartData) {
593
593
  return window?.bMallCartData
594
594
  }
595
595
  const cartData = await this.bMallGetSkuNumService(bMallTag)
596
596
  let items
597
597
  if (cartData.ok && cartData.result) {
598
598
  items = cartData?.result?.items || {}
599
599
  }
600
600
  if (isH5) {
601
601
  window.bMallCartData = items
602
602
  }
603
603
  return items
604
604
  }
605
605
 
606
606
  async bMallCartHandle(goodItem, num) {
607
607
  try {
608
608
  const {
609
609
  skuUuid,
610
610
  limitUpper,
611
611
  limitLower,
612
612
  } = goodItem
613
613
  let cartNum = Number(num)
614
614
  if (limitLower && cartNum && cartNum < limitLower) {
615
615
  cartNum = limitLower
616
616
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
617
617
  cartNum = limitUpper
618
618
  }
619
619
  if (skuUuid && cartNum > 0) {
620
620
  return this.bMallChangeCartService({
621
621
  ...goodItem,
622
622
  skuUuid,
623
623
  num: cartNum,
624
624
  })
625
625
  } else if (!skuUuid && cartNum > 0) {
626
626
  return this.bMallAddCartService({ ...goodItem, num: cartNum })
627
627
  } else if (skuUuid && !cartNum) {
628
628
  return this.bMallRemoveCartService({
629
629
  ...goodItem,
630
630
  skuUuid,
631
631
  num: cartNum,
632
632
  })
633
633
  } else {
634
634
  console.error('参数不全')
635
635
  return false
636
636
  }
637
637
  } catch (e) {
638
638
  console.error(e)
639
639
  }
640
640
  }
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = {
3
2
  displayHeight: 1920,
4
3
  offSetY: 0
5
4
  }
6
5
  console.log('>>>>>>>>>>>>>>>>>>> render taroEventSendPageScrollInfo origin time:', Date.now(), 'res:', options)
7
6
  if(options){
8
7
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = options
9
8
  }
10
9
  const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
11
10
  PAGE_PV_PARAM: 'pagePvParam',
12
11
  NATIVE_SCORLL_VIEW: 'nativeScrollControl',
13
12
  OPEN: 'open',
14
13
  const { displayHeight, offSetY } = res
15
14
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
16
15
  if (isIosDevice) return res
17
16
  if (isAndroidDevice) {
18
17
  const deviceRatio = window.devicePixelRatio
19
18
  const cssDisplayHeight = Math.ceil(displayHeight / deviceRatio)
20
19
  const cssOffsetY = Math.ceil(offSetY / deviceRatio)
21
20
  return {
22
21
  displayHeight: cssDisplayHeight,
23
22
  offSetY: cssOffsetY
24
23
  }
25
24
  }
25
+ import Taro from '@tarojs/taro'
26
26
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = {
27
27
  displayHeight: 1920,
28
28
  offSetY: 0
29
29
  }
30
30
  console.log('>>>>>>>>>>>>>>>>>>> render taroEventSendPageScrollInfo origin time:', Date.now(), 'res:', options)
31
31
  if(options){
32
32
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = options
33
33
  }
34
34
  const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
35
35
  PAGE_PV_PARAM: 'pagePvParam',
36
36
  NATIVE_SCORLL_VIEW: 'nativeScrollControl',
37
37
  OPEN: 'open',
38
38
  const { displayHeight, offSetY } = res
39
39
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
40
40
  if (isIosDevice) return res
41
41
  if (isAndroidDevice) {
42
42
  const deviceRatio = window.devicePixelRatio
43
43
  const cssDisplayHeight = Math.ceil(displayHeight / deviceRatio)
44
44
  const cssOffsetY = Math.ceil(offSetY / deviceRatio)
45
45
  return {
46
46
  displayHeight: cssDisplayHeight,
47
47
  offSetY: cssOffsetY
48
48
  }
49
49
  }