2024-08-19 14:56:36 +08:00
|
|
|
@CustomDialog
|
|
|
|
|
export default struct errorMsgDialog {
|
|
|
|
|
private controller?: CustomDialogController
|
|
|
|
|
cancel: () => void = () => {
|
|
|
|
|
}
|
|
|
|
|
confirm: () => void = () => {
|
|
|
|
|
}
|
2024-08-20 09:12:02 +08:00
|
|
|
dialogRatio:number=0.8
|
2024-08-19 14:56:36 +08:00
|
|
|
title?: string
|
|
|
|
|
type: string //1 tip 2loading 3Dialog
|
|
|
|
|
@State angle: number = 0
|
|
|
|
|
|
2024-08-20 09:12:02 +08:00
|
|
|
@Styles
|
|
|
|
|
commStyle(){
|
2024-08-20 09:43:25 +08:00
|
|
|
.width(220 * globalThis.ratio * this.dialogRatio *0.6)
|
|
|
|
|
.height(69 * globalThis.ratio * this.dialogRatio*0.6)
|
2024-08-20 09:12:02 +08:00
|
|
|
.backgroundImage($r('app.media.button_nor'))
|
|
|
|
|
.backgroundImageSize({ width: '100%', height: '100%' })
|
|
|
|
|
// .margin({ bottom: 12 * this.ratio })
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-19 14:56:36 +08:00
|
|
|
build() {
|
|
|
|
|
Column() {
|
|
|
|
|
if(this.title){
|
|
|
|
|
Text(this.title)
|
2024-08-20 09:12:02 +08:00
|
|
|
.fontSize(30* this.dialogRatio)
|
|
|
|
|
.margin(120* this.dialogRatio)
|
2024-08-19 14:56:36 +08:00
|
|
|
}
|
|
|
|
|
if (this.type=='2') {
|
|
|
|
|
Image($r('app.media.open_loading'))
|
|
|
|
|
.width(200)
|
|
|
|
|
.rotate({ angle: this.angle })
|
|
|
|
|
.height(200)
|
|
|
|
|
.animation({
|
|
|
|
|
duration: 5000, // 动画时长
|
|
|
|
|
curve: Curve.EaseOut, // 动画曲线
|
|
|
|
|
delay: 500, // 动画延迟
|
|
|
|
|
iterations: -1, // 播放次数
|
|
|
|
|
playMode: PlayMode.Normal, // 动画模式
|
|
|
|
|
})
|
|
|
|
|
.margin(50)
|
|
|
|
|
}
|
2024-08-20 09:12:02 +08:00
|
|
|
if (this.type=='3') {
|
|
|
|
|
Row() {
|
|
|
|
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
|
|
|
|
Text(' 取 消 ')
|
2024-08-20 09:43:25 +08:00
|
|
|
.fontSize(24 * globalThis.ratio* this.dialogRatio*0.6 )
|
2024-08-20 09:12:02 +08:00
|
|
|
.fontColor('#fff')
|
2024-08-20 09:43:25 +08:00
|
|
|
.width(60 * globalThis.ratio* this.dialogRatio)
|
2024-08-20 09:12:02 +08:00
|
|
|
}
|
|
|
|
|
.commStyle()
|
|
|
|
|
.onClick(() => {
|
|
|
|
|
if (this.controller != undefined) {
|
|
|
|
|
this.cancel()
|
|
|
|
|
this.controller.close()
|
|
|
|
|
}
|
|
|
|
|
}).margin({ right: 10 * globalThis.ratio * this.dialogRatio})
|
|
|
|
|
|
|
|
|
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
|
|
|
|
Text(' 确 定 ')
|
2024-08-20 09:43:25 +08:00
|
|
|
.fontSize(24 * globalThis.ratio* this.dialogRatio*0.6)
|
2024-08-20 09:12:02 +08:00
|
|
|
.fontColor('#fff')
|
2024-08-20 09:43:25 +08:00
|
|
|
.width(60 * globalThis.ratio* this.dialogRatio)
|
2024-08-20 09:12:02 +08:00
|
|
|
}
|
|
|
|
|
.commStyle()
|
|
|
|
|
.onClick(() => {
|
|
|
|
|
if (this.controller != undefined){
|
|
|
|
|
this.confirm()
|
|
|
|
|
this.controller.close()
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-08-20 09:43:25 +08:00
|
|
|
}.padding({bottom:20})
|
2024-08-20 09:12:02 +08:00
|
|
|
|
|
|
|
|
}
|
2024-08-19 14:56:36 +08:00
|
|
|
}.backgroundColor('#E6E3DF')
|
|
|
|
|
.borderRadius(19 * globalThis.ratio)
|
|
|
|
|
.constraintSize({ minWidth: 520 })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aboutToAppear() {
|
|
|
|
|
AppStorage.SetOrCreate('errorMsg', 0);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
console.log('this.type',this.type,this.angle)
|
|
|
|
|
if (this.type=='2') {
|
|
|
|
|
this.angle = 360
|
|
|
|
|
}
|
|
|
|
|
},1000)
|
|
|
|
|
if(this.type=='1'){
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.controller.close()
|
|
|
|
|
},2000)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
aboutToDisappear() {
|
|
|
|
|
this.title=''
|
|
|
|
|
this.angle = 0
|
|
|
|
|
}
|
|
|
|
|
}
|