@conecli/cone-render 0.10.1-shop3.113 → 0.10.1-shop3.115

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 React from 'react';
2
1
  console.warn('🚗 ~~ file: index.tsx:22 ~~ reportException() ~~ {type, detail, text}:', {
3
2
  type,
4
3
  data,
5
4
  text,
6
5
  });
7
6
  draBusinessCustomReport({
8
7
  eventName: 'business',
9
8
  errorName: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_${type}`),
10
9
  errorMessage: '[双价格组件]' + text,
11
10
  extraData: JSON.stringify({
12
11
  type,
13
12
  data,
14
13
  }),
15
14
  });
16
15
  return rest.some((item) => item === undefined || item === '');
17
16
  const numPrice = Number(strPrice);
18
17
  if (isNaN(numPrice)) {
19
18
  reportException({
20
19
  type: 'isNotNumericType',
21
20
  data: props,
22
21
  text: `传入价格字段值“${strPrice}”转换数字报错`,
23
22
  });
24
23
  return false;
25
24
  }
26
25
  else if (numPrice <= 0) {
27
26
  reportException({
28
27
  type: 'isNotPositiveNumber',
29
28
  data: props,
30
29
  text: `传入价格字段值“${strPrice}”不是一个正数`,
31
30
  });
32
31
  return false;
33
32
  }
34
33
  const result = numPrice.toString().match(/(\d+)(\.(\d+))?/);
35
34
  if (result && result[3]?.length > 2) {
36
35
  reportException({
37
36
  type: 'decimalPlaceTooLong',
38
37
  data: props,
39
38
  text: `传入价格字段值“${strPrice}”小数位不能超过2位`,
40
39
  });
41
40
  return false;
42
41
  }
43
42
  if (/^\d+(\.\d+)?[eE][+-]?\d+$/.test(strPrice)) {
44
43
  reportException({
45
44
  type: 'findScientificNotation',
46
45
  data: props,
47
46
  text: `传入价格字段值“${strPrice}”是一个科学计数法格式`,
48
47
  });
49
48
  }
50
49
  return true;
51
50
  const { jdPrice, finalPrice, forceShowFinalPrice } = props;
52
51
  if (jdPrice && finalPrice) {
53
52
  const getLastPassValidateState = forceShowFinalPrice || Number(finalPrice) < Number(jdPrice);
54
53
  !getLastPassValidateState &&
55
54
  reportException({
56
55
  type: 'pricesCompareException',
57
56
  data: props,
58
57
  text: `身份/到手价必须小于松果价`,
59
58
  });
60
59
  return getLastPassValidateState;
61
60
  } else {
62
61
  return true;
63
62
  }
64
63
  const numPrice = Number(strPrice);
65
64
  const result = numPrice.toString().match(/(\d+)(\.(\d+))?/);
66
65
  if (result) {
67
66
  return {
68
67
  integerPrice: result[1],
69
68
  decimalPrice: (result[3] || '').replace(/0+$/, ''),
70
69
  };
71
70
  } else {
72
71
  reportException({
73
72
  type: 'deconstructException',
74
73
  data: props,
75
74
  text: `解构传入价格字段值“${strPrice}”解构发生异常`,
76
75
  });
77
76
  return null;
78
77
  }
79
78
  const {
80
79
  jdPrice,
81
80
  finalPrice,
82
81
  priceText = '',
83
82
  priceTextColor = '',
84
83
  subPriceTextColor = '',
85
84
  subPriceColor = '',
86
85
  priceUnit = '',
87
86
  priceType,
88
87
  hitUserIdentity = false,
89
88
  forceShowFinalPrice = false,
90
89
  hideSmallPrice = false,
91
90
  fallbackRender = null,
92
91
  className = null,
93
92
  style = {},
94
93
  childrenClassName = null,
95
94
  bigNoPriceClassName = null,
96
95
  bigSymbolClassName = null,
97
96
  bigIntegerClassName = null,
98
97
  bigDecimalClassName = null,
99
98
  priceDescClassName = null,
100
99
  smallPriceClassName = null,
101
100
  smallPriceDescClassName = null,
102
101
  lineNumber = 1,
103
102
  size = 'M',
104
103
  isDefaultRemoveSmallPrice = false,
105
104
  useFontV2 = false,
106
105
  useFontV2Bold = false,
107
106
  useSmallFontV2 = false,
108
107
  useSmallFontV2Bold = false,
109
108
  nativeProps,
110
109
  } = props;
111
110
  let useBackstop = false;
112
111
  const isShowPriceUnit = priceUnit && priceUnit !== '';
113
112
  if (isNull(props.priceType)) {
114
113
  useBackstop = true;
115
114
  reportException({
116
115
  type: 'paramMiss',
117
116
  data: props,
118
117
  text: '缺少必要入参:priceType',
119
118
  });
120
119
  } else if (
121
120
  !allowedNoHitUserIdentityTypes.includes(props.priceType) &&
122
121
  props.hitUserIdentity === undefined
123
122
  ) {
124
123
  useBackstop = true;
125
124
  reportException({
126
125
  type: 'paramMiss',
127
126
  data: props,
128
127
  text: `价格类型${props.priceType}缺少必要入参:hitUserIdentity`,
129
128
  });
130
129
  }
131
130
  const especialHitStyleType = {
132
131
  7: 'plusStyle',
133
132
  9: 'samStyle',
134
133
  };
135
134
  const especialMissStyleType = {
136
135
  7: 'plusStyle',
137
136
  8: 'fansStyle',
138
137
  9: 'samStyle',
139
138
  10: 'studentStyle',
140
139
  12: 'yhdStyle',
141
140
  13: 'memberStyle',
142
141
  };
143
142
  const isUseFinalPriceAsBigPrice = allowedNoHitUserIdentityTypes.includes(priceType);
144
143
  const isEquivalentHit = isUseFinalPriceAsBigPrice || hitUserIdentity;
145
144
  const isOnlyShowBigPrice = priceType === 3 || isNull(finalPrice);
146
145
  const smallPrice = isEquivalentHit ? jdPrice : finalPrice;
147
146
  const isHideSmallPrice =
148
147
  hideSmallPrice || priceType === 14 || isDefaultRemoveSmallPrice || isNaN(Number(smallPrice));
149
148
  const isTextPrice = priceType === 4;
150
149
  if (!isTextPrice && !useBackstop) {
151
150
  if (finalPrice && !numericPriceValidate(finalPrice, props)) {
152
151
  useBackstop = true;
153
152
  } else if (jdPrice && !numericPriceValidate(jdPrice, props)) {
154
153
  useBackstop = true;
155
154
  }
156
155
  if (!useBackstop && !isOnlyShowBigPrice && !isHideSmallPrice && !pricesCompareValidate(props)) {
157
156
  useBackstop = true;
158
157
  }
159
158
  }
160
159
  const bigPriceObj =
161
160
  isTextPrice || useBackstop
162
161
  ? {}
163
162
  : getDeconstructPrice(isEquivalentHit && !isNull(finalPrice) ? finalPrice : jdPrice, props);
164
163
  const { integerPrice = '', decimalPrice = '' } = bigPriceObj || {};
165
164
  const isPriceDescInFront = isEquivalentHit;
166
165
  const hitColorStyle = isEquivalentHit ? styles[especialHitStyleType[priceType]] : null;
167
166
  const missColorStyle = isEquivalentHit ? null : styles[especialMissStyleType[priceType]];
168
167
  const isBigPriceHasDecimal = decimalPrice !== '' && !/^0+$/.test(decimalPrice);
169
168
  const sizeLineHeight = {
170
169
  XS: 28,
171
170
  S: 34,
172
171
  M: 40,
173
172
  L: 46,
174
173
  XL: 52,
175
174
  };
176
175
  const lineHeight = Taro.pxTransform(sizeLineHeight[size] * 1.25);
177
176
  const wrapHeight = Taro.pxTransform(sizeLineHeight[size] * 1.25 * lineNumber);
178
177
  const computedHeightStyle = {
179
178
  height: wrapHeight,
180
179
  };
181
180
  const itemCommonStyle = {
182
181
  height: lineHeight,
183
182
  };
184
183
  const bigPriceTextStyle = priceTextColor ? { color: priceTextColor } : {};
185
184
  const smallPriceTextStyle = subPriceTextColor ? { color: subPriceTextColor } : {};
186
185
  const smallPriceStyle = subPriceColor ? { color: subPriceColor } : {};
187
186
  const needSizeStyles = [
188
187
  'bigNoPrice',
189
188
  'bigSymbol',
190
189
  'bigInteger',
191
190
  'bigDecimal',
192
191
  'priceDesc',
193
192
  'smallPrice',
194
193
  'priceUnit',
195
194
  ];
196
195
  const sizeStyles = needSizeStyles.reduce((acc, cur) => {
197
196
  acc[cur] = styles[cur + size];
198
197
  return acc;
199
198
  }, {});
200
199
  const finalFallbackText = global?.languageJsonData?.noPriceTip || '暂无报价';
201
200
  const noPriceShowText =
202
201
  priceText || (/^[\u4e00-\u9fa5]+$/.test(jdPrice) ? jdPrice : finalFallbackText);
203
202
  if (useBackstop && fallbackRender) {
204
203
  return fallbackRender;
205
204
  }
206
205
  return (
207
206
  <View
208
207
  className={classNames(styles.wrap, className)}
209
208
  style={{ ...computedHeightStyle, ...style }}
210
209
  {...nativeProps}
211
210
  >
212
211
  {isTextPrice || useBackstop ? (
213
212
  <Text
214
213
  className={classNames(
215
214
  styles.childStyle,
216
215
  styles.bigStyle,
217
216
  styles.bigNoPrice,
218
217
  sizeStyles['bigNoPrice'],
219
218
  childrenClassName,
220
219
  bigNoPriceClassName,
221
220
  )}
222
221
  style={{ ...itemCommonStyle }}
223
222
  >
224
223
  {useBackstop ? finalFallbackText : noPriceShowText}
225
224
  </Text>
226
225
  ) : (
227
226
  [
228
227
  <Text
229
228
  className={classNames(
230
229
  styles.childStyle,
231
230
  styles.bigStyle,
232
231
  styles.bigSymbol,
233
232
  sizeStyles['bigSymbol'],
234
233
  hitColorStyle,
235
234
  childrenClassName,
236
235
  bigSymbolClassName,
237
236
  {
238
237
  [styles.fontV2]: useFontV2,
239
238
  [styles.fontV2Bold]: useFontV2Bold,
240
239
  },
241
240
  )}
242
241
  key="bigSymbol"
243
242
  style={{ ...itemCommonStyle }}
244
243
  >
245
244
  ¥
246
245
  </Text>,
247
246
  <Text
248
247
  className={classNames(
249
248
  styles.childStyle,
250
249
  styles.bigStyle,
251
250
  styles.bigInteger,
252
251
  sizeStyles['bigInteger'],
253
252
  hitColorStyle,
254
253
  !isOnlyShowBigPrice &&
255
254
  !isBigPriceHasDecimal &&
256
255
  !isPriceDescInFront &&
257
256
  !isShowPriceUnit
258
257
  ? styles.rightMargin
259
258
  : null,
260
259
  childrenClassName,
261
260
  bigIntegerClassName,
262
261
  {
263
262
  [styles.fontV2]: useFontV2,
264
263
  [styles.fontV2Bold]: useFontV2Bold,
265
264
  },
266
265
  )}
267
266
  key="bigInteger"
268
267
  style={{ ...itemCommonStyle }}
269
268
  >
270
269
  {integerPrice}
271
270
  </Text>,
272
271
  isBigPriceHasDecimal ? (
273
272
  <Text
274
273
  className={classNames(
275
274
  styles.childStyle,
276
275
  styles.bigStyle,
277
276
  styles.bigDecimal,
278
277
  sizeStyles['bigDecimal'],
279
278
  hitColorStyle,
280
279
  isPriceDescInFront || priceText === '' || isShowPriceUnit
281
280
  ? null
282
281
  : styles.rightMargin,
283
282
  childrenClassName,
284
283
  bigDecimalClassName,
285
284
  {
286
285
  [styles.fontV2]: useFontV2,
287
286
  [styles.fontV2Bold]: useFontV2Bold,
288
287
  },
289
288
  )}
290
289
  key="bigDecimal"
291
290
  style={{ ...itemCommonStyle }}
292
291
  >
293
292
  .{decimalPrice}
294
293
  </Text>
295
294
  ) : null,
296
295
  isShowPriceUnit ? (
297
296
  <Text
298
297
  className={classNames(
299
298
  styles.childStyle,
300
299
  styles.priceUnit,
301
300
  styles.rightMargin,
302
301
  sizeStyles['priceUnit'],
303
302
  styles.bigStyle,
304
303
  hitColorStyle,
305
304
  childrenClassName,
306
305
  priceDescClassName,
307
306
  )}
308
307
  key="descFrontUnit"
309
308
  style={{ ...itemCommonStyle }}
310
309
  >
311
310
  {priceUnit}
312
311
  </Text>
313
312
  ) : null,
314
313
  !isOnlyShowBigPrice && [
315
314
  isPriceDescInFront && (
316
315
  <Text
317
316
  className={classNames(
318
317
  styles.childStyle,
319
318
  styles.priceDesc,
320
319
  {
321
320
  [styles['priceEnDesc']]: isLanguageForEn,
322
321
  },
323
322
  {
324
323
  [styles['priceHiddenDesc']]: priceText === '',
325
324
  },
326
325
  sizeStyles['priceDesc'],
327
326
  styles.bigStyle,
328
327
  hitColorStyle,
329
328
  isPriceDescInFront && !isShowPriceUnit && !isHideSmallPrice
330
329
  ? styles.rightMargin
331
330
  : null,
332
331
  childrenClassName,
333
332
  priceDescClassName,
334
333
  )}
335
334
  key="descFront"
336
335
  style={{ ...itemCommonStyle, ...bigPriceTextStyle }}
337
336
  >
338
337
  {priceText === '' ? '_' : priceText}
339
338
  </Text>
340
339
  ),
341
340
  <View
342
341
  style={{
343
342
  display: 'inline-flex',
344
343
  }}
345
344
  >
346
345
  {smallPrice && !isHideSmallPrice ? (
347
346
  <Text
348
347
  className={classNames(
349
348
  styles.childStyle,
350
349
  styles.smallPrice,
351
350
  sizeStyles['smallPrice'],
352
351
  styles.smallStyle,
353
352
  missColorStyle,
354
353
  childrenClassName,
355
354
  smallPriceClassName,
356
355
  {
357
356
  [styles.fontV2]: useSmallFontV2Bold ? false : useSmallFontV2 || useFontV2,
358
357
  [styles.fontV2Bold]: useSmallFontV2
359
358
  ? false
360
359
  : useSmallFontV2Bold || useFontV2Bold,
361
360
  },
362
361
  )}
363
362
  key="smallPrice"
364
363
  style={{ ...itemCommonStyle, ...smallPriceStyle }}
365
364
  >
366
365
  ¥{Number(smallPrice)}
367
366
  </Text>
368
367
  ) : null}
369
368
  {isShowPriceUnit && !isHideSmallPrice ? (
370
369
  <Text
371
370
  className={classNames(
372
371
  styles.childStyle,
373
372
  styles.priceUnit,
374
373
  sizeStyles['priceUnit'],
375
374
  styles.smallStyle,
376
375
  styles.missPriceDesc,
377
376
  missColorStyle,
378
377
  childrenClassName,
379
378
  smallPriceDescClassName || priceDescClassName,
380
379
  )}
381
380
  key="descFrontUnit"
382
381
  style={{ ...itemCommonStyle, ...smallPriceStyle }}
383
382
  >
384
383
  {priceUnit}
385
384
  </Text>
386
385
  ) : null}
387
386
  {!isPriceDescInFront && !isHideSmallPrice && (
388
387
  <Text
389
388
  className={classNames(
390
389
  styles.childStyle,
391
390
  styles.priceDesc,
392
391
  {
393
392
  [styles['priceEnDesc']]: isLanguageForEn,
394
393
  },
395
394
  {
396
395
  [styles['priceHiddenDesc']]: priceText === '',
397
396
  },
398
397
  sizeStyles['priceDesc'],
399
398
  styles.smallStyle,
400
399
  styles.missPriceDesc,
401
400
  missColorStyle,
402
401
  childrenClassName,
403
402
  smallPriceDescClassName || priceDescClassName,
404
403
  )}
405
404
  key="descBack"
406
405
  style={{ ...itemCommonStyle, ...smallPriceTextStyle }}
407
406
  >
408
407
  {priceText === '' ? '_' : priceText}
409
408
  </Text>
410
409
  )}
411
410
  </View>,
412
411
  ],
413
412
  ]
414
413
  )}
415
414
  </View>
416
415
  );
416
+ import React from 'react';
417
417
  console.warn('🚗 ~~ file: index.tsx:22 ~~ reportException() ~~ {type, detail, text}:', {
418
418
  type,
419
419
  data,
420
420
  text,
421
421
  });
422
422
  if(isH5 && global?.info?.pageInfo?.dataType === BUSINESS_TYPE.ONLINE){
423
423
  draBusinessCustomReport({
424
424
  eventName: 'business',
425
425
  errorName: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_${type}`),
426
426
  errorMessage: '[双价格组件]' + text,
427
427
  extraData: JSON.stringify({
428
428
  type,
429
429
  data,
430
430
  }),
431
431
  });
432
432
  }
433
433
  return rest.some((item) => item === undefined || item === '');
434
434
  const numPrice = Number(strPrice);
435
435
  if (isNaN(numPrice)) {
436
436
  reportException({
437
437
  type: 'isNotNumericType',
438
438
  data: props,
439
439
  text: `传入价格字段值“${strPrice}”转换数字报错`,
440
440
  });
441
441
  return false;
442
442
  }
443
443
  else if (numPrice <= 0) {
444
444
  reportException({
445
445
  type: 'isNotPositiveNumber',
446
446
  data: props,
447
447
  text: `传入价格字段值“${strPrice}”不是一个正数`,
448
448
  });
449
449
  return false;
450
450
  }
451
451
  const result = numPrice.toString().match(/(\d+)(\.(\d+))?/);
452
452
  if (result && result[3]?.length > 2) {
453
453
  reportException({
454
454
  type: 'decimalPlaceTooLong',
455
455
  data: props,
456
456
  text: `传入价格字段值“${strPrice}”小数位不能超过2位`,
457
457
  });
458
458
  return false;
459
459
  }
460
460
  if (/^\d+(\.\d+)?[eE][+-]?\d+$/.test(strPrice)) {
461
461
  reportException({
462
462
  type: 'findScientificNotation',
463
463
  data: props,
464
464
  text: `传入价格字段值“${strPrice}”是一个科学计数法格式`,
465
465
  });
466
466
  }
467
467
  return true;
468
468
  const { jdPrice, finalPrice, forceShowFinalPrice } = props;
469
469
  if (jdPrice && finalPrice) {
470
470
  const getLastPassValidateState = forceShowFinalPrice || Number(finalPrice) < Number(jdPrice);
471
471
  !getLastPassValidateState &&
472
472
  reportException({
473
473
  type: 'pricesCompareException',
474
474
  data: props,
475
475
  text: `身份/到手价必须小于松果价`,
476
476
  });
477
477
  return getLastPassValidateState;
478
478
  } else {
479
479
  return true;
480
480
  }
481
481
  const numPrice = Number(strPrice);
482
482
  const result = numPrice.toString().match(/(\d+)(\.(\d+))?/);
483
483
  if (result) {
484
484
  return {
485
485
  integerPrice: result[1],
486
486
  decimalPrice: (result[3] || '').replace(/0+$/, ''),
487
487
  };
488
488
  } else {
489
489
  reportException({
490
490
  type: 'deconstructException',
491
491
  data: props,
492
492
  text: `解构传入价格字段值“${strPrice}”解构发生异常`,
493
493
  });
494
494
  return null;
495
495
  }
496
496
  const {
497
497
  jdPrice,
498
498
  finalPrice,
499
499
  priceText = '',
500
500
  priceTextColor = '',
501
501
  subPriceTextColor = '',
502
502
  subPriceColor = '',
503
503
  priceUnit = '',
504
504
  priceType,
505
505
  hitUserIdentity = false,
506
506
  forceShowFinalPrice = false,
507
507
  hideSmallPrice = false,
508
508
  fallbackRender = null,
509
509
  className = null,
510
510
  style = {},
511
511
  childrenClassName = null,
512
512
  bigNoPriceClassName = null,
513
513
  bigSymbolClassName = null,
514
514
  bigIntegerClassName = null,
515
515
  bigDecimalClassName = null,
516
516
  priceDescClassName = null,
517
517
  smallPriceClassName = null,
518
518
  smallPriceDescClassName = null,
519
519
  lineNumber = 1,
520
520
  size = 'M',
521
521
  isDefaultRemoveSmallPrice = false,
522
522
  useFontV2 = false,
523
523
  useFontV2Bold = false,
524
524
  useSmallFontV2 = false,
525
525
  useSmallFontV2Bold = false,
526
526
  nativeProps,
527
527
  } = props;
528
528
  let useBackstop = false;
529
529
  const isShowPriceUnit = priceUnit && priceUnit !== '';
530
530
  if (isNull(props.priceType)) {
531
531
  useBackstop = true;
532
532
  reportException({
533
533
  type: 'paramMiss',
534
534
  data: props,
535
535
  text: '缺少必要入参:priceType',
536
536
  });
537
537
  } else if (
538
538
  !allowedNoHitUserIdentityTypes.includes(props.priceType) &&
539
539
  props.hitUserIdentity === undefined
540
540
  ) {
541
541
  useBackstop = true;
542
542
  reportException({
543
543
  type: 'paramMiss',
544
544
  data: props,
545
545
  text: `价格类型${props.priceType}缺少必要入参:hitUserIdentity`,
546
546
  });
547
547
  }
548
548
  const especialHitStyleType = {
549
549
  7: 'plusStyle',
550
550
  9: 'samStyle',
551
551
  };
552
552
  const especialMissStyleType = {
553
553
  7: 'plusStyle',
554
554
  8: 'fansStyle',
555
555
  9: 'samStyle',
556
556
  10: 'studentStyle',
557
557
  12: 'yhdStyle',
558
558
  13: 'memberStyle',
559
559
  };
560
560
  const isUseFinalPriceAsBigPrice = allowedNoHitUserIdentityTypes.includes(priceType);
561
561
  const isEquivalentHit = isUseFinalPriceAsBigPrice || hitUserIdentity;
562
562
  const isOnlyShowBigPrice = priceType === 3 || isNull(finalPrice);
563
563
  const smallPrice = isEquivalentHit ? jdPrice : finalPrice;
564
564
  const isHideSmallPrice =
565
565
  hideSmallPrice || priceType === 14 || isDefaultRemoveSmallPrice || isNaN(Number(smallPrice));
566
566
  const isTextPrice = priceType === 4;
567
567
  if (!isTextPrice && !useBackstop) {
568
568
  if (finalPrice && !numericPriceValidate(finalPrice, props)) {
569
569
  useBackstop = true;
570
570
  } else if (jdPrice && !numericPriceValidate(jdPrice, props)) {
571
571
  useBackstop = true;
572
572
  }
573
573
  if (!useBackstop && !isOnlyShowBigPrice && !isHideSmallPrice && !pricesCompareValidate(props)) {
574
574
  useBackstop = true;
575
575
  }
576
576
  }
577
577
  const bigPriceObj =
578
578
  isTextPrice || useBackstop
579
579
  ? {}
580
580
  : getDeconstructPrice(isEquivalentHit && !isNull(finalPrice) ? finalPrice : jdPrice, props);
581
581
  const { integerPrice = '', decimalPrice = '' } = bigPriceObj || {};
582
582
  const isPriceDescInFront = isEquivalentHit;
583
583
  const hitColorStyle = isEquivalentHit ? styles[especialHitStyleType[priceType]] : null;
584
584
  const missColorStyle = isEquivalentHit ? null : styles[especialMissStyleType[priceType]];
585
585
  const isBigPriceHasDecimal = decimalPrice !== '' && !/^0+$/.test(decimalPrice);
586
586
  const sizeLineHeight = {
587
587
  XS: 28,
588
588
  S: 34,
589
589
  M: 40,
590
590
  L: 46,
591
591
  XL: 52,
592
592
  };
593
593
  const lineHeight = Taro.pxTransform(sizeLineHeight[size] * 1.25);
594
594
  const wrapHeight = Taro.pxTransform(sizeLineHeight[size] * 1.25 * lineNumber);
595
595
  const computedHeightStyle = {
596
596
  height: wrapHeight,
597
597
  };
598
598
  const itemCommonStyle = {
599
599
  height: lineHeight,
600
600
  };
601
601
  const bigPriceTextStyle = priceTextColor ? { color: priceTextColor } : {};
602
602
  const smallPriceTextStyle = subPriceTextColor ? { color: subPriceTextColor } : {};
603
603
  const smallPriceStyle = subPriceColor ? { color: subPriceColor } : {};
604
604
  const needSizeStyles = [
605
605
  'bigNoPrice',
606
606
  'bigSymbol',
607
607
  'bigInteger',
608
608
  'bigDecimal',
609
609
  'priceDesc',
610
610
  'smallPrice',
611
611
  'priceUnit',
612
612
  ];
613
613
  const sizeStyles = needSizeStyles.reduce((acc, cur) => {
614
614
  acc[cur] = styles[cur + size];
615
615
  return acc;
616
616
  }, {});
617
617
  const finalFallbackText = global?.languageJsonData?.noPriceTip || '暂无报价';
618
618
  const noPriceShowText =
619
619
  priceText || (/^[\u4e00-\u9fa5]+$/.test(jdPrice) ? jdPrice : finalFallbackText);
620
620
  if (useBackstop && fallbackRender) {
621
621
  return fallbackRender;
622
622
  }
623
623
  return (
624
624
  <View
625
625
  className={classNames(styles.wrap, className)}
626
626
  style={{ ...computedHeightStyle, ...style }}
627
627
  {...nativeProps}
628
628
  >
629
629
  {isTextPrice || useBackstop ? (
630
630
  <Text
631
631
  className={classNames(
632
632
  styles.childStyle,
633
633
  styles.bigStyle,
634
634
  styles.bigNoPrice,
635
635
  sizeStyles['bigNoPrice'],
636
636
  childrenClassName,
637
637
  bigNoPriceClassName,
638
638
  )}
639
639
  style={{ ...itemCommonStyle }}
640
640
  >
641
641
  {useBackstop ? finalFallbackText : noPriceShowText}
642
642
  </Text>
643
643
  ) : (
644
644
  [
645
645
  <Text
646
646
  className={classNames(
647
647
  styles.childStyle,
648
648
  styles.bigStyle,
649
649
  styles.bigSymbol,
650
650
  sizeStyles['bigSymbol'],
651
651
  hitColorStyle,
652
652
  childrenClassName,
653
653
  bigSymbolClassName,
654
654
  {
655
655
  [styles.fontV2]: useFontV2,
656
656
  [styles.fontV2Bold]: useFontV2Bold,
657
657
  },
658
658
  )}
659
659
  key="bigSymbol"
660
660
  style={{ ...itemCommonStyle }}
661
661
  >
662
662
  ¥
663
663
  </Text>,
664
664
  <Text
665
665
  className={classNames(
666
666
  styles.childStyle,
667
667
  styles.bigStyle,
668
668
  styles.bigInteger,
669
669
  sizeStyles['bigInteger'],
670
670
  hitColorStyle,
671
671
  !isOnlyShowBigPrice &&
672
672
  !isBigPriceHasDecimal &&
673
673
  !isPriceDescInFront &&
674
674
  !isShowPriceUnit
675
675
  ? styles.rightMargin
676
676
  : null,
677
677
  childrenClassName,
678
678
  bigIntegerClassName,
679
679
  {
680
680
  [styles.fontV2]: useFontV2,
681
681
  [styles.fontV2Bold]: useFontV2Bold,
682
682
  },
683
683
  )}
684
684
  key="bigInteger"
685
685
  style={{ ...itemCommonStyle }}
686
686
  >
687
687
  {integerPrice}
688
688
  </Text>,
689
689
  isBigPriceHasDecimal ? (
690
690
  <Text
691
691
  className={classNames(
692
692
  styles.childStyle,
693
693
  styles.bigStyle,
694
694
  styles.bigDecimal,
695
695
  sizeStyles['bigDecimal'],
696
696
  hitColorStyle,
697
697
  isPriceDescInFront || priceText === '' || isShowPriceUnit
698
698
  ? null
699
699
  : styles.rightMargin,
700
700
  childrenClassName,
701
701
  bigDecimalClassName,
702
702
  {
703
703
  [styles.fontV2]: useFontV2,
704
704
  [styles.fontV2Bold]: useFontV2Bold,
705
705
  },
706
706
  )}
707
707
  key="bigDecimal"
708
708
  style={{ ...itemCommonStyle }}
709
709
  >
710
710
  .{decimalPrice}
711
711
  </Text>
712
712
  ) : null,
713
713
  isShowPriceUnit ? (
714
714
  <Text
715
715
  className={classNames(
716
716
  styles.childStyle,
717
717
  styles.priceUnit,
718
718
  styles.rightMargin,
719
719
  sizeStyles['priceUnit'],
720
720
  styles.bigStyle,
721
721
  hitColorStyle,
722
722
  childrenClassName,
723
723
  priceDescClassName,
724
724
  )}
725
725
  key="descFrontUnit"
726
726
  style={{ ...itemCommonStyle }}
727
727
  >
728
728
  {priceUnit}
729
729
  </Text>
730
730
  ) : null,
731
731
  !isOnlyShowBigPrice && [
732
732
  isPriceDescInFront && (
733
733
  <Text
734
734
  className={classNames(
735
735
  styles.childStyle,
736
736
  styles.priceDesc,
737
737
  {
738
738
  [styles['priceEnDesc']]: isLanguageForEn,
739
739
  },
740
740
  {
741
741
  [styles['priceHiddenDesc']]: priceText === '',
742
742
  },
743
743
  sizeStyles['priceDesc'],
744
744
  styles.bigStyle,
745
745
  hitColorStyle,
746
746
  isPriceDescInFront && !isShowPriceUnit && !isHideSmallPrice
747
747
  ? styles.rightMargin
748
748
  : null,
749
749
  childrenClassName,
750
750
  priceDescClassName,
751
751
  )}
752
752
  key="descFront"
753
753
  style={{ ...itemCommonStyle, ...bigPriceTextStyle }}
754
754
  >
755
755
  {priceText === '' ? '_' : priceText}
756
756
  </Text>
757
757
  ),
758
758
  <View
759
759
  style={{
760
760
  display: 'inline-flex',
761
761
  }}
762
762
  >
763
763
  {smallPrice && !isHideSmallPrice ? (
764
764
  <Text
765
765
  className={classNames(
766
766
  styles.childStyle,
767
767
  styles.smallPrice,
768
768
  sizeStyles['smallPrice'],
769
769
  styles.smallStyle,
770
770
  missColorStyle,
771
771
  childrenClassName,
772
772
  smallPriceClassName,
773
773
  {
774
774
  [styles.fontV2]: useSmallFontV2Bold ? false : useSmallFontV2 || useFontV2,
775
775
  [styles.fontV2Bold]: useSmallFontV2
776
776
  ? false
777
777
  : useSmallFontV2Bold || useFontV2Bold,
778
778
  },
779
779
  )}
780
780
  key="smallPrice"
781
781
  style={{ ...itemCommonStyle, ...smallPriceStyle }}
782
782
  >
783
783
  ¥{Number(smallPrice)}
784
784
  </Text>
785
785
  ) : null}
786
786
  {isShowPriceUnit && !isHideSmallPrice ? (
787
787
  <Text
788
788
  className={classNames(
789
789
  styles.childStyle,
790
790
  styles.priceUnit,
791
791
  sizeStyles['priceUnit'],
792
792
  styles.smallStyle,
793
793
  styles.missPriceDesc,
794
794
  missColorStyle,
795
795
  childrenClassName,
796
796
  smallPriceDescClassName || priceDescClassName,
797
797
  )}
798
798
  key="descFrontUnit"
799
799
  style={{ ...itemCommonStyle, ...smallPriceStyle }}
800
800
  >
801
801
  {priceUnit}
802
802
  </Text>
803
803
  ) : null}
804
804
  {!isPriceDescInFront && !isHideSmallPrice && (
805
805
  <Text
806
806
  className={classNames(
807
807
  styles.childStyle,
808
808
  styles.priceDesc,
809
809
  {
810
810
  [styles['priceEnDesc']]: isLanguageForEn,
811
811
  },
812
812
  {
813
813
  [styles['priceHiddenDesc']]: priceText === '',
814
814
  },
815
815
  sizeStyles['priceDesc'],
816
816
  styles.smallStyle,
817
817
  styles.missPriceDesc,
818
818
  missColorStyle,
819
819
  childrenClassName,
820
820
  smallPriceDescClassName || priceDescClassName,
821
821
  )}
822
822
  key="descBack"
823
823
  style={{ ...itemCommonStyle, ...smallPriceTextStyle }}
824
824
  >
825
825
  {priceText === '' ? '_' : priceText}
826
826
  </Text>
827
827
  )}
828
828
  </View>,
829
829
  ],
830
830
  ]
831
831
  )}
832
832
  </View>
833
833
  );