@ledvance/ui-biz-bundle 1.1.172 → 1.1.173

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.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.172",
7
+ "version": "1.1.173",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -90,6 +90,7 @@ export const useEditPriceSegment = (segment: PriceSegment | undefined,
90
90
  marginEnd: cx(6),
91
91
  fontSize: cx(16),
92
92
  color: theme?.textInput.fontColor,
93
+ flex:1,
93
94
  },
94
95
  textInputSpacer: {
95
96
  height: 1,
@@ -51,6 +51,12 @@ export const useEnergyData = (params: EnergyConsumptionChartProps, devId: string
51
51
  }
52
52
  }, 5000, { immediate: true })
53
53
 
54
+ // 同步外部传入的价格和单位
55
+ useEffect(() => {
56
+ state.price = isNaN(Number(params.price)) ? 0 : Number(params.price)
57
+ state.unit = params.unit
58
+ }, [params.price, params.unit])
59
+
54
60
  // 副作用:获取数据
55
61
  useEffect(() => {
56
62
  state.loading = true
@@ -488,6 +488,46 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
488
488
  </View>
489
489
  </Card>
490
490
  <Spacer />
491
+ {/* pricing radio button*/}
492
+ <Segmented
493
+ style={{ marginHorizontal: cx(24) }}
494
+ options={[
495
+ { label: I18n.getLang('consumption_energy_type_fixed'), value: 'fixed' },
496
+ { label: I18n.getLang('consumption_energy_type_dynamic'), value: 'dynamic' },
497
+ ]}
498
+ value={state.energyType}
499
+ onChange={(value)=>{
500
+ const fixedModel = state.network_fixed_data ?? {
501
+ price: '0',
502
+ unit: '$',
503
+ energyType: 'fixed',
504
+ generatePrice: '0',
505
+ }
506
+ state.loading = true
507
+ updatePrice(devId, {...fixedModel, energyType: value,}).then((res)=>{
508
+ state.loading = false
509
+ if(res && res.success) {
510
+ state.energyType = value
511
+ if(value === 'fixed'){
512
+ state.price = fixedModel.price
513
+ } else {
514
+ const segments = isGeneration ? (dynamicData?.generatePrices ??[]) : (dynamicData?.intervalPrices??[])
515
+ state.price = String(calculateAveragePrice(segments))
516
+ }
517
+ }else{
518
+ showDialog({
519
+ method: 'confirm',
520
+ title: I18n.getLang('title_tips'),
521
+ subTitle: I18n.getLang('common_server_api_error'),
522
+ onConfirm: (_, { close }) => {
523
+ close()
524
+ }
525
+ })
526
+ }
527
+ })
528
+ }}
529
+ />
530
+ <Spacer style={{height: cx(10)}}/>
491
531
  {/* 365 day */}
492
532
  <Card
493
533
  style={styles.cardContainer}
@@ -512,9 +552,6 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
512
552
  />
513
553
  </TouchableOpacity>}
514
554
  </View>
515
- <View style={{ height: cx(35), justifyContent: 'center' }}>
516
- <Text style={[styles.cardTitle]}>{I18n.getLang('consumption_energy_type_title')}</Text>
517
- </View>
518
555
  </View>
519
556
  <View>
520
557
  <View style={{ flexDirection: 'row', alignItems: 'flex-end', marginLeft: cx(10) }}>
@@ -525,9 +562,6 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
525
562
  <Text style={[styles.consumptionNum, { fontSize: cx(30), marginRight: cx(8) }]}>{localeNumber(totalElectricity)}</Text>
526
563
  <Text style={[styles.consumptionNum, { fontSize: cx(20), marginBottom: cx(4) }]}>kWh</Text>
527
564
  </View>
528
- <View style={{ flexDirection: 'row', alignItems: 'flex-end', marginLeft: cx(10) }}>
529
- <Text style={[styles.consumptionNum, { fontSize: cx(16), marginRight: cx(8) }]}>{I18n.getLang(state.energyType === 'fixed' ? 'consumption_energy_type_fixed' : 'consumption_energy_type_dynamic')}</Text>
530
- </View>
531
565
  </View>
532
566
  </View>
533
567
  <Spacer />
@@ -577,7 +611,7 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
577
611
  <Text style={{ color: props.theme?.global.fontColor, fontWeight: 'bold' }}>{state.price ? `${localeNumber(Number(state.price) * totalElectricity, 2)} ${state.unit}` : '-'}</Text>
578
612
  </View>
579
613
  <View style={{ flexDirection: 'row', alignItems: 'center' }}>
580
- <TouchableOpacity onPress={() => {
614
+ {state.energyType === 'fixed' && <TouchableOpacity onPress={() => {
581
615
  state.showPopup = true
582
616
  state.popupType = 'money'
583
617
  }}>
@@ -585,7 +619,8 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
585
619
  <Text style={{ color: props.theme?.button.fontColor }}>{I18n.getLang('consumption_data_field3_button_text')}</Text>
586
620
  </View>
587
621
  </TouchableOpacity>
588
- <TouchableOpacity onPress={() => {
622
+ }
623
+ {state.energyType === 'dynamic' && <TouchableOpacity onPress={() => {
589
624
  navigation.navigate(ui_biz_routerKey.ui_biz_set_segmented_prices, {
590
625
  backTitle: backTitle,
591
626
  dynamicData: dynamicData ?? {
@@ -607,8 +642,8 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
607
642
  [isGeneration ? 'generatePrices' : 'intervalPrices']: segments
608
643
  }
609
644
  const[fixedRes, dynamicRes] = await Promise.all([
610
- updatePrice(devId, {...fixedModel, energyType: 'dynamic', unit: currency}),
611
- updateDynamicPrice(devId, dynamicMdel)
645
+ updatePrice(devId, {...fixedModel, energyType: 'dynamic', unit: currency}),
646
+ updateDynamicPrice(devId, dynamicMdel)
612
647
  ])
613
648
  const isDynamicSuccess = dynamicRes && dynamicRes.success
614
649
  const isRegularSuccess = fixedRes && fixedRes.success
@@ -633,6 +668,7 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
633
668
  <Text style={{ color: props.theme?.button.fontColor }}>{I18n.getLang('consumption_data_field_dynamic_money')}</Text>
634
669
  </View>
635
670
  </TouchableOpacity>
671
+ }
636
672
  </View>
637
673
 
638
674
  </View>
@@ -55,7 +55,8 @@ export const useSetSegmentPrice = (params: SetSegmentedPricesParams, theme?: The
55
55
  }
56
56
  ptr = segment.endMinute;
57
57
  }
58
- if(ptr < TOTAL_MINUTES) {
58
+ //优化项:如果指针是0,表示没有设置过时间段,这个时候不需要帮用户自动填充成00:00 - 23:59增加用户的麻烦,因为至少要两段才可以保存,
59
+ if(ptr > 0 && ptr < TOTAL_MINUTES) {
59
60
  return {
60
61
  startMinute: ptr,
61
62
  endMinute: TOTAL_MINUTES,