@conecli/cone-render 0.10.1-shop3.26 → 0.10.1-shop3.27

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,6 +1,7 @@
1
1
 
2
2
  :global {
3
3
  .d-mini-price {
4
+ --after-ele-color: '';
4
5
  position: relative;
5
6
  color: #f23030;
6
7
  display: inline-block;
@@ -67,6 +68,11 @@
67
68
  margin-left: 8px;
68
69
  }
69
70
  }
71
+ &.d-price-text-clor {
72
+ &:after {
73
+ color: var(--after-ele-color) !important;
74
+ }
75
+ }
70
76
  &.d-plus-price {
71
77
  .int-txt,
72
78
  .sym-sub,
@@ -1 +1 @@
1
- import React from 'react';
2
1
  let value = `${initValue}`;
3
2
  if (!cnPriceTextList.includes(value)) {
4
3
  if (value && !/^[0123456789-]*$/.test(value.substring(0, 1))) {
5
4
  symbol = value.substring(0, 1);
6
5
  value = value.substring(1);
7
6
  }
8
7
  if (/^\d+(\.\d+)?[eE][+-]?\d+$/.test(value)) {
9
8
  sgmCustomReport({
10
9
  code: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
11
10
  msg: {
12
11
  price: value,
13
12
  originalPrice: initValue,
14
13
  msg: '当前价格为科学计数数据,上报关注该价格',
15
14
  },
16
15
  });
17
16
  }
18
17
  if (!decToIntegerState) {
19
18
  value = parseFloat(value).toFixed(decLength);
20
19
  } else {
21
20
  if (value.indexOf('.') !== -1) {
22
21
  value = parseFloat(value).toFixed(decLength);
23
22
  value = `${value}`.replace(/0+$/, '');
24
23
  }
25
24
  }
26
25
  if (value === 'NaN') {
27
26
  sgmCustomReport({
28
27
  code: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
29
28
  msg: {
30
29
  price: value,
31
30
  originalPrice: initValue,
32
31
  msg: '价格转换异常,兜底展示暂无报价',
33
32
  },
34
33
  });
35
34
  value = '暂无报价';
36
35
  }
37
36
  }
38
37
  const [intVal, decimalVal] = `${value}`.split('.');
39
38
  return {
40
39
  currencySymbol: !cnPriceTextList.includes(intVal) ? symbol : '',
41
40
  intVal,
42
41
  decimalVal,
43
42
  };
44
43
  const {
45
44
  prefixCls,
46
45
  symPos,
47
46
  symbol,
48
47
  decPos,
49
48
  status,
50
49
  className,
51
50
  style,
52
51
  symClassName,
53
52
  intClassName,
54
53
  decClassName,
55
54
  noPriceClassName,
56
55
  value,
57
56
  decLength,
58
57
  decToIntegerState,
59
58
  isPlusPrice,
60
59
  isSamsPrice,
61
60
  isMemberPrice,
62
61
  isSfpPrice,
63
62
  memberPriceIcon,
64
63
  isShowPriceLabel,
65
64
  priceLabelText,
66
65
  useFontV2 = false,
67
66
  useFontV2Bold = false,
68
67
  } = props;
69
68
  const cls = classNames(
70
69
  className ? `${className}` : '',
71
70
  prefixCls,
72
71
  {
73
72
  'd-font-v2': useFontV2,
74
73
  'd-font-v2-bold': useFontV2Bold,
75
74
  },
76
75
  'd-imag-rendering-crisp-edges',
77
76
  {
78
77
  del: status === 'del',
79
78
  },
80
79
  {
81
80
  'd-plus-price': isPlusPrice,
82
81
  },
83
82
  {
84
83
  'd-sams-price': isSamsPrice,
85
84
  },
86
85
  {
87
86
  'd-sfp-price': isSfpPrice,
88
87
  },
89
88
  {
90
89
  'd-member-price': isMemberPrice,
91
90
  },
92
91
  {
93
92
  [`d-member-price-${memberPriceIcon}`]: memberPriceIcon,
94
93
  },
95
94
  {
96
95
  'd-price-label': isShowPriceLabel,
97
96
  },
98
97
  );
99
98
  const symCls = classNames(symClassName ? `${symClassName}` : '', {
100
99
  'sym-sub': symPos === 'sub',
101
100
  'sym-sup': symPos === 'sup',
102
101
  });
103
102
  const intCls = classNames(intClassName ? `${intClassName}` : '');
104
103
  const decCls = classNames(decClassName ? `${decClassName}` : '', {
105
104
  'dec-sub': decPos === 'sub',
106
105
  'dec-sup': decPos === 'sup',
107
106
  });
108
107
  const noPriceCls = classNames(noPriceClassName ? `${noPriceClassName}` : '');
109
108
  const { currencySymbol, intVal, decimalVal } = dealPrice(
110
109
  value,
111
110
  decLength,
112
111
  symbol,
113
112
  decToIntegerState,
114
113
  );
115
114
  return (
116
115
  <View className={cls} style={style} data-after={isShowPriceLabel ? priceLabelText : ''}>
117
116
  {intVal === '-1' ? (
118
117
  <Text className={`${prefixCls}-txt int-txt off-shelf ${noPriceCls}`}>{`暂无报价`}</Text>
119
118
  ) : (
120
119
  <>
121
120
  <Text className={`${prefixCls}-sym ${symCls}`}>{currencySymbol}</Text>
122
121
  <Text className={`${prefixCls}-txt int-txt ${intCls}`}>{intVal}</Text>
123
122
  {!!decimalVal && (
124
123
  <Text className={`${prefixCls}-txt dec-txt ${decCls}`}>.{decimalVal}</Text>
125
124
  )}
126
125
  </>
127
126
  )}
128
127
  </View>
129
128
  );
130
129
  prefixCls: 'd-mini-price',
131
130
  style: {},
132
131
  status: '',
133
132
  symbol: '¥',
134
133
  symPos: 'sub',
135
134
  decLength: 2,
136
135
  decPos: 'sub',
137
136
  decToIntegerState: false,
138
137
  isPlusPrice: false,
139
138
  isShowPriceLabel: false,
140
139
  priceLabelText: '到手价',
141
140
  useFontV2: false,
142
141
  useFontV2Bold: false,
142
+ import React, { useEffect, useRef } from 'react';
143
143
  let value = `${initValue}`;
144
144
  if (!cnPriceTextList.includes(value)) {
145
145
  if (value && !/^[0123456789-]*$/.test(value.substring(0, 1))) {
146
146
  symbol = value.substring(0, 1);
147
147
  value = value.substring(1);
148
148
  }
149
149
  if (/^\d+(\.\d+)?[eE][+-]?\d+$/.test(value)) {
150
150
  sgmCustomReport({
151
151
  code: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
152
152
  msg: {
153
153
  price: value,
154
154
  originalPrice: initValue,
155
155
  msg: '当前价格为科学计数数据,上报关注该价格',
156
156
  },
157
157
  });
158
158
  }
159
159
  if (!decToIntegerState) {
160
160
  value = parseFloat(value).toFixed(decLength);
161
161
  } else {
162
162
  if (value.indexOf('.') !== -1) {
163
163
  value = parseFloat(value).toFixed(decLength);
164
164
  value = `${value}`.replace(/0+$/, '');
165
165
  }
166
166
  }
167
167
  if (value === 'NaN') {
168
168
  sgmCustomReport({
169
169
  code: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
170
170
  msg: {
171
171
  price: value,
172
172
  originalPrice: initValue,
173
173
  msg: '价格转换异常,兜底展示暂无报价',
174
174
  },
175
175
  });
176
176
  value = '暂无报价';
177
177
  }
178
178
  }
179
179
  const [intVal, decimalVal] = `${value}`.split('.');
180
180
  return {
181
181
  currencySymbol: !cnPriceTextList.includes(intVal) ? symbol : '',
182
182
  intVal,
183
183
  decimalVal,
184
184
  };
185
185
  const {
186
186
  prefixCls,
187
187
  symPos,
188
188
  symbol,
189
189
  decPos,
190
190
  status,
191
191
  className,
192
192
  style,
193
193
  symClassName,
194
194
  intClassName,
195
195
  decClassName,
196
196
  noPriceClassName,
197
197
  value,
198
198
  decLength,
199
199
  decToIntegerState,
200
200
  isPlusPrice,
201
201
  isSamsPrice,
202
202
  isMemberPrice,
203
203
  isSfpPrice,
204
204
  memberPriceIcon,
205
205
  isShowPriceLabel,
206
206
  priceLabelText,
207
207
  priceTextColor,
208
208
  useFontV2 = false,
209
209
  useFontV2Bold = false,
210
210
  } = props;
211
211
  const cRef = useRef<any>(null);
212
212
  useEffect(() => {
213
213
  if (isShowPriceLabel && priceTextColor && cRef.current) {
214
214
  cRef.current?.style?.setProperty('--after-ele-color', priceTextColor);
215
215
  }
216
216
  }, [isShowPriceLabel, priceTextColor]);
217
217
  const cls = classNames(
218
218
  className ? `${className}` : '',
219
219
  prefixCls,
220
220
  {
221
221
  'd-font-v2': useFontV2,
222
222
  'd-font-v2-bold': useFontV2Bold,
223
223
  },
224
224
  'd-imag-rendering-crisp-edges',
225
225
  {
226
226
  del: status === 'del',
227
227
  },
228
228
  {
229
229
  'd-plus-price': isPlusPrice,
230
230
  },
231
231
  {
232
232
  'd-sams-price': isSamsPrice,
233
233
  },
234
234
  {
235
235
  'd-sfp-price': isSfpPrice,
236
236
  },
237
237
  {
238
238
  'd-member-price': isMemberPrice,
239
239
  },
240
240
  {
241
241
  [`d-member-price-${memberPriceIcon}`]: memberPriceIcon,
242
242
  },
243
243
  {
244
244
  'd-price-label': isShowPriceLabel,
245
245
  },
246
246
  {
247
247
  'd-price-text-clor': isShowPriceLabel && priceTextColor,
248
248
  },
249
249
  );
250
250
  const symCls = classNames(symClassName ? `${symClassName}` : '', {
251
251
  'sym-sub': symPos === 'sub',
252
252
  'sym-sup': symPos === 'sup',
253
253
  });
254
254
  const intCls = classNames(intClassName ? `${intClassName}` : '');
255
255
  const decCls = classNames(decClassName ? `${decClassName}` : '', {
256
256
  'dec-sub': decPos === 'sub',
257
257
  'dec-sup': decPos === 'sup',
258
258
  });
259
259
  const noPriceCls = classNames(noPriceClassName ? `${noPriceClassName}` : '');
260
260
  const { currencySymbol, intVal, decimalVal } = dealPrice(
261
261
  value,
262
262
  decLength,
263
263
  symbol,
264
264
  decToIntegerState,
265
265
  );
266
266
  return (
267
267
  <View
268
268
  ref={cRef}
269
269
  className={cls}
270
270
  style={style}
271
271
  data-after={isShowPriceLabel ? priceLabelText : ''}
272
272
  >
273
273
  {intVal === '-1' ? (
274
274
  <Text className={`${prefixCls}-txt int-txt off-shelf ${noPriceCls}`}>{`暂无报价`}</Text>
275
275
  ) : (
276
276
  <>
277
277
  <Text className={`${prefixCls}-sym ${symCls}`}>{currencySymbol}</Text>
278
278
  <Text className={`${prefixCls}-txt int-txt ${intCls}`}>{intVal}</Text>
279
279
  {!!decimalVal && (
280
280
  <Text className={`${prefixCls}-txt dec-txt ${decCls}`}>.{decimalVal}</Text>
281
281
  )}
282
282
  </>
283
283
  )}
284
284
  </View>
285
285
  );
286
286
  prefixCls: 'd-mini-price',
287
287
  style: {},
288
288
  status: '',
289
289
  symbol: '¥',
290
290
  symPos: 'sub',
291
291
  decLength: 2,
292
292
  decPos: 'sub',
293
293
  decToIntegerState: false,
294
294
  isPlusPrice: false,
295
295
  isShowPriceLabel: false,
296
296
  priceLabelText: '到手价',
297
297
  priceTextColor: '',
298
298
  useFontV2: false,
299
299
  useFontV2Bold: false,
@@ -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
  );
@@ -1 +1 @@
1
- import React from 'react'
2
1
  subMessage?: string
3
2
  netWorkStyleType?: string
4
3
  viewMaxHeight?: string
5
4
  noPosition?: boolean
6
5
  floorLoadWay?: number
7
6
  floorKind?: number
8
7
  shopId?: string
9
8
  moduleDesignerType?: string
10
9
  showCommonFloorHead?: boolean
11
10
  borderRadius: number
12
11
  borderTopLeftRadius?: number
13
12
  borderTopRightRadius?: number
14
13
  borderBottomLeftRadius?: number
15
14
  borderBottomRightRadius?: number
16
15
  marginTop?: number
17
16
  marginBottom?: number
18
17
  marginLeft?: number
19
18
  marginRight?: number
20
19
  paddingTop?: number
21
20
  paddingBottom?: number
22
21
  paddingLeft?: number
23
22
  paddingRight?: number
24
23
  containerId: string
25
24
  background?: string
26
25
  containerPosition?: string
27
26
  key?: string
28
27
  floors: floorItemData[]
29
28
  includeUids: string[]
30
29
  typeCn: string
31
30
  typeCode?: string
32
31
  addLuxuryStyle?: boolean
33
32
  addLuxuryBackupStyle?: boolean
34
33
  renderExtendComponent?: functionType
35
34
  insertContainerStartComponent?: functionType
36
35
  floorExtendData?: any
37
36
  }
38
37
  isRealTimeRender: boolean
39
38
  forceRenderTime: number
40
39
  luxuryFixed?: boolean
41
40
  customErrorIsvFloorModule?: React.ReactElement | undefined
42
41
  containerIndex?: number
43
42
  containerData?: any
44
43
  shopTotalInfo?: any
45
44
  selectContainerFn?: functionType
46
45
  selectContainerId?: string
47
46
  placeHolderPreContainerId?: string
48
47
  children?: any
49
48
  luxuryFixed?: boolean
50
49
  style?: {
51
50
  [key: string]: any
52
51
  };
53
52
  layoutLeftRightMargin?: number
54
53
  }
55
54
  isShowPlaceHolder?: boolean
56
55
 
57
56
  useFontV2?: boolean
58
57
  useFontV2Bold?: boolean
59
58
  onlyShowDaySpaceTextState?: boolean
60
59
  showDayToSecondState?: boolean
61
60
  useFontV2: boolean
62
61
  useFontV2Bold: boolean
63
62
  onFormSubmit?: functionType
64
63
  onFormReset?: functionType
65
64
  isFormDialog?: boolean
66
65
  forbiddenBgScrollState?: boolean
67
66
  evenList: any[]
68
67
  oddList: any[]
68
+ import React from 'react'
69
69
  subMessage?: string
70
70
  netWorkStyleType?: string
71
71
  viewMaxHeight?: string
72
72
  noPosition?: boolean
73
73
  floorLoadWay?: number
74
74
  floorKind?: number
75
75
  shopId?: string
76
76
  moduleDesignerType?: string
77
77
  showCommonFloorHead?: boolean
78
78
  borderRadius: number
79
79
  borderTopLeftRadius?: number
80
80
  borderTopRightRadius?: number
81
81
  borderBottomLeftRadius?: number
82
82
  borderBottomRightRadius?: number
83
83
  marginTop?: number
84
84
  marginBottom?: number
85
85
  marginLeft?: number
86
86
  marginRight?: number
87
87
  paddingTop?: number
88
88
  paddingBottom?: number
89
89
  paddingLeft?: number
90
90
  paddingRight?: number
91
91
  containerId: string
92
92
  background?: string
93
93
  containerPosition?: string
94
94
  key?: string
95
95
  floors: floorItemData[]
96
96
  includeUids: string[]
97
97
  typeCn: string
98
98
  typeCode?: string
99
99
  addLuxuryStyle?: boolean
100
100
  addLuxuryBackupStyle?: boolean
101
101
  renderExtendComponent?: functionType
102
102
  insertContainerStartComponent?: functionType
103
103
  floorExtendData?: any
104
104
  }
105
105
  isRealTimeRender: boolean
106
106
  forceRenderTime: number
107
107
  luxuryFixed?: boolean
108
108
  customErrorIsvFloorModule?: React.ReactElement | undefined
109
109
  containerIndex?: number
110
110
  containerData?: any
111
111
  shopTotalInfo?: any
112
112
  selectContainerFn?: functionType
113
113
  selectContainerId?: string
114
114
  placeHolderPreContainerId?: string
115
115
  children?: any
116
116
  luxuryFixed?: boolean
117
117
  style?: {
118
118
  [key: string]: any
119
119
  };
120
120
  layoutLeftRightMargin?: number
121
121
  }
122
122
  isShowPlaceHolder?: boolean
123
123
 
124
124
  useFontV2?: boolean
125
125
  useFontV2Bold?: boolean
126
126
  onlyShowDaySpaceTextState?: boolean
127
127
  showDayToSecondState?: boolean
128
128
  useFontV2: boolean
129
129
  useFontV2Bold: boolean
130
130
  onFormSubmit?: functionType
131
131
  onFormReset?: functionType
132
132
  isFormDialog?: boolean
133
133
  forbiddenBgScrollState?: boolean
134
134
  evenList: any[]
135
135
  oddList: any[]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conecli/cone-render",
3
- "version": "0.10.1-shop3.26",
3
+ "version": "0.10.1-shop3.27",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist/"