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

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