更新云信相关代码
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
import { BasicConstant, calculateExactAge, hdHttp, HdLoadingDialog,HdNav, HdResponse } from '@itcast/basic'
|
||||
import { TabBarTopComp } from './TabBarTopComp';
|
||||
import { HashMap } from '@kit.ArkTS';
|
||||
import { router } from '@kit.ArkUI';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { InterrogationPatientInfoBean } from '../model/InterrogationPatientInfoBean';
|
||||
|
||||
|
||||
@Component
|
||||
export struct BaseInfoComp {
|
||||
@State sex: number=0;
|
||||
|
||||
hashMap: HashMap<string, string> = new HashMap();
|
||||
@State params:Record<string, string> = router.getParams() as Record<string, string>;
|
||||
@State name:string='';
|
||||
dialog: CustomDialogController = new CustomDialogController({
|
||||
builder: HdLoadingDialog({ message: '加载中...' }),
|
||||
customStyle: true,
|
||||
alignment: DialogAlignment.Center
|
||||
})
|
||||
@State birthday: string='' ;
|
||||
@State address: string='' ;
|
||||
@State whether_hbv: string='' ;
|
||||
@State whether_pregnant: string='';
|
||||
@State expected_date_of_childbirth: string='';
|
||||
|
||||
aboutToAppear() {
|
||||
|
||||
this.initData()
|
||||
}
|
||||
|
||||
initData()
|
||||
{
|
||||
this.dialog.open()
|
||||
this.hashMap.clear();
|
||||
this.hashMap.set('step1_uuid', this.params.uuid)
|
||||
|
||||
hdHttp.httpReq<string>(BasicConstant.InterrogationPatientInfo,this.hashMap).then(async (res: HdResponse<string>) => {
|
||||
this.dialog.close()
|
||||
let json:InterrogationPatientInfoBean = JSON.parse(res+'') as InterrogationPatientInfoBean;
|
||||
this.name=json.data.name+' '
|
||||
this.sex=json.data.sex
|
||||
this.birthday=json.data.birthday
|
||||
this.address=json.data.address
|
||||
if(json.data.whether_hbv==0)
|
||||
{
|
||||
this.whether_hbv='无'
|
||||
}
|
||||
else if(json.data.whether_hbv==1)
|
||||
{
|
||||
this.whether_hbv='有'
|
||||
}
|
||||
else
|
||||
{
|
||||
this.whether_hbv='未知'
|
||||
}
|
||||
if(json.data.whether_pregnant==0)
|
||||
{
|
||||
this.whether_pregnant=''
|
||||
}
|
||||
else if(json.data.whether_pregnant==1)
|
||||
{
|
||||
this.whether_pregnant='无计划'
|
||||
}
|
||||
else if(json.data.whether_pregnant==2)
|
||||
{
|
||||
this.whether_pregnant='计划中'
|
||||
}
|
||||
else if(json.data.whether_pregnant==3)
|
||||
{
|
||||
this.whether_pregnant='已怀孕'
|
||||
}
|
||||
else if(json.data.whether_pregnant==4)
|
||||
{
|
||||
this.whether_pregnant='家有宝宝'
|
||||
}
|
||||
if(json.data.expected_date_of_childbirth!=null)
|
||||
{
|
||||
this.expected_date_of_childbirth=json.data.expected_date_of_childbirth
|
||||
}
|
||||
|
||||
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close()
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
build() {
|
||||
|
||||
Column() {
|
||||
|
||||
Row()
|
||||
{
|
||||
Text('姓名').customStyle().layoutWeight(1)
|
||||
Text(this.name.substring(0,1)+'**').customStyle1()
|
||||
}
|
||||
.width('100%')
|
||||
Text('').height(1).width('100%')
|
||||
.backgroundColor($r('app.color.common_gray_border'))
|
||||
Row()
|
||||
{
|
||||
Text('性别').customStyle().layoutWeight(1)
|
||||
Text(this.sex==0?"男":"女").customStyle1()
|
||||
}
|
||||
.width('100%')
|
||||
Text('').height(1).width('100%')
|
||||
.backgroundColor($r('app.color.common_gray_border'))
|
||||
Row()
|
||||
{
|
||||
Text('年龄').customStyle().layoutWeight(1)
|
||||
Text(this.getYears(this.birthday)+'').customStyle1()
|
||||
}
|
||||
.width('100%')
|
||||
Text('').height(1).width('100%')
|
||||
.backgroundColor($r('app.color.common_gray_border'))
|
||||
Row()
|
||||
{
|
||||
Text('地址').customStyle().layoutWeight(1)
|
||||
Text(this.address).customStyle1()
|
||||
}
|
||||
.width('100%')
|
||||
Text('').height(1).width('100%')
|
||||
.backgroundColor($r('app.color.common_gray_border'))
|
||||
Row()
|
||||
{
|
||||
Text('是否怀孕').customStyle().layoutWeight(1)
|
||||
Text(this.whether_pregnant).customStyle1()
|
||||
}
|
||||
.width('100%')
|
||||
.visibility(this.whether_pregnant==''?Visibility.None:Visibility.Visible)
|
||||
Text('').height(1).width('100%')
|
||||
.backgroundColor($r('app.color.common_gray_border')).visibility(this.whether_pregnant==''?Visibility.None:Visibility.Visible)
|
||||
Row()
|
||||
{
|
||||
Text('是否怀孕').customStyle().layoutWeight(1)
|
||||
Text(this.expected_date_of_childbirth).customStyle1()
|
||||
}
|
||||
.width('100%')
|
||||
.visibility(this.expected_date_of_childbirth==''?Visibility.None:Visibility.Visible)
|
||||
Text('').height(1).width('100%')
|
||||
.backgroundColor($r('app.color.common_gray_border')).visibility(this.expected_date_of_childbirth==''?Visibility.None:Visibility.Visible)
|
||||
Row()
|
||||
{
|
||||
Text('肝硬化或肝癌家族史').customStyle().layoutWeight(1)
|
||||
Text(this.whether_hbv).customStyle1()
|
||||
}
|
||||
.width('100%')
|
||||
}.width('100%')
|
||||
.height('100%')
|
||||
.backgroundColor(Color.White)
|
||||
.padding({left:10,right:10})
|
||||
|
||||
}
|
||||
getYears(birthDateStr:string): number
|
||||
{
|
||||
const birthDate: Date = new Date(birthDateStr);
|
||||
return calculateExactAge(birthDate)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Extend(Text)
|
||||
function customStyle() {
|
||||
|
||||
.fontColor($r('app.color.common_gray_01'))
|
||||
.fontSize(16)
|
||||
.padding({top:15,bottom:15})
|
||||
|
||||
}
|
||||
|
||||
@Extend(Text)
|
||||
function customStyle1() {
|
||||
|
||||
.fontColor($r('app.color.999999'))
|
||||
.fontSize(16)
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user