Showing
11 changed files
with
277 additions
and
36 deletions
| @@ -270,8 +270,19 @@ export class HttpUrlUtils { | @@ -270,8 +270,19 @@ export class HttpUrlUtils { | ||
| 270 | return url; | 270 | return url; |
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | + static getVerifyCodeByTokenUrl() { | ||
| 274 | + let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/sendVerifyCodeByToken"; | ||
| 275 | + return url; | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + | ||
| 273 | static getForgetPasswordUrl() { | 279 | static getForgetPasswordUrl() { |
| 274 | - let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/forgotPassword"; | 280 | + let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/user/zh/c/forgotPassword"; |
| 281 | + return url; | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + static getResetPassworddUrl() { | ||
| 285 | + let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/user/zh/c/resetPassword"; | ||
| 275 | return url; | 286 | return url; |
| 276 | } | 287 | } |
| 277 | 288 | ||
| @@ -295,6 +306,11 @@ export class HttpUrlUtils { | @@ -295,6 +306,11 @@ export class HttpUrlUtils { | ||
| 295 | return url; | 306 | return url; |
| 296 | } | 307 | } |
| 297 | 308 | ||
| 309 | + static getCheckVerifyByTokenCodeUrl() { | ||
| 310 | + let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/checkVerifyCodeByToken"; | ||
| 311 | + return url; | ||
| 312 | + } | ||
| 313 | + | ||
| 298 | static getAppointmentListDataUrl() { | 314 | static getAppointmentListDataUrl() { |
| 299 | let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH | 315 | let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH |
| 300 | return url | 316 | return url |
| @@ -59,13 +59,12 @@ export struct AccountAndSecurityLayout { | @@ -59,13 +59,12 @@ export struct AccountAndSecurityLayout { | ||
| 59 | .onClick(() => { | 59 | .onClick(() => { |
| 60 | console.log(index + "") | 60 | console.log(index + "") |
| 61 | if (index == 0){ | 61 | if (index == 0){ |
| 62 | - | 62 | + let pageType = {'pageType': 2} as Record<string, number>; |
| 63 | + WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType) | ||
| 63 | }else if (index == 1) { | 64 | }else if (index == 1) { |
| 64 | 65 | ||
| 65 | - let params: SettingPasswordParams = { | ||
| 66 | - pageID:'1', | ||
| 67 | - } | ||
| 68 | - WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params) | 66 | + let pageType = {'pageType': 1} as Record<string, number>; |
| 67 | + WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType) | ||
| 69 | } | 68 | } |
| 70 | }) | 69 | }) |
| 71 | 70 | ||
| @@ -83,7 +82,7 @@ export struct AccountAndSecurityLayout { | @@ -83,7 +82,7 @@ export struct AccountAndSecurityLayout { | ||
| 83 | }.height("100%") | 82 | }.height("100%") |
| 84 | 83 | ||
| 85 | Column() { | 84 | Column() { |
| 86 | - Button('退出登录',{ stateEffect: true }).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').onClick(()=>{ | 85 | + Button('退出登录',{ stateEffect: true ,type: ButtonType.Normal}).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').borderRadius('8lpx').onClick(()=>{ |
| 87 | AlertDialog.show({ | 86 | AlertDialog.show({ |
| 88 | title: '🥟id : ' + "button", | 87 | title: '🥟id : ' + "button", |
| 89 | message: '标题:' + '退出登录', | 88 | message: '标题:' + '退出登录', |
16.3 KB
| @@ -6,6 +6,7 @@ import promptAction from '@ohos.promptAction' | @@ -6,6 +6,7 @@ import promptAction from '@ohos.promptAction' | ||
| 6 | import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/Index' | 6 | import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/Index' |
| 7 | import { WDRouterRule, WDRouterPage } from 'wdRouter'; | 7 | import { WDRouterRule, WDRouterPage } from 'wdRouter'; |
| 8 | import { SettingPasswordParams } from './SettingPasswordLayout' | 8 | import { SettingPasswordParams } from './SettingPasswordLayout' |
| 9 | +import { Router } from '@ohos.arkui.UIContext' | ||
| 9 | 10 | ||
| 10 | 11 | ||
| 11 | const TAG = 'ForgetPasswordPage' | 12 | const TAG = 'ForgetPasswordPage' |
| @@ -20,23 +21,30 @@ struct ForgetPasswordPage { | @@ -20,23 +21,30 @@ struct ForgetPasswordPage { | ||
| 20 | @State isSubmit: boolean = false //是否可以提交 默认不可以 | 21 | @State isSubmit: boolean = false //是否可以提交 默认不可以 |
| 21 | loginViewModel: LoginViewModel = new LoginViewModel() | 22 | loginViewModel: LoginViewModel = new LoginViewModel() |
| 22 | @State @Watch('onCodeSend') isCodeSend: boolean = false //验证码点击发送事件 | 23 | @State @Watch('onCodeSend') isCodeSend: boolean = false //验证码点击发送事件 |
| 24 | + pageType:number = (router.getParams() as Record<string, number>)['pageType']; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2 | ||
| 25 | + pageTitle = '找回密码'; | ||
| 23 | onCodeSend() { | 26 | onCodeSend() { |
| 24 | if (this.isCodeSend) { | 27 | if (this.isCodeSend) { |
| 25 | this.sendVerifyCode() | 28 | this.sendVerifyCode() |
| 26 | } | 29 | } |
| 27 | } | 30 | } |
| 28 | 31 | ||
| 32 | + | ||
| 33 | + | ||
| 29 | build() { | 34 | build() { |
| 30 | Column() { | 35 | Column() { |
| 31 | Image($r('app.media.login_back_icon')).width(24).height(24).margin({ left: 15, top: 10 }).onClick(() => { | 36 | Image($r('app.media.login_back_icon')).width(24).height(24).margin({ left: 15, top: 10 }).onClick(() => { |
| 32 | router.back() | 37 | router.back() |
| 33 | }) | 38 | }) |
| 34 | - Text('找回密码').fontSize(22).fontColor('#333333').fontWeight(FontWeight.Bold).margin({ left: 25, top: 112 }) | 39 | + |
| 40 | + | ||
| 41 | + Text(this.pageTitle).fontSize(22).fontColor('#333333').fontWeight(FontWeight.Bold).margin({ left: 25, top: 112 }) | ||
| 35 | LoginInputComponent({ | 42 | LoginInputComponent({ |
| 36 | phoneContent: $phoneContent, | 43 | phoneContent: $phoneContent, |
| 37 | codeContent: $codeContent, | 44 | codeContent: $codeContent, |
| 38 | isSubmit: $isSubmit, | 45 | isSubmit: $isSubmit, |
| 39 | - isCodeSend: $isCodeSend | 46 | + isCodeSend: $isCodeSend, |
| 47 | + pageType:this.pageType | ||
| 40 | }) | 48 | }) |
| 41 | Row() { | 49 | Row() { |
| 42 | Text("确认") | 50 | Text("确认") |
| @@ -60,6 +68,15 @@ struct ForgetPasswordPage { | @@ -60,6 +68,15 @@ struct ForgetPasswordPage { | ||
| 60 | } | 68 | } |
| 61 | 69 | ||
| 62 | aboutToAppear() { | 70 | aboutToAppear() { |
| 71 | + if (this.pageType == 0){ | ||
| 72 | + this.pageTitle = '找回密码' | ||
| 73 | + }else if (this.pageType == 1){ | ||
| 74 | + this.pageTitle = '验证当前手机号' | ||
| 75 | + }else if (this.pageType == 2){ | ||
| 76 | + this.pageTitle = '验证当前手机号' | ||
| 77 | + }else if (this.pageType == 2){ | ||
| 78 | + this.pageTitle = '更换手机号' | ||
| 79 | + } | ||
| 63 | if (this.isCodeSend) { | 80 | if (this.isCodeSend) { |
| 64 | this.sendVerifyCode() | 81 | this.sendVerifyCode() |
| 65 | } | 82 | } |
| @@ -95,6 +112,7 @@ struct ForgetPasswordPage { | @@ -95,6 +112,7 @@ struct ForgetPasswordPage { | ||
| 95 | pageID:'1', | 112 | pageID:'1', |
| 96 | phoneContent:this.phoneContent, | 113 | phoneContent:this.phoneContent, |
| 97 | codeContent:this.codeContent, | 114 | codeContent:this.codeContent, |
| 115 | + pageType:this.pageType | ||
| 98 | } | 116 | } |
| 99 | WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params) | 117 | WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params) |
| 100 | 118 |
| @@ -9,15 +9,40 @@ export struct LoginInputComponent { | @@ -9,15 +9,40 @@ export struct LoginInputComponent { | ||
| 9 | @Link isCodeSend: boolean //验证码控件是否点击 默认没有 发送接口 | 9 | @Link isCodeSend: boolean //验证码控件是否点击 默认没有 发送接口 |
| 10 | @Link isSubmit: boolean //是否可以提交 | 10 | @Link isSubmit: boolean //是否可以提交 |
| 11 | isFirst:boolean=true//是否第一次获取验证码 | 11 | isFirst:boolean=true//是否第一次获取验证码 |
| 12 | - | 12 | + pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2 |
| 13 | build() { | 13 | build() { |
| 14 | Column() { | 14 | Column() { |
| 15 | this.addCodeLayout() | 15 | this.addCodeLayout() |
| 16 | }.width('100%').padding({ left: 25, right: 25 }) | 16 | }.width('100%').padding({ left: 25, right: 25 }) |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | + aboutToAppear(){ | ||
| 20 | + if (this.pageType == 1) { | ||
| 21 | + this.phoneContent = '18655957611'; | ||
| 22 | + } | ||
| 23 | + } | ||
| 19 | @Builder | 24 | @Builder |
| 20 | addCodeLayout() { | 25 | addCodeLayout() { |
| 26 | + if (this.pageType == 1){ | ||
| 27 | + TextInput({ placeholder: this.securityPhone('18655957611') }) | ||
| 28 | + .fontSize(16) | ||
| 29 | + .height(48) | ||
| 30 | + .maxLength(11) | ||
| 31 | + .margin({ top: 36 }) | ||
| 32 | + .backgroundColor("#F5F5F5") | ||
| 33 | + .borderRadius(4) | ||
| 34 | + .enabled(false) | ||
| 35 | + .type(InputType.PhoneNumber) | ||
| 36 | + .onChange((content) => { | ||
| 37 | + this.phoneContent = content | ||
| 38 | + this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6) | ||
| 39 | + if (content.length >= 11) { | ||
| 40 | + this.codeBtnState = true | ||
| 41 | + } else { | ||
| 42 | + this.codeBtnState = false | ||
| 43 | + } | ||
| 44 | + }) | ||
| 45 | + }else{ | ||
| 21 | TextInput({ placeholder: "请输入手机号" }) | 46 | TextInput({ placeholder: "请输入手机号" }) |
| 22 | .fontSize(16) | 47 | .fontSize(16) |
| 23 | .height(48) | 48 | .height(48) |
| @@ -35,6 +60,8 @@ export struct LoginInputComponent { | @@ -35,6 +60,8 @@ export struct LoginInputComponent { | ||
| 35 | this.codeBtnState = false | 60 | this.codeBtnState = false |
| 36 | } | 61 | } |
| 37 | }) | 62 | }) |
| 63 | + } | ||
| 64 | + | ||
| 38 | 65 | ||
| 39 | Row() { | 66 | Row() { |
| 40 | TextInput({ placeholder: "验证码" }) | 67 | TextInput({ placeholder: "验证码" }) |
| @@ -86,4 +113,11 @@ export struct LoginInputComponent { | @@ -86,4 +113,11 @@ export struct LoginInputComponent { | ||
| 86 | .backgroundImageSize({width:'100%',height:48}) | 113 | .backgroundImageSize({width:'100%',height:48}) |
| 87 | 114 | ||
| 88 | } | 115 | } |
| 116 | + | ||
| 117 | + securityPhone(phoneNum:string):string{ | ||
| 118 | + let securityNum:string; | ||
| 119 | + let needSecurityString = phoneNum.substring(3, phoneNum.length - 4); | ||
| 120 | + securityNum = phoneNum.replace(needSecurityString,'****') | ||
| 121 | + return securityNum; | ||
| 122 | + } | ||
| 89 | } | 123 | } |
| 1 | import HashMap from '@ohos.util.HashMap'; | 1 | import HashMap from '@ohos.util.HashMap'; |
| 2 | import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; | 2 | import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; |
| 3 | -import { Logger } from 'wdKit'; | 3 | +import { Logger, SPHelper } from 'wdKit'; |
| 4 | import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | 4 | import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; |
| 5 | import { LoginBean } from './LoginBean'; | 5 | import { LoginBean } from './LoginBean'; |
| 6 | import { CheckVerifyBean } from './CheckVerifyBean'; | 6 | import { CheckVerifyBean } from './CheckVerifyBean'; |
| 7 | +import { | ||
| 8 | + SpConstants | ||
| 9 | +} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants' | ||
| 10 | + | ||
| 7 | 11 | ||
| 8 | const TAG = 'LoginModel' | 12 | const TAG = 'LoginModel' |
| 9 | 13 | ||
| @@ -32,6 +36,29 @@ export class LoginModel { | @@ -32,6 +36,29 @@ export class LoginModel { | ||
| 32 | 36 | ||
| 33 | } | 37 | } |
| 34 | 38 | ||
| 39 | + sendVerifyCodeByToken() { | ||
| 40 | + let bean: Record<string, string> = {}; | ||
| 41 | + // bean['phoneNum'] = number | ||
| 42 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 43 | + return new Promise<string>((success, fail) => { | ||
| 44 | + HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getVerifyCodeByTokenUrl(), bean, headers).then((data: ResponseDTO<string>) => { | ||
| 45 | + if (!data || !data.data) { | ||
| 46 | + fail("数据为空") | ||
| 47 | + return | ||
| 48 | + } | ||
| 49 | + if (data.code != 0) { | ||
| 50 | + fail(data.message) | ||
| 51 | + return | ||
| 52 | + } | ||
| 53 | + success(data.data) | ||
| 54 | + }, (error: Error) => { | ||
| 55 | + fail(error.message) | ||
| 56 | + Logger.debug("LoginViewModel:error ", error.toString()) | ||
| 57 | + }) | ||
| 58 | + }) | ||
| 59 | + | ||
| 60 | + } | ||
| 61 | + | ||
| 35 | 62 | ||
| 36 | //{"phone":"13625644528","loginType":2,"deviceId":"60da5af6-9c59-3566-8622-8c6c00710994","verificationCode":"644528"} | 63 | //{"phone":"13625644528","loginType":2,"deviceId":"60da5af6-9c59-3566-8622-8c6c00710994","verificationCode":"644528"} |
| 37 | appLogin(phone: string, loginType: number, verificationCode: string) { | 64 | appLogin(phone: string, loginType: number, verificationCode: string) { |
| @@ -113,13 +140,68 @@ export class LoginModel { | @@ -113,13 +140,68 @@ export class LoginModel { | ||
| 113 | }) | 140 | }) |
| 114 | } | 141 | } |
| 115 | 142 | ||
| 116 | - //忘记密码 设置新密码 | 143 | + checkVerifyCodeByToken(verifyCode: string) { |
| 144 | + let bean: Record<string, Object> = {}; | ||
| 145 | + bean['verifyCode'] = verifyCode | ||
| 146 | + // bean['phone'] = phone | ||
| 147 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 148 | + return new Promise<CheckVerifyBean>((success, fail) => { | ||
| 149 | + HttpRequest.post<ResponseDTO<CheckVerifyBean>>(HttpUrlUtils.getCheckVerifyByTokenCodeUrl(), bean, headers).then((data: ResponseDTO<CheckVerifyBean>) => { | ||
| 150 | + Logger.debug("LoginViewModel:success2 ", data.message) | ||
| 151 | + if (!data || !data.data) { | ||
| 152 | + fail("数据为空") | ||
| 153 | + return | ||
| 154 | + } | ||
| 155 | + if (data.code != 0) { | ||
| 156 | + fail(data.message) | ||
| 157 | + return | ||
| 158 | + } | ||
| 159 | + success(data.data) | ||
| 160 | + }, (error: Error) => { | ||
| 161 | + Logger.debug("LoginViewModel:error2 ", error.toString()) | ||
| 162 | + fail(error.message) | ||
| 163 | + }) | ||
| 164 | + }) | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + //修改密码 //需要老密码 | ||
| 117 | resetPassword(password: string, tempToken: string) { | 168 | resetPassword(password: string, tempToken: string) { |
| 118 | let bean: Record<string, string> = {}; | 169 | let bean: Record<string, string> = {}; |
| 170 | + // bean['password'] = password; | ||
| 171 | + // bean['tempToken'] = tempToken; | ||
| 172 | + | ||
| 173 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 174 | + | ||
| 175 | + return new Promise<string>((success, fail) => { | ||
| 176 | + HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<string>) => { | ||
| 177 | + if (!data || !data.data) { | ||
| 178 | + fail("数据为空") | ||
| 179 | + return | ||
| 180 | + } | ||
| 181 | + if (data.code != 0) { | ||
| 182 | + fail(data.message) | ||
| 183 | + return | ||
| 184 | + } | ||
| 185 | + success(data.data) | ||
| 186 | + }, (error: Error) => { | ||
| 187 | + fail(error.message) | ||
| 188 | + Logger.debug("LoginViewModel:error ", error.toString()) | ||
| 189 | + }) | ||
| 190 | + }) | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + | ||
| 194 | + | ||
| 195 | + //忘记密码 //不需要老密码 | ||
| 196 | + forgotPassword(password: string, tempToken: string) { | ||
| 197 | + let bean: Record<string, string> = {}; | ||
| 119 | bean['password'] = password; | 198 | bean['password'] = password; |
| 120 | bean['tempToken'] = tempToken; | 199 | bean['tempToken'] = tempToken; |
| 121 | 200 | ||
| 122 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 201 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 202 | + let JwtToken = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, '') as string; | ||
| 203 | + | ||
| 204 | + headers.set('JwtToken',(JwtToken)); | ||
| 123 | return new Promise<string>((success, fail) => { | 205 | return new Promise<string>((success, fail) => { |
| 124 | HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<string>) => { | 206 | HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<string>) => { |
| 125 | if (!data || !data.data) { | 207 | if (!data || !data.data) { |
| @@ -137,5 +219,6 @@ export class LoginModel { | @@ -137,5 +219,6 @@ export class LoginModel { | ||
| 137 | }) | 219 | }) |
| 138 | }) | 220 | }) |
| 139 | } | 221 | } |
| 222 | + | ||
| 140 | } | 223 | } |
| 141 | 224 |
| @@ -141,7 +141,8 @@ struct LoginPage { | @@ -141,7 +141,8 @@ struct LoginPage { | ||
| 141 | Text('忘记密码').fontColor('#666666').fontSize(14).margin({ top: 16 }) | 141 | Text('忘记密码').fontColor('#666666').fontSize(14).margin({ top: 16 }) |
| 142 | .onClick(() => { | 142 | .onClick(() => { |
| 143 | // router.pushUrl({ url: 'pages/login/ForgetPasswordPage' }) | 143 | // router.pushUrl({ url: 'pages/login/ForgetPasswordPage' }) |
| 144 | - WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage) | 144 | + let pageType = {'pageType': 0} as Record<string, number>; |
| 145 | + WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType) | ||
| 145 | }) | 146 | }) |
| 146 | } | 147 | } |
| 147 | 148 |
| @@ -31,6 +31,17 @@ export class LoginViewModel { | @@ -31,6 +31,17 @@ export class LoginViewModel { | ||
| 31 | 31 | ||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | + sendVerifyCodeByToken() { | ||
| 35 | + return new Promise<string>((success, fail) => { | ||
| 36 | + this.loginModel.sendVerifyCodeByToken().then((data) => { | ||
| 37 | + success(data) | ||
| 38 | + }).catch((message: string) => { | ||
| 39 | + fail(message) | ||
| 40 | + }) | ||
| 41 | + }) | ||
| 42 | + | ||
| 43 | + } | ||
| 44 | + | ||
| 34 | appLogin(phone: string, loginType: number, verificationCode: string) { | 45 | appLogin(phone: string, loginType: number, verificationCode: string) { |
| 35 | 46 | ||
| 36 | return new Promise<LoginBean>((success, fail) => { | 47 | return new Promise<LoginBean>((success, fail) => { |
| @@ -91,8 +102,21 @@ export class LoginViewModel { | @@ -91,8 +102,21 @@ export class LoginViewModel { | ||
| 91 | }) | 102 | }) |
| 92 | }) | 103 | }) |
| 93 | } | 104 | } |
| 105 | + checkVerifyCodeByToken(verifyCode: string) { | ||
| 106 | + return new Promise<CheckVerifyBean>((success, reject) => { | ||
| 107 | + this.loginModel.checkVerifyCodeByToken(verifyCode).then((data: CheckVerifyBean) => { | ||
| 108 | + //todo 保存数据 | ||
| 109 | + SPHelper.default.save(SpConstants.USER_TEMP_TOKEN, data.temToken) | ||
| 110 | + SPHelper.default.save(SpConstants.USER_JWT_TOKEN, data.jwtToken) | ||
| 111 | + success(data) | ||
| 94 | 112 | ||
| 95 | - //重置密码 | 113 | + }, (value: string) => { |
| 114 | + reject(value) | ||
| 115 | + }) | ||
| 116 | + }) | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + //重置密码 需要老密码 | ||
| 96 | resetPassword(password: string, tempToken: string) { | 120 | resetPassword(password: string, tempToken: string) { |
| 97 | return new Promise<string>(async (success, fail) => { | 121 | return new Promise<string>(async (success, fail) => { |
| 98 | let passwordNew = await this.doMd(password) | 122 | let passwordNew = await this.doMd(password) |
| @@ -105,6 +129,18 @@ export class LoginViewModel { | @@ -105,6 +129,18 @@ export class LoginViewModel { | ||
| 105 | 129 | ||
| 106 | } | 130 | } |
| 107 | 131 | ||
| 132 | + //忘记密码 | ||
| 133 | + forgotPassword(password: string, tempToken: string) { | ||
| 134 | + return new Promise<string>(async (success, fail) => { | ||
| 135 | + let passwordNew = await this.doMd(password) | ||
| 136 | + this.loginModel.forgotPassword(passwordNew, tempToken).then((data) => { | ||
| 137 | + success(data) | ||
| 138 | + }).catch((message: string) => { | ||
| 139 | + fail(message) | ||
| 140 | + }) | ||
| 141 | + }) | ||
| 142 | + | ||
| 143 | + } | ||
| 108 | 144 | ||
| 109 | 145 | ||
| 110 | async doMd(content: string): Promise<string> { | 146 | async doMd(content: string): Promise<string> { |
| @@ -8,6 +8,8 @@ import { | @@ -8,6 +8,8 @@ import { | ||
| 8 | SpConstants | 8 | SpConstants |
| 9 | } from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants' | 9 | } from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants' |
| 10 | import data_preferences from '@ohos.data.preferences'; | 10 | import data_preferences from '@ohos.data.preferences'; |
| 11 | +import { WDRouterPage, WDRouterRule } from 'wdRouter'; | ||
| 12 | + | ||
| 11 | const TAG = "SettingPasswordLayout" | 13 | const TAG = "SettingPasswordLayout" |
| 12 | 14 | ||
| 13 | export interface SettingPasswordParams { | 15 | export interface SettingPasswordParams { |
| @@ -15,6 +17,7 @@ export interface SettingPasswordParams { | @@ -15,6 +17,7 @@ export interface SettingPasswordParams { | ||
| 15 | phoneContent?: string; | 17 | phoneContent?: string; |
| 16 | codeContent?: string; | 18 | codeContent?: string; |
| 17 | tempToken?:string; | 19 | tempToken?:string; |
| 20 | + pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2 | ||
| 18 | } | 21 | } |
| 19 | 22 | ||
| 20 | export default class AccoutPageDataModel { | 23 | export default class AccoutPageDataModel { |
| @@ -53,6 +56,7 @@ export struct SettingPasswordLayout { | @@ -53,6 +56,7 @@ export struct SettingPasswordLayout { | ||
| 53 | password02: string = ''; | 56 | password02: string = ''; |
| 54 | passwordOri: string = ''; | 57 | passwordOri: string = ''; |
| 55 | loginViewModel = new LoginViewModel() | 58 | loginViewModel = new LoginViewModel() |
| 59 | + pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机 | ||
| 56 | 60 | ||
| 57 | aboutToAppear() { | 61 | aboutToAppear() { |
| 58 | let params:SettingPasswordParams = router.getParams() as SettingPasswordParams; | 62 | let params:SettingPasswordParams = router.getParams() as SettingPasswordParams; |
| @@ -61,6 +65,7 @@ export struct SettingPasswordLayout { | @@ -61,6 +65,7 @@ export struct SettingPasswordLayout { | ||
| 61 | 65 | ||
| 62 | this.phoneContent = params.phoneContent!; | 66 | this.phoneContent = params.phoneContent!; |
| 63 | this.codeContent = params.codeContent!; | 67 | this.codeContent = params.codeContent!; |
| 68 | + this.pageType = params.pageType; | ||
| 64 | } | 69 | } |
| 65 | 70 | ||
| 66 | getPageListData(pageId:number) { | 71 | getPageListData(pageId:number) { |
| @@ -304,22 +309,30 @@ export struct SettingPasswordLayout { | @@ -304,22 +309,30 @@ export struct SettingPasswordLayout { | ||
| 304 | promptAction.showToast({ message: '密码不符合密码规范' }) | 309 | promptAction.showToast({ message: '密码不符合密码规范' }) |
| 305 | return | 310 | return |
| 306 | } | 311 | } |
| 307 | - | ||
| 308 | - | ||
| 309 | - promptAction.showToast({ message: '请求接口' }) | ||
| 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) { | 312 | if (this.password01 != this.password02) { |
| 318 | promptAction.showToast({ message: '密码不一致' }) | 313 | promptAction.showToast({ message: '密码不一致' }) |
| 319 | return | 314 | return |
| 320 | } | 315 | } |
| 321 | - | 316 | + if(this.pageId == 1){ //设置密码 |
| 317 | + SPHelper.default.get(SpConstants.USER_JWT_TOKEN, '').then((str) => { | ||
| 318 | + this.loginViewModel.forgotPassword(this.password01, str.toString()).then((data =>{ | ||
| 319 | + if (this.pageType == 0) {//登录页 | ||
| 320 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage); | ||
| 321 | + }else if(this.pageType == 1){//设置 | ||
| 322 | + let params: Params = { | ||
| 323 | + pageID: 'AccountAndSecurityLayout' | ||
| 324 | + } | ||
| 325 | + WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params) | ||
| 326 | + } | ||
| 327 | + })) | ||
| 328 | + }).catch((err: Error) => { | ||
| 329 | + Logger.error(TAG, 'catch err:' + JSON.stringify(err)); | ||
| 330 | + }); | ||
| 322 | } | 331 | } |
| 332 | + // promptAction.showToast({ message: '请求接口' }) | ||
| 333 | + } | ||
| 334 | + | ||
| 335 | + | ||
| 323 | } | 336 | } |
| 324 | 337 | ||
| 325 | // 输入框数据变动:输入数据处理 | 338 | // 输入框数据变动:输入数据处理 |
| @@ -338,15 +351,6 @@ export struct SettingPasswordLayout { | @@ -338,15 +351,6 @@ export struct SettingPasswordLayout { | ||
| 338 | } else { | 351 | } else { |
| 339 | this.btnStatus = false; | 352 | this.btnStatus = false; |
| 340 | } | 353 | } |
| 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 | - | ||
| 350 | } | 354 | } |
| 351 | } | 355 | } |
| 352 | } | 356 | } |
| @@ -36,8 +36,58 @@ | @@ -36,8 +36,58 @@ | ||
| 36 | ], | 36 | ], |
| 37 | "requestPermissions": [ | 37 | "requestPermissions": [ |
| 38 | { | 38 | { |
| 39 | + "name": "ohos.permission.CAMERA", | ||
| 40 | + "reason": "$string:EntryAbility_desc", | ||
| 41 | + "usedScene": { | ||
| 42 | + "abilities": [ | ||
| 43 | + "FormAbility" | ||
| 44 | + ], | ||
| 45 | + "when": "inuse" | ||
| 46 | + } | ||
| 47 | + }, | ||
| 48 | + { | ||
| 49 | + "name": "ohos.permission.READ_MEDIA", | ||
| 50 | + "reason": "$string:EntryAbility_desc", | ||
| 51 | + "usedScene": { | ||
| 52 | + "abilities": [ | ||
| 53 | + "FormAbility" | ||
| 54 | + ], | ||
| 55 | + "when": "inuse" | ||
| 56 | + } | ||
| 57 | + }, | ||
| 58 | + { | ||
| 59 | + "name": "ohos.permission.WRITE_MEDIA", | ||
| 60 | + "reason": "$string:EntryAbility_desc", | ||
| 61 | + "usedScene": { | ||
| 62 | + "abilities": [ | ||
| 63 | + "FormAbility" | ||
| 64 | + ], | ||
| 65 | + "when": "inuse" | ||
| 66 | + } | ||
| 67 | + }, | ||
| 68 | + { | ||
| 69 | + "name": "ohos.permission.LOCATION", | ||
| 70 | + "reason": "$string:EntryAbility_desc", | ||
| 71 | + "usedScene": { | ||
| 72 | + "abilities": [ | ||
| 73 | + "FormAbility" | ||
| 74 | + ], | ||
| 75 | + "when": "inuse" | ||
| 76 | + } | ||
| 77 | + }, | ||
| 78 | + { | ||
| 79 | + "name": "ohos.permission.MICROPHONE", | ||
| 80 | + "reason": "$string:EntryAbility_desc", | ||
| 81 | + "usedScene": { | ||
| 82 | + "abilities": [ | ||
| 83 | + "FormAbility" | ||
| 84 | + ], | ||
| 85 | + "when": "inuse" | ||
| 86 | + } | ||
| 87 | + }, | ||
| 88 | + { | ||
| 39 | "name": "ohos.permission.INTERNET" | 89 | "name": "ohos.permission.INTERNET" |
| 40 | } | 90 | } |
| 41 | - ] | 91 | + ], |
| 42 | } | 92 | } |
| 43 | } | 93 | } |
-
Please register or login to post a comment