@conecli/cone-render 0.10.1-shop3.25 → 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,