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