自定义警告弹窗

This commit is contained in:
xiaoxiao 2025-06-13 17:32:06 +08:00
parent 8300766e5c
commit c4a3b21499
5 changed files with 147 additions and 54 deletions

View File

@ -54,4 +54,6 @@ export { Huanzhelast444Model } from './src/main/ets/models/Huanzhelast444Model'
export { huanzheDb } from './src/main/ets/utils/HuanzhelasDbHelper'
export { HdSearchNav } from './src/main/ets/components/HdSearchNav'
export { HdSearchNav } from './src/main/ets/components/HdSearchNav'
export { DefaultHintProWindows } from './src/main/ets/Views/DefaultHintProWindows'

View File

@ -0,0 +1,65 @@
@CustomDialog
export struct DefaultHintProWindows {
@Prop title: string = '温馨提示';
@Prop titleFont: number = 18;
@Prop message: string = '';
@Prop messageFont: number = 16;
@Prop cancleTitle: string = '取消';
@Prop cancleTitleColor:ResourceStr = '#666666';
@Prop confirmTitle:string = '确定';
@Prop confirmTitleColor:ResourceStr = '#000000';
@Prop cancleColor:ResourceStr = '#FFFFFF';
@Prop confirmColor:ResourceStr = '#FFFFFF';
controller: CustomDialogController;
// 添加回调函数属性
private selectedButton: (index: number) => void = () => {};
// 修改构造函数
constructor(controller: CustomDialogController, selectedButton: (index:number) => void) {
super();
this.controller = controller;
this.selectedButton = selectedButton;
}
build() {
Row(){
Column() {
Text(this.title)
.fontSize(this.titleFont)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Center)
.margin({ top: 20 })
Text(this.message)
.fontSize(this.messageFont)
.textAlign(TextAlign.Center)
.margin({ top: 10 })
Row({ space: 20 }) {
Button({ buttonStyle: ButtonStyleMode.TEXTUAL }) {
Text(this.cancleTitle)
.fontSize(15)
.fontColor(this.cancleTitleColor)
}
.width('45%').height(30).backgroundColor(this.cancleColor)
.onClick(() => {
this.selectedButton(0)
})
.visibility(this.cancleTitle?Visibility.Visible:Visibility.None)
Button({ buttonStyle: ButtonStyleMode.TEXTUAL }) {
Text(this.confirmTitle)
.fontSize(15)
.fontColor(this.confirmTitleColor)
}.width('45%').height(30).backgroundColor(this.cancleColor)
.onClick(() => {
this.selectedButton(1)
})
}.margin({ top: 20, bottom: 20 })
}
.width('100%').backgroundColor(Color.White)
}.borderRadius(24)
}
}

View File

@ -1,4 +1,4 @@
import { BasicConstant, authStore } from '@itcast/basic'
import { BasicConstant, authStore,DefaultHintProWindows } from '@itcast/basic'
import { commentModel } from '../model/VideoCommentModel'
import { CommentChildView } from '../components/CommentChildView'
import { router,promptAction } from '@kit.ArkUI';
@ -13,6 +13,31 @@ export struct VideoDetailsComment {
@Prop model:commentModel;
@Prop videoCommentUuid:string;
@State isShowMoreComment:boolean = false;
private hintWindowDialog!: CustomDialogController;
aboutToAppear(): void {
this.hintPopWindowDialog();
}
private hintPopWindowDialog() {
this.hintWindowDialog = new CustomDialogController({
builder:DefaultHintProWindows({
controller:this.hintWindowDialog,
message:'确定要删除评论?',
cancleTitleColor: '#666666',
confirmTitleColor: $r('app.color.main_color'),
selectedButton: (index:number)=>{
if (index === 1) {
this.deleteComment();
}
this.hintWindowDialog.close();
}
}),
alignment: DialogAlignment.Center,
cornerRadius:24,
backgroundColor: ('rgba(0,0,0,0.5)'),
})
}
deleteComment() {
const updateDataUrl:string = BasicConstant.deleteComment;
@ -56,14 +81,7 @@ export struct VideoDetailsComment {
Image($r('app.media.video_comment_delete'))
.width(20).height(20).margin({right:15})
.onClick(()=>{
promptAction.showDialog({ title: '温馨提示', message: '确定要删除评论?',
buttons: [{ text: '取消', color: '#666666' }, { text: '确定', color: $r('app.color.main_color') }],
})
.then(data => {
if (data.index == 1) {
this.deleteComment();
}
})
this.hintWindowDialog.open()
})
} else {
Text('回复')

View File

@ -1,5 +1,5 @@
import { BasicConstant,ExpertData,perfactAuth,ChangeUtil,authStore,preferenceStore,LoginInfo,
logger } from '@itcast/basic'
logger,DefaultHintProWindows } from '@itcast/basic'
import { LengthMetrics, promptAction, router } from '@kit.ArkUI'
import { EditUserDataItem } from '@itcast/basic/src/main/ets/Views/EditUserDataItem'
import { PerfactInputSheet } from '@itcast/basic/src/main/ets/Views/PerfactInputSheet'
@ -85,6 +85,7 @@ export struct PerfectUserDataComp {
private diseaseSheetDialog!:CustomDialogController;
private sexSheetDilog!:CustomDialogController;
private perfactInputSheet!:CustomDialogController;
private hintWindowDialog!: CustomDialogController;
aboutToAppear() {
this.initSexDialog();
@ -95,6 +96,7 @@ export struct PerfectUserDataComp {
this.initCerficatePhotoDialog();
this.initDiseaseSheetDIalog();
this.handleState()
this.hintPopWindowDialog();
// logger.info("Response this.photoPath "+this.photoPath)
// 收到eventId为1的事件后执行回调函数
@ -126,14 +128,7 @@ export struct PerfectUserDataComp {
if(this.checkInfo!=''||this.checkInfo!=null)
{
this.info=this.checkInfo
promptAction.showDialog({ title: '温馨提示', message: this.checkInfo,
buttons: [{ text: '确定', color: $r('app.color.main_color') }],
})
.then(data => {
if (data.index == 1) {
}
})
this.hintWindowDialog.open();
}
}
@ -475,6 +470,21 @@ export struct PerfectUserDataComp {
})
}
private hintPopWindowDialog() {
this.hintWindowDialog = new CustomDialogController({
builder:DefaultHintProWindows({
controller:this.hintWindowDialog,
message:this.checkInfo,
confirmTitleColor: $r('app.color.main_color'),
selectedButton: (index:number)=>{
this.hintWindowDialog.close();
}
}),
alignment: DialogAlignment.Center,
cornerRadius:24,
backgroundColor: ('rgba(0,0,0,0.5)'),
})
}
build() {

View File

@ -1,5 +1,5 @@
import { HdNav } from '@itcast/basic';
import { hdHttp, HdResponse,BasicConstant,ExpertData, authStore } from '@itcast/basic'
import { hdHttp, HdResponse,BasicConstant,DefaultHintProWindows, authStore } from '@itcast/basic'
import { BusinessError } from '@kit.BasicServicesKit';
import { router } from '@kit.ArkUI'
import promptAction from '@ohos.promptAction';
@ -18,6 +18,7 @@ interface callBackData {
@Entry
@Component
struct CancelAccount {
@State hintMessage:string = '';
@State feedbackText: string =
' 账户注销后不可恢复,您将永久放弃此账户现有权益\n' +
' 1.您将不能再使用此账户随访患者,不能接收随访患者发送的信息\n' +
@ -27,6 +28,32 @@ struct CancelAccount {
' 收到您的注销申请后我们将在10个工作日内帮您完成注销及数据清除工作'
controller:TextAreaController = new TextAreaController();
private hintWindowDialog!: CustomDialogController;
aboutToAppear(): void {
this.hintPopWindowDialog();
}
private hintPopWindowDialog() {
this.hintWindowDialog = new CustomDialogController({
builder:DefaultHintProWindows({
controller:this.hintWindowDialog,
message:this.hintMessage,
cancleTitleColor: this.hintMessage.includes('确定要注销肝胆相照平台账号吗?')?'#000000':'#666666',
confirmTitleColor: this.hintMessage.includes('确定要注销肝胆相照平台账号吗?')?'#999999':'#000000',
selectedButton: (index:number)=>{
if (index === 1 && this.hintMessage.includes('确定要注销肝胆相照平台账号吗?')) {
this.uploadCancleAccountAction();
}
this.hintWindowDialog.close();
}
}),
alignment: DialogAlignment.Center,
cornerRadius:24,
backgroundColor: ('rgba(0,0,0,0.5)'),
})
}
uploadCancleAccountAction() {
hdHttp.post<string>(BasicConstant.urlExpert + 'patientList', {
expertUuid: authStore.getUser().uuid
@ -34,11 +61,8 @@ struct CancelAccount {
let json: callBackData = JSON.parse(res + '') as callBackData;
console.log('注销账户数据:', json);
if (json.data.length > 0) {
promptAction.showDialog({
title: '温馨提示',
message: '请您解除所有随访患者后再提交注销申请',
buttons: [{ text: '确定', color: '#000000' }],
})
this.hintMessage = '请您解除所有随访患者后再提交注销申请'
this.hintWindowDialog.open();
} else {
this.uploadFeedBackAction();
}
@ -55,11 +79,7 @@ struct CancelAccount {
let json: callBackData = JSON.parse(res + '') as callBackData;
console.log('提交注销账户数据:', json);
if (json.code == 1) {
promptAction.showDialog({
title: '温馨提示',
message: '提交成功!',
buttons: [{ text: '取消', color: '#000000' }, { text: '确定', color: '#000000' }]
})
this.hintMessage = '提交成功!'
} else {
promptAction.showToast({ message: json.message });
}
@ -111,29 +131,7 @@ struct CancelAccount {
}
// 提交反馈处理
private submitFeedback(): void {
// 提交逻辑实现
promptAction.showDialog({
title:'注销账户',
message:'确定要注销肝胆相照平台账号吗?\n注销后您的所有数据将无法恢复',
alignment:DialogAlignment.Center,
buttons:[
{
text:'取消',
color:'#333333'
},
{
text:'确定',
color:'#999999'
}
]
})
.then(data=>{
if (data.index === 1) {
this.uploadCancleAccountAction();
}
})
.catch((error:Error)=>{
console.info('showDialog error:'+error)
})
this.hintMessage = '确定要注销肝胆相照平台账号吗?\n注销后您的所有数据将无法恢复';
this.hintWindowDialog.open();
}
}