| | |
| | | import { ComponentContent, router } from "@kit.ArkUI" |
| | | import { ComponentContent, promptAction, router } from "@kit.ArkUI" |
| | | import { PromptActionClass } from '../../utils/PromptActionClass'; |
| | | import { http } from "@kit.NetworkKit"; |
| | | import { HttpResponseResult } from "../../data/HttpResponse"; |
| | | import { common } from "@kit.AbilityKit"; |
| | | import { ROMAIN } from "../../utils/config"; |
| | | |
| | | export class UserInfo { |
| | | nickName: string = '' |
| | | mobilePhone: string = '' |
| | | age: string = '' |
| | | gender: string = '' |
| | | job: string = '' |
| | | preferJob: string = '' |
| | | introduce: string = '' |
| | | } |
| | | class accountListItem { |
| | | title: string = '' |
| | | icon: string | Resource = '' |
| | |
| | | .backgroundColor(Color.White) |
| | | } |
| | | |
| | | @Entry |
| | | @Component |
| | | export struct AccountPage { |
| | | @State ListItems: accountListItem[] = [ |
| | |
| | | private contentNode: ComponentContent<Object> = |
| | | new ComponentContent(this.ctx, wrapBuilder(buildText), new DialogParams((this.dialogMessage))); |
| | | params: DialogParams = new DialogParams('注册成功') |
| | | @State userInfo: UserInfo = { |
| | | nickName: '', |
| | | mobilePhone: '', |
| | | age: '', |
| | | gender: '', |
| | | job: '', |
| | | preferJob: '', |
| | | introduce: '', |
| | | } |
| | | @Link selectIndex: number | undefined; |
| | | |
| | | aboutToAppear(): void { |
| | | PromptActionClass.setContext(this.ctx); |
| | | PromptActionClass.setContentNode(this.contentNode); |
| | | PromptActionClass.setOptions({ alignment: DialogAlignment.Center, offset: { dx: 0, dy: 0 } }); |
| | | this.getUserInfo() |
| | | } |
| | | |
| | | getUserInfo() { |
| | | let httpRequest = http.createHttp(); |
| | | httpRequest.request( |
| | | `${ROMAIN}/quiz-community/public/v1.0/users/userinfo`, |
| | | { |
| | | method: http.RequestMethod.GET, |
| | | header: { 'Content-Type': 'application/json', 'x-jwt-token': `Bearer ${AppStorage.get('x-jwt-token')}` }, |
| | | }, |
| | | (err, data) => { |
| | | console.log('response', '/users/userinfo') |
| | | console.log(JSON.stringify(data.result)) |
| | | if (data.responseCode == 200) { |
| | | const resData = (typeof data.result == 'string' ? JSON.parse(data.result) : data.result) as HttpResponseResult<UserInfo> |
| | | if (resData.code == 200) { |
| | | this.userInfo = resData.data as UserInfo |
| | | } else { |
| | | promptAction.showToast({ message: resData.msg }) |
| | | } |
| | | } |
| | | } |
| | | ) |
| | | } |
| | | |
| | | build() { |
| | | Column() { |
| | | Text('个人中心') |
| | |
| | | .width(50) |
| | | .height(50) |
| | | Column() { |
| | | Text('李强') |
| | | Text(this.userInfo.nickName || '李强') |
| | | .fontSize(16) |
| | | .width('100%') |
| | | .fontWeight(600) |
| | | .fontColor(Color.Black) |
| | | .textAlign(TextAlign.Start) |
| | | Text('男 | 28岁 | 前端开发工程师') |
| | | Text(`${this.userInfo.gender || '男'} | ${this.userInfo.age || 28}岁 | ${this.userInfo.job || '前端开发工程师'}`) |
| | | .fontColor('#333333') |
| | | .fontSize(14) |
| | | .width('100%') |
| | |
| | | .justifyContent(FlexAlign.SpaceBetween) |
| | | .layoutWeight(1) |
| | | Image($r('app.media.chevron_right')) |
| | | .width(18) |
| | | .height(18) |
| | | .width(14) |
| | | .height(14) |
| | | } |
| | | .width('100%') |
| | | .onClick(() =>{ |
| | | router.pushUrl({ |
| | | url: '' |
| | | url: 'pages/account/UserInfoPage' |
| | | }) |
| | | }) |
| | | |
| | |
| | | .backgroundColor(Color.White) |
| | | .padding({ left: 10, right: 10, top: 4, bottom: 4 }) |
| | | .fontColor('#1756f4') |
| | | .onClick(() => { |
| | | this.selectIndex = 1 |
| | | }) |
| | | } |
| | | .width('100%') |
| | | .justifyContent(FlexAlign.SpaceBetween) |
| | | |
| | | Row() { |
| | | Text('当前学习级别:青铜') |
| | | .width('100%') |
| | | .fontColor(Color.White) |
| | | .fontSize(14) |
| | | Image($r('app.media.bronze_icon')) |
| | | .width(20) |
| | | .height(20) |
| | | .margin({ left: 6 }) |
| | | } |
| | | .width('100%') |
| | | .justifyContent(FlexAlign.Start) |
| | | |
| | | Row() { |
| | | Column({ space: 4 }) { |
| | | Text('学习时长') |
| | |
| | | .fontWeight(500) |
| | | .fontColor(Color.Black) |
| | | } |
| | | .onClick(() => { |
| | | router.pushUrl({ |
| | | url: 'pages/account/LearningRecordPage' |
| | | }) |
| | | }) |
| | | |
| | | Column({ space: 6 }) { |
| | | Image($r('app.media.account_course')) |
| | | .width(40) |
| | |
| | | .fontWeight(500) |
| | | .fontColor(Color.Black) |
| | | } |
| | | .onClick(() => { |
| | | router.pushUrl({ |
| | | url: 'pages/account/CourseCollection' |
| | | }) |
| | | }) |
| | | |
| | | Column({ space: 6 }) { |
| | | Image($r('app.media.account_vitae')) |
| | | .width(40) |
| | |
| | | .fontWeight(500) |
| | | .fontColor(Color.Black) |
| | | } |
| | | .onClick(() => { |
| | | router.pushUrl({ |
| | | url: 'pages/account/PersonVitae' |
| | | }) |
| | | }) |
| | | |
| | | Column({ space: 6 }) { |
| | | Image($r('app.media.account_communicated')) |
| | | .width(40) |
| | |
| | | .onClick(() => { |
| | | if (item.title == '隐私设置') { |
| | | router.pushUrl({ |
| | | url: '' |
| | | url: 'pages/account/SettingPage' |
| | | }) |
| | | } else if (item.title == '消息通知') { |
| | | |
| | | router.pushUrl({ |
| | | url: 'pages/account/MessagePushPage' |
| | | }) |
| | | } else if (item.title == '帮助中心') { |
| | | this.contentNode = new ComponentContent(this.ctx, wrapBuilder(buildText1), new DialogParams((this.dialogMessage))); |
| | | PromptActionClass.setContentNode(this.contentNode); |
| | | PromptActionClass.openDialog() |
| | | } else if (item.title == '关于我们') { |
| | | |
| | | router.pushUrl({ |
| | | url: 'pages/account/AboutPage' |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | |
| | | .width('100%') |
| | | .fontColor(Color.White) |
| | | .backgroundColor('#1761f4') |
| | | .onClick(() => { |
| | | (getContext(this) as common.UIAbilityContext)?.terminateSelf() |
| | | }) |
| | | } |
| | | .padding(16) |
| | | .width('100%') |
| | | .background(Color.White) |
| | | .backgroundColor(Color.White) |
| | | .height(300) |
| | | |
| | | } |