@conecli/cone-render 0.10.1-shop3.43 → 0.10.1-shop3.44

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