74 lines
1.9 KiB
Plaintext
Raw Normal View History

2024-06-04 11:19:22 +08:00
import router from '@ohos.router';
import { getCurrentTime } from '../../common/service/timeService';
2024-12-29 21:43:12 +08:00
import { voiceService } from '../../common/service/voiceService';
2024-12-30 13:20:49 +08:00
import imageBtn from '../compontents/imageBtn'
2024-01-05 11:11:15 +08:00
@Component
2024-06-04 11:19:22 +08:00
export default struct TopLogo {
2024-01-05 11:11:15 +08:00
@State ratio: number = 850 / 960
@State timeText: string = '';
@Link outFlag: boolean; //返回按钮触发
2024-06-04 11:19:22 +08:00
private timer: any = null;
2024-12-29 21:43:12 +08:00
private vocObj = null;
2024-06-04 11:19:22 +08:00
constructor() {
super()
}
build() {
2024-01-05 11:11:15 +08:00
Column() {
2024-06-04 11:19:22 +08:00
Column() {
}
2024-01-05 11:11:15 +08:00
.backgroundColor('#333230')
.width('100%')
.height('10%')
2024-06-04 11:19:22 +08:00
2024-01-05 11:11:15 +08:00
Row() {
Row() {
2024-06-04 11:19:22 +08:00
Image($r('app.media.shortLogo'))
.width('10.2%')
.height('5.7%')
.margin({ left: 30 * this.ratio, top: -15 * this.ratio })
Text(this.timeText)
.fontSize(30 * this.ratio)
.fontColor('#CCB48F')
.margin({ top: -15 * this.ratio, left: 14 * this.ratio }) //fontsize40
2024-01-05 11:11:15 +08:00
}
2024-12-30 13:20:49 +08:00
imageBtn({btnWidth:'16.7%',btnHeight:'12.2%',imgSrc:$r('app.media.topB_back')})
2024-06-04 11:19:22 +08:00
.onClick(() => {
2024-12-29 21:43:12 +08:00
this.vocObj.playAudio({
type: 1,
name: 'button_media.wav'
})
2024-06-04 11:19:22 +08:00
this.outFlag = true
2024-12-30 13:20:49 +08:00
router.back()
2024-01-05 11:11:15 +08:00
})
}
2024-06-04 11:19:22 +08:00
.position({ x: 0, y: 0 })
2024-01-05 11:11:15 +08:00
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
}
.width('100%')
}
async aboutToAppear() {
console.log('jiangsong: topLogo aboutToAppear1111')
2024-12-29 21:43:12 +08:00
this.vocObj = new voiceService(async (status, val, next) => {
});
2024-01-05 11:11:15 +08:00
this.timeText = await getCurrentTime();
this.timer = setInterval(async () => {
this.timeText = await getCurrentTime();
}, 1000)
2024-01-31 14:35:16 +08:00
// this.vocObj = new voiceService(async (status,val) => {
// if (status == 'idle') {
// router.back()
// }
// });
2024-01-05 11:11:15 +08:00
}
2024-06-04 11:19:22 +08:00
2024-01-05 11:11:15 +08:00
aboutToDisappear() {
clearInterval(this.timer)
console.log('jiangsong: topLogo aboutToDisappear222222222')
}
}
2024-12-30 13:20:49 +08:00