diff --git a/commons/basic/Index.ets b/commons/basic/Index.ets index 8c0722f..d52ae5e 100644 --- a/commons/basic/Index.ets +++ b/commons/basic/Index.ets @@ -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' \ No newline at end of file +export { HdSearchNav } from './src/main/ets/components/HdSearchNav' + +export { DefaultHintProWindows } from './src/main/ets/Views/DefaultHintProWindows' \ No newline at end of file diff --git a/commons/basic/src/main/ets/Views/DefaultHintProWindows.ets b/commons/basic/src/main/ets/Views/DefaultHintProWindows.ets new file mode 100644 index 0000000..f693341 --- /dev/null +++ b/commons/basic/src/main/ets/Views/DefaultHintProWindows.ets @@ -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) + } +} diff --git a/features/Home/src/main/ets/components/VideoDetailsComment.ets b/features/Home/src/main/ets/components/VideoDetailsComment.ets index d30beab..e3e4dda 100644 --- a/features/Home/src/main/ets/components/VideoDetailsComment.ets +++ b/features/Home/src/main/ets/components/VideoDetailsComment.ets @@ -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('回复') diff --git a/products/expert/src/main/ets/pages/MinePage/CancelAccount.ets b/products/expert/src/main/ets/pages/MinePage/CancelAccount.ets index e264e17..81d46ab 100644 --- a/products/expert/src/main/ets/pages/MinePage/CancelAccount.ets +++ b/products/expert/src/main/ets/pages/MinePage/CancelAccount.ets @@ -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(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(); } } \ No newline at end of file