@conecli/cone-render 0.10.1-shop3.122 → 0.10.1-shop3.124

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