@conecli/cone-render 0.10.1-shop3.5 → 0.10.1-shop3.7

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.
Files changed (38) hide show
  1. package/dist/common/const.ts +1 -1
  2. package/dist/common/index.h5.ts +1 -1
  3. package/dist/common/index.jd.ts +1 -1
  4. package/dist/common/index.ts +1 -1
  5. package/dist/common/index.weapp.ts +1 -1
  6. package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
  7. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  8. package/dist/components/base/CustomScrollView/index-back.tsx +1 -0
  9. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  10. package/dist/components/base/Dialog/index.module.scss +11 -0
  11. package/dist/components/base/InViewRender/index.tsx +1 -1
  12. package/dist/components/floorItem.weapp.tsx +1 -1
  13. package/dist/interface/common.ts +1 -1
  14. package/dist/jumpEventReport/const.ts +1 -1
  15. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  16. package/dist/jumpEventReport/web.jd.ts +1 -1
  17. package/dist/libs/taroAppReport.js +2 -2
  18. package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -56
  19. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  20. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  21. package/dist/open/api/shopMember.ts +1 -1
  22. package/dist/open/api/util.ts +1 -1
  23. package/dist/sass/app.h5.scss +252 -224
  24. package/dist/service/fetchGateway.ts +1 -1
  25. package/dist/service/fetchGateway.weapp.ts +1 -0
  26. package/dist/service/http/colorSign.ts +1 -1
  27. package/dist/service/http/const.ts +1 -1
  28. package/dist/service/http/h5Http.ts +1 -1
  29. package/dist/service/requestServer.h5.ts +1 -1
  30. package/dist/service/requestServer.ts +1 -1
  31. package/dist/service/requestServer.weapp.ts +1 -0
  32. package/dist/utils/h5Utils.ts +1 -1
  33. package/dist/utils/index.h5.ts +1 -1
  34. package/dist/utils/index.ts +1 -1
  35. package/dist/utils/index.weapp.ts +1 -1
  36. package/dist/utils/jumpExtMapUtil.js +1 -0
  37. package/dist/utils/utils.ts +1 -1
  38. package/package.json +1 -1
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  isSupportHybridHttpRequest,
3
2
  draInterfaceCustomReport,
4
3
  draBusinessCustomReport,
5
4
  jsonHeader = 'application/json;charset=utf-8',
6
5
  formDataHeader = 'application/x-www-form-urlencoded',
7
6
  HYBRID: 'httpRequest_hybrid',
8
7
  TARO: 'httpRequest_taro',
9
8
  #requestTimeStamp: number
10
9
  #responseTimeStamp: number
11
10
  #getResTimeStamp: number
12
11
  #reportType: string
13
12
  #callbackFunction: string
14
13
 
15
14
  async request({
16
15
  url,
17
16
  method = 'POST',
18
17
  timeout = 7000,
19
18
  isColorVerify = false,
20
19
  ...otherOptions
21
20
  }): Promise<Taro.request.SuccessCallbackResult<any>> {
22
21
  const { header: otherHeader, ...otherOpts } = otherOptions
23
22
  const header = {
24
23
  'content-type':
25
24
  method === 'POST'
26
25
  ? RequestHeaderContentType.formDataHeader
27
26
  : RequestHeaderContentType.jsonHeader,
28
27
  ...otherHeader,
29
28
  }
30
29
  let getRequestUrl = url
31
30
  let requestTask
32
31
  const data = otherOpts?.data
33
32
  const isGatewayRequest =
34
33
  url === this.api.apiFunc && typeof data === 'object'
35
34
  if (isGatewayRequest) {
36
35
  getRequestUrl = this._handleSpecialGatewayUrl(url)
37
36
  const shouldUseHybridRequest = this._shouldUseHybridRequest(data)
38
37
  if (shouldUseHybridRequest) {
39
38
  requestTask = this._hybridRequest(getRequestUrl, data)
40
39
  } else {
41
40
  otherOpts.data = await this._prepareGatewayReqData(data, isColorVerify)
42
41
  requestTask = this._taroRequest(
43
42
  getRequestUrl,
44
43
  otherOpts,
45
44
  method,
46
45
  timeout,
47
46
  header,
48
47
  )
49
48
  }
50
49
  } else {
51
50
  requestTask = this._taroRequest(
52
51
  getRequestUrl,
53
52
  otherOpts,
54
53
  method,
55
54
  timeout,
56
55
  header,
57
56
  )
58
57
  }
59
58
  const requestTimeoutPromise =
60
59
  new Promise<ServiceInterFace.RequestPromiseRes>((resolve) => {
61
60
  setTimeout(() => {
62
61
  resolve({
63
62
  statusCode: 500,
64
63
  resTimeoutState: true,
65
64
  errMsg: 'request timeout',
66
65
  })
67
66
  }, timeout)
68
67
  })
69
68
  return Promise.race([requestTask, requestTimeoutPromise]).then(
70
69
  (res: any) => {
71
70
  if (res && res.statusCode === 500 && res.resTimeoutState) {
72
71
  if (this.#reportType === HTTP_REQUEST_TYPE.HYBRID) {
73
72
  this._clearFunction(this.#callbackFunction)
74
73
  } else {
75
74
  requestTask.abort && requestTask.abort()
76
75
  }
77
76
  }
78
77
  this._handleReportInterfaceError(url, data, timeout, res)
79
78
  return res
80
79
  },
81
80
  )
82
81
  }
83
82
 
84
83
  _handleSpecialGatewayUrl(url: string): string {
85
84
  if (isPc && window.location.hostname.includes('.jd.hk')) {
86
85
  return this.api.hkApiFunc
87
86
  }
88
87
  if (
89
88
  isJdApp &&
90
89
  window?.shopGlobalSwitch?.dualProtocol &&
91
90
  !window.location.href.includes('jshopx_vconsole')
92
91
  ) {
93
92
  return window?.shopGlobalSwitch?.dualProtocol?.apiTestApp || url
94
93
  }
95
94
  return url
96
95
  }
97
96
 
98
97
  _shouldUseHybridRequest(data: any): boolean {
99
98
  try {
100
99
  const isWhxFunctionId = /^whx\_/.test(data?.functionId)
101
100
  const isGlobalOpenHybirdHttpRequest =
102
101
  window?.shopGlobalSwitch?.openHybirdHttpRequest === 'true'
103
102
  if (
104
103
  !isJdApp ||
105
104
  !isSupportHybridHttpRequest ||
106
105
  !isGlobalOpenHybirdHttpRequest ||
107
106
  isWhxFunctionId ||
108
107
  isJdAndHarmonyDevice
109
108
  ) {
110
109
  return false
111
110
  }
112
111
  const configData = global.getDynamicConfig('hybridHttpSwitch')
113
112
  const { globalOn = false, grayscale = {} } = configData || {}
114
113
  const buildType = process.env.BUILD_TYPE || ''
115
114
  const isInvokeGray = globalOn || grayscale[buildType]
116
115
  console.log(
117
116
  '使用hybrid请求是否命中灰度,isInvokeGray:',
118
117
  isInvokeGray,
119
118
  '获取mpaas配置hybridHttpSwitch原始数据configData',
120
119
  configData,
121
120
  )
122
121
  const hasWindowXWebView = !!window.XWebView
123
122
  return isInvokeGray && hasWindowXWebView
124
123
  } catch (e) {
125
124
  console.log('获取是否使用Hybrid请求出错,e:', e)
126
125
  return false
127
126
  }
128
127
  }
129
128
 
130
129
  _hybridRequest(url: string, data: any): Promise<any> {
131
130
  return new Promise((resolve, reject) => {
132
131
  try {
133
132
  const changeCurrentUrl = url.startsWith('//') ? `https:${url}` : url
134
133
  const { functionId, body, ...otherH5Param } = data
135
134
  const reqParams = {
136
135
  url: isIosDevice ? `${changeCurrentUrl}/` : changeCurrentUrl,
137
136
  functionId: functionId,
138
137
  body: body,
139
138
  headerType: '0',
140
139
  param: {
141
140
  ...otherH5Param,
142
141
  },
143
142
  header: {
144
143
  Referer: window.location.origin,
145
144
  },
146
145
  }
147
146
  const callbackFunction = this._generateCallbackFunction()
148
147
  this.#callbackFunction = callbackFunction
149
148
  this.#requestTimeStamp = Date.now()
150
149
  this.#reportType = HTTP_REQUEST_TYPE.HYBRID
151
150
  window.XWebView.callNative(
152
151
  'ColorQueryPlugin',
153
152
  'colorRequest',
154
153
  JSON.stringify(reqParams),
155
154
  callbackFunction,
156
155
  '1',
157
156
  )
158
157
  window[callbackFunction] = (result) => {
159
158
  this.#responseTimeStamp = Date.now()
160
159
  try {
161
160
  const resultObj =
162
161
  typeof result === 'string' ? JSON.parse(result) : result
163
162
  resolve(resultObj)
164
163
  } catch (error) {
165
164
  const errMsg = 'hybrid网络请求JSON解析失败, error: ' + error
166
165
  draBusinessCustomReport({
167
166
  type: `${HTTP_REQUEST_TYPE.HYBRID}_jsonParseError`,
168
167
  errMsg,
169
168
  result,
170
169
  })
171
170
  reject({ errMsg })
172
171
  }
173
172
  this._clearFunction(callbackFunction)
174
173
  }
175
174
  } catch (error) {
176
175
  reject({
177
176
  errMsg:
178
177
  'hybrid网络请求,App下调用window.XWebView.callNative出错, error: ' +
179
178
  error,
180
179
  })
181
180
  }
182
181
  })
183
182
  }
184
183
 
185
184
  _generateCallbackFunction() {
186
185
  return `hybridHttpRequestCallback_${Date.now()}_${Math.ceil(
187
186
  Math.random() * 100000,
188
187
  )}`
189
188
  }
190
189
 
191
190
  _clearFunction(functionName: string) {
192
191
  try {
193
192
  delete window[functionName]
194
193
  } catch (e) {
195
194
  window[functionName] = undefined
196
195
  }
197
196
  }
198
197
 
199
198
  async _prepareGatewayReqData(
200
199
  data: any,
201
200
  isColorVerify: boolean,
202
201
  ): Promise<any> {
203
202
  const { functionId } = data
204
203
  console.log('获取当前是否需要color加固', isColorVerify, functionId)
205
204
  if (isColorVerify) {
206
205
  const { h5st } = await colorSign.paramsSign(data)
207
206
  h5st && (data.h5st = encodeURI(h5st))
208
207
  console.log(`${functionId}的apiReq_h5st===>:${h5st}`)
209
208
  }
210
209
  const { jsToken } = await colorSign.getFmInfo()
211
210
  console.log(`${functionId}的api jsToken指纹===>:${jsToken}`)
212
211
  jsToken && (data['x-api-eid-token'] = jsToken)
213
212
  return data
214
213
  }
215
214
 
216
215
  _taroRequest(
217
216
  url: string,
218
217
  otherOpts: any,
219
218
  method: string,
220
219
  timeout: number,
221
220
  header: string,
222
221
  ): Promise<any> {
223
222
  const reqParam = {
224
223
  url,
225
224
  method,
226
225
  timeout,
227
226
  header,
228
227
  credentials: 'include',
229
228
  ...otherOpts,
230
229
  }
231
230
  this.#requestTimeStamp = Date.now()
232
231
  this.#reportType = HTTP_REQUEST_TYPE.TARO
233
232
  return Taro.request(reqParam)
234
233
  }
235
234
 
236
235
  _reportRequestTime(url: string, data: any): void {
237
236
  this.#getResTimeStamp = Date.now()
238
237
  if (this.#reportType === HTTP_REQUEST_TYPE.TARO) {
239
238
  this.#responseTimeStamp = this.#getResTimeStamp
240
239
  }
241
240
  draInterfaceCustomReport(
242
241
  {
243
242
  type: `${this.#reportType}_consumeTime`,
244
243
  url,
245
244
  functionId: data?.functionId,
246
245
  requestTimeStamp: this.#requestTimeStamp,
247
246
  responseTimeStamp: this.#responseTimeStamp,
248
247
  errMsg: `使用${this.#reportType}调用接口请求响应耗时`,
249
248
  source: 'remote',
250
249
  },
251
250
  {
252
251
  consumeTime: `${this.#responseTimeStamp - this.#requestTimeStamp}ms`,
253
252
  getResTime: `${this.#getResTimeStamp - this.#requestTimeStamp}ms`,
254
253
  },
255
254
  )
256
255
  }
257
256
 
258
257
  _handleReportInterfaceError(
259
258
  url: string,
260
259
  reqData: any,
261
260
  timeOut: any,
262
261
  res: any,
263
262
  ): void {
264
263
  const source = 'remote'
265
264
  const requestType = this.#reportType
266
265
  let errorType = ''
267
266
  let subMsg = ''
268
267
  let reportFlag = false
269
268
  if (res) {
270
269
  const { statusCode, data, status, resTimeoutState } = res
271
270
  if (statusCode === 500 && resTimeoutState) {
272
271
  reportFlag = true
273
272
  errorType = 'timeout'
274
273
  subMsg = `接口请求超时${timeOut}ms`
275
274
  } else if ((statusCode === 200 || status === '0') && data) {
276
275
  const resCode = Object.prototype.hasOwnProperty.call(data, 'code')
277
276
  ? Number(data.code)
278
277
  : -1
279
278
  const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
280
279
  ? Number(data.subCode)
281
280
  : -1
282
281
  const isSuccess =
283
282
  data.success === true ||
284
283
  data.isSuccess ||
285
284
  resCode === 0 ||
286
285
  resCode === 200 ||
287
286
  subCode === 0
288
287
  if (!isSuccess && resCode !== 3) {
289
288
  reportFlag = true
290
289
  errorType = 'dataError'
291
290
  subMsg = '接口请求返回数据异常'
292
291
  }
293
292
  } else {
294
293
  reportFlag = true
295
294
  errorType = 'statusError'
296
295
  subMsg = '接口请求错误,h5请求statusCode非200,或hybrid请求status非0,或未返回data字段'
297
296
  }
298
297
  }
299
298
  reportFlag &&
300
299
  draInterfaceCustomReport({
301
300
  subMsg,
302
301
  url,
303
302
  source,
304
303
  requestType,
305
304
  errorType,
306
305
  functionId: reqData?.functionId,
307
306
  appid: reqData?.appId,
308
307
  client: reqData?.client,
309
308
  clientVersion: reqData?.clientVersion,
310
309
  statusCode: res?.statusCode,
311
310
  status: res?.status,
312
311
  code: res?.data?.code || res?.data?.subCode,
313
312
  errMsg: res?.errMsg || res?.msg || res?.message || res?.data?.echo,
314
313
  originReqDataStr: JSON.stringify(reqData),
315
314
  originResDataStr: JSON.stringify(res),
316
315
  })
317
316
  }
317
+ import Taro from '@tarojs/taro';
318
318
  isSupportHybridHttpRequest,
319
319
  draInterfaceCustomReport,
320
320
  draBusinessCustomReport,
321
321
  jsonHeader = 'application/json;charset=utf-8',
322
322
  formDataHeader = 'application/x-www-form-urlencoded',
323
323
  HYBRID: 'httpRequest_hybrid',
324
324
  TARO: 'httpRequest_taro',
325
325
  #requestTimeStamp: number;
326
326
  #responseTimeStamp: number;
327
327
  #getResTimeStamp: number;
328
328
  #reportType: string;
329
329
  #callbackFunction: string;
330
330
 
331
331
  async request({
332
332
  url,
333
333
  method = 'POST',
334
334
  timeout = 7000,
335
335
  isColorVerify = false,
336
336
  ...otherOptions
337
337
  }): Promise<Taro.request.SuccessCallbackResult<any>> {
338
338
  const { header: otherHeader, ...otherOpts } = otherOptions;
339
339
  const header = {
340
340
  'content-type':
341
341
  method === 'POST'
342
342
  ? RequestHeaderContentType.formDataHeader
343
343
  : RequestHeaderContentType.jsonHeader,
344
344
  ...otherHeader,
345
345
  };
346
346
  let getRequestUrl = url;
347
347
  let requestTask;
348
348
  const data = otherOpts?.data;
349
349
  const isGatewayRequest = url === this.api.apiFunc && typeof data === 'object';
350
350
  if (isGatewayRequest) {
351
351
  getRequestUrl = this._handleSpecialGatewayUrl(url);
352
352
  const shouldUseHybridRequest = this._shouldUseHybridRequest(data);
353
353
  if (shouldUseHybridRequest) {
354
354
  requestTask = this._hybridRequest(getRequestUrl, data);
355
355
  } else {
356
356
  otherOpts.data = await this._prepareGatewayReqData(data, isColorVerify);
357
357
  requestTask = this._taroRequest(getRequestUrl, otherOpts, method, timeout, header);
358
358
  }
359
359
  } else {
360
360
  requestTask = this._taroRequest(getRequestUrl, otherOpts, method, timeout, header);
361
361
  }
362
362
  const requestTimeoutPromise = new Promise<ServiceInterFace.RequestPromiseRes>((resolve) => {
363
363
  setTimeout(() => {
364
364
  resolve({
365
365
  statusCode: 500,
366
366
  resTimeoutState: true,
367
367
  errMsg: 'request timeout',
368
368
  });
369
369
  }, timeout);
370
370
  });
371
371
  return Promise.race([requestTask, requestTimeoutPromise]).then((res: any) => {
372
372
  if (res && res.statusCode === 500 && res.resTimeoutState) {
373
373
  if (this.#reportType === HTTP_REQUEST_TYPE.HYBRID) {
374
374
  this._clearFunction(this.#callbackFunction);
375
375
  } else {
376
376
  requestTask.abort && requestTask.abort();
377
377
  }
378
378
  }
379
379
  this._handleReportInterfaceError(url, data, timeout, res);
380
380
  return res;
381
381
  });
382
382
  }
383
383
 
384
384
  _handleSpecialGatewayUrl(url: string): string {
385
385
  if (isPc && window.location.hostname.includes('.jd.hk')) {
386
386
  return this.api.hkApiFunc;
387
387
  }
388
388
  if (
389
389
  isJdApp &&
390
390
  window?.shopGlobalSwitch?.dualProtocol &&
391
391
  !window.location.href.includes('jshopx_vconsole')
392
392
  ) {
393
393
  return window?.shopGlobalSwitch?.dualProtocol?.apiTestApp || url;
394
394
  }
395
395
  return url;
396
396
  }
397
397
 
398
398
  _shouldUseHybridRequest(data: any): boolean {
399
399
  try {
400
400
  const isWhxFunctionId = /^whx\_/.test(data?.functionId);
401
401
  const isGlobalOpenHybirdHttpRequest =
402
402
  window?.shopGlobalSwitch?.openHybirdHttpRequest === 'true';
403
403
  if (
404
404
  !isJdApp ||
405
405
  !isSupportHybridHttpRequest ||
406
406
  !isGlobalOpenHybirdHttpRequest ||
407
407
  isWhxFunctionId ||
408
408
  isJdAndHarmonyDevice
409
409
  ) {
410
410
  return false;
411
411
  }
412
412
  const configData = global.getDynamicConfig('hybridHttpSwitch');
413
413
  const { globalOn = false, grayscale = {} } = configData || {};
414
414
  const buildType = process.env.BUILD_TYPE || '';
415
415
  const isInvokeGray = globalOn || grayscale[buildType];
416
416
  console.log(
417
417
  '使用hybrid请求是否命中灰度,isInvokeGray:',
418
418
  isInvokeGray,
419
419
  '获取mpaas配置hybridHttpSwitch原始数据configData',
420
420
  configData,
421
421
  );
422
422
  const hasWindowXWebView = !!window.XWebView;
423
423
  return isInvokeGray && hasWindowXWebView;
424
424
  } catch (e) {
425
425
  console.log('获取是否使用Hybrid请求出错,e:', e);
426
426
  return false;
427
427
  }
428
428
  }
429
429
 
430
430
  _hybridRequest(url: string, data: any): Promise<any> {
431
431
  return new Promise((resolve, reject) => {
432
432
  try {
433
433
  const changeCurrentUrl = url.startsWith('//') ? `https:${url}` : url;
434
434
  const { functionId, body, ...otherH5Param } = data;
435
435
  const reqParams = {
436
436
  url: isIosDevice ? `${changeCurrentUrl}/` : changeCurrentUrl,
437
437
  functionId: functionId,
438
438
  body: body,
439
439
  headerType: '0',
440
440
  param: {
441
441
  ...otherH5Param,
442
442
  },
443
443
  header: {
444
444
  Referer: window.location.origin,
445
445
  },
446
446
  };
447
447
  const callbackFunction = this._generateCallbackFunction();
448
448
  this.#callbackFunction = callbackFunction;
449
449
  this.#requestTimeStamp = Date.now();
450
450
  this.#reportType = HTTP_REQUEST_TYPE.HYBRID;
451
451
  window.XWebView.callNative(
452
452
  'ColorQueryPlugin',
453
453
  'colorRequest',
454
454
  JSON.stringify(reqParams),
455
455
  callbackFunction,
456
456
  '1',
457
457
  );
458
458
  window[callbackFunction] = (result) => {
459
459
  this.#responseTimeStamp = Date.now();
460
460
  try {
461
461
  const resultObj = typeof result === 'string' ? JSON.parse(result) : result;
462
462
  resolve(resultObj);
463
463
  } catch (error) {
464
464
  const errMsg = 'hybrid网络请求JSON解析失败, error: ' + error;
465
465
  draBusinessCustomReport({
466
466
  type: `${HTTP_REQUEST_TYPE.HYBRID}_jsonParseError`,
467
467
  errMsg,
468
468
  result,
469
469
  });
470
470
  reject({ errMsg });
471
471
  }
472
472
  this._clearFunction(callbackFunction);
473
473
  };
474
474
  } catch (error) {
475
475
  reject({
476
476
  errMsg: 'hybrid网络请求,App下调用window.XWebView.callNative出错, error: ' + error,
477
477
  });
478
478
  }
479
479
  });
480
480
  }
481
481
 
482
482
  _generateCallbackFunction() {
483
483
  return `hybridHttpRequestCallback_${Date.now()}_${Math.ceil(Math.random() * 100000)}`;
484
484
  }
485
485
 
486
486
  _clearFunction(functionName: string) {
487
487
  try {
488
488
  delete window[functionName];
489
489
  } catch (e) {
490
490
  window[functionName] = undefined;
491
491
  }
492
492
  }
493
493
 
494
494
  async _prepareGatewayReqData(data: any, isColorVerify: boolean): Promise<any> {
495
495
  const { functionId } = data;
496
496
  console.log('获取当前是否需要color加固', isColorVerify, functionId);
497
497
  if (isColorVerify) {
498
498
  const { h5st } = await colorSign.paramsSign(data);
499
499
  h5st && (data.h5st = encodeURI(h5st));
500
500
  console.log(`${functionId}的apiReq_h5st===>:${h5st}`);
501
501
  }
502
502
  const { jsToken } = await colorSign.getFmInfo();
503
503
  console.log(`${functionId}的api jsToken指纹===>:${jsToken}`);
504
504
  jsToken && (data['x-api-eid-token'] = jsToken);
505
505
  return data;
506
506
  }
507
507
 
508
508
  _taroRequest(
509
509
  url: string,
510
510
  otherOpts: any,
511
511
  method: string,
512
512
  timeout: number,
513
513
  header: string,
514
514
  ): Promise<any> {
515
515
  const reqParam = {
516
516
  url,
517
517
  method,
518
518
  timeout,
519
519
  header,
520
520
  credentials: 'include',
521
521
  ...otherOpts,
522
522
  };
523
523
  this.#requestTimeStamp = Date.now();
524
524
  this.#reportType = HTTP_REQUEST_TYPE.TARO;
525
525
  return Taro.request(reqParam);
526
526
  }
527
527
 
528
528
  _reportRequestTime(url: string, data: any): void {
529
529
  this.#getResTimeStamp = Date.now();
530
530
  if (this.#reportType === HTTP_REQUEST_TYPE.TARO) {
531
531
  this.#responseTimeStamp = this.#getResTimeStamp;
532
532
  }
533
533
  draInterfaceCustomReport(
534
534
  {
535
535
  type: `${this.#reportType}_consumeTime`,
536
536
  url,
537
537
  functionId: data?.functionId,
538
538
  requestTimeStamp: this.#requestTimeStamp,
539
539
  responseTimeStamp: this.#responseTimeStamp,
540
540
  errMsg: `使用${this.#reportType}调用接口请求响应耗时`,
541
541
  source: 'remote',
542
542
  },
543
543
  {
544
544
  consumeTime: `${this.#responseTimeStamp - this.#requestTimeStamp}ms`,
545
545
  getResTime: `${this.#getResTimeStamp - this.#requestTimeStamp}ms`,
546
546
  },
547
547
  );
548
548
  }
549
549
 
550
550
  _handleReportInterfaceError(url: string, reqData: any, timeOut: any, res: any): void {
551
551
  const source = 'remote';
552
552
  const requestType = this.#reportType;
553
553
  let errorType = '';
554
554
  let subMsg = '';
555
555
  let reportFlag = false;
556
556
  if (res) {
557
557
  const { statusCode, data, status, resTimeoutState } = res;
558
558
  if (statusCode === 500 && resTimeoutState) {
559
559
  reportFlag = true;
560
560
  errorType = 'timeout';
561
561
  subMsg = `接口请求超时${timeOut}ms`;
562
562
  } else if ((statusCode === 200 || status === '0') && data) {
563
563
  const resCode = Object.prototype.hasOwnProperty.call(data, 'code') ? Number(data.code) : -1;
564
564
  const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
565
565
  ? Number(data.subCode)
566
566
  : -1;
567
567
  const isSuccess =
568
568
  data.success === true ||
569
569
  data.isSuccess ||
570
570
  resCode === 0 ||
571
571
  resCode === 200 ||
572
572
  subCode === 0;
573
573
  if (!isSuccess && resCode !== 3) {
574
574
  reportFlag = true;
575
575
  errorType = 'dataError';
576
576
  subMsg = '接口请求返回数据异常';
577
577
  }
578
578
  } else {
579
579
  reportFlag = true;
580
580
  errorType = 'statusError';
581
581
  subMsg = '接口请求错误,h5请求statusCode非200,或hybrid请求status非0,或未返回data字段';
582
582
  }
583
583
  }
584
584
  reportFlag &&
585
585
  draInterfaceCustomReport({
586
586
  subMsg,
587
587
  url,
588
588
  source,
589
589
  requestType,
590
590
  errorType,
591
591
  functionId: reqData?.functionId,
592
592
  appid: reqData?.appId,
593
593
  client: reqData?.client,
594
594
  clientVersion: reqData?.clientVersion,
595
595
  statusCode: res?.statusCode,
596
596
  status: res?.status,
597
597
  code: res?.data?.code || res?.data?.subCode,
598
598
  errMsg: res?.errMsg || res?.msg || res?.message || res?.data?.echo,
599
599
  originReqDataStr: JSON.stringify(reqData),
600
600
  originResDataStr: JSON.stringify(res),
601
601
  });
602
602
  }