yangsunyue_wd

desc:隐私设置、忘记密码、关于

... ... @@ -270,8 +270,19 @@ export class HttpUrlUtils {
return url;
}
static getVerifyCodeByTokenUrl() {
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/sendVerifyCodeByToken";
return url;
}
static getForgetPasswordUrl() {
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/forgotPassword";
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/user/zh/c/forgotPassword";
return url;
}
static getResetPassworddUrl() {
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/user/zh/c/resetPassword";
return url;
}
... ... @@ -295,6 +306,11 @@ export class HttpUrlUtils {
return url;
}
static getCheckVerifyByTokenCodeUrl() {
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/checkVerifyCodeByToken";
return url;
}
static getAppointmentListDataUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH
return url
... ...
... ... @@ -63,7 +63,7 @@ export struct AboutPageUI {
Blank()
Image($r('app.media.app_icon'))
Image($r('app.media.about_us_code'))
.width('192lpx')
.height('192lpx')
... ...
... ... @@ -59,13 +59,12 @@ export struct AccountAndSecurityLayout {
.onClick(() => {
console.log(index + "")
if (index == 0){
let pageType = {'pageType': 2} as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
}else if (index == 1) {
let params: SettingPasswordParams = {
pageID:'1',
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params)
let pageType = {'pageType': 1} as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
}
})
... ... @@ -83,7 +82,7 @@ export struct AccountAndSecurityLayout {
}.height("100%")
Column() {
Button('退出登录',{ stateEffect: true }).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').onClick(()=>{
Button('退出登录',{ stateEffect: true ,type: ButtonType.Normal}).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').borderRadius('8lpx').onClick(()=>{
AlertDialog.show({
title: '🥟id : ' + "button",
message: '标题:' + '退出登录',
... ...
... ... @@ -6,6 +6,7 @@ import promptAction from '@ohos.promptAction'
import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/Index'
import { WDRouterRule, WDRouterPage } from 'wdRouter';
import { SettingPasswordParams } from './SettingPasswordLayout'
import { Router } from '@ohos.arkui.UIContext'
const TAG = 'ForgetPasswordPage'
... ... @@ -20,23 +21,30 @@ struct ForgetPasswordPage {
@State isSubmit: boolean = false //是否可以提交 默认不可以
loginViewModel: LoginViewModel = new LoginViewModel()
@State @Watch('onCodeSend') isCodeSend: boolean = false //验证码点击发送事件
pageType:number = (router.getParams() as Record<string, number>)['pageType']; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2
pageTitle = '找回密码';
onCodeSend() {
if (this.isCodeSend) {
this.sendVerifyCode()
}
}
build() {
Column() {
Image($r('app.media.login_back_icon')).width(24).height(24).margin({ left: 15, top: 10 }).onClick(() => {
router.back()
})
Text('找回密码').fontSize(22).fontColor('#333333').fontWeight(FontWeight.Bold).margin({ left: 25, top: 112 })
Text(this.pageTitle).fontSize(22).fontColor('#333333').fontWeight(FontWeight.Bold).margin({ left: 25, top: 112 })
LoginInputComponent({
phoneContent: $phoneContent,
codeContent: $codeContent,
isSubmit: $isSubmit,
isCodeSend: $isCodeSend
isCodeSend: $isCodeSend,
pageType:this.pageType
})
Row() {
Text("确认")
... ... @@ -60,6 +68,15 @@ struct ForgetPasswordPage {
}
aboutToAppear() {
if (this.pageType == 0){
this.pageTitle = '找回密码'
}else if (this.pageType == 1){
this.pageTitle = '验证当前手机号'
}else if (this.pageType == 2){
this.pageTitle = '验证当前手机号'
}else if (this.pageType == 2){
this.pageTitle = '更换手机号'
}
if (this.isCodeSend) {
this.sendVerifyCode()
}
... ... @@ -95,6 +112,7 @@ struct ForgetPasswordPage {
pageID:'1',
phoneContent:this.phoneContent,
codeContent:this.codeContent,
pageType:this.pageType
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params)
... ...
... ... @@ -9,32 +9,59 @@ export struct LoginInputComponent {
@Link isCodeSend: boolean //验证码控件是否点击 默认没有 发送接口
@Link isSubmit: boolean //是否可以提交
isFirst:boolean=true//是否第一次获取验证码
pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2
build() {
Column() {
this.addCodeLayout()
}.width('100%').padding({ left: 25, right: 25 })
}
aboutToAppear(){
if (this.pageType == 1) {
this.phoneContent = '18655957611';
}
}
@Builder
addCodeLayout() {
TextInput({ placeholder: "请输入手机号" })
.fontSize(16)
.height(48)
.maxLength(11)
.margin({ top: 36 })
.backgroundColor("#F5F5F5")
.borderRadius(4)
.type(InputType.PhoneNumber)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
if (content.length >= 11) {
this.codeBtnState = true
} else {
this.codeBtnState = false
}
})
if (this.pageType == 1){
TextInput({ placeholder: this.securityPhone('18655957611') })
.fontSize(16)
.height(48)
.maxLength(11)
.margin({ top: 36 })
.backgroundColor("#F5F5F5")
.borderRadius(4)
.enabled(false)
.type(InputType.PhoneNumber)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
if (content.length >= 11) {
this.codeBtnState = true
} else {
this.codeBtnState = false
}
})
}else{
TextInput({ placeholder: "请输入手机号" })
.fontSize(16)
.height(48)
.maxLength(11)
.margin({ top: 36 })
.backgroundColor("#F5F5F5")
.borderRadius(4)
.type(InputType.PhoneNumber)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
if (content.length >= 11) {
this.codeBtnState = true
} else {
this.codeBtnState = false
}
})
}
Row() {
TextInput({ placeholder: "验证码" })
... ... @@ -86,4 +113,11 @@ export struct LoginInputComponent {
.backgroundImageSize({width:'100%',height:48})
}
securityPhone(phoneNum:string):string{
let securityNum:string;
let needSecurityString = phoneNum.substring(3, phoneNum.length - 4);
securityNum = phoneNum.replace(needSecurityString,'****')
return securityNum;
}
}
\ No newline at end of file
... ...
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { Logger } from 'wdKit';
import { Logger, SPHelper } from 'wdKit';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { LoginBean } from './LoginBean';
import { CheckVerifyBean } from './CheckVerifyBean';
import {
SpConstants
} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants'
const TAG = 'LoginModel'
... ... @@ -32,6 +36,29 @@ export class LoginModel {
}
sendVerifyCodeByToken() {
let bean: Record<string, string> = {};
// bean['phoneNum'] = number
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<string>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getVerifyCodeByTokenUrl(), bean, headers).then((data: ResponseDTO<string>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
fail(error.message)
Logger.debug("LoginViewModel:error ", error.toString())
})
})
}
//{"phone":"13625644528","loginType":2,"deviceId":"60da5af6-9c59-3566-8622-8c6c00710994","verificationCode":"644528"}
appLogin(phone: string, loginType: number, verificationCode: string) {
... ... @@ -113,13 +140,68 @@ export class LoginModel {
})
}
//忘记密码 设置新密码
checkVerifyCodeByToken(verifyCode: string) {
let bean: Record<string, Object> = {};
bean['verifyCode'] = verifyCode
// bean['phone'] = phone
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<CheckVerifyBean>((success, fail) => {
HttpRequest.post<ResponseDTO<CheckVerifyBean>>(HttpUrlUtils.getCheckVerifyByTokenCodeUrl(), bean, headers).then((data: ResponseDTO<CheckVerifyBean>) => {
Logger.debug("LoginViewModel:success2 ", data.message)
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
Logger.debug("LoginViewModel:error2 ", error.toString())
fail(error.message)
})
})
}
//修改密码 //需要老密码
resetPassword(password: string, tempToken: string) {
let bean: Record<string, string> = {};
// bean['password'] = password;
// bean['tempToken'] = tempToken;
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<string>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<string>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
fail(error.message)
Logger.debug("LoginViewModel:error ", error.toString())
})
})
}
//忘记密码 //不需要老密码
forgotPassword(password: string, tempToken: string) {
let bean: Record<string, string> = {};
bean['password'] = password;
bean['tempToken'] = tempToken;
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let JwtToken = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, '') as string;
headers.set('JwtToken',(JwtToken));
return new Promise<string>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<string>) => {
if (!data || !data.data) {
... ... @@ -137,5 +219,6 @@ export class LoginModel {
})
})
}
}
... ...
... ... @@ -141,7 +141,8 @@ struct LoginPage {
Text('忘记密码').fontColor('#666666').fontSize(14).margin({ top: 16 })
.onClick(() => {
// router.pushUrl({ url: 'pages/login/ForgetPasswordPage' })
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage)
let pageType = {'pageType': 0} as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
})
}
... ...
... ... @@ -31,6 +31,17 @@ export class LoginViewModel {
}
sendVerifyCodeByToken() {
return new Promise<string>((success, fail) => {
this.loginModel.sendVerifyCodeByToken().then((data) => {
success(data)
}).catch((message: string) => {
fail(message)
})
})
}
appLogin(phone: string, loginType: number, verificationCode: string) {
return new Promise<LoginBean>((success, fail) => {
... ... @@ -91,8 +102,21 @@ export class LoginViewModel {
})
})
}
checkVerifyCodeByToken(verifyCode: string) {
return new Promise<CheckVerifyBean>((success, reject) => {
this.loginModel.checkVerifyCodeByToken(verifyCode).then((data: CheckVerifyBean) => {
//todo 保存数据
SPHelper.default.save(SpConstants.USER_TEMP_TOKEN, data.temToken)
SPHelper.default.save(SpConstants.USER_JWT_TOKEN, data.jwtToken)
success(data)
//重置密码
}, (value: string) => {
reject(value)
})
})
}
//重置密码 需要老密码
resetPassword(password: string, tempToken: string) {
return new Promise<string>(async (success, fail) => {
let passwordNew = await this.doMd(password)
... ... @@ -105,6 +129,18 @@ export class LoginViewModel {
}
//忘记密码
forgotPassword(password: string, tempToken: string) {
return new Promise<string>(async (success, fail) => {
let passwordNew = await this.doMd(password)
this.loginModel.forgotPassword(passwordNew, tempToken).then((data) => {
success(data)
}).catch((message: string) => {
fail(message)
})
})
}
async doMd(content: string): Promise<string> {
... ...
... ... @@ -8,6 +8,8 @@ import {
SpConstants
} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants'
import data_preferences from '@ohos.data.preferences';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
const TAG = "SettingPasswordLayout"
export interface SettingPasswordParams {
... ... @@ -15,6 +17,7 @@ export interface SettingPasswordParams {
phoneContent?: string;
codeContent?: string;
tempToken?:string;
pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2
}
export default class AccoutPageDataModel {
... ... @@ -53,6 +56,7 @@ export struct SettingPasswordLayout {
password02: string = '';
passwordOri: string = '';
loginViewModel = new LoginViewModel()
pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机
aboutToAppear() {
let params:SettingPasswordParams = router.getParams() as SettingPasswordParams;
... ... @@ -61,6 +65,7 @@ export struct SettingPasswordLayout {
this.phoneContent = params.phoneContent!;
this.codeContent = params.codeContent!;
this.pageType = params.pageType;
}
getPageListData(pageId:number) {
... ... @@ -304,22 +309,30 @@ export struct SettingPasswordLayout {
promptAction.showToast({ message: '密码不符合密码规范' })
return
}
promptAction.showToast({ message: '请求接口' })
}
if(this.pageId == 1){ //设置密码
if (this.password01.length < 6 || this.password01.length > 20) {
promptAction.showToast({ message: '密码不符合密码规范' })
return
}
if (this.password01 != this.password02) {
promptAction.showToast({ message: '密码不一致' })
return
}
if(this.pageId == 1){ //设置密码
SPHelper.default.get(SpConstants.USER_JWT_TOKEN, '').then((str) => {
this.loginViewModel.forgotPassword(this.password01, str.toString()).then((data =>{
if (this.pageType == 0) {//登录页
WDRouterRule.jumpWithPage(WDRouterPage.loginPage);
}else if(this.pageType == 1){//设置
let params: Params = {
pageID: 'AccountAndSecurityLayout'
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
}
}))
}).catch((err: Error) => {
Logger.error(TAG, 'catch err:' + JSON.stringify(err));
});
}
// promptAction.showToast({ message: '请求接口' })
}
}
// 输入框数据变动:输入数据处理
... ... @@ -338,15 +351,6 @@ export struct SettingPasswordLayout {
} else {
this.btnStatus = false;
}
SPHelper.default.get(SpConstants.USER_JWT_TOKEN, '').then((str) => {
this.loginViewModel.resetPassword(this.password01, str.toString()).then((data =>{
}))
}).catch((err: Error) => {
Logger.error(TAG, 'catch err:' + JSON.stringify(err));
});
}
}
}
... ...
... ... @@ -36,8 +36,58 @@
],
"requestPermissions": [
{
"name": "ohos.permission.CAMERA",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.READ_MEDIA",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.WRITE_MEDIA",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.MICROPHONE",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.INTERNET"
}
]
],
}
}
\ No newline at end of file
... ...