@conecli/cone-render 0.10.1-shop3.132 → 0.10.1-shop3.133

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
  nativeProps,
233
233
  } = props;
234
234
  const cRef = useRef<any>(null);
235
235
  useEffect(() => {
236
236
  if (isShowPriceLabel && priceTextColor && cRef.current) {
237
237
  cRef.current?.style?.setProperty('--after-ele-color', priceTextColor);
238
238
  }
239
239
  }, [isShowPriceLabel, priceTextColor]);
240
240
  const cls = classNames(
241
241
  className ? `${className}` : '',
242
242
  prefixCls,
243
243
  {
244
244
  'd-font-v2': useFontV2,
245
245
  'd-font-v2-bold': useFontV2Bold,
246
246
  },
247
247
  'd-imag-rendering-crisp-edges',
248
248
  {
249
249
  del: status === 'del',
250
250
  },
251
251
  {
252
252
  'd-plus-price': isPlusPrice,
253
253
  },
254
254
  {
255
255
  'd-sams-price': isSamsPrice,
256
256
  },
257
257
  {
258
258
  'd-sfp-price': isSfpPrice,
259
259
  },
260
260
  {
261
261
  'd-member-price': isMemberPrice,
262
262
  },
263
263
  {
264
264
  [`d-member-price-${memberPriceIcon}`]: memberPriceIcon,
265
265
  },
266
266
  {
267
267
  'd-price-label': isShowPriceLabel,
268
268
  },
269
269
  {
270
270
  'd-price-text-clor': isShowPriceLabel && priceTextColor,
271
271
  },
272
272
  );
273
273
  const symCls = classNames(symClassName ? `${symClassName}` : '', {
274
274
  'sym-sub': symPos === 'sub',
275
275
  'sym-sup': symPos === 'sup',
276
276
  });
277
277
  const intCls = classNames(intClassName ? `${intClassName}` : '');
278
278
  const decCls = classNames(decClassName ? `${decClassName}` : '', {
279
279
  'dec-sub': decPos === 'sub',
280
280
  'dec-sup': decPos === 'sup',
281
281
  });
282
282
  const noPriceCls = classNames(noPriceClassName ? `${noPriceClassName}` : '');
283
283
  const { currencySymbol, intVal, decimalVal } = dealPrice(
284
284
  value,
285
285
  decLength,
286
286
  symbol,
287
287
  decToIntegerState,
288
288
  );
289
289
  return (
290
290
  <View
291
291
  ref={cRef}
292
292
  className={cls}
293
293
  style={style}
294
294
  data-after={isShowPriceLabel ? priceLabelText : ''}
295
295
  {...nativeProps}
296
296
  >
297
297
  {intVal === '-1' ? (
298
298
  <Text className={`${prefixCls}-txt int-txt off-shelf ${noPriceCls}`}>{`暂无报价`}</Text>
299
299
  ) : (
300
300
  <>
301
301
  <Text className={`${prefixCls}-sym ${symCls}`}>{currencySymbol}</Text>
302
302
  <Text className={`${prefixCls}-txt int-txt ${intCls}`}>{intVal}</Text>
303
303
  {!!decimalVal && (
304
304
  <Text className={`${prefixCls}-txt dec-txt ${decCls}`}>.{decimalVal}</Text>
305
305
  )}
306
306
  </>
307
307
  )}
308
308
  </View>
309
309
  );
310
310
  prefixCls: 'd-mini-price',
311
311
  style: {},
312
312
  status: '',
313
313
  symbol: '¥',
314
314
  symPos: 'sub',
315
315
  decLength: 2,
316
316
  decPos: 'sub',
317
317
  decToIntegerState: false,
318
318
  isPlusPrice: false,
319
319
  isShowPriceLabel: false,
320
320
  priceLabelText: '到手价',
321
321
  priceTextColor: '',
322
322
  useFontV2: false,
323
323
  useFontV2Bold: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conecli/cone-render",
3
- "version": "0.10.1-shop3.132",
3
+ "version": "0.10.1-shop3.133",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist/"