我的页

This commit is contained in:
xiaoxiao
2025-05-14 13:10:06 +08:00
parent ab1f72ba6c
commit 1a0b9e0436
22 changed files with 305 additions and 77 deletions
@@ -1,13 +1,47 @@
import { hdHttp, HdResponse, BasicConstant, ExpertData, authStore } from '@itcast/basic'
import { BusinessError } from '@kit.BasicServicesKit';
import promptAction from '@ohos.promptAction';
import { router } from '@kit.ArkUI'
import HashMap from '@ohos.util.HashMap';
import { router } from '@kit.ArkUI';
interface updateExtraData {
expertUuid: string,
password: string,
oriPwd: string
}
interface callBackData {
code: number,
message:string,
msg:string,
data: string
}
@Preview
@Component
export struct ChangePasswordComp {
@State oldPassword: string = ''
@State newPassword: string = ''
@State confirmPassword: string = ''
uploadChangePasswordAction(){
hdHttp.post<string>(BasicConstant.urlExpert+'modifyPwd', {
expertUuid: authStore.getUser().uuid,
password: this.confirmPassword,
oriPwd: this.oldPassword
} as updateExtraData).then(async (res: HdResponse<string>) => {
let json:callBackData = JSON.parse(res+'') as callBackData;
console.log('更新登录密码数据:',json);
if (json.code == 1) {
promptAction.showToast({message:'修改成功'});
router.back();
} else {
promptAction.showToast({message:json.message});
}
}).catch((err: BusinessError) => {
console.info(`Response fail: ${err}`);
})
}
build() {
Column() {
// 原密码输入框
@@ -72,8 +106,36 @@ export struct ChangePasswordComp {
.borderWidth(1)
.fontColor($r('app.color.main_color'))
.onClick(() => {
// 处理密码修改提交逻辑
this.handleSubmit()
const passwordRegex = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/
if (this.oldPassword.length <= 0 || !this.oldPassword) {
promptAction.showToast({message:'请输入原密码'})
return
}
if (!passwordRegex.test(this.oldPassword)) {
promptAction.showToast({message:'原密码格式错误'})
return
}
if (this.newPassword.length <= 0 || !this.newPassword) {
promptAction.showToast({message:'请输入原密码'})
return
}
if (!passwordRegex.test(this.newPassword)) {
promptAction.showToast({message:'新密码格式错误'})
return
}
if (this.confirmPassword.length <= 0 || !this.confirmPassword) {
promptAction.showToast({message:'请确认新密码'})
return
}
if (this.newPassword !== this.confirmPassword) {
promptAction.showToast({message:'新密码与确认密码不一致'})
return
}
if (!passwordRegex.test(this.confirmPassword)) {
promptAction.showToast({message:'密码格式不正确,请重新输入!'})
return
}
this.uploadChangePasswordAction()
})
}
.width('100%')
@@ -81,21 +143,4 @@ export struct ChangePasswordComp {
.backgroundColor(Color.White)
}
// 提交处理函数
private handleSubmit() {
// 这里添加密码验证和提交逻辑
// 验证规则示例:
if (this.newPassword !== this.confirmPassword) {
promptAction.showToast({message:'两次输入的新密码不一致'})
return
}
const passwordRegex = /^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d]{6,16}$/
if (!passwordRegex.test(this.newPassword)) {
promptAction.showToast({message:'密码必须为6-16位数字字母组合'})
return
}
// 调用修改密码接口...
}
}
@@ -22,7 +22,7 @@ export struct ChangePhoneComp {
hashMap.set('newMobile',this.phoneNumber)
hashMap.set('oldMobile',authStore.getUser().photo)
hashMap.set('sms',this.smsCode)
hdHttp.httpReq<string>(BasicConstant.urlmyLan+'updateMobile',hashMap).then(async (res: HdResponse<string>) => {
hdHttp.httpReq<string>(BasicConstant.urlExpertAPI+'updateMobile',hashMap).then(async (res: HdResponse<string>) => {
let json:callBackData = JSON.parse(res+'') as callBackData;
console.log('更新手机号数据:',json);
if (json.code == 200) {
@@ -40,7 +40,7 @@ export struct ChangePhoneComp {
const hashMap: HashMap<string, string> = new HashMap();
hashMap.set('type','6');
hashMap.set('mobile',this.phoneNumber)
hdHttp.httpReq<string>(BasicConstant.urlmyLan+'smsSend',hashMap).then(async (res: HdResponse<string>) => {
hdHttp.httpReq<string>(BasicConstant.urlExpertAPI+'smsSend',hashMap).then(async (res: HdResponse<string>) => {
let json:callBackData = JSON.parse(res+'') as callBackData;
console.log('获取验证码数据:',json);
if (json.code == 200) {
@@ -76,7 +76,7 @@ export struct ChangePhoneComp {
.objectFit(ImageFit.Contain)
.margin({left:10})
TextInput({ placeholder: '请输入手机号码' })
TextInput({ placeholder: '请输入新的手机号码' })
.fontSize(16)
.backgroundColor(Color.White)
.onChange((value: string) => {
@@ -43,7 +43,7 @@ interface UploadAvatarResponse {
@Component
export struct EditUserDataComp {
@State photoPath:string = BasicConstant.imageHeader+authStore.getUser().photo;
@State photoPath:string = BasicConstant.urlImage+authStore.getUser().photo;
@State name:string = authStore.getUser().realName;
@State sex:string = authStore.getUser().sex == 0 ? '男' : '女';
@State birthday:string = authStore.getUser().birthDate;
@@ -55,7 +55,7 @@ export struct EditUserDataComp {
@State officePhone:string = authStore.getUser().officePhone;
@State positionName:string = authStore.getUser().positionName;
@State certificate:string = authStore.getUser().certificate;
@State certificatePhoto:string = BasicConstant.imageHeader+authStore.getUser().certificateImg;
@State certificatePhoto:string = BasicConstant.urlImage+authStore.getUser().certificateImg;
@State diseaseName:string = '';
@State intro:string = authStore.getUser().intro;
@@ -315,13 +315,14 @@ export struct EditUserDataComp {
Column() {
Column(){
Text('基本资料')
.height(20)
.fontSize(16)
.margin({left:15})
.fontColor($r('app.color.main_color'))
}
.width('100%')
.height(17)
.backgroundColor(Color.Gray)
.height(20)
.backgroundColor('#D1D1D1')
.alignItems(HorizontalAlign.Start)
// 基本信息字段
EditUserDataItem({ label: '头像', required: true, content: this.photoPath, hasArrow: true })
@@ -354,13 +355,14 @@ export struct EditUserDataComp {
Column() {
Column(){
Text('专业资料')
.height(20)
.fontSize(16)
.margin({left:15})
.fontColor($r('app.color.main_color'))
}
.width('100%')
.height(17)
.backgroundColor(Color.Gray)
.height(20)
.backgroundColor('#D1D1D1')
.alignItems(HorizontalAlign.Start)
EditUserDataItem({ label: '医院', required: true, content: this.hospatilName })
@@ -42,7 +42,7 @@ export struct EditUserDataItem {
.margin({ right: this.hasArrow?0:10 })
} else {
Text(this.content)
.fontSize(16)
.fontSize(14)
.fontColor('#333333')
.width('60%')
.textOverflow({ overflow: TextOverflow.Ellipsis })
@@ -1,9 +1,9 @@
import { it } from "@ohos/hypium";
import { MyPageSectionClass } from "../model/MyPageSectionClass";
import { MyPageSectionItem } from '../view/MyPageSectionItem'
import { common, Want } from '@kit.AbilityKit';
import notificationManager from '@ohos.notificationManager';
import { Theme } from "@ohos.arkui.theme";
import { router } from '@kit.ArkUI'
import { BusinessError } from "@kit.BasicServicesKit";
import emitter from '@ohos.events.emitter';
@@ -12,25 +12,23 @@ export struct FourSection {
@State sectionTitle: string = "常规操作";
@State currentIndex: number = 0;
@State pushStatus: string = '通知已开';
@State pushIconPath: Resource = $r('app.media.my_page_message_on')
@State refreshFlag: boolean = false;
@State fourSectionList:Array<MyPageSectionClass> = [
new MyPageSectionClass('oneItem',$r('app.media.app_icon'),'微信绑定','/pages/MyHomePage'),
new MyPageSectionClass('twoItem',$r('app.media.app_icon'),'更换手机号','/pages/MyHomePage'),
new MyPageSectionClass('threeItem',$r('app.media.app_icon'),this.pushStatus,'/pages/MyHomePage'),
new MyPageSectionClass('fourItem',$r('app.media.app_icon'),'发现新版本','/pages/MyHomePage')
new MyPageSectionClass('oneItem',$r('app.media.app_icon'),'微信绑定',''),
new MyPageSectionClass('twoItem',$r('app.media.my_page_choosePhone'),'更换手机号','pages/MinePage/ChangePhonePage'),
new MyPageSectionClass('threeItem',this.pushIconPath,this.pushStatus,''),
new MyPageSectionClass('fourItem',$r('app.media.my_page_version'),'发现新版本','')
];
aboutToAppear() {
console.log('FourSection aboutToAppear!');
this.checkNotificationStatus();
// 监听通知状态变化事件
emitter.on('notification_status_changed', this.onNotificationChanged);
}
aboutToDisappear() {
// 取消事件监听
emitter.off('notification_status_changed', this.onNotificationChanged);
}
@@ -53,10 +51,11 @@ export struct FourSection {
let isEnabled = await notificationManager.isNotificationEnabledSync();
console.log('当前通知状态:', isEnabled);
this.pushStatus = isEnabled ? '通知已开' : '通知已关';
this.pushIconPath = this.pushStatus == '通知已开'?$r('app.media.my_page_message_on'):$r('app.media.my_home_push_down');
// 更新数组中的标题
this.fourSectionList = this.fourSectionList.map((item, index) => {
if (index === 2) {
return new MyPageSectionClass(item.id, item.imageSrc, this.pushStatus, item.path);
return new MyPageSectionClass(item.id, this.pushIconPath, this.pushStatus, item.path);
}
return item;
});
@@ -103,6 +102,10 @@ export struct FourSection {
.onClick(()=>{
if (item.title.includes('通知')) {
this.handleNotificationClick();
} else {
router.pushUrl({
url:item.path
})
}
})
}, (item: MyPageSectionClass) => item.id)
@@ -24,7 +24,7 @@ interface heroFirst {
@Component
export struct HeaderView {
@State heroIndex: number = 0 // 当前页索引
@State photoPath:string = BasicConstant.imageHeader+authStore.getUser().photo;
@State photoPath:string = BasicConstant.urlImage+authStore.getUser().photo;
@State name:string = authStore.getUser().realName;
@State myPageData:object = new Object;
@State heroArray:Array<object> = [];
@@ -64,7 +64,7 @@ export struct HeaderView {
uploadBackImgAction() {
const hashMap: HashMap<string, string> = new HashMap();
const userDataUrl:string = BasicConstant.urlmyLan+'my';
const userDataUrl:string = BasicConstant.urlExpertAPI+'my';
hdHttp.httpReq<string>(userDataUrl,hashMap).then(async (res: HdResponse<string>) => {
console.info(`我的背景图: ${res}`);
let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel;
@@ -131,7 +131,12 @@ export struct HeaderView {
.onClick(() => {
console.log('Show HeroPopWindow');
})
.onClick(()=>this.dialogController.open())
.onClick(()=>{
this.dialogController.open();
// if (!this.heroArray[index] as heroFirst == 'ranking') {
// this.dialogController.open(heroId:this.heroArray[index]['id'] as string);
// }
})
}
})
}
@@ -1,9 +1,38 @@
import { it } from "@ohos/hypium";
import { hdHttp, HdResponse,BasicConstant, logger,RequestDefaultModel, Data } from '@itcast/basic'
import { promptAction } from '@kit.ArkUI'
import HashMap from '@ohos.util.HashMap';
import { BusinessError } from '@kit.BasicServicesKit';
import { authStore } from '@itcast/basic'
interface DefaultData {
}
@CustomDialog
export struct HeroPopWindow {
@Prop heroId:string = '';
@State detailsData:object = new Object;
private years: string[] = ['2019年英雄榜','2018年英雄榜','2017年英雄榜','2016年英雄榜','2015年英雄榜'];
controller: CustomDialogController;
heroDetailsRequestUrl:string = BasicConstant.urlExpertAPI+'gethonorDetail'
hashMap: HashMap<string, string> = new HashMap();
updateHeroDetailsAction(){
this.hashMap.set('id',this.heroId);
hdHttp.httpReq<string>(this.heroDetailsRequestUrl,this.hashMap).then(async (res: HdResponse<string>) => {
let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel;
if(json.code=='1') {
this.detailsData = json.data;
} else {
console.error('英雄榜失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })
}
}).catch((err: BusinessError) => {
console.info(`Response fail: ${err}`);
})
}
build() {
Stack() {
//半透明黑色背景
@@ -7,9 +7,9 @@ export struct MyPageSectionItem {
build() {
Column(){
Image(this.sectionItem.imageSrc)
.backgroundColor(Color.Gray)
.width(35).height(35)
.borderRadius(17.5)
.objectFit(ImageFit.Auto)
Text(this.sectionItem.title)
.fontSize(12)
.fontColor(Color.Black)
@@ -14,7 +14,6 @@ export struct OfficeSelectedSheet {
controller: CustomDialogController;
@State officeNameArr:Array<string> = [];
private officeArr:Array<DefaultData> = [];
@Prop selectedOffice:object = new Object;
@State selectedModel:DefaultData = { officeName: '', officeUuid: '' };
@State selectedIndex:number = 0;
@@ -44,9 +43,11 @@ export struct OfficeSelectedSheet {
this.officeNameArr = json.data.map(item => item.officeName);
console.log('科室名称数组:', this.officeNameArr);
for (let index = 0; index < this.officeNameArr.length; index++) {
const element = this.officeNameArr[index];
if (element == authStore.getUser().officeName) {
const officeObject = this.officeArr[index] as DefaultData;
const name = this.officeNameArr[index];
if (name == authStore.getUser().officeName) {
this.selectedIndex = index;
this.selectedModel = {officeName:name,officeUuid:officeObject.officeUuid}
}
}
} else {
@@ -64,7 +65,7 @@ export struct OfficeSelectedSheet {
Row({space:70}) {
Button('取消')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
// .backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
@@ -78,7 +79,6 @@ export struct OfficeSelectedSheet {
Button('确定')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
@@ -43,9 +43,11 @@ export struct PositionSelectedSheet {
this.officeArr = json.data as DefaultData[];
this.officeNameArr = json.data.map(item => item.name);
for (let index = 0; index < this.officeNameArr.length; index++) {
const element = this.officeNameArr[index];
if (element == authStore.getUser().positionName) {
const object = this.officeArr[index] as DefaultData;
const nameIndex = this.officeNameArr[index];
if (nameIndex == authStore.getUser().positionName) {
this.selectedIndex = index;
this.selectedModel = {name:nameIndex,uuid:object.uuid}
}
}
console.log('职称名称数组:', this.officeNameArr);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

@@ -29,7 +29,7 @@ export struct LoginComp {
@State
type:string ='账号密码登录'
loginUrl:string=BasicConstant.urlmyLan+'umSmsLogin'
loginUrl:string=BasicConstant.urlExpertAPI+'umSmsLogin'
hashMap: HashMap<string, string> = new HashMap();
@@ -67,12 +67,12 @@ export struct LoginComp {
if(this.isPassLogin)
{
this.hashMap.set('password',this.code)
this.loginUrl=BasicConstant.urlmyLan+'login'
this.loginUrl=BasicConstant.urlExpertAPI+'login'
}
else
{
this.hashMap.set('sms',this.current_code)
this.loginUrl=BasicConstant.urlmyLan+'umSmsLogin'
this.loginUrl=BasicConstant.urlExpertAPI+'umSmsLogin'
}
this.hashMap.set('current_spec','hongmeng')
hdHttp.httpReq<string>(this.loginUrl,this.hashMap).then(async (res: HdResponse<string>) => {
@@ -126,7 +126,7 @@ export struct LoginComp {
this.hashMap.clear();
this.hashMap.set('mobile',this.mobile)
this.hashMap.set('type','7')
hdHttp.httpReq<string>(BasicConstant.urlmyLan+'smsSend',this.hashMap).then(async (res: HdResponse<string>) => {
hdHttp.httpReq<string>(BasicConstant.urlExpertAPI+'smsSend',this.hashMap).then(async (res: HdResponse<string>) => {
}).catch((err: BusinessError) => {
this.loading = false
console.info(`Response login succeeded: ${err}`);