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