|
|
|
@ -10,9 +10,17 @@ export struct ParameterSettings {
|
|
|
|
@State lgnLat: LgnLatData = new LgnLatData();
|
|
|
|
@State lgnLat: LgnLatData = new LgnLatData();
|
|
|
|
@State sunRiseSet: SunRiseSetData = new SunRiseSetData();
|
|
|
|
@State sunRiseSet: SunRiseSetData = new SunRiseSetData();
|
|
|
|
@State sunRiseTime: SunRiseTimeData = new SunRiseTimeData();
|
|
|
|
@State sunRiseTime: SunRiseTimeData = new SunRiseTimeData();
|
|
|
|
|
|
|
|
@State weekModes: number[] = [0, 0, 0, 0, 0, 0, 0]; // Sun-Sat
|
|
|
|
|
|
|
|
@State fullWeekModeData: number[] = []; // Store full config data to write back
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private days: string[] = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
|
|
|
|
|
|
|
private displayIndices: number[] = [1, 2, 3, 4, 5, 6, 0]; // Display order: Mon-Sat, Sun
|
|
|
|
|
|
|
|
private modeOptions: string[] = ['模式1', '模式2', '模式3'];
|
|
|
|
|
|
|
|
|
|
|
|
private m9zService: M9zService = M9zService.getInstance();
|
|
|
|
private m9zService: M9zService = M9zService.getInstance();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
aboutToAppear() {
|
|
|
|
aboutToAppear() {
|
|
|
|
if (this.deviceId) {
|
|
|
|
if (this.deviceId) {
|
|
|
|
// initial load handled by onTabChange? No, initial index might be 0, this is 1. IF this is 1 initially?
|
|
|
|
// initial load handled by onTabChange? No, initial index might be 0, this is 1. IF this is 1 initially?
|
|
|
|
@ -66,7 +74,24 @@ export struct ParameterSettings {
|
|
|
|
this.m9zService.getSunRiseTime({
|
|
|
|
this.m9zService.getSunRiseTime({
|
|
|
|
onSuccess: (data: SunRiseTimeData): void => {
|
|
|
|
onSuccess: (data: SunRiseTimeData): void => {
|
|
|
|
this.sunRiseTime = data;
|
|
|
|
this.sunRiseTime = data;
|
|
|
|
this.isLoading = false;
|
|
|
|
// 4. Get Week Mode
|
|
|
|
|
|
|
|
this.m9zService.getWeekMode({
|
|
|
|
|
|
|
|
onSuccess: (data: number[]): void => {
|
|
|
|
|
|
|
|
console.info('WeeklyMode Raw Data:', JSON.stringify(data)); // Debug log
|
|
|
|
|
|
|
|
if (data && data.length >= 7) {
|
|
|
|
|
|
|
|
this.fullWeekModeData = data;
|
|
|
|
|
|
|
|
// Assume last 7 bytes are the week modes (Mon-Sun).
|
|
|
|
|
|
|
|
const startIndex = data.length - 7;
|
|
|
|
|
|
|
|
this.weekModes = data.slice(startIndex);
|
|
|
|
|
|
|
|
console.info('WeeklyMode extracted:', JSON.stringify(this.weekModes));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.isLoading = false;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onError: (err: string): void => {
|
|
|
|
|
|
|
|
console.error('WeeklyMode Error:', err);
|
|
|
|
|
|
|
|
this.isLoading = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onError: (err: string): void => {
|
|
|
|
onError: (err: string): void => {
|
|
|
|
this.isLoading = false;
|
|
|
|
this.isLoading = false;
|
|
|
|
@ -134,6 +159,28 @@ export struct ParameterSettings {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setWeekMode() {
|
|
|
|
|
|
|
|
if (this.fullWeekModeData.length < 7) {
|
|
|
|
|
|
|
|
promptAction.showToast({ message: '未获取到完整配置,无法保存' });
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update full data with current week modes
|
|
|
|
|
|
|
|
const startIndex = this.fullWeekModeData.length - 7;
|
|
|
|
|
|
|
|
for (let i = 0; i < 7; i++) {
|
|
|
|
|
|
|
|
this.fullWeekModeData[startIndex + i] = this.weekModes[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.info('WeeklyMode Saving:', JSON.stringify(this.fullWeekModeData));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.m9zService.setWeekMode(this.fullWeekModeData, {
|
|
|
|
|
|
|
|
onSuccess: (val: boolean): void => { promptAction.showToast({ message: '周模式保存成功' }); },
|
|
|
|
|
|
|
|
onError: (err: string): void => { promptAction.showToast({ message: '保存失败: ' + err }); }
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build() {
|
|
|
|
build() {
|
|
|
|
Stack() {
|
|
|
|
Stack() {
|
|
|
|
Scroll() {
|
|
|
|
Scroll() {
|
|
|
|
@ -209,6 +256,44 @@ export struct ParameterSettings {
|
|
|
|
.backgroundColor('rgba(20, 38, 81, 0.95)')
|
|
|
|
.backgroundColor('rgba(20, 38, 81, 0.95)')
|
|
|
|
.borderRadius(8)
|
|
|
|
.borderRadius(8)
|
|
|
|
.margin({bottom: 15})
|
|
|
|
.margin({bottom: 15})
|
|
|
|
|
|
|
|
.margin({bottom: 15})
|
|
|
|
|
|
|
|
.width('100%')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 周运行模式设置
|
|
|
|
|
|
|
|
Column() {
|
|
|
|
|
|
|
|
Text('周运行模式设置').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#22fdc8').width('100%').margin({bottom: 10})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ForEach(this.displayIndices, (dataIndex: number) => {
|
|
|
|
|
|
|
|
Row() {
|
|
|
|
|
|
|
|
Text(this.days[dataIndex]).fontColor('#eaf6fc').width(50)
|
|
|
|
|
|
|
|
Select([
|
|
|
|
|
|
|
|
{ value: '模式1' },
|
|
|
|
|
|
|
|
{ value: '模式2' },
|
|
|
|
|
|
|
|
{ value: '模式3' }
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
.selected(this.weekModes[dataIndex])
|
|
|
|
|
|
|
|
.value(this.modeOptions[this.weekModes[dataIndex]])
|
|
|
|
|
|
|
|
.font({ size: 14 })
|
|
|
|
|
|
|
|
.fontColor('#fff')
|
|
|
|
|
|
|
|
.selectedOptionFont({ size: 14 })
|
|
|
|
|
|
|
|
.optionFont({ size: 14 })
|
|
|
|
|
|
|
|
.menuBackgroundColor('#2d3a51')
|
|
|
|
|
|
|
|
.onSelect((idx: number) => {
|
|
|
|
|
|
|
|
this.weekModes[dataIndex] = idx;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.backgroundColor('#333')
|
|
|
|
|
|
|
|
.height(30)
|
|
|
|
|
|
|
|
}.width('100%').margin({bottom: 5}).justifyContent(FlexAlign.Start)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Row() {
|
|
|
|
|
|
|
|
Button('保存').fontSize(12).onClick(() => this.setWeekMode())
|
|
|
|
|
|
|
|
}.margin({top: 10})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.padding(10)
|
|
|
|
|
|
|
|
.backgroundColor('rgba(20, 38, 81, 0.95)')
|
|
|
|
|
|
|
|
.borderRadius(8)
|
|
|
|
|
|
|
|
.margin({bottom: 15})
|
|
|
|
.width('100%')
|
|
|
|
.width('100%')
|
|
|
|
|
|
|
|
|
|
|
|
// 重启
|
|
|
|
// 重启
|
|
|
|
|