|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import { M9zService, LgnLatData, SunRiseSetData, SunRiseTimeData } from '../../utils/M9zService';
|
|
|
|
|
import { M9zService, LgnLatData, SunRiseSetData, SunRiseTimeData, BluetoothConfig } from '../../utils/M9zService';
|
|
|
|
|
import { promptAction } from '@kit.ArkUI';
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
|
@ -12,6 +12,18 @@ export struct ParameterSettings {
|
|
|
|
|
@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
|
|
|
|
|
@State bluetoothConfig: BluetoothConfig = new BluetoothConfig();
|
|
|
|
|
|
|
|
|
|
// ... (existing properties)
|
|
|
|
|
|
|
|
|
|
// ... (refreshData chain)
|
|
|
|
|
// Inside fetchSunRiseTime -> onSuccess -> getWeekMode -> onSuccess:
|
|
|
|
|
// After getting week mode, call fetchBluetoothConfig?
|
|
|
|
|
// Or just call it in parallel since they are independent? The user requested sequential for AutoMode tasks, maybe good practice here too.
|
|
|
|
|
// I will add it to the chain to be safe.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private days: string[] = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
|
|
|
|
private displayIndices: number[] = [1, 2, 3, 4, 5, 6, 0]; // Display order: Mon-Sat, Sun
|
|
|
|
|
@ -85,20 +97,48 @@ export struct ParameterSettings {
|
|
|
|
|
this.weekModes = data.slice(startIndex);
|
|
|
|
|
console.info('WeeklyMode extracted:', JSON.stringify(this.weekModes));
|
|
|
|
|
}
|
|
|
|
|
this.isLoading = false;
|
|
|
|
|
this.fetchBluetoothConfig();
|
|
|
|
|
},
|
|
|
|
|
onError: (err: string): void => {
|
|
|
|
|
console.error('WeeklyMode Error:', err);
|
|
|
|
|
this.isLoading = false;
|
|
|
|
|
this.fetchBluetoothConfig();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (err: string): void => {
|
|
|
|
|
this.fetchBluetoothConfig();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fetchBluetoothConfig() {
|
|
|
|
|
this.m9zService.getBluetoothConfig({
|
|
|
|
|
onSuccess: (data: BluetoothConfig): void => {
|
|
|
|
|
this.bluetoothConfig = data;
|
|
|
|
|
this.isLoading = false;
|
|
|
|
|
},
|
|
|
|
|
onError: (err: string): void => {
|
|
|
|
|
console.error('Get Bluetooth Config failed', err);
|
|
|
|
|
this.isLoading = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveBluetoothConfig() {
|
|
|
|
|
if (!this.bluetoothConfig.name) {
|
|
|
|
|
promptAction.showToast({ message: '蓝牙名称不能为空' });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.m9zService.setBluetoothConfig(this.bluetoothConfig, {
|
|
|
|
|
onSuccess: (success: boolean): void => {
|
|
|
|
|
promptAction.showToast({ message: '蓝牙名称修改成功' });
|
|
|
|
|
},
|
|
|
|
|
onError: (err: string): void => {
|
|
|
|
|
promptAction.showToast({ message: '修改失败: ' + err });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
syncLocation() {
|
|
|
|
|
// 模拟同步定位,实际应调用定位API
|
|
|
|
|
const newData = new LgnLatData();
|
|
|
|
|
@ -185,6 +225,25 @@ export struct ParameterSettings {
|
|
|
|
|
Stack() {
|
|
|
|
|
Scroll() {
|
|
|
|
|
Column() {
|
|
|
|
|
// 蓝牙设置
|
|
|
|
|
Column() {
|
|
|
|
|
Text('蓝牙设置').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#22fdc8').width('100%').margin({bottom: 10})
|
|
|
|
|
|
|
|
|
|
Row() {
|
|
|
|
|
Text('蓝牙名称: ').fontColor('#eaf6fc')
|
|
|
|
|
TextInput({ text: this.bluetoothConfig.name })
|
|
|
|
|
.layoutWeight(1)
|
|
|
|
|
.onChange((val) => { this.bluetoothConfig.name = val; })
|
|
|
|
|
.fontColor('#fff').backgroundColor('#333')
|
|
|
|
|
Button('保存').fontSize(12).onClick(() => this.saveBluetoothConfig()).margin({left: 10})
|
|
|
|
|
}.width('100%')
|
|
|
|
|
}
|
|
|
|
|
.padding(10)
|
|
|
|
|
.backgroundColor('rgba(20, 38, 81, 0.95)')
|
|
|
|
|
.borderRadius(8)
|
|
|
|
|
.margin({bottom: 15})
|
|
|
|
|
.width('100%')
|
|
|
|
|
|
|
|
|
|
// 经纬度设置
|
|
|
|
|
Column() {
|
|
|
|
|
Text('经纬度设置').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#22fdc8').width('100%').margin({bottom: 10})
|
|
|
|
|
|