@conecli/cone-render 0.10.1-shop-beta.23 → 0.10.1-shop-beta.26

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