@conecli/cone-render 0.10.1-shop3.136 → 0.10.1-shop3.138

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