From 5f97e4b263b76b25f22592c02fbd482977e043bc Mon Sep 17 00:00:00 2001 From: wwf <1971391498@qq.com> Date: 星期三, 01 十月 2025 16:22:14 +0800 Subject: [PATCH] 登录、注册 --- AppScope/resources/base/media/foreground.png | 0 entry/src/main/resources/base/media/classification_AI.png | 0 entry/src/main/resources/base/media/tabs_account_icon_active.png | 0 entry/src/main/resources/base/media/logo.png | 0 entry/src/main/ets/pages/MainPage.ets | 76 ++ entry/src/main/resources/base/media/tabs_home_icon_active.png | 0 entry/src/main/resources/base/media/start_page_bg.png | 0 entry/src/main/resources/base/media/tabs_search_platform_icon_active.png | 0 entry/src/main/resources/base/profile/main_pages.json | 6 entry/src/main/resources/base/media/login_page_bg.png | 0 entry/src/main/resources/base/media/signIn_page_check.png | 0 entry/src/main/resources/base/media/active_list_img.png | 0 entry/src/main/resources/base/media/tabs_account_icon.png | 0 entry/src/main/ets/pages/home/Home.ets | 233 ++++++++ entry/src/main/ets/pages/account/AccountPage.ets | 23 entry/src/main/resources/base/media/startIcon.png | 0 entry/src/main/resources/base/media/tabs_message_icon_active.png | 0 entry/src/main/ets/pages/message/MessagePage.ets | 94 +++ entry/src/main/module.json5 | 5 entry/src/main/resources/base/media/image1.png | 0 entry/src/main/ets/entryability/EntryAbility.ets | 5 entry/src/main/ets/data/HttpResponse.ets | 5 entry/src/main/ets/pages/search/SearchPage.ets | 82 +++ entry/src/main/resources/base/media/icon_password.svg | 3 entry/src/main/ets/data/UserInfoBase.ets | 7 entry/src/main/resources/base/media/tabs_search_platform_icon.png | 0 entry/src/main/ets/utils/PromptActionClass.ets | 63 ++ entry/src/main/ets/utils/PreferencesUtils.ets | 92 +++ entry/src/main/ets/pages/message/MessageDetailsPage.ets | 131 +++++ entry/src/main/resources/base/media/tabs_message_icon.png | 0 entry/src/main/resources/base/media/tabs_home_icon.png | 0 /dev/null | 32 - entry/src/main/ets/pages/login/SignInPage.ets | 254 +++++++++ entry/src/main/resources/base/media/date_icon.png | 0 entry/src/main/resources/base/media/icon_username.svg | 3 oh-package-lock.json5 | 3 entry/src/main/ets/pages/login/LoginPage.ets | 286 +++++++++++ entry/src/main/resources/base/element/string.json | 6 entry/src/main/ets/pages/StartPage.ets | 92 +++ entry/src/main/resources/base/media/title_decoration_icon.png | 0 40 files changed, 1,463 insertions(+), 38 deletions(-) diff --git a/AppScope/resources/base/media/foreground.png b/AppScope/resources/base/media/foreground.png index 97014d3..85a6867 100644 --- a/AppScope/resources/base/media/foreground.png +++ b/AppScope/resources/base/media/foreground.png Binary files differ diff --git a/code-linter.json5 b/code-linter.json5 deleted file mode 100644 index 073990f..0000000 --- a/code-linter.json5 +++ /dev/null @@ -1,32 +0,0 @@ -{ - "files": [ - "**/*.ets" - ], - "ignore": [ - "**/src/ohosTest/**/*", - "**/src/test/**/*", - "**/src/mock/**/*", - "**/node_modules/**/*", - "**/oh_modules/**/*", - "**/build/**/*", - "**/.preview/**/*" - ], - "ruleSet": [ - "plugin:@performance/recommended", - "plugin:@typescript-eslint/recommended" - ], - "rules": { - "@security/no-unsafe-aes": "error", - "@security/no-unsafe-hash": "error", - "@security/no-unsafe-mac": "warn", - "@security/no-unsafe-dh": "error", - "@security/no-unsafe-dsa": "error", - "@security/no-unsafe-ecdsa": "error", - "@security/no-unsafe-rsa-encrypt": "error", - "@security/no-unsafe-rsa-sign": "error", - "@security/no-unsafe-rsa-key": "error", - "@security/no-unsafe-dsa-key": "error", - "@security/no-unsafe-dh-key": "error", - "@security/no-unsafe-3des": "error" - } -} \ No newline at end of file diff --git a/entry/src/main/ets/data/HttpResponse.ets b/entry/src/main/ets/data/HttpResponse.ets new file mode 100644 index 0000000..faea959 --- /dev/null +++ b/entry/src/main/ets/data/HttpResponse.ets @@ -0,0 +1,5 @@ +export class HttpResponseResult<T> { + code: number = 0 + msg: string = '' + data: T | null = null +} \ No newline at end of file diff --git a/entry/src/main/ets/data/UserInfoBase.ets b/entry/src/main/ets/data/UserInfoBase.ets new file mode 100644 index 0000000..00ef62f --- /dev/null +++ b/entry/src/main/ets/data/UserInfoBase.ets @@ -0,0 +1,7 @@ +/** + * @Description : ps瀛樺偍鐨勫璞$被鍨� + */ +export class UserInfoBase { + account: string = '' + password: string = '' +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 508880a..f48be59 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,6 +1,7 @@ import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; +import PreferencesUtils from '../utils/PreferencesUtils'; const DOMAIN = 0x0000; @@ -8,6 +9,8 @@ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + + PreferencesUtils.loadPreferences(this.context,'UserInfo') } onDestroy(): void { @@ -18,7 +21,7 @@ // Main window is created, set main page for this ability hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/Index', (err) => { + windowStage.loadContent('pages/StartPage', (err) => { if (err.code) { hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); return; diff --git a/entry/src/main/ets/pages/MainPage.ets b/entry/src/main/ets/pages/MainPage.ets new file mode 100644 index 0000000..a55e4b1 --- /dev/null +++ b/entry/src/main/ets/pages/MainPage.ets @@ -0,0 +1,76 @@ +import { Home } from './home/Home' + +/** + * @Description : 搴曢儴瀵艰埅锛孉PP妯″潡 + * Tabs 閫夐」鍗″姛鑳� + */ +class TabBarBase { + icon: ResourceStr = '' + title: string = '' +} +@Entry +@Component +struct MainPage { + @State tabBarList: TabBarBase[] = [ + { icon: 'tabs_home_icon', title: '涓婚〉' }, + { icon: 'tabs_search_platform_icon', title: '鍙戠幇' }, + { icon: 'tabs_message_icon', title: '娑堟伅' }, + { icon: 'tabs_account_icon', title: '鎴戠殑' } + ] + @State selectIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder tabItem(icon: ResourceStr,title: string,index: number){ + Column({space: 5}){ + Image($r('app.media.' + icon + (index===this.selectIndex ? '_active' : '' ))) + .width(22) + .height(22) + Text(title) + .fontSize(14) + .fontColor(index === this.selectIndex ? "#1756f4" : '#6a6a6a') + } + .onClick(() => { + this.selectIndex = index + this.tabController.changeIndex(this.selectIndex) + }) + } + build() { + Stack({alignContent: Alignment.Bottom}){ + Tabs({barPosition: BarPosition.End,controller: this.tabController}){ + ForEach(this.tabBarList,(item: TabBarBase,index:number) => { + TabContent(){ + if (index === 0) { + Home() + } else if (index === 1){ + // SearchPage() + } else if (index === 2){ + // MessagePage() + } else if (index === 3){ + // AccountPage() + } + } + //璋冪敤鑷畾涔夌殑鏍峰紡 + // .tabBar(this.tabItem(item.icon,item.title,index)) + }) + } + .barHeight(0) + .onChange((index: number) => { + this.selectIndex = index + }) + + Row() { + ForEach(this.tabBarList, (item: TabBarBase, index) => { + this.tabItem(item.icon, item.title, index) + }) + } + .justifyContent(FlexAlign.SpaceAround) + .width('100%') + .height(60) + .padding(10) + .border({ width: { top: 1 }, color: { top: '#e3e3e3' }, style: { top: BorderStyle.Solid }}) + .backgroundColor(Color.White) + } + .width('100%') + .height('100%') + } +} diff --git a/entry/src/main/ets/pages/StartPage.ets b/entry/src/main/ets/pages/StartPage.ets new file mode 100644 index 0000000..ff22c45 --- /dev/null +++ b/entry/src/main/ets/pages/StartPage.ets @@ -0,0 +1,92 @@ +/** + * @Description : 鍚姩椤甸潰 + */ +@Entry +@Component +struct StartUpPage { + @State logoY: number = -200 + @State columnY: number = 200 + @State isShow: boolean = false + aboutToAppear(): void { + + } + build() { + Column(){ + Image($r('app.media.logo')) + .width(100) + .height(100) + //璁剧疆logo鍥剧墖鐨刌杞翠綅缃� + .translate({y: this.logoY}) + //灞炴�у姩鐢� + .animation({ + //鍔ㄧ敾鏃堕暱 + duration: 3000, + //鎾斁閫熷害 + tempo: 1, + //寰幆娆℃暟 -1鏃犻檺寰幆 + iterations: 1, + curve: Curve.EaseInOut, + //鎾斁妯″紡锛� + playMode: PlayMode.Normal, + //寤舵椂鎾斁 + delay: 500 + }) + + Blank() + Column({ space: 10 }) { + Text('瀛﹁仒鍚岃').newExtend(30, 700) + Text('浠ュ涔犺搫鍔涳紝浠ュ簲鑱橀�氬叧').newExtend(20, 400) + .textCase(TextCase.UpperCase) + Blank() + } + .shadow({ + radius: 8, + color: '#efefef', + offsetX: 0, + offsetY: -10 + }) + .StartColumn() + .translate({ y: this.columnY }) + .animation({ + duration: 3000, + delay: 500, + curve: Curve.EaseInOut, + iterations: 1 + }) + .onAppear(() => { + //鎵ц鍔ㄧ敾鎿嶄綔 + this.logoY = 200 + this.columnY = 0 + //璁剧疆鍊掕鏃� + let intervalId = setInterval(() => { + //椤甸潰璺宠浆 + this.getUIContext().getRouter().replaceUrl({ + url:'pages/login/LoginPage' + }) + //閿�姣佽鏃跺櫒 + clearInterval(intervalId) + },4000) + }) + } + .width('100%') + .height('100%') + .backgroundImage($r('app.media.start_page_bg')) + .backgroundImageSize({width: '100%',height:'100%'}) + } +} + +@Extend(Column) +function StartColumn() { + .width('100%') + .height(180) + .alignItems(HorizontalAlign.Start) + .borderRadius({ topLeft: 20, topRight: 20 }) + .backgroundColor(Color.White) + .padding(20) +} + +@Extend(Text) +function newExtend(mSize: number,mWeight: FontWeight) { + .fontSize(mSize) + .fontWeight(mWeight) +} diff --git a/entry/src/main/ets/pages/account/AccountPage.ets b/entry/src/main/ets/pages/account/AccountPage.ets new file mode 100644 index 0000000..290aae7 --- /dev/null +++ b/entry/src/main/ets/pages/account/AccountPage.ets @@ -0,0 +1,23 @@ +@Entry +@Component +export struct AccountPage { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('AccountPageHelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/home/Home.ets b/entry/src/main/ets/pages/home/Home.ets new file mode 100644 index 0000000..4f6cbe7 --- /dev/null +++ b/entry/src/main/ets/pages/home/Home.ets @@ -0,0 +1,233 @@ +class TabBarBase { + title: string = '' +} +class Classification { + title: string = '' + icon: ResourceStr = '' +} +class Activity { + title: string = '' + timeScope: string = '' + signupCount: number = 0 + statusText: string = '' +} +@Entry +@Component +export struct Home { + @State pageHeight: number = 0 + @State activeIndex:number = 0 + @State tabList: TabBarBase[] = [ + { title: '棣栭〉' }, + { title: '璇剧▼' } + ] + private tabController: TabsController = new TabsController() + @State swiperList: ResourceStr[] = [ + $r('app.media.image1'), + $r('app.media.image1'), + $r('app.media.image1'), + ] + @State swiperIndex: number = 0 + //TabBar鏍峰紡 + @State classificationList: Classification[] = [ + { title: '鏁伴��', icon: $r('app.media.classification_shutong') }, + { title: '瀹夊叏', icon: $r('app.media.classification_safety') }, + { title: '浜戣绠�', icon: $r('app.media.classification_cloudcalc') }, + { title: '瀛樺偍', icon: $r('app.media.classification_storage') }, + { title: '椴查箯', icon: $r('app.media.classification_roc') }, + { title: 'AI', icon: $r('app.media.classification_AI') }, + { title: '杩炴帴', icon: $r('app.media.classification_link') }, + { title: '澶ф暟鎹�', icon: $r('app.media.classification_bigdata') }, + { title: '浜戞湇鍔�', icon: $r('app.media.classification_cloudservice') }, + { title: '鏇村', icon: $r('app.media.classification_more') }, + ] + @State activityList: Activity[] = [ + { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '鎶ュ悕涓�' }, + { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '杩涜涓�' }, + { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '宸茬粨鏉�' }, + { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '鎶ュ悕涓�' }, + { title: '鍖椾含浜哄伐鏅鸿兘IE', timeScope: '20250520-20250620', signupCount: 80, statusText: '宸茬粨鏉�' }, + ] + + @Builder tabBarItem(name:string,index: number){ + Row(){ + Text(name) + .fontSize(this.activeIndex == index ? 16 : 14) + .fontWeight(700) + .fontColor(this.activeIndex == index ? '#1756f4' : '#666666') + .margin(index == 0 ? { left: '50%' } : { right: '50%' } ) + } + .onClick(() => { + this.activeIndex = index + this.tabController.changeIndex(index) + }) + } + + getTagFontColor(statusText: string) { + switch (statusText) { + case '鎶ュ悕涓�': + return '#10920e' + case '杩涜涓�': + return '#ffa100' + default : + return '#666666' + } + } + + getTagBgColor(statusText: string) { + switch (statusText) { + case '鎶ュ悕涓�': + return '#d5f2db' + case '杩涜涓�': + return '#fff0cc' + default : + return '#ebebeb' + } + } + + build() { + Column() { + Text('楦胯挋瀹炶棣栭〉') + .width('100%') + .textAlign(TextAlign.Center) + .fontWeight(800) + .fontSize(18) + Tabs({controller:this.tabController}){ + ForEach(this.tabList, (item: TabBarBase, index: number) => { + // 棣栭〉 ------------ + if (item.title == '棣栭〉') { + TabContent() { + Column({ space: 10 }){ + Swiper() { + ForEach(this.swiperList, (item: Resource) => { + Image(item) + .width('100%') + .height(120) + .backgroundColor(0xAFEEEE) + }) + } + .borderRadius(10) + .interval(3000) + .autoPlay(true) + .indicator( + Indicator.dot() + .itemWidth(8) + .itemHeight(8) + .selectedItemWidth(16) + .selectedItemHeight(8) + .color(Color.White) + ) + .onChange((index) => { + this.swiperIndex = index; + }) + + Grid() { + ForEach(this.classificationList, (item: Classification ) => { + GridItem() { + Column({ space: 6 }) { + Image(item.icon) + .width(26) + .height(26) + Text(item.title) + .fontSize(12) + .fontWeight(500) + } + } + }) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr') + .columnsGap(14) + .rowsGap(14) + .width('100%') + .height(110) + + Row() { + Image($r('app.media.title_decoration_icon')) + .width(4) + Text('鐑棬鍩硅') + .margin({ left: 8 }) + .fontSize(16) + .fontWeight(700) + + } + .alignItems(VerticalAlign.Center) + .width('100%') + + List({ space: 10, initialIndex: 0 }) { + ForEach(this.activityList, (item: Activity, index: number) => { + ListItem() { + Row() { + Column({ space: 6 }) { + Text(item.title) + .fontSize(12) + .fontWeight(500) + Row() { + Image($r('app.media.date_icon')) + .width(12) + .height(12) + Text(item.timeScope) + .fontSize(10) + .fontColor('#676767') + .margin({ left: 4 }) + } + Text(`${item.signupCount || 0}浜哄凡鎶ュ悕`) + .fontSize(10) + .fontColor('#676767') + Text(item.statusText) + .fontSize(10) + .fontWeight(500) + .padding(6) + .borderRadius(10) + .fontColor(this.getTagFontColor(item.statusText)) + .backgroundColor(this.getTagBgColor(item.statusText)) + } + .height('100%') + .justifyContent(FlexAlign.Start) + .alignItems(HorizontalAlign.Start) + Image($r('app.media.active_list_img')) + .aspectRatio(16/9) + .height('100%') + } + .width('100%') + .height(100) + .padding(10) + .justifyContent(FlexAlign.SpaceBetween) + } + }, (index: number) => index.toString()) + } + .listDirection(Axis.Vertical) // 鎺掑垪鏂瑰悜 + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ strokeWidth: 1, color: '#e8e8e8' }) // 姣忚涔嬮棿鐨勫垎鐣岀嚎 + .edgeEffect(EdgeEffect.Spring) + .width('100%') + .height(300) + } + .height('100%') + } + .tabBar(this.tabBarItem(item.title, index)) + .height('100%') + } + + // 璇剧▼------------ + if (item.title == '璇剧▼') { + TabContent() { + Text('璇剧▼content') + + }.tabBar(this.tabBarItem(item.title, index)) + } + }) + } + .barHeight(40) + .margin({ top: 6 }) + .width('100%') + .height('100%') + .padding({ left: 14, right: 14, bottom: 14 }) + .onChange((index: number) => { + this.activeIndex = index + }) + } + .width('100%') + .height('100%') + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/login/LoginPage.ets b/entry/src/main/ets/pages/login/LoginPage.ets new file mode 100644 index 0000000..60e1a7b --- /dev/null +++ b/entry/src/main/ets/pages/login/LoginPage.ets @@ -0,0 +1,286 @@ +import { UserInfoBase } from '../../data/UserInfoBase' +import { promptAction } from '@kit.ArkUI' +import PreferencesUtils from '../../utils/PreferencesUtils' +import http from '@ohos.net.http'; +import { HttpResponseResult } from '../../data/HttpResponse'; +import { JSON } from '@kit.ArkTS'; + +/** + * @Description : 鐧诲綍椤� + */ +@Entry +@Component +struct LoginPage { + @State account: string = '' + @State password: string = '' + @State rememberPassword: boolean = false + @State agreement: boolean = false + @State accountErrorFlag: boolean = false + @State passwordErrorFlag: boolean = false + //鐢ㄦ潵鑾峰彇瀛樺偍鐨勫瘑鐮佸拰鐢ㄦ埛璐﹀彿 + @State userInfoData: UserInfoBase = new UserInfoBase() + + aboutToAppear(): void { + PreferencesUtils.getPreferences('UserInfo','user','').then((value: string) => { + if (!value) return + this.userInfoData = JSON.parse(value) as UserInfoBase + this.account = this.userInfoData.account + this.password = this.userInfoData.password + if (this.account && this.password) { + this.rememberPassword = true + } + }) + } + + submitLogin() { + if (!this.account) { + this.accountErrorFlag = true + return + } + if (!this.password || this.password.length !== 8) { + this.passwordErrorFlag = true + return + } + if (!this.agreement) { + promptAction.showToast({ + message: '璇峰嬀閫夊崗璁拰闅愮鏀跨瓥', + backgroundColor: '#242933', + backgroundBlurStyle: BlurStyle.NONE, + textColor: Color.White + }) + return + } + this.userInfoData = { + account: this.account, + password: this.password + } + let httpRequest = http.createHttp(); + + // 鍑嗗瑕佹彁浜ょ殑鏁版嵁浣� + interface PostData { + mobilePhone: string, + password: string + } + let postData: PostData = { + mobilePhone: this.account, + password: this.password + } + + httpRequest.request( + "http://192.168.20.70:8080/quiz-community/public/v1.0/users/login", + { + method: http.RequestMethod.PUT, + header: { 'Content-Type': 'application/json' }, + extraData: postData + }, + (err, data) => { + console.log('response', '/users/register') + console.log(JSON.stringify(data.result)) + if (data.responseCode == 200) { + interface Data { + token: string + } + const resData = (typeof data.result == 'string' ? JSON.parse(data.result) : data.result) as HttpResponseResult<Data> + if (resData.code == 200) { + + PreferencesUtils.putPreferences('UserInfo','user',JSON.stringify(this.userInfoData)) + AppStorage.SetOrCreate('x-jwt-token', resData.data?.token) + promptAction.showToast({ message: '鐧诲綍鎴愬姛' }) + } else { + promptAction.showToast({ message: resData.msg }) + } + } else { + promptAction.showToast({ message: err.message }) + } + } + ) + } + + build() { + Column({space: 10}){ + Text('鎮ㄥソ锛�') + .width('100%') + .fontSize(22) + .fontWeight(800) + .fontColor(Color.White) + Text('娆㈣繋浣跨敤瀛﹁仒鍚岃') + .width('100%') + .fontSize(22) + .fontWeight(800) + .fontColor(Color.White) + Column({ space: 20 }) { + Text('璐﹀彿鐧诲綍') + .width('100%') + .textAlign(TextAlign.Center) + .fontSize(20) + .fontWeight(800) + + Row() { + Image($r('app.media.icon_username')) + .width(16) + .height(16) + TextInput({ placeholder: '璇疯緭鍏ヨ处鍙�', text: $$this.account }) + .type(InputType.USER_NAME) + .backgroundColor('#f3f7fe') + .onChange(() => { + this.accountErrorFlag = false + }) + } + .width('100%') + .backgroundColor('#f3f7fe') + .border(this.accountErrorFlag ? { width: 1, color: Color.Red } : { width: 'none' }) + .borderRadius(10) + .padding({ left: 10, right: 10 }) + + if(this.accountErrorFlag) { + Text('璐﹀彿涓嶈兘绌烘垨璐﹀彿鏈夎') + .width('100%') + .fontSize(12) + .fontColor(Color.Red) + .margin({ top: -16, bottom: -16, left: 20 }) + } + + Row() { + Image($r('app.media.icon_password')) + .width(16) + .height(16) + TextInput({ placeholder: '璇疯緭鍏ュ瘑鐮�', text: $$this.password }) + .type(InputType.Password) + .backgroundColor('#f3f7fe') + .onChange(() =>{ + this.passwordErrorFlag = false + }) + } + .width('100%') + .backgroundColor('#f3f7fe') + .border(this.passwordErrorFlag ? { width: 1, color: Color.Red } : { width: 'none' }) + .borderRadius(10) + .padding({ left: 10, right: 10 }) + + if(this.passwordErrorFlag) { + Text('瀵嗙爜涓嶈兘绌烘垨瀵嗙爜鏈夎') + .width('100%') + .fontSize(12) + .fontColor(Color.Red) + .margin({ top: -16, bottom: -16, left: 20 }) + } + + Row(){ + Row() { + Checkbox() + .select($$this.rememberPassword) + .selectedColor(0x39a2db) + .shape(CheckBoxShape.ROUNDED_SQUARE) + .width(14) + Text('璁颁綇瀵嗙爜') + .fontSize(14) + } + .onClick(() => this.rememberPassword = !this.rememberPassword) + Text('蹇樿瀵嗙爜?') + .fontSize(14) + .fontColor('#1756f4') + .decoration({ type: TextDecorationType.Underline, color: '#1756f4' }) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + + Button('鐧� 褰�') + .type(ButtonType.Normal) + .width('100%') + .borderRadius(10) + .onClick(() => { + this.submitLogin() + }) + + Row() { + Checkbox() + .select($$this.agreement) + .selectedColor(0x39a2db) + .shape(CheckBoxShape.ROUNDED_SQUARE) + .width(14) + Text(){ + Span('鎴戝凡闃呰骞跺悓鎰�') + .fontColor(Color.Black) + Span('銆婄敤鎴峰崗璁��') + .fontColor('#1756f4') + Span('鍜�') + .fontColor(Color.Black) + Span('銆婇殣绉佸崗璁��') + .fontColor('#1756f4') + } + .fontSize(12) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .onClick(() => { this.agreement = !this.agreement }) + + } + .width('100%') + .margin({ top: 20 }) + .padding({ top: 30, bottom: 30, left: 20, right: 20 }) + .borderRadius(6) + .backgroundColor(Color.White) + + Row() { + Text() { + Span('娌℃湁璐﹀彿锛�') + Span('绔嬪嵆娉ㄥ唽>') + .fontColor('#1756f4') + .decoration({ type: TextDecorationType.Underline, color: '#1756f4' }) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ + url: 'pages/login/SignInPage' + }) + }) + } + .fontSize(14) + .fontWeight(500) + .margin({ top: 10 }) + } + + // Row(){ + // Text('娉ㄥ唽') + // .fontColor(Color.White) + // .onClick(() => { + // this.getUIContext().getRouter().pushUrl({ + // url: 'pages/login/SingInPage' + // }) + // }) + // }.width('90%') + // .offset({y: -15,x: -20}) + // .justifyContent(FlexAlign.End) + // Blank() + // Button('鐧� 褰�') + // .width('90%') + // .height(70) + // .fontSize(25) + // .backgroundColor("#ff09b8aa") + // .onClick(() => { + // //鐐瑰嚮鑾峰彇杈撳叆妗嗗唴瀹� + // console.log(`鐢ㄦ埛鍚嶏細${this.userInfoData.userName},瀵嗙爜锛� ${this.userInfoData.userPwd}`); + // if (this.userName === '' || this.userName === undefined || this.userName.trim().length <= 0 || this.userName != this.userInfoData.userName) { + // this.isShowName = false + // this.getUIContext().getPromptAction().showToast({message: '鐢ㄦ埛涓嶈兘绌烘垨鐢ㄦ埛鍚嶆湁璇�'}) + // return //缁撴潫褰撳墠閫昏緫锛屼笉鍦ㄥ悜涓嬫墽琛� + // } + // if (this.userPwd === '' || this.userPwd === undefined || this.userPwd.trim().length <= 0 || this.userPwd != this.userInfoData.userPwd) { + // this.getUIContext().getPromptAction().showToast({message: '瀵嗙爜涓嶈兘绌烘垨瀵嗙爜鏈夎'}) + // this.isShowPwd = false + // return //缁撴潫褰撳墠閫昏緫锛屼笉鍦ㄥ悜涓嬫墽琛� + // } + // this.getUIContext().getPromptAction().showToast({message: '鐧诲綍鎴愬姛'}) + // this.getUIContext().getRouter().replaceUrl({ + // url:'pages/MainPage' + // }) + // }) + } + .width('100%') + .height('100%') + .padding({ top: 100, left: 20, right: 20 }) + .backgroundImage($r('app.media.login_page_bg')) + .backgroundImageSize({width: '100%',height:'100%'}) + + } +} + + diff --git a/entry/src/main/ets/pages/login/SignInPage.ets b/entry/src/main/ets/pages/login/SignInPage.ets new file mode 100644 index 0000000..011d93c --- /dev/null +++ b/entry/src/main/ets/pages/login/SignInPage.ets @@ -0,0 +1,254 @@ +import { promptAction } from '@kit.ArkUI' +import http from '@ohos.net.http'; +import { HttpResponseResult } from '../../data/HttpResponse'; +import { ComponentContent } from '@kit.ArkUI'; +import { PromptActionClass } from '../../utils/PromptActionClass'; + +class DialogParams { + text: string = ""; + + constructor(text: string) { + this.text = text; + } +} +@Builder +function buildText(params: DialogParams) { + Column({ space: 10 }) { + Image($r('app.media.signIn_page_check')) + .width(80) + .height(80) + Text(params.text) + .fontSize(20) + .fontWeight(FontWeight.Bold) + Text() + .fontSize(16) + .fontColor('#666666') + Button('杩斿洖鐧诲綍椤�') + .type(ButtonType.Normal) + .borderRadius(8) + .width('100%') + .onClick(() => { + PromptActionClass.closeDialog(); + PromptActionClass.ctx.getRouter().replaceUrl({ + url: 'pages/login/LoginPage' + }) + }) + } + .width(300) + .padding({ top: 40, bottom: 40, left: 20, right: 20 }) + .borderRadius(14) + .backgroundColor(Color.White) +} + +/** + * @Description : 娉ㄥ唽椤� + */ +@Entry +@Component +struct SignInPage { + @State account: string = '' + @State password: string = '' + @State confirmPassword: string = '' + @State accountErrorFlag: boolean = false + @State passwordErrorFlag: boolean = false + @State confirmPasswordErrorFlag: boolean = false + @State dialogMessage: string = '娉ㄥ唽鎴愬姛'; + private ctx: UIContext = this.getUIContext(); + private contentNode: ComponentContent<Object> = + new ComponentContent(this.ctx, wrapBuilder(buildText), new DialogParams((this.dialogMessage))); + params: DialogParams = new DialogParams('娉ㄥ唽鎴愬姛') + + aboutToAppear(): void { + PromptActionClass.setContext(this.ctx); + PromptActionClass.setContentNode(this.contentNode); + PromptActionClass.setOptions({ alignment: DialogAlignment.Center, offset: { dx: 0, dy: 0 } }); + } + + submitRegister() { + if (!this.account) { + this.accountErrorFlag = true + return + } + if (!this.password || this.password.length !== 8) { + this.passwordErrorFlag = true + return + } + if (this.confirmPassword !== this.password) { + this.confirmPasswordErrorFlag = true + return + } + let httpRequest = http.createHttp(); + + // 鍑嗗瑕佹彁浜ょ殑鏁版嵁浣� + interface PostData { + mobilePhone: string, + password: string + } + let postData: PostData = { + mobilePhone: this.account, + password: this.password + } + + httpRequest.request( + "http://192.168.20.70:8080/quiz-community/public/v1.0/users/register", + { + method: http.RequestMethod.POST, + header: { 'Content-Type': 'application/json' }, + extraData: postData + }, + (err, data) => { + console.log('response', '/users/register') + console.log(JSON.stringify(data.result)) + if (data.responseCode == 200) { + const resData = (typeof data.result == 'string' ? JSON.parse(data.result) : data.result) as HttpResponseResult<null> + if (resData.code == 200) { + PromptActionClass.openDialog() + } else { + promptAction.showToast({ message: resData.msg }) + } + } else { + promptAction.showToast({ message: err.message }) + } + } + ) + } + + build() { + Column({space: 10}){ + Text('鎮ㄥソ锛�') + .width('100%') + .fontSize(22) + .fontWeight(800) + .fontColor(Color.White) + .onClick(() => { + PromptActionClass.openDialog() + }) + Text('娆㈣繋浣跨敤瀛﹁仒鍚岃') + .width('100%') + .fontSize(22) + .fontWeight(800) + .fontColor(Color.White) + Column({ space: 20 }) { + Text('璐﹀彿娉ㄥ唽') + .width('100%') + .textAlign(TextAlign.Center) + .fontSize(20) + .fontWeight(800) + + Row() { + Image($r('app.media.icon_username')) + .width(16) + .height(16) + TextInput({ placeholder: '璇疯緭鍏ヨ处鍙�', text: $$this.account }) + .type(InputType.USER_NAME) + .backgroundColor('#f3f7fe') + .onChange(() => { + this.accountErrorFlag = false + }) + } + .width('100%') + .backgroundColor('#f3f7fe') + .border(this.accountErrorFlag ? { width: 1, color: Color.Red } : { width: 'none' }) + .borderRadius(10) + .padding({ left: 10, right: 10 }) + + if(this.accountErrorFlag) { + Text('璐﹀彿涓嶈兘绌�') + .width('100%') + .fontSize(12) + .fontColor(Color.Red) + .margin({ top: -16, bottom: -16, left: 20 }) + } + + Row() { + Image($r('app.media.icon_password')) + .width(16) + .height(16) + TextInput({ placeholder: '璇疯緭鍏�8浣嶅瘑鐮�', text: $$this.password }) + .type(InputType.Password) + .backgroundColor('#f3f7fe') + .onChange(() =>{ + this.passwordErrorFlag = false + }) + } + .width('100%') + .backgroundColor('#f3f7fe') + .border(this.passwordErrorFlag ? { width: 1, color: Color.Red } : { width: 'none' }) + .borderRadius(10) + .padding({ left: 10, right: 10 }) + + if(this.passwordErrorFlag) { + Text('璇疯緭鍏�8浣嶆暟鐨勫瘑鐮�') + .width('100%') + .fontSize(12) + .fontColor(Color.Red) + .margin({ top: -16, bottom: -16, left: 20 }) + } + + Row() { + Image($r('app.media.icon_password')) + .width(16) + .height(16) + TextInput({ placeholder: '璇峰啀娆¤緭鍏ュ瘑鐮�', text: $$this.confirmPassword }) + .type(InputType.Password) + .backgroundColor('#f3f7fe') + .onChange(() =>{ + this.confirmPasswordErrorFlag = false + }) + } + .width('100%') + .backgroundColor('#f3f7fe') + .border(this.confirmPasswordErrorFlag ? { width: 1, color: Color.Red } : { width: 'none' }) + .borderRadius(10) + .padding({ left: 10, right: 10 }) + + if(this.confirmPasswordErrorFlag) { + Text('涓ゆ瀵嗙爜杈撳叆涓嶄竴鑷�') + .width('100%') + .fontSize(12) + .fontColor(Color.Red) + .margin({ top: -16, bottom: -16, left: 20 }) + } + + Button('娉� 鍐�') + .type(ButtonType.Normal) + .width('100%') + .borderRadius(10) + .onClick(() => { + this.submitRegister() + }) + + } + .width('100%') + .margin({ top: 20 }) + .padding({ top: 30, bottom: 30, left: 20, right: 20 }) + .borderRadius(6) + .backgroundColor(Color.White) + + Row() { + Text() { + Span('宸叉湁璐﹀彿锛�') + Span('绔嬪嵆鐧诲綍>') + .fontColor('#1756f4') + .decoration({ type: TextDecorationType.Underline, color: '#1756f4' }) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ + url: 'pages/login/LoginPage' + }) + }) + } + .fontSize(14) + .fontWeight(500) + .margin({ top: 10 }) + } + } + .width('100%') + .height('100%') + .padding({ top: 100, left: 20, right: 20 }) + .backgroundImage($r('app.media.login_page_bg')) + .backgroundImageSize({width: '100%',height:'100%'}) + + } +} + + diff --git a/entry/src/main/ets/pages/message/MessageDetailsPage.ets b/entry/src/main/ets/pages/message/MessageDetailsPage.ets new file mode 100644 index 0000000..69dbc17 --- /dev/null +++ b/entry/src/main/ets/pages/message/MessageDetailsPage.ets @@ -0,0 +1,131 @@ +import { CommonConstantWX } from '../../common/CommonConstantWX' +import { WxMessageBase } from '../../data/WxMessageBase' +import { WxUserInfoBase } from '../../data/WxUserInfoBase' +import { TitleUtils } from '../../utils/TitleUtils' + +/** + * @ProjectName : HealthNS + * @FileName : MessageDetailsPage + * @UserName : 淇ⅵ + * @Time : 2025/9/14 16:35 + * @Description : 鏂囦欢鎻忚堪 + */ +@Entry +@Component +struct MessageDetailsPage { + @State msgData: Array<WxMessageBase> = CommonConstantWX.mUserMessage + @State mContent:string = '' + private mScroller: Scroller = new Scroller() + @State mUserInfo: WxUserInfoBase = new WxMessageBase() + aboutToAppear(): void { + let params = this.getUIContext().getRouter().getParams() as Record<string,WxUserInfoBase> + this.mUserInfo = params.userInfo + } + build() { + RelativeContainer(){ + TitleUtils({titleName:this.mUserInfo.name}) + .id('heard') + List({space: 15,scroller:this.mScroller}){ + ForEach(this.msgData,(item: WxMessageBase) => { + ListItem(){ + MessageDetailsItem({item: item,icon: this.mUserInfo.img}) + } + }) + } + .id('list') + .alignRules({ + top:{anchor: 'heard',align: VerticalAlign.Bottom}, + bottom: {anchor: 'rowBottom',align: VerticalAlign.Top} + }) + .padding(10) + Row({space: 5}){ + Image($r('app.media.wx_voice_icon')).MessageImageSty() + TextArea({text: this.mContent}) + .backgroundColor(Color.White) + .borderRadius(5) + .width('70%') + .offset({y: 5}) + .onChange((value: string) => { + this.mContent = value + }) + Image($r('app.media.wx_smile_icon')).MessageImageSty() + if (this.mContent.trim().length === 0 || !this.mContent){ + Image($r('app.media.wx_more_icon')).MessageImageSty() + } else { + Button(){ + Text('鍙戦��') + .fontSize(15) + .fontColor(Color.White) + } + .padding(5) + //鍙戦�佹暟鎹紝娣诲姞鍒颁簡鑱婂ぉ鍒楄〃 + .onClick(() =>{ + this.msgData.push({ + id: 99, + content: this.mContent, + img: $r('app.media.avatar_icon1'), + category: 1 + }) + this.mContent = '' + //婊氬姩鍒板簳閮� + this.mScroller.scrollToIndex(this.msgData.length - 1) + }) + } + + } + .width('100%') + .alignItems(VerticalAlign.Bottom) + .padding(10) + .backgroundColor("#ffe9e6e6") + .id('rowBottom') + .alignRules({ + bottom: {anchor: '__container__',align: VerticalAlign.Bottom} + }) + } + .width('100%') + .height('100%') + .backgroundColor('#ccc') + } +} + +@Component +struct MessageDetailsItem { + @Prop item: WxMessageBase + @Prop icon: ResourceStr + build() { + if (this.item.category === 0){ + Row({space:5}){ + Image(this.icon) + .width(40) + .height(40) + Text(this.item.content) + .backgroundColor(Color.White) + .padding(5) + } + .width('78%') + } else { + Row({space:5}){ + Row(){ + Text(this.item.content) + .backgroundColor("#ff3cc12e") + .padding(5) + } + .justifyContent(FlexAlign.End) + .width('78%') + Image($r('app.media.avatar_icon1')) + .width(40) + .height(40) + } + .width('100%') + .justifyContent(FlexAlign.End) + } + + } +} + +@Extend(Image) +function MessageImageSty() { + .width(25) + .height(25) + .objectFit(ImageFit.Fill) +} diff --git a/entry/src/main/ets/pages/message/MessagePage.ets b/entry/src/main/ets/pages/message/MessagePage.ets new file mode 100644 index 0000000..af21043 --- /dev/null +++ b/entry/src/main/ets/pages/message/MessagePage.ets @@ -0,0 +1,94 @@ +import { CommonConstantWX } from "../../common/CommonConstantWX" +import { WxUserInfoBase } from "../../data/WxUserInfoBase" + +/* + * Search({placeholder: '璇疯緭鍏ユ偍瑕佹悳绱㈢殑鍐呭',value: 'DeepSeek'}) + .width('90%') + .backgroundColor(Color.White) + .searchButton('鎼滅储') + .onChange((value: string) => { + console.info(`杈撳叆鐨勫唴瀹逛负锛�${value}`) + }) + //鎻愪氦鏂规硶 + .onSubmit((value:string) => { + console.info(`鎻愪氦鐨勫唴瀹逛负锛�${value}`) + }) + * */ +@Entry +@Component +export struct MessagePage { + @State userList:Array<WxUserInfoBase> = CommonConstantWX.mUser + @State searchUser:Array<WxUserInfoBase> = [] + build() { + Column({space: 10}) { + Search({placeholder: '鎼滅储'}) + .backgroundColor(Color.White) + .width('90%') + .borderRadius(5) + .onChange((value: string) =>{ + //姣忔杈撳叆閮借娓呯┖searchUser鏁扮粍 + this.searchUser = [] + let searchCount = 0 + //杩涜閬嶅巻锛屽湪鏁扮粍婧愬ご鏌ユ壘鍜寁alue鐩稿叧鐨勬暟鎹� + for (let index = 0; index < this.userList.length; index++) { + const element = this.userList[index]; + //鍒ゆ柇姣忎竴鏉℃暟鎹槸鍚︽湁鍜孷alue鐩稿叧鐨勫唴瀹� + if (element.name?.indexOf(value) != -1) { + //鎵惧埌鐩稿叧鐨勬暟鎹紝娣诲姞鍒皊earch鏁扮粍褰撲腑锛屽苟涓旀暟鎹姞涓� + searchCount ++ + this.searchUser.push(element) + } + } + //鍒ゆ柇SearchCount鏄惁涓�0 + if (searchCount === 0) { + //琛ㄧず鏌ユ棤姝や汉 + this.searchUser.push({ + id: 999, + name: '鏃犳鐢ㄦ埛', + img:$r('app.media.avatar_icon') + }) + } + + }) + List({space: 20}){ + ForEach(this.searchUser.length === 0 ? this.userList: this.searchUser,(item: WxUserInfoBase) => { + ListItem(){ + userInfoItem({item: item}) + } + }) + } + .height('90%') + .padding({top:10}) + .margin({bottom: 30}) + .backgroundColor(Color.White) + .divider({strokeWidth: 2,color: '#ccc'}) + } + .height('100%') + .width('100%') + .backgroundColor('#ccc') + } +} + +@Component +struct userInfoItem { + @Prop item: WxUserInfoBase + build() { + Row({space: 15}){ + Image(this.item.img) + .width(40) + .height(40) + .objectFit(ImageFit.Cover) + Text(this.item.name) + .fontSize(20) + } + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ + url: 'pages/message/MessageDetailsPage', + params:{ + userInfo: this.item + } + }) + }) + .padding(10) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/search/SearchPage.ets b/entry/src/main/ets/pages/search/SearchPage.ets new file mode 100644 index 0000000..408cf26 --- /dev/null +++ b/entry/src/main/ets/pages/search/SearchPage.ets @@ -0,0 +1,82 @@ +import { AxiosResponse } from "@ohos/axios" +import { NewsBase, NewsBaseData } from "../../data/NewsBase" +import { TextBase } from "../../data/TextBase" +import { NewsApi, TextApi } from "../../http/AxiosAPI" + +@Entry +@Component +export struct SearchPage { + //鍙橀噺鎵胯浇鏂伴椈鏁版嵁 + @State newsBase: NewsBase = new NewsBase() + @State TextData: TextBase = new TextBase() + async aboutToAppear() { + let newsData:NewsBase = await NewsApi() + this.newsBase = newsData + let textData:TextBase = await TextApi() + this.TextData = textData + console.info('textData ' + JSON.stringify(textData)) + } + build() { + Column() { + Column(){ + Text(JSON.stringify(this.TextData.text)) + .fontWeight(700) + .fontSize(20) + + } + .width('95%') + .height(50) + .borderRadius(20) + .backgroundColor(Color.White) + .justifyContent(FlexAlign.Center) + .onClick(() => { + console.info('TextData: ' + JSON.stringify(this.TextData.text)) + }) + List({space:15}){ + ForEach(this.newsBase.data,(item:NewsBaseData) =>{ + ListItem(){ + newsItem({newsData: item}) + } + }) + } + .alignListItem(ListItemAlign.Center) + } + .height('100%') + .width('100%') + .backgroundColor("#ffececec") + } +} +//鏉$洰鏍峰紡锛岃嚜瀹氫箟缁勪欢 +@Component +struct newsItem { + @Prop newsData: NewsBaseData + build() { + Row({space: 10}){ + Image(this.newsData.pic) + //鍗犱綅鍥� + .alt($r('app.media.app_logo_image')) + .width(100) + .height(70) + .objectFit(ImageFit.Fill) + Column({space: 10}){ + Text(this.newsData.title).SearchTextSty(18,700) + Text(this.newsData.desc).SearchTextSty(15,400,Color.Black,2) + Text(`鐑害锛� ${this.newsData.hot}`).SearchTextSty(10,400,Color.Red) + .textAlign(TextAlign.End) + } + .width('65%') + } + .width('95%') + .padding(10) + .borderRadius(10) + .backgroundColor(Color.White) + } +} +@Extend(Text) function SearchTextSty(mSize:number,mWeight?:FontWeight,mColor?: ResourceColor,mLines?: number){ + .fontSize(mSize) + .fontWeight(mWeight? mWeight : 400) + .fontColor(mColor? mColor : Color.Black) + .maxLines(mLines? mLines : 1) + .textOverflow({overflow: TextOverflow.Ellipsis}) + .width('100%') +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/PreferencesUtils.ets b/entry/src/main/ets/utils/PreferencesUtils.ets new file mode 100644 index 0000000..584527d --- /dev/null +++ b/entry/src/main/ets/utils/PreferencesUtils.ets @@ -0,0 +1,92 @@ +import { preferences } from "@kit.ArkData"; + +/** + * @ProjectName : HealthNS + * @FileName : PreferencesUtils + * @UserName : 淇ⅵ + * @Time : 2025/9/14 09:25 + * @Description : 鏈湴鎸佷箙鍖栧瓨鍌� + */ +class PreferencesUtils { + //鍒涘缓PS鏈湴瀛樺偍鐨勯泦鍚堟暟鎹紝鍙互鏀寔澶氫釜瀛樺偍瀛樺湪 + prefMap: Map<string,preferences.Preferences> = new Map(); + //鍒濆鍖栨柟娉� 鍚屾锛堢被浼间簬鎺掗槦锛屼笂涓换鍔″畬鎴愶紝鎵嶅洖鍒颁笅涓�涓换鍔★紝鍩烘湰涓嶈兘鏈夎�楁椂鎿嶄綔锛� + //寮傛锛屽紑杈熶竴涓瓙绾跨▼锛屽湪瀛愮嚎绋嬭繍琛屽畬姣曪紝缁撴灉杩斿洖缁欎富绾跨▼ + //鎻愪緵寮傛绾跨▼璇硶绯� async/await + //context: Context 褰撳墠閭d釜椤甸潰瑕佷娇鐢紝name瀛樺偍鐨勫悕绉� + async loadPreferences(context: Context,name:string){ + //涓轰簡淇濊瘉姝e父杩涜鍒濆鍖栵紝鎺ㄨ崘浣跨敤寮傚父鎹曡幏锛屼繚璇佸湪寮傚父鎯呭喌涓嬶紝APP涓嶄細宕╂簝 + try { + //鍒濆鍖栨棤闂锛屾墽琛屾甯搁�昏緫 + //鍒涘缓PS瀛樺偍 + const pref = await preferences.getPreferences(context,name) + //鍒濆鍚庣殑瀛樺偍锛屽瓨鏀捐繎Map闆嗗悎 + this.prefMap.set(name,pref) + console.info(`鍒濆鍖�${name}瀛樺偍瀹屾垚`) + } catch (e) { + console.info(`鍒濆鍖�${name}澶辫触锛屽け璐ュ師鍥狅細 ${e}}`) + } + } + //娣诲姞鏁版嵁 name: PS瀛樺偍鐨勫悕绉帮紝key锛氬瓨鍌ㄥ�肩殑鍒悕锛寁alue瀛樺偍鐨勫叿浣撳�� + async putPreferences(name:string,key:string,value:preferences.ValueType){ + //鍏堝垽鏂璏ap鏁版嵁閲屾湁娌℃湁姝e父鍒濆鍖栵紙闆嗗悎閲屽瓨涓嶅瓨鍦ㄥ綋鍓峆S瀛樺偍锛� + if (!this.prefMap.has(name)) { + //! 闈烇紝琛ㄧず鏀筆S涓嶅瓨鍦� + console.info(`${name}瀛樺偍涓嶅瓨鍦�,璇峰垵濮嬪寲`) + return + } + try { + //褰揚S瀛樺偍瀛樺湪锛屾墽琛屽綋涓嬮�昏緫 + const pref = this.prefMap.get(name) + //鍐欏叆鏁版嵁 + await pref?.put(key,value) + //鎸佷箙鍖栵紝鍒风鐩� + await pref?.flush() + console.info(`${name}瀛樺偍鍐欏叆鏁版嵁鎴愬姛`) + } catch (e){ + console.info(`${name}瀛樺偍鍐欏叆鏁版嵁澶辫触锛屽け璐ュ師鍥狅細 ${e}`) + } + } + //璇诲彇鏁版嵁 + async getPreferences(name: string,key: string,defaultValue: preferences.ValueType){ + //鍏堝垽鏂璏ap鏁版嵁閲屾湁娌℃湁姝e父鍒濆鍖栵紙闆嗗悎閲屽瓨涓嶅瓨鍦ㄥ綋鍓峆S瀛樺偍锛� + if (!this.prefMap.has(name)) { + //! 闈烇紝琛ㄧず鏀筆S涓嶅瓨鍦� + console.info(`璇诲彇${name}瀛樺偍涓嶅瓨鍦�,璇峰垵濮嬪寲`) + return + } + try { + //鑾峰彇Map閲岄潰瀛樼殑瀛樺偍 + const pref = this.prefMap.get(name) + //寮�濮嬭鍙栨暟鎹� + const value = await pref?.get(key,defaultValue) + console.info(`璇诲彇${name}瀛樺偍鎴愬姛锛屾暟鎹负锛�${JSON.stringify(value)}`) + return value + } catch (e){ + console.info(`璇诲彇${name}瀛樺偍鎵嬪け璐ワ紝澶辫触鍘熷洜: ${e}}`) + return e + } + } + //鍒犻櫎鏁版嵁 + async delPreferences(name:string,key:string){ + //鍏堝垽鏂璏ap鏁版嵁閲屾湁娌℃湁姝e父鍒濆鍖栵紙闆嗗悎閲屽瓨涓嶅瓨鍦ㄥ綋鍓峆S瀛樺偍锛� + if (!this.prefMap.has(name)) { + //! 闈烇紝琛ㄧず鏀筆S涓嶅瓨鍦� + console.info(`璇诲彇${name}瀛樺偍涓嶅瓨鍦�,鏃犳硶鍒犻櫎`) + return + } + try { + //鎷垮埌瀛樺偍 + const pref = this.prefMap.get(name) + //寮�濮嬪垹闄ゆ暟鎹� + await pref?.delete(key) + //鍒风鐩� + await pref?.flush() + console.info(`鍒犻櫎${name}瀛樺偍鎴愬姛`) + }catch (e) { + console.info(`鍒犻櫎${name}瀛樺偍澶辫触锛屽け璐ュ師鍥�:${e}`) + } + } +} +//浠垮崟鍒╋紝鏁翠釜椤圭洰鍙渶瑕佷竴涓瓨鍌紝鍑忓皯绾跨▼娑堣�� +export default new PreferencesUtils() as PreferencesUtils \ No newline at end of file diff --git a/entry/src/main/ets/utils/PromptActionClass.ets b/entry/src/main/ets/utils/PromptActionClass.ets new file mode 100644 index 0000000..44edfba --- /dev/null +++ b/entry/src/main/ets/utils/PromptActionClass.ets @@ -0,0 +1,63 @@ +// PromptActionClass.ets +import { BusinessError } from '@kit.BasicServicesKit'; +import { ComponentContent, promptAction, UIContext } from '@kit.ArkUI'; + +export class PromptActionClass { + static ctx: UIContext; + static contentNode: ComponentContent<Object>; + static options: promptAction.BaseDialogOptions; + + static setContext(context: UIContext) { + PromptActionClass.ctx = context; + } + + static setContentNode(node: ComponentContent<Object>) { + PromptActionClass.contentNode = node; + } + + static setOptions(options: promptAction.BaseDialogOptions) { + PromptActionClass.options = options; + } + + static openDialog() { + if (PromptActionClass.contentNode !== null) { + PromptActionClass.ctx.getPromptAction().openCustomDialog(PromptActionClass.contentNode, PromptActionClass.options) + .then(() => { + console.info('OpenCustomDialog complete.'); + }) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenCustomDialog args error code is ${code}, message is ${message}`); + }) + } + } + + static closeDialog() { + if (PromptActionClass.contentNode !== null) { + PromptActionClass.ctx.getPromptAction().closeCustomDialog(PromptActionClass.contentNode) + .then(() => { + console.info('CloseCustomDialog complete.'); + }) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseCustomDialog args error code is ${code}, message is ${message}`); + }) + } + } + + static updateDialog(options: promptAction.BaseDialogOptions) { + if (PromptActionClass.contentNode !== null) { + PromptActionClass.ctx.getPromptAction().updateCustomDialog(PromptActionClass.contentNode, options) + .then(() => { + console.info('UpdateCustomDialog complete.'); + }) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`UpdateCustomDialog args error code is ${code}, message is ${message}`); + }) + } + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index ad219d7..f0eded4 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -45,6 +45,11 @@ } ], } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + } ] } } \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index f945955..69fba10 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -2,15 +2,15 @@ "string": [ { "name": "module_desc", - "value": "module description" + "value": "瀛﹁仒鍚岃" }, { "name": "EntryAbility_desc", - "value": "description" + "value": "瀛﹁仒鍚岃" }, { "name": "EntryAbility_label", - "value": "label" + "value": "瀛﹁仒鍚岃" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/base/media/active_list_img.png b/entry/src/main/resources/base/media/active_list_img.png new file mode 100644 index 0000000..0ba7ba8 --- /dev/null +++ b/entry/src/main/resources/base/media/active_list_img.png Binary files differ diff --git a/entry/src/main/resources/base/media/classification_AI.png b/entry/src/main/resources/base/media/classification_AI.png new file mode 100644 index 0000000..82e988d --- /dev/null +++ b/entry/src/main/resources/base/media/classification_AI.png Binary files differ diff --git a/entry/src/main/resources/base/media/date_icon.png b/entry/src/main/resources/base/media/date_icon.png new file mode 100644 index 0000000..853145a --- /dev/null +++ b/entry/src/main/resources/base/media/date_icon.png Binary files differ diff --git a/entry/src/main/resources/base/media/icon_password.svg b/entry/src/main/resources/base/media/icon_password.svg new file mode 100644 index 0000000..ec3455a --- /dev/null +++ b/entry/src/main/resources/base/media/icon_password.svg @@ -0,0 +1,3 @@ +<svg width="52" height="52" viewBox="0 0 52 52" fill="none" xmlns="http://www.w3.org/2000/svg"> +<path d="M14.625 19.5V15.7084C14.625 9.42558 19.7167 4.33337 26 4.33337C32.2833 4.33337 37.375 9.42287 37.375 15.7084V19.5H37.9172C41.2062 19.5 43.875 22.171 43.875 25.4584V41.7084C43.875 45.0001 41.2105 47.6667 37.9172 47.6667H14.0833C10.7938 47.6667 8.125 44.9958 8.125 41.7084V25.4584C8.125 22.1667 10.7895 19.5 14.0828 19.5H14.625ZM17.875 19.5H34.125V15.7084C34.125 11.218 30.4888 7.58337 26 7.58337C21.5118 7.58337 17.875 11.2207 17.875 15.7084V19.5ZM11.375 25.4584V41.7084C11.375 43.2012 12.5894 44.4167 14.0828 44.4167H37.9167C38.2725 44.4171 38.6248 44.3474 38.9536 44.2114C39.2824 44.0755 39.5811 43.876 39.8327 43.6244C40.0843 43.3728 40.2838 43.0741 40.4197 42.7453C40.5557 42.4165 40.6254 42.0642 40.625 41.7084V25.4584C40.625 23.9655 39.4106 22.75 37.9172 22.75H14.0833C13.7276 22.7496 13.3752 22.8194 13.0464 22.9553C12.7176 23.0913 12.4189 23.2908 12.1673 23.5423C11.9157 23.7939 11.7162 24.0926 11.5803 24.4214C11.4443 24.7502 11.3746 25.1026 11.375 25.4584Z" fill="#1756F4"/> +</svg> diff --git a/entry/src/main/resources/base/media/icon_username.svg b/entry/src/main/resources/base/media/icon_username.svg new file mode 100644 index 0000000..8dc863b --- /dev/null +++ b/entry/src/main/resources/base/media/icon_username.svg @@ -0,0 +1,3 @@ +<svg width="52" height="52" viewBox="0 0 52 52" fill="none" xmlns="http://www.w3.org/2000/svg"> +<path d="M30.7509 49.4094H21.4523C12.4091 49.4094 5.26379 49.4094 5.26379 44.4411V43.5382C5.26379 34.7738 12.5249 27.6427 21.4523 27.6427H30.7509C39.6712 27.6427 46.9323 34.7738 46.9323 43.5382V44.4434C46.93 49.4094 39.4325 49.4094 30.7509 49.4094ZM21.4523 31.1882C14.482 31.1882 8.80925 36.7285 8.80925 43.5382V44.4434C8.80925 45.8663 17.3467 45.8663 21.4523 45.8663H30.7509C33.8756 45.8663 43.3869 45.8663 43.3869 44.4434V43.5382C43.3869 36.7285 37.7189 31.1882 30.7509 31.1882H21.4523ZM25.6312 27.5434C18.5025 27.5434 12.7022 21.8423 12.7022 14.8389C12.7022 7.83543 18.5025 2.13434 25.6312 2.13434C32.76 2.13434 38.5603 7.83307 38.5603 14.8389C38.5603 21.8447 32.76 27.5434 25.6312 27.5434ZM16.25 14.8389C16.25 19.8876 20.4596 23.998 25.6336 23.998C30.8076 23.998 35.0172 19.89 35.0172 14.8389C35.0172 9.78779 30.8076 5.67979 25.6336 5.67979C20.4596 5.67979 16.25 9.79016 16.25 14.8389Z" fill="#1756F4"/> +</svg> diff --git a/entry/src/main/resources/base/media/image1.png b/entry/src/main/resources/base/media/image1.png new file mode 100644 index 0000000..45911cb --- /dev/null +++ b/entry/src/main/resources/base/media/image1.png Binary files differ diff --git a/entry/src/main/resources/base/media/login_page_bg.png b/entry/src/main/resources/base/media/login_page_bg.png new file mode 100644 index 0000000..8b2ffc6 --- /dev/null +++ b/entry/src/main/resources/base/media/login_page_bg.png Binary files differ diff --git a/entry/src/main/resources/base/media/logo.png b/entry/src/main/resources/base/media/logo.png new file mode 100644 index 0000000..85a6867 --- /dev/null +++ b/entry/src/main/resources/base/media/logo.png Binary files differ diff --git a/entry/src/main/resources/base/media/signIn_page_check.png b/entry/src/main/resources/base/media/signIn_page_check.png new file mode 100644 index 0000000..14a74e9 --- /dev/null +++ b/entry/src/main/resources/base/media/signIn_page_check.png Binary files differ diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png index 205ad8b..85a6867 100644 --- a/entry/src/main/resources/base/media/startIcon.png +++ b/entry/src/main/resources/base/media/startIcon.png Binary files differ diff --git a/entry/src/main/resources/base/media/start_page_bg.png b/entry/src/main/resources/base/media/start_page_bg.png new file mode 100644 index 0000000..5a4b96e --- /dev/null +++ b/entry/src/main/resources/base/media/start_page_bg.png Binary files differ diff --git a/entry/src/main/resources/base/media/tabs_account_icon.png b/entry/src/main/resources/base/media/tabs_account_icon.png new file mode 100644 index 0000000..0f73f9a --- /dev/null +++ b/entry/src/main/resources/base/media/tabs_account_icon.png Binary files differ diff --git a/entry/src/main/resources/base/media/tabs_account_icon_active.png b/entry/src/main/resources/base/media/tabs_account_icon_active.png new file mode 100644 index 0000000..3d699bb --- /dev/null +++ b/entry/src/main/resources/base/media/tabs_account_icon_active.png Binary files differ diff --git a/entry/src/main/resources/base/media/tabs_home_icon.png b/entry/src/main/resources/base/media/tabs_home_icon.png new file mode 100644 index 0000000..5617c98 --- /dev/null +++ b/entry/src/main/resources/base/media/tabs_home_icon.png Binary files differ diff --git a/entry/src/main/resources/base/media/tabs_home_icon_active.png b/entry/src/main/resources/base/media/tabs_home_icon_active.png new file mode 100644 index 0000000..91a565a --- /dev/null +++ b/entry/src/main/resources/base/media/tabs_home_icon_active.png Binary files differ diff --git a/entry/src/main/resources/base/media/tabs_message_icon.png b/entry/src/main/resources/base/media/tabs_message_icon.png new file mode 100644 index 0000000..d78ef90 --- /dev/null +++ b/entry/src/main/resources/base/media/tabs_message_icon.png Binary files differ diff --git a/entry/src/main/resources/base/media/tabs_message_icon_active.png b/entry/src/main/resources/base/media/tabs_message_icon_active.png new file mode 100644 index 0000000..12a6563 --- /dev/null +++ b/entry/src/main/resources/base/media/tabs_message_icon_active.png Binary files differ diff --git a/entry/src/main/resources/base/media/tabs_search_platform_icon.png b/entry/src/main/resources/base/media/tabs_search_platform_icon.png new file mode 100644 index 0000000..3b06f68 --- /dev/null +++ b/entry/src/main/resources/base/media/tabs_search_platform_icon.png Binary files differ diff --git a/entry/src/main/resources/base/media/tabs_search_platform_icon_active.png b/entry/src/main/resources/base/media/tabs_search_platform_icon_active.png new file mode 100644 index 0000000..012023e --- /dev/null +++ b/entry/src/main/resources/base/media/tabs_search_platform_icon_active.png Binary files differ diff --git a/entry/src/main/resources/base/media/title_decoration_icon.png b/entry/src/main/resources/base/media/title_decoration_icon.png new file mode 100644 index 0000000..395b069 --- /dev/null +++ b/entry/src/main/resources/base/media/title_decoration_icon.png Binary files differ diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 1898d94..316bba2 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,9 @@ { "src": [ - "pages/Index" + "pages/Index", + "pages/StartPage", + "pages/login/LoginPage", + "pages/login/SignInPage", + "pages/MainPage" ] } diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 index 7fcf818..c2f6d1b 100644 --- a/oh-package-lock.json5 +++ b/oh-package-lock.json5 @@ -1,6 +1,7 @@ { "meta": { - "stableOrder": true + "stableOrder": true, + "enableUnifiedLockfile": false }, "lockfileVersion": 3, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", -- Gitblit v1.8.0