harmony/features/netease/src/main/ets/view/InterrogationDetailComp.ets
2025-07-11 17:33:40 +08:00

328 lines
12 KiB
Plaintext

import { authStore, BasicConstant,
calculateExactAge,
hdHttp, HdLoadingDialog, HdNav, HdResponse,
PhotoGrids,
ViewImageInfo} from '@itcast/basic'
import { HashMap } from '@kit.ArkTS';
import { GetInterrogationBean, ConsultPhoto, SupplementListBean, AnswerListBean } from '../model/ConsulModel';
import { BusinessError } from '@kit.BasicServicesKit';
import { promptAction, router } from '@kit.ArkUI';
@Component
export struct InterrogationDetailComp {
@State patientName: string='' ;
hashMap: HashMap<string, string> = new HashMap();
@State params:Record<string, string> = router.getParams() as Record<string, string>;
@State state: string='1' ;
@State createDate: string='' ;
@State content: string='' ;
@State diseaseName: string='' ;
@State imgListurl:string[]=[]
@State sex:number=0
@State birthday: string='' ;
@State supplementList:SupplementListBean[]=[]
@State AnswerList:AnswerListBean[]=[]
@State flag_more:boolean=true
scroller = new Scroller()
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
aboutToAppear() {
this.initData()
}
initData()
{
this.dialog.open()
this.hashMap.clear();
this.hashMap.set('uuid', this.params.uuid)
hdHttp.httpReq<string>(BasicConstant.getInterrogation,this.hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close()
let json:GetInterrogationBean = JSON.parse(res+'') as GetInterrogationBean;
this.patientName=json.data.name
this.state=json.data.user_status
this.sex=json.data.sex
this.birthday=json.data.birthday
this.createDate=json.data.create_date
this.content=json.data.disease_describe
this.diseaseName=json.data.disease_name
if(json.data.imgs!=null)
{
this.imgListurl = [...json.data.imgs.split(",")]
}
this.supplementList=json.data.SupplementList
this.AnswerList=json.data.AnswerList
}).catch((err: BusinessError) => {
this.dialog.close()
})
}
build() {
Column() {
HdNav({ title: '问题详情', showRightIcon: false, showLeftIcon: true})
Scroll(this.scroller) {
Column() {
Row() {
Text() {
Span(this.state == '0' ? $r('app.string.cancellation') : this.patientName.substring(0, 1) + '**')
.fontColor($r('app.color.top_title'))
Span(this.sex == 0 ? "(男 " + this.getYears(this.birthday) + "岁)" :
"(女 " + this.getYears(this.birthday) + "岁)").fontColor($r('app.color.common_gray_03'))
}.fontSize(19).padding({ left: 10, right: 3 }).textAlign(TextAlign.Start)
Image($r('app.media.iv_zixun')).width(91).height(17)
.onClick(() => {
router.pushUrl({
url: 'pages/Netease/PatientSimplyPage',
params: { uuid: this.params.uuid }
});
})
}
.padding({ top: 10, bottom: 10 })
.alignSelf(ItemAlign.Start)
Row() {
Text(this.diseaseName.includes("甲、乙、丙、丁") ? '肝炎' : this.diseaseName)
.fontSize(11)
.borderColor($r('app.color.top_title'))
.fontColor($r('app.color.top_title'))
.width(63)
.height(25)
.borderRadius(17)
.borderWidth(1)
.textAlign(TextAlign.Center)
Blank()
Text(this.createDate ? this.createDate.length > 10 ? this.createDate.substring(0, 10) : this.createDate :
'')
.fontSize(15).fontColor($r('app.color.common_gray_03')).padding({ left: 5 })
}
.width('100%')
.alignSelf(ItemAlign.Start)
.padding({ left: 10, right: 10, bottom: 10 })
Row() {
Text(this.content)
.fontSize(14)
.fontColor($r('app.color.common_gray_03'))
.padding(9)
.backgroundColor($r('app.color.f6f6f6'))
.borderRadius(8)
.width('100%')
}
.margin({ left: 10, right: 10, bottom: 10 })
PhotoGrids({ imgList: this.changeToImg(this.imgListurl) })
Row()
{
Text(this.flag_more?'查看更多':'收起').fontSize(14).fontColor($r('app.color.top_title'))
Image(this.flag_more?$r('app.media.icon_down'):$r('app.media.icon_up')).width(8).height(4)
}
.margin(10)
.onClick(()=>{
this.flag_more=!this.flag_more
})
.visibility(this.supplementList.length&&this.AnswerList.length>0?Visibility.Visible:Visibility.None)
List() {
ForEach(this.supplementList, (item: SupplementListBean,index:number) => {
ListItem() {
Column() {
Row()
{
Text('信息补充').width(54).height(30).fontColor(Color.White).fontSize(11)
.textAlign(TextAlign.Center)
.padding({bottom:5})
.backgroundImage($r('app.media.complete_question'))
.backgroundImageSize(ImageSize.FILL)
Blank()
Text(item.create_date.split(" ")[0]).fontColor($r('app.color.common_gray_03'))
}
.width('100%')
.padding(10)
Text(item.disease_describe)
.fontSize(14).fontColor($r('app.color.common_gray_03')).padding(9)
.backgroundColor($r('app.color.f6f6f6')).borderRadius(8)
.width('calc(100% - 20vp)')
.margin({bottom:10})
PhotoGrids({ imgList: this.changeToImg(item.imgs?[...item.imgs.split(",") ]:[]) })
// PhotoGridUrl({ imgListurl: item.imgs?[...item.imgs.split(",") ]:[] })
}
}
})
} .visibility(this.flag_more?Visibility.None:Visibility.Visible)
Text('').width('100%').height(10).backgroundColor($r('app.color.efefef'))
.visibility(this.AnswerList.length>0?Visibility.Visible:Visibility.None)
Text('医生回答')
.fontSize(18).fontColor($r('app.color.top_title'))
.width('calc(100% - 20vp)')
.margin({bottom:10,top:10})
.visibility(this.AnswerList.length>0?Visibility.Visible:Visibility.None)
Text('').width('100%').height(0.5).backgroundColor($r('app.color.f6f6f6'))
.visibility(this.AnswerList.length>0?Visibility.Visible:Visibility.None)
List() {
ForEach(this.AnswerList, (item: AnswerListBean,index:number) => {
ListItem() {
Column() {
Row()
{
Image(BasicConstant.urlHtml+item.photo).width(45).height(45).borderRadius(6)
Column()
{
Row() {
Text()
{
if(item.expert_status=='0')
{
Span($r('app.string.cancellation')).fontColor($r('app.color.top_title')).fontSize(18)
}
else
{
Span(item.realname.length>5?item.realname.substring(0,5)+"...":item.realname).fontColor($r('app.color.top_title')).fontSize(18)
}
Span('|').fontColor($r('app.color.common_gray_03')).fontSize(17).padding({left:5,right:5}).visibility(item.name=='其他'?Visibility.Hidden:Visibility.Visible)
Span(item.name).fontColor($r('app.color.common_gray_03')).fontSize(17).visibility(item.name=='其他'?Visibility.Hidden:Visibility.Visible)
}.layoutWeight(1)
Text('满意答复').fontSize(13).padding({left:9,right:9,bottom:3,top:3})
.backgroundColor('#ffa800').borderRadius(17).fontColor(Color.White).visibility(item.satisfied=='1'?Visibility.Visible:Visibility.None)
}.width('100%')
Row() {
Text(item.hospital_name).fontColor($r('app.color.common_gray_03')).fontSize(14).
visibility(item.hospital_name=='其他医院'?Visibility.Hidden:Visibility.Visible)
.layoutWeight(1)
Text(item.create_date).fontColor($r('app.color.common_gray_03')).fontSize(16)
}
.margin({top:5})
.width('100%')
}.layoutWeight(1)
.margin({left:10})
}
.width('100%')
.padding(10)
Text(item.note)
.fontSize(14).fontColor($r('app.color.common_gray_03')).padding(9)
.backgroundColor($r('app.color.f6f6f6')).borderRadius(8)
.width('calc(100% - 20vp)')
.margin({bottom:10})
PhotoGrids({ imgList: this.changeToImg(item.imgs?[...item.imgs.split(",") ]:[]) })
}
}
})
}
.divider({
strokeWidth: 5, // 线宽
color:$r('app.color.f6f6f6'), // 颜色
})
}
}
.width('100%')
.layoutWeight(1)
.align(Alignment.TopStart)
Column()
{
Text()
{
Span('特别声明:').fontColor($r('app.color.top_title'))
Span('答案仅为医生个人经验或建议分享,不能视为诊断依据,如有诊疗需求,请务必前往正规医院就诊。').fontColor($r('app.color.common_gray_03'))
}
.fontSize(14).padding(9).margin({left:10,right:10,top:10,bottom:10})
.backgroundColor($r('app.color.f6f6f6')).borderRadius(8)
Button({ type: ButtonType.Normal }){
Text(this.params.isHistory =='false'?'我要回答':'我要编辑')
}
.width('100%')
.height(53)
.backgroundColor($r('app.color.patient_theme'))
.fontColor(Color.White)
.onClick(() => {
if(this.params.isHistory =='false')
{
router.pushUrl({
url: 'pages/Netease/MyOpinionPage',
params: { uuid:this.params.uuid,isHistory:this.params.isHistory}
});
}
else
{
router.pushUrl({
url: 'pages/Netease/MyOpinionPage',
params: { uuid:this.params.uuid,isHistory:this.params.isHistory,myAnswer:this.getMyanswer(this.AnswerList)}
});
}
})
}
.backgroundColor(Color.White)
.width('100%')
}
.width('100%')
.width('100%')
.onClick(() => {
// router.pushUrl({
// url: 'pages/Netease/ConsultationDetailPage',
// params: { uuid: this.item.uuid}
// });
})
}
getYears(birthDateStr:string): number
{
const birthDate: Date = new Date(birthDateStr);
return calculateExactAge(birthDate)
}
changeToImg( imgListurl:string[])
{
let imgListtmps:ViewImageInfo[]=[]
imgListurl.forEach((url: string) => {
let item = {url:url} as ViewImageInfo
imgListtmps.push(item)
})
return imgListtmps
}
getMyanswer(AnswerList:AnswerListBean[])
{
let targetItem = AnswerList.find(item => authStore.getUser().uuid ==item.expert_uuid );
return targetItem
}
}