@conecli/cone-render 0.10.1-shop-beta.34 → 0.10.1-shop-beta.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import React, { useEffect, useRef } 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
  draBusinessCustomReport({
10
9
  eventName: 'business',
11
10
  errorName: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
12
11
  errorMessage: '当前价格为科学计数数据,上报关注该价格',
13
12
  extraData: JSON.stringify({
14
13
  price: value,
15
14
  originalPrice: initValue,
16
15
  }),
17
16
  });
18
17
  }
19
18
  if (!decToIntegerState) {
20
19
  value = parseFloat(value).toFixed(decLength);
21
20
  } else {
22
21
  if (value.indexOf('.') !== -1) {
23
22
  value = parseFloat(value).toFixed(decLength);
24
23
  value = `${value}`.replace(/0+$/, '');
25
24
  }
26
25
  }
27
26
  if (value === 'NaN') {
28
27
  draBusinessCustomReport({
29
28
  eventName: 'business',
30
29
  errorName: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
31
30
  errorMessage: '价格转换异常,兜底展示暂无报价',
32
31
  extraData: JSON.stringify({
33
32
  price: value,
34
33
  originalPrice: initValue,
35
34
  }),
36
35
  });
37
36
  value = '暂无报价';
38
37
  }
39
38
  }
40
39
  const [intVal, decimalVal] = `${value}`.split('.');
41
40
  return {
42
41
  currencySymbol: !cnPriceTextList.includes(intVal) ? symbol : '',
43
42
  intVal,
44
43
  decimalVal,
45
44
  };
46
45
  const {
47
46
  prefixCls,
48
47
  symPos,
49
48
  symbol,
50
49
  decPos,
51
50
  status,
52
51
  className,
53
52
  style,
54
53
  symClassName,
55
54
  intClassName,
56
55
  decClassName,
57
56
  noPriceClassName,
58
57
  value,
59
58
  decLength,
60
59
  decToIntegerState,
61
60
  isPlusPrice,
62
61
  isSamsPrice,
63
62
  isMemberPrice,
64
63
  isSfpPrice,
65
64
  memberPriceIcon,
66
65
  isShowPriceLabel,
67
66
  priceLabelText,
68
67
  priceTextColor,
69
68
  useFontV2 = false,
70
69
  useFontV2Bold = false,
71
70
  nativeProps,
72
71
  } = props;
73
72
  const cRef = useRef<any>(null);
74
73
  useEffect(() => {
75
74
  if (isShowPriceLabel && priceTextColor && cRef.current) {
76
75
  cRef.current?.style?.setProperty('--after-ele-color', priceTextColor);
77
76
  }
78
77
  }, [isShowPriceLabel, priceTextColor]);
79
78
  const cls = classNames(
80
79
  className ? `${className}` : '',
81
80
  prefixCls,
82
81
  {
83
82
  'd-font-v2': useFontV2,
84
83
  'd-font-v2-bold': useFontV2Bold,
85
84
  },
86
85
  'd-imag-rendering-crisp-edges',
87
86
  {
88
87
  del: status === 'del',
89
88
  },
90
89
  {
91
90
  'd-plus-price': isPlusPrice,
92
91
  },
93
92
  {
94
93
  'd-sams-price': isSamsPrice,
95
94
  },
96
95
  {
97
96
  'd-sfp-price': isSfpPrice,
98
97
  },
99
98
  {
100
99
  'd-member-price': isMemberPrice,
101
100
  },
102
101
  {
103
102
  [`d-member-price-${memberPriceIcon}`]: memberPriceIcon,
104
103
  },
105
104
  {
106
105
  'd-price-label': isShowPriceLabel,
107
106
  },
108
107
  {
109
108
  'd-price-text-clor': isShowPriceLabel && priceTextColor,
110
109
  },
111
110
  );
112
111
  const symCls = classNames(symClassName ? `${symClassName}` : '', {
113
112
  'sym-sub': symPos === 'sub',
114
113
  'sym-sup': symPos === 'sup',
115
114
  });
116
115
  const intCls = classNames(intClassName ? `${intClassName}` : '');
117
116
  const decCls = classNames(decClassName ? `${decClassName}` : '', {
118
117
  'dec-sub': decPos === 'sub',
119
118
  'dec-sup': decPos === 'sup',
120
119
  });
121
120
  const noPriceCls = classNames(noPriceClassName ? `${noPriceClassName}` : '');
122
121
  const { currencySymbol, intVal, decimalVal } = dealPrice(
123
122
  value,
124
123
  decLength,
125
124
  symbol,
126
125
  decToIntegerState,
127
126
  );
128
127
  return (
129
128
  <View
130
129
  ref={cRef}
131
130
  className={cls}
132
131
  style={style}
133
132
  data-after={isShowPriceLabel ? priceLabelText : ''}
134
133
  {...nativeProps}
135
134
  >
136
135
  {intVal === '-1' ? (
137
136
  <Text className={`${prefixCls}-txt int-txt off-shelf ${noPriceCls}`}>{`暂无报价`}</Text>
138
137
  ) : (
139
138
  <>
140
139
  <Text className={`${prefixCls}-sym ${symCls}`}>{currencySymbol}</Text>
141
140
  <Text className={`${prefixCls}-txt int-txt ${intCls}`}>{intVal}</Text>
142
141
  {!!decimalVal && (
143
142
  <Text className={`${prefixCls}-txt dec-txt ${decCls}`}>.{decimalVal}</Text>
144
143
  )}
145
144
  </>
146
145
  )}
147
146
  </View>
148
147
  );
149
148
  prefixCls: 'd-mini-price',
150
149
  style: {},
151
150
  status: '',
152
151
  symbol: '¥',
153
152
  symPos: 'sub',
154
153
  decLength: 2,
155
154
  decPos: 'sub',
156
155
  decToIntegerState: false,
157
156
  isPlusPrice: false,
158
157
  isShowPriceLabel: false,
159
158
  priceLabelText: '到手价',
160
159
  priceTextColor: '',
161
160
  useFontV2: false,
162
161
  useFontV2Bold: false,
162
+ import React, { useEffect, useRef } from 'react';
163
163
  let value = `${initValue}`;
164
164
  if (!cnPriceTextList.includes(value)) {
165
165
  if (value && !/^[0123456789-]*$/.test(value.substring(0, 1))) {
166
166
  symbol = value.substring(0, 1);
167
167
  value = value.substring(1);
168
168
  }
169
169
  if (/^\d+(\.\d+)?[eE][+-]?\d+$/.test(value)) {
170
170
  draBusinessCustomReport({
171
171
  eventName: 'business',
172
172
  errorName: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
173
173
  errorMessage: '当前价格为科学计数数据,上报关注该价格',
174
174
  extraData: JSON.stringify({
175
175
  price: value,
176
176
  originalPrice: initValue,
177
177
  }),
178
178
  });
179
179
  }
180
180
  if (!decToIntegerState) {
181
181
  value = parseFloat(value).toFixed(decLength);
182
182
  } else {
183
183
  if (value.indexOf('.') !== -1) {
184
184
  value = parseFloat(value).toFixed(decLength);
185
185
  value = `${value}`.replace(/0+$/, '');
186
186
  }
187
187
  }
188
188
  if (value === 'NaN') {
189
189
  draBusinessCustomReport({
190
190
  eventName: 'business',
191
191
  errorName: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
192
192
  errorMessage: '价格转换异常,兜底展示暂无报价',
193
193
  extraData: JSON.stringify({
194
194
  price: value,
195
195
  originalPrice: initValue,
196
196
  }),
197
197
  });
198
198
  value = '暂无报价';
199
199
  }
200
200
  }
201
201
  const [intVal, decimalVal] = `${value}`.split('.');
202
202
  return {
203
203
  currencySymbol: !cnPriceTextList.includes(intVal) ? symbol : '',
204
204
  intVal,
205
205
  decimalVal,
206
206
  };
207
207
  const {
208
208
  prefixCls,
209
209
  symPos,
210
210
  symbol,
211
211
  decPos,
212
212
  status,
213
213
  className,
214
214
  style,
215
215
  symClassName,
216
216
  intClassName,
217
217
  decClassName,
218
218
  noPriceClassName,
219
219
  value,
220
220
  decLength,
221
221
  decToIntegerState,
222
222
  isPlusPrice,
223
223
  isSamsPrice,
224
224
  isMemberPrice,
225
225
  isSfpPrice,
226
226
  memberPriceIcon,
227
227
  isShowPriceLabel,
228
228
  priceLabelText,
229
229
  priceTextColor,
230
230
  useFontV2 = false,
231
231
  useFontV2Bold = false,
232
232
  } = props;
233
233
  const cRef = useRef<any>(null);
234
234
  useEffect(() => {
235
235
  if (isShowPriceLabel && priceTextColor && cRef.current) {
236
236
  cRef.current?.style?.setProperty('--after-ele-color', priceTextColor);
237
237
  }
238
238
  }, [isShowPriceLabel, priceTextColor]);
239
239
  const cls = classNames(
240
240
  className ? `${className}` : '',
241
241
  prefixCls,
242
242
  {
243
243
  'd-font-v2': useFontV2,
244
244
  'd-font-v2-bold': useFontV2Bold,
245
245
  },
246
246
  'd-imag-rendering-crisp-edges',
247
247
  {
248
248
  del: status === 'del',
249
249
  },
250
250
  {
251
251
  'd-plus-price': isPlusPrice,
252
252
  },
253
253
  {
254
254
  'd-sams-price': isSamsPrice,
255
255
  },
256
256
  {
257
257
  'd-sfp-price': isSfpPrice,
258
258
  },
259
259
  {
260
260
  'd-member-price': isMemberPrice,
261
261
  },
262
262
  {
263
263
  [`d-member-price-${memberPriceIcon}`]: memberPriceIcon,
264
264
  },
265
265
  {
266
266
  'd-price-label': isShowPriceLabel,
267
267
  },
268
268
  {
269
269
  'd-price-text-clor': isShowPriceLabel && priceTextColor,
270
270
  },
271
271
  );
272
272
  const symCls = classNames(symClassName ? `${symClassName}` : '', {
273
273
  'sym-sub': symPos === 'sub',
274
274
  'sym-sup': symPos === 'sup',
275
275
  });
276
276
  const intCls = classNames(intClassName ? `${intClassName}` : '');
277
277
  const decCls = classNames(decClassName ? `${decClassName}` : '', {
278
278
  'dec-sub': decPos === 'sub',
279
279
  'dec-sup': decPos === 'sup',
280
280
  });
281
281
  const noPriceCls = classNames(noPriceClassName ? `${noPriceClassName}` : '');
282
282
  const { currencySymbol, intVal, decimalVal } = dealPrice(
283
283
  value,
284
284
  decLength,
285
285
  symbol,
286
286
  decToIntegerState,
287
287
  );
288
288
  return (
289
289
  <View
290
290
  ref={cRef}
291
291
  className={cls}
292
292
  style={style}
293
293
  data-after={isShowPriceLabel ? priceLabelText : ''}
294
294
  >
295
295
  {intVal === '-1' ? (
296
296
  <Text className={`${prefixCls}-txt int-txt off-shelf ${noPriceCls}`}>{`暂无报价`}</Text>
297
297
  ) : (
298
298
  <>
299
299
  <Text className={`${prefixCls}-sym ${symCls}`}>{currencySymbol}</Text>
300
300
  <Text className={`${prefixCls}-txt int-txt ${intCls}`}>{intVal}</Text>
301
301
  {!!decimalVal && (
302
302
  <Text className={`${prefixCls}-txt dec-txt ${decCls}`}>.{decimalVal}</Text>
303
303
  )}
304
304
  </>
305
305
  )}
306
306
  </View>
307
307
  );
308
308
  prefixCls: 'd-mini-price',
309
309
  style: {},
310
310
  status: '',
311
311
  symbol: '¥',
312
312
  symPos: 'sub',
313
313
  decLength: 2,
314
314
  decPos: 'sub',
315
315
  decToIntegerState: false,
316
316
  isPlusPrice: false,
317
317
  isShowPriceLabel: false,
318
318
  priceLabelText: '到手价',
319
319
  priceTextColor: '',
320
320
  useFontV2: false,
321
321
  useFontV2Bold: false,