Showing
15 changed files
with
260 additions
and
58 deletions
| @@ -3,6 +3,8 @@ import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; | @@ -3,6 +3,8 @@ import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; | ||
| 3 | import common from '@ohos.app.ability.common'; | 3 | import common from '@ohos.app.ability.common'; |
| 4 | import featureAbility from '@ohos.ability.featureAbility'; | 4 | import featureAbility from '@ohos.ability.featureAbility'; |
| 5 | import wantConstant from '@ohos.ability.wantConstant'; | 5 | import wantConstant from '@ohos.ability.wantConstant'; |
| 6 | +import Want from '@ohos.app.ability.Want'; | ||
| 7 | +import { AppUtils } from './AppUtils'; | ||
| 6 | 8 | ||
| 7 | export class PermissionUtil { | 9 | export class PermissionUtil { |
| 8 | async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> { | 10 | async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> { |
| @@ -43,21 +45,21 @@ export class PermissionUtil { | @@ -43,21 +45,21 @@ export class PermissionUtil { | ||
| 43 | return hasPermissions; | 45 | return hasPermissions; |
| 44 | } | 46 | } |
| 45 | 47 | ||
| 46 | - static reqPermissionsFromUser(permissions: Array<Permissions>): void { | ||
| 47 | - // let context = getContext(this) as common.UIAbilityContext; | ||
| 48 | - // let atManager = abilityAccessCtrl.createAtManager(); | ||
| 49 | - // // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 | ||
| 50 | - // atManager.requestPermissionsFromUser(context, permissions).then((data) => { | ||
| 51 | - // let grantStatus: Array<number> = data.authResults; | ||
| 52 | - // let length: number = grantStatus.length; | ||
| 53 | - // for (let i = 0; i < length; i++) { | ||
| 54 | - // if (grantStatus[i] === 0) { | ||
| 55 | - // // 用户授权,可以继续访问目标操作 | ||
| 56 | - // | ||
| 57 | - // } else { | ||
| 58 | - // | ||
| 59 | - // this.jumpSetting(); | ||
| 60 | - // // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 | 48 | + static reqPermissionsFromUser(permissions: Array<Permissions>, component: Object): void { |
| 49 | + let context = getContext(component) as common.UIAbilityContext; | ||
| 50 | + let atManager = abilityAccessCtrl.createAtManager(); | ||
| 51 | + // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 | ||
| 52 | + atManager.requestPermissionsFromUser(context, permissions).then((data) => { | ||
| 53 | + let grantStatus: Array<number> = data.authResults; | ||
| 54 | + let length: number = grantStatus.length; | ||
| 55 | + for (let i = 0; i < length; i++) { | ||
| 56 | + if (grantStatus[i] === 0) { | ||
| 57 | + // 用户授权,可以继续访问目标操作 | ||
| 58 | + | ||
| 59 | + } else { | ||
| 60 | + | ||
| 61 | + PermissionUtil.openPermissionsInSystemSettings(component); | ||
| 62 | + // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 | ||
| 61 | // AlertDialog.show({ | 63 | // AlertDialog.show({ |
| 62 | // title: '权限设置', | 64 | // title: '权限设置', |
| 63 | // message: '到系统设置中打开相应的权限', | 65 | // message: '到系统设置中打开相应的权限', |
| @@ -68,17 +70,28 @@ export class PermissionUtil { | @@ -68,17 +70,28 @@ export class PermissionUtil { | ||
| 68 | // }, | 70 | // }, |
| 69 | // } | 71 | // } |
| 70 | // }) | 72 | // }) |
| 71 | - // return; | ||
| 72 | - // } | ||
| 73 | - // } | ||
| 74 | - // // 授权成功 | ||
| 75 | - // }).catch((err) => { | 73 | + return; |
| 74 | + } | ||
| 75 | + } | ||
| 76 | + // 授权成功 | ||
| 77 | + }).catch((err:Error) => { | ||
| 76 | // console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`); | 78 | // console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`); |
| 77 | - // }) | 79 | + }) |
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | 82 | ||
| 81 | - static jumpSetting() { | ||
| 82 | - | 83 | + static openPermissionsInSystemSettings(component: Object): void { |
| 84 | + let context = getContext(component) as common.UIAbilityContext; | ||
| 85 | + let wantInfo:Want = { | ||
| 86 | + action: 'action.settings.app.info', | ||
| 87 | + parameters: { | ||
| 88 | + settingsParamBundleName: AppUtils.getPackageName(context) // 打开指定应用的详情页面 | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + context.startAbility(wantInfo).then(() => { | ||
| 92 | + // ... | ||
| 93 | + }).catch((err:Error) => { | ||
| 94 | + // ... | ||
| 95 | + }) | ||
| 83 | } | 96 | } |
| 84 | } | 97 | } |
| @@ -265,6 +265,21 @@ export class HttpUrlUtils { | @@ -265,6 +265,21 @@ export class HttpUrlUtils { | ||
| 265 | return url; | 265 | return url; |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | + static getForgetPasswordUrl() { | ||
| 269 | + let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/forgotPassword"; | ||
| 270 | + return url; | ||
| 271 | + } | ||
| 272 | + | ||
| 273 | + static queryUserDetail() { | ||
| 274 | + let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/user/zh/c/queryUserDetail"; | ||
| 275 | + return url; | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + static editUserDetail() { | ||
| 279 | + let url = HttpUrlUtils.hostUrl + "/user/zh/c/editUserDetail"; | ||
| 280 | + return url; | ||
| 281 | + } | ||
| 282 | + | ||
| 268 | static getAppLoginUrl() :string{ | 283 | static getAppLoginUrl() :string{ |
| 269 | let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/auth/zh/c/appLogin"; | 284 | let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/auth/zh/c/appLogin"; |
| 270 | return url; | 285 | return url; |
| @@ -55,9 +55,7 @@ export class WDRouterPage { | @@ -55,9 +55,7 @@ export class WDRouterPage { | ||
| 55 | static aboutPage = new WDRouterPage("wdComponent", "ets/components/page/SettingAboutPage"); | 55 | static aboutPage = new WDRouterPage("wdComponent", "ets/components/page/SettingAboutPage"); |
| 56 | // 设置页 | 56 | // 设置页 |
| 57 | static settingPage = new WDRouterPage("wdComponent", "ets/components/page/SettingPage"); | 57 | static settingPage = new WDRouterPage("wdComponent", "ets/components/page/SettingPage"); |
| 58 | - // 账户与安全页 | ||
| 59 | - // static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview"); | ||
| 60 | // 设置密码页、设置手机号页等等 (需要传参) | 58 | // 设置密码页、设置手机号页等等 (需要传参) |
| 61 | - // static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview"); | 59 | + static settingPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/SettingPasswordPage"); |
| 62 | 60 | ||
| 63 | } | 61 | } |
| @@ -12,6 +12,7 @@ | @@ -12,6 +12,7 @@ | ||
| 12 | "wdWebComponent": "file:../../commons/wdWebComponent", | 12 | "wdWebComponent": "file:../../commons/wdWebComponent", |
| 13 | "wdBean": "file:../../features/wdBean", | 13 | "wdBean": "file:../../features/wdBean", |
| 14 | "wdRouter": "file:../../commons/wdRouter", | 14 | "wdRouter": "file:../../commons/wdRouter", |
| 15 | - "wdNetwork": "file:../../commons/wdNetwork" | 15 | + "wdNetwork": "file:../../commons/wdNetwork", |
| 16 | + "wdLogin": "file:../../features/wdLogin" | ||
| 16 | } | 17 | } |
| 17 | } | 18 | } |
| 1 | +import { Params } from 'wdBean'; | ||
| 2 | +import { WDRouterPage, WDRouterRule } from 'wdRouter'; | ||
| 3 | + | ||
| 1 | const TAG = 'AboutPageUI'; | 4 | const TAG = 'AboutPageUI'; |
| 2 | 5 | ||
| 3 | @Component | 6 | @Component |
| @@ -41,8 +44,16 @@ export struct AboutPageUI { | @@ -41,8 +44,16 @@ export struct AboutPageUI { | ||
| 41 | ForEach(this.listData, (item:string, index : number) =>{ | 44 | ForEach(this.listData, (item:string, index : number) =>{ |
| 42 | ListItem() { | 45 | ListItem() { |
| 43 | this.getArrowCell(item, index) | 46 | this.getArrowCell(item, index) |
| 47 | + }.onClick(() =>{ | ||
| 48 | + if (index == 0) { | ||
| 49 | + let bean={contentId:"1",pageID:""} as Params | ||
| 50 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | ||
| 51 | + }else{ | ||
| 52 | + let bean={contentId:"2",pageID:""} as Params | ||
| 53 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | ||
| 44 | } | 54 | } |
| 45 | }) | 55 | }) |
| 56 | + }) | ||
| 46 | }.divider({ | 57 | }.divider({ |
| 47 | strokeWidth: 1, | 58 | strokeWidth: 1, |
| 48 | startMargin: '29lpx', | 59 | startMargin: '29lpx', |
| @@ -2,20 +2,17 @@ | @@ -2,20 +2,17 @@ | ||
| 2 | import { BottomNavi, CommonConstants } from 'wdConstant'; | 2 | import { BottomNavi, CommonConstants } from 'wdConstant'; |
| 3 | import { Logger } from 'wdKit'; | 3 | import { Logger } from 'wdKit'; |
| 4 | import { TopNavigationComponent } from '../page/TopNavigationComponent'; | 4 | import { TopNavigationComponent } from '../page/TopNavigationComponent'; |
| 5 | -// import { BottomNavDTO } from '../../repository/bean/BottomNavDTO'; | ||
| 6 | -// import { UIUtils } from '../../repository/UIUtils'; | ||
| 7 | -// import { MinePageComponent } from './MinePageComponent'; | ||
| 8 | import PageViewModel from '../../viewmodel/PageViewModel'; | 5 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 9 | import {MineMainSettingFunctionItem} from '../../viewmodel/MineMainSettingFunctionItem'; | 6 | import {MineMainSettingFunctionItem} from '../../viewmodel/MineMainSettingFunctionItem'; |
| 10 | import MineSettingDatasModel from '../../model/MineSettingDatasModel'; | 7 | import MineSettingDatasModel from '../../model/MineSettingDatasModel'; |
| 11 | -// import MineMainSettingFunctionItem from '../../model/MineSettingDatasModel'; | ||
| 12 | -// import { MineMainSettingFunctionItem } from '../setting/MineSettingDatasModel' | ||
| 13 | - | ||
| 14 | import storageStatistics from "@ohos.file.storageStatistics"; | 8 | import storageStatistics from "@ohos.file.storageStatistics"; |
| 15 | import { BusinessError } from '@ohos.base'; | 9 | import { BusinessError } from '@ohos.base'; |
| 16 | import ArrayList from '@ohos.util.ArrayList'; | 10 | import ArrayList from '@ohos.util.ArrayList'; |
| 17 | import router from '@ohos.router'; | 11 | import router from '@ohos.router'; |
| 18 | - | 12 | +import { WDRouterPage, WDRouterRule } from 'wdRouter'; |
| 13 | +import { Params } from 'wdBean'; | ||
| 14 | +import { SettingPasswordParams } from 'wdLogin'; | ||
| 15 | +export { SettingPasswordParams } from "wdLogin" | ||
| 19 | 16 | ||
| 20 | @Component | 17 | @Component |
| 21 | export struct AccountAndSecurityLayout { | 18 | export struct AccountAndSecurityLayout { |
| @@ -61,11 +58,14 @@ export struct AccountAndSecurityLayout { | @@ -61,11 +58,14 @@ export struct AccountAndSecurityLayout { | ||
| 61 | } | 58 | } |
| 62 | .onClick(() => { | 59 | .onClick(() => { |
| 63 | console.log(index + "") | 60 | console.log(index + "") |
| 64 | - if (index == 1) { | ||
| 65 | - router.pushUrl({ | ||
| 66 | - url:"pages/SettingPasswordPage", | ||
| 67 | - params : {'currentType' : 4} | ||
| 68 | - }) | 61 | + if (index == 0){ |
| 62 | + | ||
| 63 | + }else if (index == 1) { | ||
| 64 | + | ||
| 65 | + let params: SettingPasswordParams = { | ||
| 66 | + pageID:'1', | ||
| 67 | + } | ||
| 68 | + WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params) | ||
| 69 | } | 69 | } |
| 70 | }) | 70 | }) |
| 71 | 71 |
| @@ -23,7 +23,7 @@ export struct MineSettingComponent { | @@ -23,7 +23,7 @@ export struct MineSettingComponent { | ||
| 23 | if (err) { | 23 | if (err) { |
| 24 | console.error(`Invoke getCurrentBundleStats failed, code is ${err.code}, message is ${err.message}`); | 24 | console.error(`Invoke getCurrentBundleStats failed, code is ${err.code}, message is ${err.message}`); |
| 25 | } else { | 25 | } else { |
| 26 | - this.cacheSice = bundleStats.appSize / 1024.00 / 1024.00; | 26 | + this.cacheSice = bundleStats.cacheSize / 1024.00 / 1024.00; |
| 27 | } | 27 | } |
| 28 | }); | 28 | }); |
| 29 | } | 29 | } |
| @@ -68,13 +68,13 @@ export struct MineSettingComponent { | @@ -68,13 +68,13 @@ export struct MineSettingComponent { | ||
| 68 | // pageType:'AccountAndSecurityLayout' | 68 | // pageType:'AccountAndSecurityLayout' |
| 69 | // }; | 69 | // }; |
| 70 | console.log(subIndex + "") | 70 | console.log(subIndex + "") |
| 71 | - if (subIndex == 0) { | 71 | + if (subIndex == 0 && index == 0) { |
| 72 | 72 | ||
| 73 | let params: Params = { | 73 | let params: Params = { |
| 74 | pageID: 'AccountAndSecurityLayout' | 74 | pageID: 'AccountAndSecurityLayout' |
| 75 | } | 75 | } |
| 76 | WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params) | 76 | WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params) |
| 77 | - }else if (subIndex == 2) { | 77 | + }else if (subIndex == 2 && index == 0) { |
| 78 | WDRouterRule.jumpWithPage(WDRouterPage.privacySettingPage) | 78 | WDRouterRule.jumpWithPage(WDRouterPage.privacySettingPage) |
| 79 | } | 79 | } |
| 80 | 80 | ||
| @@ -157,11 +157,11 @@ export struct MineSettingComponent { | @@ -157,11 +157,11 @@ export struct MineSettingComponent { | ||
| 157 | // 左侧logo和标题 | 157 | // 左侧logo和标题 |
| 158 | Row() { | 158 | Row() { |
| 159 | // 判断有没有图片 | 159 | // 判断有没有图片 |
| 160 | - if (this.privacySwitch) { | ||
| 161 | - Image('https://pic.rmb.bdstatic.com/e182cf67c341d1128d2a6cc05886bf62.jpeg@s_0,h_2000') | ||
| 162 | - .height('38lpx') | ||
| 163 | - .margin({ right: '5lpx' }) | ||
| 164 | - } | 160 | + // if (this.privacySwitch) { |
| 161 | + // Image('https://pic.rmb.bdstatic.com/e182cf67c341d1128d2a6cc05886bf62.jpeg@s_0,h_2000') | ||
| 162 | + // .height('38lpx') | ||
| 163 | + // .margin({ right: '5lpx' }) | ||
| 164 | + // } | ||
| 165 | Text(`${item}`) | 165 | Text(`${item}`) |
| 166 | .margin({ top: '8lpx' }) | 166 | .margin({ top: '8lpx' }) |
| 167 | .height('38lpx') | 167 | .height('38lpx') |
| @@ -24,7 +24,8 @@ export struct PrivacySettingComponents { | @@ -24,7 +24,8 @@ export struct PrivacySettingComponents { | ||
| 24 | async getPermissionStatus() { | 24 | async getPermissionStatus() { |
| 25 | const permissionUtil = new PermissionUtil(); | 25 | const permissionUtil = new PermissionUtil(); |
| 26 | for (const element of this.listData) { | 26 | for (const element of this.listData) { |
| 27 | - if (element.privacyName = '开启个性推荐') { | 27 | + if (element.privacyName == '开启个性推荐') { |
| 28 | + element.queryUserDetail(); | ||
| 28 | continue; | 29 | continue; |
| 29 | } | 30 | } |
| 30 | const result = await permissionUtil.checkPermissions(element.permissionKey); | 31 | const result = await permissionUtil.checkPermissions(element.permissionKey); |
| @@ -58,7 +59,7 @@ export struct PrivacySettingComponents { | @@ -58,7 +59,7 @@ export struct PrivacySettingComponents { | ||
| 58 | if (!item.permission) { | 59 | if (!item.permission) { |
| 59 | //跳转权限设置 | 60 | //跳转权限设置 |
| 60 | const permissionUtil = new PermissionUtil(); | 61 | const permissionUtil = new PermissionUtil(); |
| 61 | - PermissionUtil.reqPermissionsFromUser([item.permissionKey]); | 62 | + PermissionUtil.reqPermissionsFromUser([item.permissionKey], this); |
| 62 | } | 63 | } |
| 63 | } | 64 | } |
| 64 | }) | 65 | }) |
| 1 | import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; | 1 | import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; |
| 2 | +import HashMap from '@ohos.util.HashMap'; | ||
| 3 | +import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; | ||
| 4 | +import { Logger } from 'wdKit'; | ||
| 5 | +import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | ||
| 6 | + | ||
| 7 | + | ||
| 2 | @Observed | 8 | @Observed |
| 3 | export class PrivacySettingModel{ | 9 | export class PrivacySettingModel{ |
| 4 | privacyName: string | 10 | privacyName: string |
| @@ -10,4 +16,59 @@ export class PrivacySettingModel{ | @@ -10,4 +16,59 @@ export class PrivacySettingModel{ | ||
| 10 | this.permission = permission; | 16 | this.permission = permission; |
| 11 | this.permissionKey = permissionKey; | 17 | this.permissionKey = permissionKey; |
| 12 | } | 18 | } |
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + queryUserDetail() { | ||
| 23 | + let bean: Record<string, string> = {}; | ||
| 24 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 25 | + return new Promise<string>((success, fail) => { | ||
| 26 | + HttpRequest.get<ResponseDTO<string>>(HttpUrlUtils.queryUserDetail(), headers).then((data: ResponseDTO<string>) => { | ||
| 27 | + if (!data || !data.data) { | ||
| 28 | + fail("数据为空") | ||
| 29 | + return | ||
| 30 | + } | ||
| 31 | + if (data.code != 0) { | ||
| 32 | + fail(data.message) | ||
| 33 | + return | ||
| 34 | + } | ||
| 35 | + // this.permission = data.data.userExtend.airec as boolean; | ||
| 36 | + success(data.data) | ||
| 37 | + }, (error: Error) => { | ||
| 38 | + fail(error.message) | ||
| 39 | + Logger.debug("LoginViewModel:error ", error.toString()) | ||
| 40 | + }) | ||
| 41 | + }) | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + editUserDetail(airec:string) { | ||
| 46 | + let bean: Record<string, string> = {}; | ||
| 47 | + bean['airec'] = airec; | ||
| 48 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 49 | + return new Promise<string>((success, fail) => { | ||
| 50 | + HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.editUserDetail(), bean, headers).then((data: ResponseDTO<string>) => { | ||
| 51 | + if (!data || !data.data) { | ||
| 52 | + fail("数据为空") | ||
| 53 | + return | ||
| 54 | + } | ||
| 55 | + if (data.code != 0) { | ||
| 56 | + fail(data.message) | ||
| 57 | + return | ||
| 58 | + } | ||
| 59 | + success(data.data) | ||
| 60 | + }, (error: Error) => { | ||
| 61 | + fail(error.message) | ||
| 62 | + Logger.debug("LoginViewModel:error ", error.toString()) | ||
| 63 | + }) | ||
| 64 | + }) | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + | ||
| 71 | + | ||
| 72 | + | ||
| 73 | + | ||
| 13 | } | 74 | } |
| @@ -3,6 +3,10 @@ import { LoginInputComponent } from './LoginInputComponent' | @@ -3,6 +3,10 @@ import { LoginInputComponent } from './LoginInputComponent' | ||
| 3 | import { LoginViewModel } from './LoginViewModel' | 3 | import { LoginViewModel } from './LoginViewModel' |
| 4 | import router from '@ohos.router' | 4 | import router from '@ohos.router' |
| 5 | import promptAction from '@ohos.promptAction' | 5 | import promptAction from '@ohos.promptAction' |
| 6 | +import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/Index' | ||
| 7 | +import { WDRouterRule, WDRouterPage } from 'wdRouter'; | ||
| 8 | +import { SettingPasswordParams } from './SettingPasswordLayout' | ||
| 9 | + | ||
| 6 | 10 | ||
| 7 | const TAG = 'ForgetPasswordPage' | 11 | const TAG = 'ForgetPasswordPage' |
| 8 | /** | 12 | /** |
| @@ -85,7 +89,13 @@ struct ForgetPasswordPage { | @@ -85,7 +89,13 @@ struct ForgetPasswordPage { | ||
| 85 | } | 89 | } |
| 86 | 90 | ||
| 87 | this.loginViewModel.checkVerifyCode(this.phoneContent, this.codeContent).then(() => { | 91 | this.loginViewModel.checkVerifyCode(this.phoneContent, this.codeContent).then(() => { |
| 88 | - //todo 跳转密码设置页面 | 92 | + let params: SettingPasswordParams = { |
| 93 | + pageID:'1', | ||
| 94 | + phoneContent:this.phoneContent, | ||
| 95 | + codeContent:this.codeContent, | ||
| 96 | + } | ||
| 97 | + WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params) | ||
| 98 | + | ||
| 89 | promptAction.showToast({message:"校验成功,准备跳转设置页面"}) | 99 | promptAction.showToast({message:"校验成功,准备跳转设置页面"}) |
| 90 | Logger.debug(TAG,"校验成功") | 100 | Logger.debug(TAG,"校验成功") |
| 91 | }).catch((error:string)=>{ | 101 | }).catch((error:string)=>{ |
| @@ -112,5 +112,30 @@ export class LoginModel { | @@ -112,5 +112,30 @@ export class LoginModel { | ||
| 112 | }) | 112 | }) |
| 113 | }) | 113 | }) |
| 114 | } | 114 | } |
| 115 | + | ||
| 116 | + //忘记密码 设置新密码 | ||
| 117 | + resetPassword(password: string, tempToken: string) { | ||
| 118 | + let bean: Record<string, string> = {}; | ||
| 119 | + bean['password'] = password; | ||
| 120 | + bean['tempToken'] = tempToken; | ||
| 121 | + | ||
| 122 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 123 | + return new Promise<string>((success, fail) => { | ||
| 124 | + HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<string>) => { | ||
| 125 | + if (!data || !data.data) { | ||
| 126 | + fail("数据为空") | ||
| 127 | + return | ||
| 128 | + } | ||
| 129 | + if (data.code != 0) { | ||
| 130 | + fail(data.message) | ||
| 131 | + return | ||
| 132 | + } | ||
| 133 | + success(data.data) | ||
| 134 | + }, (error: Error) => { | ||
| 135 | + fail(error.message) | ||
| 136 | + Logger.debug("LoginViewModel:error ", error.toString()) | ||
| 137 | + }) | ||
| 138 | + }) | ||
| 139 | + } | ||
| 115 | } | 140 | } |
| 116 | 141 |
| @@ -92,6 +92,20 @@ export class LoginViewModel { | @@ -92,6 +92,20 @@ export class LoginViewModel { | ||
| 92 | }) | 92 | }) |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | + //重置密码 | ||
| 96 | + resetPassword(password: string, tempToken: string) { | ||
| 97 | + return new Promise<string>(async (success, fail) => { | ||
| 98 | + let passwordNew = await this.doMd(password) | ||
| 99 | + this.loginModel.resetPassword(passwordNew, tempToken).then((data) => { | ||
| 100 | + success(data) | ||
| 101 | + }).catch((message: string) => { | ||
| 102 | + fail(message) | ||
| 103 | + }) | ||
| 104 | + }) | ||
| 105 | + | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + | ||
| 95 | 109 | ||
| 96 | async doMd(content: string): Promise<string> { | 110 | async doMd(content: string): Promise<string> { |
| 97 | let mdAlgName = 'SHA256'; // 摘要算法名 | 111 | let mdAlgName = 'SHA256'; // 摘要算法名 |
| 1 | import ArrayList from '@ohos.util.ArrayList'; | 1 | import ArrayList from '@ohos.util.ArrayList'; |
| 2 | import promptAction from '@ohos.promptAction'; | 2 | import promptAction from '@ohos.promptAction'; |
| 3 | +import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/Index'; | ||
| 4 | +import router from '@ohos.router'; | ||
| 5 | +import { LoginViewModel } from './LoginViewModel'; | ||
| 6 | +import { Logger, SPHelper } from 'wdKit'; | ||
| 7 | +import { | ||
| 8 | + SpConstants | ||
| 9 | +} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants' | ||
| 10 | +import data_preferences from '@ohos.data.preferences'; | ||
| 11 | +const TAG = "SettingPasswordLayout" | ||
| 12 | + | ||
| 13 | +export interface SettingPasswordParams { | ||
| 14 | + pageID: string; | ||
| 15 | + phoneContent?: string; | ||
| 16 | + codeContent?: string; | ||
| 17 | + tempToken?:string; | ||
| 18 | +} | ||
| 3 | 19 | ||
| 4 | export default class AccoutPageDataModel { | 20 | export default class AccoutPageDataModel { |
| 5 | // 页面数据 | 21 | // 页面数据 |
| 6 | compType: number // 0:标题 / 1:密码输入框 / 2:验证码输入框 / 3:desc描述 / 4:按钮 / 5:logo / 6:子标题 7:手机号输入框 7:空白 | 22 | compType: number // 0:标题 / 1:密码输入框 / 2:验证码输入框 / 3:desc描述 / 4:按钮 / 5:logo / 6:子标题 7:手机号输入框 7:空白 |
| 7 | compLogo: string | 23 | compLogo: string |
| 8 | compTitle: string | 24 | compTitle: string |
| 9 | - // compSubTitle: string | 25 | + compSubTitle: string = ''; |
| 10 | compDesc: string | 26 | compDesc: string |
| 11 | compButtonTitle: string | 27 | compButtonTitle: string |
| 12 | inputPlacholder: string | 28 | inputPlacholder: string |
| @@ -23,16 +39,28 @@ export default class AccoutPageDataModel { | @@ -23,16 +39,28 @@ export default class AccoutPageDataModel { | ||
| 23 | } | 39 | } |
| 24 | } | 40 | } |
| 25 | 41 | ||
| 42 | +@Entry | ||
| 26 | @Component | 43 | @Component |
| 27 | export struct SettingPasswordLayout { | 44 | export struct SettingPasswordLayout { |
| 28 | @State listData: Array<AccoutPageDataModel> = new Array(); // 页面配置数据 | 45 | @State listData: Array<AccoutPageDataModel> = new Array(); // 页面配置数据 |
| 29 | - @State btnStatus: boolean = false | 46 | + @State btnStatus: boolean = false; |
| 47 | + pageId:number = 0; | ||
| 48 | + phoneContent:string = ''; | ||
| 49 | + codeContent:string = ''; | ||
| 50 | + tempToken:string = ''; | ||
| 51 | + | ||
| 30 | password01: string = ''; | 52 | password01: string = ''; |
| 31 | password02: string = ''; | 53 | password02: string = ''; |
| 32 | passwordOri: string = ''; | 54 | passwordOri: string = ''; |
| 55 | + loginViewModel = new LoginViewModel() | ||
| 33 | 56 | ||
| 34 | aboutToAppear() { | 57 | aboutToAppear() { |
| 35 | - this.getPageListData(4) | 58 | + let params:SettingPasswordParams = router.getParams() as SettingPasswordParams; |
| 59 | + this.pageId = parseInt(params.pageID); | ||
| 60 | + this.getPageListData(this.pageId) | ||
| 61 | + | ||
| 62 | + this.phoneContent = params.phoneContent!; | ||
| 63 | + this.codeContent = params.codeContent!; | ||
| 36 | } | 64 | } |
| 37 | 65 | ||
| 38 | getPageListData(pageId:number) { | 66 | getPageListData(pageId:number) { |
| @@ -50,8 +78,8 @@ export struct SettingPasswordLayout { | @@ -50,8 +78,8 @@ export struct SettingPasswordLayout { | ||
| 50 | this.listData.push(new AccoutPageDataModel(0, '设置密码', '', '', '', '', 0)) | 78 | this.listData.push(new AccoutPageDataModel(0, '设置密码', '', '', '', '', 0)) |
| 51 | this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入密码', 10086)) | 79 | this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入密码', 10086)) |
| 52 | this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '再次输入密码', 10087)) | 80 | this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '再次输入密码', 10087)) |
| 53 | - this.listData.push(new AccoutPageDataModel(4, '', '', '提示:密码长度6-20位,需答谢字母、小写字母、数字、特殊字符中组合三种及三种以上组成', '', '', 0)) | ||
| 54 | - this.listData.push(new AccoutPageDataModel(5, '', '', '', '确认', '', 0)) | 81 | + this.listData.push(new AccoutPageDataModel(3, '', '', '提示:密码长度6-20位,需答谢字母、小写字母、数字、特殊字符中组合三种及三种以上组成', '', '', 0)) |
| 82 | + this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0)) | ||
| 55 | break; | 83 | break; |
| 56 | 84 | ||
| 57 | case 2: | 85 | case 2: |
| @@ -75,7 +103,7 @@ export struct SettingPasswordLayout { | @@ -75,7 +103,7 @@ export struct SettingPasswordLayout { | ||
| 75 | 103 | ||
| 76 | case 4: | 104 | case 4: |
| 77 | // 有logo的 | 105 | // 有logo的 |
| 78 | - this.listData.push(new AccoutPageDataModel(5, '', 'https://img-blog.csdnimg.cn/24f43f4d626d428891ebb2adb5c2c2e9.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5YyX5aSn5Z-55paH5byg6ICB5biI,size_20,color_FFFFFF,t_70,g_se,x_16', '', '', '' , 0)) | 106 | + this.listData.push(new AccoutPageDataModel(5, '', '', '', '', '' , 0)) |
| 79 | this.listData.push(new AccoutPageDataModel(0, '修改密码', '', '', '', '', 0)) | 107 | this.listData.push(new AccoutPageDataModel(0, '修改密码', '', '', '', '', 0)) |
| 80 | this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入原密码', 10010)) | 108 | this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入原密码', 10010)) |
| 81 | this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入新密码', 10086)) | 109 | this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入新密码', 10086)) |
| @@ -277,8 +305,21 @@ export struct SettingPasswordLayout { | @@ -277,8 +305,21 @@ export struct SettingPasswordLayout { | ||
| 277 | return | 305 | return |
| 278 | } | 306 | } |
| 279 | 307 | ||
| 308 | + | ||
| 280 | promptAction.showToast({ message: '请求接口' }) | 309 | promptAction.showToast({ message: '请求接口' }) |
| 281 | } | 310 | } |
| 311 | + | ||
| 312 | + if(this.pageId == 1){ //设置密码 | ||
| 313 | + if (this.password01.length < 6 || this.password01.length > 20) { | ||
| 314 | + promptAction.showToast({ message: '密码不符合密码规范' }) | ||
| 315 | + return | ||
| 316 | + } | ||
| 317 | + if (this.password01 != this.password02) { | ||
| 318 | + promptAction.showToast({ message: '密码不一致' }) | ||
| 319 | + return | ||
| 320 | + } | ||
| 321 | + | ||
| 322 | + } | ||
| 282 | } | 323 | } |
| 283 | 324 | ||
| 284 | // 输入框数据变动:输入数据处理 | 325 | // 输入框数据变动:输入数据处理 |
| @@ -292,11 +333,21 @@ export struct SettingPasswordLayout { | @@ -292,11 +333,21 @@ export struct SettingPasswordLayout { | ||
| 292 | } | 333 | } |
| 293 | 334 | ||
| 294 | if (this.password01) { | 335 | if (this.password01) { |
| 295 | - if (this.password01 == this.password02 && this.password01.length >= 6 && this.password01.length <= 20) { | 336 | + if ((this.password01.length >= 6 && this.password01.length <= 20) && (this.password02.length >= 6 && this.password02.length <= 20)) { |
| 296 | this.btnStatus = true; | 337 | this.btnStatus = true; |
| 297 | } else { | 338 | } else { |
| 298 | this.btnStatus = false; | 339 | this.btnStatus = false; |
| 299 | } | 340 | } |
| 341 | + | ||
| 342 | + SPHelper.default.get(SpConstants.USER_JWT_TOKEN, '').then((str) => { | ||
| 343 | + this.loginViewModel.resetPassword(this.password01, str.toString()).then((data =>{ | ||
| 344 | + | ||
| 345 | + })) | ||
| 346 | + }).catch((err: Error) => { | ||
| 347 | + Logger.error(TAG, 'catch err:' + JSON.stringify(err)); | ||
| 348 | + }); | ||
| 349 | + | ||
| 300 | } | 350 | } |
| 301 | } | 351 | } |
| 302 | } | 352 | } |
| 353 | + |
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | "pages/login/LoginPage", | 4 | "pages/login/LoginPage", |
| 5 | "pages/login/ForgetPasswordPage", | 5 | "pages/login/ForgetPasswordPage", |
| 6 | "pages/login/LoginProtocolWebview", | 6 | "pages/login/LoginProtocolWebview", |
| 7 | - "pages/login/SettingPasswordPage" | 7 | + "pages/login/SettingPasswordPage", |
| 8 | + "pages/login/SettingPasswordLayout" | ||
| 8 | ] | 9 | ] |
| 9 | } | 10 | } |
-
Please register or login to post a comment