diff --git a/commons/basic/src/main/ets/components/HdNav.ets b/commons/basic/src/main/ets/components/HdNav.ets index 4fd0a8b..f8e6ee8 100644 --- a/commons/basic/src/main/ets/components/HdNav.ets +++ b/commons/basic/src/main/ets/components/HdNav.ets @@ -46,19 +46,23 @@ export struct HdNav { build() { Row() { if (this.showLeftIcon) { - Image(this.leftIcon) - .size({ width: 24, height: 24 }) - .margin({left:-5}) - .onClick(() => router.back()) - .fillColor($r('app.color.black')) + Row() + { + Image(this.leftIcon) + .size({ width: 24, height: 24 }) + .onClick(() => router.back()) + .fillColor($r('app.color.black')) + } + .size({ width: 50, height: 50 }) + + } else { Blank() - .width(24) + .width(50) } Row() { if (this.title) { Text(this.title) - // .fontWeight(600) .layoutWeight(1) .textAlign(TextAlign.Center) .fontSize(20) @@ -74,20 +78,27 @@ export struct HdNav { .layoutWeight(1) if (this.showRightIcon) { - Image(this.rightIcon) - .size({ width: 24, height: 24 }) - .objectFit(ImageFit.Contain) - .bindMenu(this.menuBuilder) - .onClick(()=>this.onRightItemClick()) + Row() + { + Image(this.rightIcon) + .size({ width: 24, height: 24 }) + .objectFit(ImageFit.Contain) + .bindMenu(this.menuBuilder) + .onClick(()=>this.onRightItemClick()) + } + .size({ width: 50, height: 50 }) + } else if (this.showRightText) { Text(this.rightText) .fontSize(16) .fontColor(this.textColor) .onClick(()=>this.onRightItemClick()) + .width(50) + .textAlign(TextAlign.Center) // .margin({right:10}) } else { Blank() - .width(24) + .width(50) } } .padding({ left: 16, right: 16, top: this.topHeight }) diff --git a/commons/basic/src/main/ets/utils/PerfactAuth.ets b/commons/basic/src/main/ets/utils/PerfactAuth.ets index bafa1ca..91785c4 100644 --- a/commons/basic/src/main/ets/utils/PerfactAuth.ets +++ b/commons/basic/src/main/ets/utils/PerfactAuth.ets @@ -31,7 +31,7 @@ class PerfactAuth { await this.getStore().flush() } - initUser() { + initUser(phone:string) { const json = this.getStore().getSync(AUTH_STORE_KEY, '{}') as string AppStorage.setOrCreate(AUTH_STORE_KEY, JSON.parse(json)) } diff --git a/features/register/src/main/ets/view/LoginComp.ets b/features/register/src/main/ets/view/LoginComp.ets index 14f0c4b..2c1de6c 100644 --- a/features/register/src/main/ets/view/LoginComp.ets +++ b/features/register/src/main/ets/view/LoginComp.ets @@ -3,6 +3,7 @@ import { promptAction, router } from '@kit.ArkUI' import { BusinessError } from '@kit.BasicServicesKit'; import HashMap from '@ohos.util.HashMap'; import { DataWebModel,preferenceStore } from '@itcast/basic' +import {perfactAuth } from '@itcast/basic' @Preview @Component export struct LoginComp { @@ -33,6 +34,8 @@ export struct LoginComp { hashMap: HashMap = new HashMap(); + + login() { if (this.loading) return; if (!this.mobile) { @@ -87,6 +90,7 @@ export struct LoginComp { getSaveUserInfor(type:number,objs:LoginInfo) { let state:number=objs.data.state if(state!=6) { + perfactAuth.initUser(this.mobile) router.pushUrl({ url: 'pages/LoginPage/LoginSetInfoPage', // 目标url params: { diff --git a/features/register/src/main/ets/view/PerfectUserDataComp.ets b/features/register/src/main/ets/view/PerfectUserDataComp.ets index 7d8ea66..2d5fee0 100644 --- a/features/register/src/main/ets/view/PerfectUserDataComp.ets +++ b/features/register/src/main/ets/view/PerfectUserDataComp.ets @@ -1,5 +1,5 @@ import { BasicConstant,ExpertData, authStore,perfactAuth } from '@itcast/basic' -import { promptAction, router } from '@kit.ArkUI' +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' import { PhotoActionSheet } from '@itcast/basic/src/main/ets/Views/PhotoActionSheet' @@ -39,13 +39,13 @@ interface callBackData { export struct PerfectUserDataComp { scroller: Scroller = new Scroller(); - @Prop loginPhone:string = '13419527489'; + @Prop loginPhone:string = ''; @State photoPath:string = BasicConstant.urlImage+authStore.getUser().photo; - @State name:string = perfactAuth.getUser('13419527489').realName?perfactAuth.getUser('13419527489').realName:'请输入姓名'; + @State name:string = perfactAuth.getUser(this.loginPhone).realName?perfactAuth.getUser('13419527489').realName:'请输入姓名'; @State sex:string = perfactAuth.getUser('13419527489').sex?perfactAuth.getUser('13419527489').sex == 0 ? '男' : '女':'请选择性别'; @State sexnum:number = perfactAuth.getUser('13419527489').sex; - @State hospatilName:string = perfactAuth.getUser('13419527489').hospitalName?'':'请选择所在医院'; + @State hospatilName:string = perfactAuth.getUser(this.loginPhone).hospitalName @State officeName:string = perfactAuth.getUser('13419527489').officeName?perfactAuth.getUser('13419527489').officeName.length>0?perfactAuth.getUser('13419527489').officeName:'请选择科室':'请选择科室'; @State officeUuid:string = perfactAuth.getUser('13419527489').officeUuid; @State officePhone:string = authStore.getUser().officePhone?perfactAuth.getUser('13419527489').officePhone.length?perfactAuth.getUser('13419527489').officePhone:'请输入所在科室的电话':'请输入所在科室的电话'; @@ -78,24 +78,36 @@ export struct PerfectUserDataComp { this.initCerficatePhotoDialog(); this.initDiseaseSheetDIalog(); - authStore.initUser() + this.hospatilName =JSON.stringify(perfactAuth.getUser(this.loginPhone)) + console.info('个人资料=loginPhone:',this.loginPhone+' 3rf '+this.hospatilName); + + emitter.on({ eventId: 250516 }, () => { this.handleSave() }) + // 收到eventId为1的事件后执行回调函数 + emitter.on({ eventId: 250517 }, (eventData: emitter.EventData) => { + console.info(`eventData: ${JSON.stringify(eventData)}`); + const params =eventData.data as Record; // 获取传递过来的参数对象 + this.hospatilName=params.name + + }); } aboutToDisappear() { emitter.off(250516) + emitter.off(250517) } + private handleSave() { promptAction.showToast({ message: '您输入的个人资料已经保存,请完善所有信息后提交审核', duration: 1000 }) const userData:ExpertData = { - positionName: this.positionName='请选择职称'?'':this.positionName, + positionName: this.positionName=='请选择职称'?'':this.positionName, userName: this.loginPhone, createDate: '', password: '', - officeName: this.officeName='请选择科室'?'':this.officeName, + officeName: this.officeName=='请选择科室'?'':this.officeName, certificateImg: this.certificatePhoto, birthDate: '', isStar: 0, @@ -105,15 +117,15 @@ export struct PerfectUserDataComp { photo: this.photoPath, qrcode: '', mobile: this.loginPhone, - hospitalName: '', + hospitalName: this.hospatilName, officeUuid: this.officeUuid, checkInfo: '', hospitalUuid: '', - officePhone: this.officePhone='请输入所在科室的电话'?'':this.officePhone, + officePhone: this.officePhone=='请输入所在科室的电话'?'':this.officePhone, positionUuid: this.positionUuid, sex: this.sexnum, provId: 0, - certificate: this.certificate='请输入执业医师证号码'?'':this.certificate, + certificate: this.certificate=='请输入执业医师证号码'?'':this.certificate, realName: this.name, isEnable: 0, isVisit: 0, @@ -128,7 +140,7 @@ export struct PerfectUserDataComp { intro: '', state: 0, specialy: [], - diseaseName:this.diseaseName='请选择专长'?'':this.diseaseName, + diseaseName:this.diseaseName=='请选择专长'?'':this.diseaseName, diseaseUuid:this.diswaseUuid }; perfactAuth.setUser('13419527489',userData); @@ -168,7 +180,7 @@ export struct PerfectUserDataComp { } } }), - keyboardAvoidDistance: {value:-2000} as LengthMetrics, // 设置弹窗底部与键盘顶部间距(单位:vp) + keyboardAvoidDistance: LengthMetrics.vp(0), // 设置弹窗底部与键盘顶部间距(单位:vp) alignment: DialogAlignment.Bottom, customStyle: true, autoCancel: false, @@ -261,6 +273,8 @@ export struct PerfectUserDataComp { }) } + + build() { Scroll(this.scroller) { Column() { @@ -357,6 +371,6 @@ export struct PerfectUserDataComp { } } -function handleSave() { - -} \ No newline at end of file +// function handleSave() { +// +// } \ No newline at end of file diff --git a/features/register/src/main/ets/view/SelectedHospitalComp.ets b/features/register/src/main/ets/view/SelectedHospitalComp.ets index bce4af2..07ec4e4 100644 --- a/features/register/src/main/ets/view/SelectedHospitalComp.ets +++ b/features/register/src/main/ets/view/SelectedHospitalComp.ets @@ -2,8 +2,8 @@ import { hdHttp, HdResponse,BasicConstant } from '@itcast/basic' import { promptAction, CommonModifier } from '@kit.ArkUI' import { BusinessError } from '@kit.BasicServicesKit'; import HashMap from '@ohos.util.HashMap'; -import { it } from '@ohos/hypium'; - +import { router } from '@kit.ArkUI' +import { emitter } from '@kit.BasicServicesKit' @Component export struct SelectedHospitalComp { scrollerForList: Scroller = new Scroller(); @@ -31,11 +31,13 @@ export struct SelectedHospitalComp { @State searchHospitals: Hospital[] = [] // 搜索关键词 @Prop searchKey: string = '' - + private controller: TabsController = new TabsController(); aboutToAppear() { this.loadProvinces(0,0) + // this.controller.setTabBarTranslate({ x: 20, y: 0 }) } + // 加载省份数据 private loadProvinces(type:number,provinceIdOrCity:number) { const areaListUrl:string = BasicConstant.urlExpertAPI+'areaList'; @@ -98,6 +100,7 @@ export struct SelectedHospitalComp { this.isHiddenSearchView = false; this.hospitalSelectedName = '请选择'; this.hospitals = json.data; + if (this.isHidenCity) { this.onTabChange(2); } else { @@ -132,7 +135,31 @@ export struct SelectedHospitalComp { } this.searchHospitalList(value,true); } + backtoEdit(item: Hospital) + { + let eventData: emitter.EventData = { + data: item + }; + // 发送eventId为1的事件,事件内容为eventData。 + emitter.emit({ eventId: 250517 }, eventData); + router.back({ url: 'pages/LoginPage/LoginSetInfoPage'}) + // router.back({ url: 'pages/LoginPage/LoginSetInfoPage',params: item}) + } + otherHospitaltoBack() + { + let item={ + city_name: this.districtsSelectedName, + county_id: this.cityId, + prov_id: this.provincerId, + prov_name: this.provincerSelectedName, + name:'其他医院', + county_name:this.districtsSelectedName, + uuid:'1', + city_id:this.cityId + } as Hospital + this.backtoEdit(item) + } build() { Column() { SearchInput((input:string)=>{ @@ -140,17 +167,17 @@ export struct SelectedHospitalComp { }) // 内容区域 - Tabs({ index: this.currentTabIndex,barModifier:this.tabBarModifier.align(Alignment.Start) }) { + Tabs({ index:this.currentTabIndex, controller: this.controller,barModifier:this.tabBarModifier.align(Alignment.Start) }) { // 省份列表 TabContent() { List() { - ForEach(this.provinces, (item : ProvinceOrCiry) => { + ForEach(this.provinces, (item: ProvinceOrCiry) => { ListItem() { Text(item.name) - .fontColor(item.name == this.provincerSelectedName?$r('app.color.main_color'):'#666666') + .fontColor(item.name == this.provincerSelectedName ? $r('app.color.main_color') : '#666666') .fontSize(17) .height(40) - .margin({left:20}) + .margin({ left: 20 }) .onClick(() => { this.selections[0] = 1; this.provincerSelectedName = item.name; @@ -158,14 +185,16 @@ export struct SelectedHospitalComp { this.districtsSelectedName = ''; this.hospitalSelectedName = ''; this.provincerId = item.id.toString(); - this.loadProvinces(1,item.id); + this.loadProvinces(1, item.id); }) } }) } .width('100%') .height('100%') - }.tabBar(this.provincerSelectedName) + } + .customTabbar(this.provincerSelectedName) + // 城市列表 TabContent() { @@ -190,8 +219,8 @@ export struct SelectedHospitalComp { } .width('100%') .height('100%') - }.tabBar(this.citySelectedName) - + } + .customTabbar(this.citySelectedName) // 区县列表 TabContent() { List() { @@ -207,9 +236,20 @@ export struct SelectedHospitalComp { // this.districtsSelectedName = item.name; this.selections[2] = 3; //医院点击 + this.backtoEdit(item) }) } }) + ListItem() { + Text('其他医院') + .fontSize(17) + .height(40) + .margin({left:20}) + .onClick(()=>{ + //医院点击 + this.otherHospitaltoBack() + }) + } } else { ForEach(this.districts, (item: ProvinceOrCiry) => { ListItem() { @@ -230,8 +270,8 @@ export struct SelectedHospitalComp { } .width('100%') .height('100%') - }.tabBar(this.districtsSelectedName) - + } + .customTabbar(this.districtsSelectedName) if (!this.isHidenCity) { // 医院列表 TabContent() { @@ -244,19 +284,39 @@ export struct SelectedHospitalComp { .margin({left:20}) .onClick(()=>{ //医院点击 + this.backtoEdit(item) }) } }) + ListItem() { + Text('其他医院') + .fontSize(17) + .height(40) + .margin({left:20}) + .onClick(()=>{ + //医院点击 + this.otherHospitaltoBack() + }) + } } .width('100%') .height('100%') - }.tabBar(this.hospitalSelectedName) + } + .customTabbar(this.hospitalSelectedName) + } } - .onChange(index => this.onTabChange(index)) - .barWidth('100%') + .onChange(index => { + this.onTabChange(index) + }) .barMode(BarMode.Scrollable) .height('100%') + .divider( { + strokeWidth: 1, + color: $r('app.color.common_gray_border'), + }) + .layoutWeight(1) + .padding({ bottom:100 }) if (this.isHiddenSearchView) { Column() { @@ -285,22 +345,7 @@ export struct SelectedHospitalComp { .height('100%') } - @Builder - CustomTabBuilder(title: string, index: number) { - Column() { - Text(title) - .fontSize(17) - .fontColor(this.currentTabIndex === index ? $r('app.color.main_color') : '#333333') - Divider() - .width('auto') - .height(3) - .color($r('app.color.main_color')) - .visibility(this.currentTabIndex === index ? Visibility.Visible : Visibility.Hidden) - } - .width('auto') - .width('auto') - .height(50) - } + } @Builder @@ -334,6 +379,20 @@ function SearchInput(onSearchInput:(input:string)=>void) { .margin({top:10}) .backgroundColor('#EEEEEE') .justifyContent(FlexAlign.Start) + +} + +@Extend(TabContent) +function customTabbar(name:string) +{ + .tabBar(SubTabBarStyle.of(name) + .labelStyle({ unselectedColor: '#848284', selectedColor:'#8D2316' , font: { size: 17 }}) + .indicator({ + color: '#8D2316', //下划线颜色 + height: 1, //下划线高度 + marginTop:16 //下划线与文字间距 + })) + .height('100%') } interface RequestProvinceCallData { diff --git a/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets b/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets index b05288e..9d39f95 100644 --- a/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets +++ b/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets @@ -8,4 +8,6 @@ struct LoginPage { LoginComp() } } + + } diff --git a/products/expert/src/main/ets/pages/LoginPage/LoginSetInfoPage.ets b/products/expert/src/main/ets/pages/LoginPage/LoginSetInfoPage.ets index f7da198..bbcc3c3 100644 --- a/products/expert/src/main/ets/pages/LoginPage/LoginSetInfoPage.ets +++ b/products/expert/src/main/ets/pages/LoginPage/LoginSetInfoPage.ets @@ -1,16 +1,17 @@ import { LoginSetInfo,PerfectUserDataComp } from 'register' import { HdNav } from '@itcast/basic' +import { router } from '@kit.ArkUI'; @Entry @Component struct LoginSetInfoPage { - @Prop loginInputPhone:string; + @State loginInputPhone:Record =router.getParams() as Record; build() { Column() { // LoginSetInfo() HdNav({ title: '完善个人资料', showRightIcon: false, showLeftIcon: true,showRightText:true,rightText:'保存' }) - PerfectUserDataComp({loginPhone:this.loginInputPhone}); + PerfectUserDataComp({loginPhone:this.loginInputPhone.loginInputPhone}); } } } \ No newline at end of file