106 lines
3.3 KiB
Plaintext
Raw Normal View History

2024-06-04 12:08:32 +08:00
import TopLogo from './compontents/TopLogo';
2024-06-04 11:19:22 +08:00
import MA_SYSTEMPARM from '../common/constants/MA_SYSTEMPARM';
import AccountTable from '../common/database/tables/AccountTable';
import { getSyncData } from '../common/service/initable';
2024-07-05 09:08:17 +08:00
import router from '@ohos.router';
2024-05-16 11:05:19 +08:00
const cBg = $rawfile('judge/km3/road/luxian_pre.png');
const lBg = $rawfile('judge/km3/road/luxian_nor.png');
const ctBg = $rawfile('judge/km3/road/luxian_pre.png');
const ltBg = $rawfile('judge/km3/road/luxian_nor.png');
//单机模式才选线路
@Entry
@Component
2024-06-04 11:19:22 +08:00
export default struct Index {
2024-05-16 11:05:19 +08:00
@State @Watch('outClick') outFlag: boolean = false;
2024-06-04 11:19:22 +08:00
@State roadObj: any = {}
2024-05-16 11:05:19 +08:00
2024-06-04 11:19:22 +08:00
async aboutToAppear() {
2024-05-16 11:05:19 +08:00
//读取systemparam表的no1等于4的
2024-06-04 11:19:22 +08:00
const systemParms: any = await getSyncData('MA_SYSTEMPARM')
systemParms.forEach((systemParm) => {
2024-05-16 11:05:19 +08:00
//TODO 字段名称待修改
const {no1,no2,no3,txt1,txt2} = systemParm;
2024-06-04 11:19:22 +08:00
if (no1 == 4) {
const temp = { no2, no3, txt1: decodeURI(txt1), txt2 }
2024-07-05 09:08:17 +08:00
this.roadObj[no2] = no2
2024-05-16 11:05:19 +08:00
}
})
}
2024-06-04 11:19:22 +08:00
build() {
Column() {
TopLogo({ outFlag: $outFlag })
2024-07-05 09:08:17 +08:00
Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row,justifyContent:FlexAlign.Start}){
List({}) {
2024-06-04 11:19:22 +08:00
ListItem() {
Column() {
Row() {
}
.backgroundImage(lBg, ImageRepeat.NoRepeat)
.backgroundImageSize({ width: '100%', height: '100%' })
.width(90)
.height(80)
2024-07-05 09:08:17 +08:00
Text(`随机`) {
2024-06-04 11:19:22 +08:00
}.fontColor('#FFF2D9').fontSize(24).padding({ top: 10 })
2024-05-16 11:05:19 +08:00
}
2024-06-04 11:19:22 +08:00
}
.backgroundImage(cBg, ImageRepeat.NoRepeat)
.backgroundImageSize({ width: '100%', height: '100%' })
.width(180)
.height(220)
.margin({ left: 5, bottom: 10 })
.onClick(async () => {
2024-07-05 09:08:17 +08:00
const roadArr = Reflect.ownKeys(this.roadObj).map((roadKey) => {
return this.roadObj[roadKey]
});
2024-07-05 18:10:12 +08:00
const wayno = roadArr[Math.floor(Math.random()*roadArr.length)];
this.goJudge(wayno)
2024-06-04 11:19:22 +08:00
})
2024-07-05 09:08:17 +08:00
ForEach(Reflect.ownKeys(this.roadObj), (roadIndex) => {
ListItem() {
Column() {
Row() {
}
.backgroundImage(lBg, ImageRepeat.NoRepeat)
.backgroundImageSize({ width: '100%', height: '100%' })
.width(90)
.height(80)
Text(`线路${this.roadObj[roadIndex] + ''}`) {
}.fontColor('#FFF2D9').fontSize(24).padding({ top: 10 })
}
}
.backgroundImage(cBg, ImageRepeat.NoRepeat)
.backgroundImageSize({ width: '100%', height: '100%' })
.width(180)
.height(220)
.margin({ left: 5, bottom: 10 })
.onClick(async () => {
2024-07-05 18:10:12 +08:00
this.goJudge(this.roadObj[roadIndex])
2024-07-05 09:08:17 +08:00
})
})
}.lanes(8).margin({ top: 50, left: 15 })
}
2024-06-04 11:19:22 +08:00
}.width('100%')
.height('100%')
.backgroundColor('#1A1A1A')
}
2024-05-16 11:05:19 +08:00
2024-07-05 18:10:12 +08:00
goJudge(wayno) {
let currentParams: any = router.getParams() || {};
const {sczb,kfdm} = currentParams;
router.replaceUrl({
url: 'pages/Judge',
params:{
sczb,
kfdm,
2024-08-19 10:11:22 +08:00
wayno,
2024-07-05 18:10:12 +08:00
}
}, router.RouterMode.Single);
2024-05-16 11:05:19 +08:00
}
2024-07-05 18:10:12 +08:00
outClick(){}
2024-05-16 11:05:19 +08:00
}