yangchenggong1_wd

fix:bug[17042] 账户与安全中设置密码会跳转页面位置不正确

... ... @@ -30,6 +30,7 @@ export struct CustomToast {
.fontSize("27lpx")
.lineHeight("38lpx")
}.borderRadius(`${this.bgBorderRadius}lpx`)
.constraintSize({maxWidth:"86%"})
.padding({top:"23lpx",bottom:'23lpx',left:"35lpx",right:"35lpx"})
.backgroundColor($r("app.color.black"))
.opacity(0.7)
... ...
... ... @@ -297,6 +297,10 @@ export class HttpUrlUtils {
*/
static readonly ATTENTION_BATCH_DATA_PATH: string = "/api/rmrb-interact/interact/zh/c/attention/batch";
/**
* 查询是否设置过密码checkSetPassword
*/
static readonly CHECK_SET_PASSWORD_PATH: string = "/api/rmrb-user-center/user/zh/c/ifSetPassword";
static getHost(): string {
return HostManager.getHost();
... ... @@ -689,4 +693,10 @@ export class HttpUrlUtils {
return url;
}
//查询是否设置过密码
static checkSetPassword() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.CHECK_SET_PASSWORD_PATH;
return url;
}
}
\ No newline at end of file
... ...
... ... @@ -68,6 +68,7 @@ export class WDRouterPage {
static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage");
static oneKeyLoginPage = new WDRouterPage("wdLogin", "ets/pages/login/OneKeyLoginPage");
static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage");
static modifyPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ModifyPasswordPage");
//我的 预约
static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage");
//我的 关注
... ...
... ... @@ -170,12 +170,19 @@ export default struct MinePageUserSimpleInfoUI {
if(value!=null){
if(StringUtils.isEmpty(this.levelHead)){
if(this.userType === "1"){
this.levelHead = value.levelHead
if(value.levelHead != undefined){
this.levelHead = value.levelHead
}
}
}
this.levelId = value.levelId
UserDataLocal.setUserLevel(this.levelId)
UserDataLocal.setUserLevelHeaderUrl(this.levelHead + "")
if(value.levelId != undefined){
this.levelId = value.levelId
UserDataLocal.setUserLevel(this.levelId)
}
if(StringUtils.isNotEmpty(this.levelHead)){
UserDataLocal.setUserLevelHeaderUrl(this.levelHead + "")
}
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
... ...
... ... @@ -3,6 +3,7 @@ import { MineSettingComponent } from '../setting/MineSettingComponent';
import { AccountAndSecurityLayout } from '../setting/AccountAndSecurityLayout';
import router from '@ohos.router';
import { Action, Params } from 'wdBean';
import { DateTimeUtils } from 'wdKit/Index';
@Entry
@Component
... ... @@ -10,11 +11,12 @@ struct SettingPage {
@State message: string = 'Hello World 02'
@State pageType: string = 'mainSetting';
@State params:Params = router.getParams() as Params;
@State enterActivityTime:number = 0;
onPageShow() {
this.pageType = this.params.pageID;
this.enterActivityTime = DateTimeUtils.getTimeStamp()
}
build() {
... ... @@ -22,7 +24,7 @@ struct SettingPage {
if (this.pageType == 'mainSetting') {
MineSettingComponent()
} else {
AccountAndSecurityLayout()
AccountAndSecurityLayout({enterActivityTime:this.enterActivityTime})
}
}.setFullWidth()
}
... ...
... ... @@ -29,6 +29,10 @@ export struct AccountAndSecurityLayout {
@State cacheSice: number = 0
@State protocolState: boolean = false //协议勾选状态
@State isAccountPage: boolean = true
@State ifSetPassword: boolean = false //是否设置过密码
@Watch("checkSetPassword") @Prop enterActivityTime:number = 0;
logoutViewModel = new LogoutViewModel()
dialogController: CustomDialogController = new CustomDialogController({
builder: CustomLogoutDialog({
... ... @@ -61,6 +65,23 @@ export struct AccountAndSecurityLayout {
// 获取设置页面数据
this.getAccountAndSecurityData()
this.addEmitEvent()
this.checkSetPassword()
}
checkSetPassword(){
MineSettingDatasModel.checkSetPassword().then((value) => {
if (value != null) {
if(value.hasSet == "1"){
this.ifSetPassword = true
if(this.listData.length>0){
this.listData[1] = new MineMainSettingFunctionItem(null, '修改密码', null, 0, false,"")
}
}else{
this.ifSetPassword = false
}
}
}).catch((err: Error) => {
})
}
async getAccountAndSecurityData() {
... ... @@ -162,9 +183,14 @@ export struct AccountAndSecurityLayout {
let pageType = {'pageType': 2} as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
}else if (index == 1) {
let pageType = {'pageType': 1} as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
if (this.ifSetPassword) {
//修改密码
WDRouterRule.jumpWithPage(WDRouterPage.modifyPasswordPage)
}else{
//设置密码
let pageType = {'pageType': 1} as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
}
}else if (index == 3) {
this.isAccountPage=false
// WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
... ...
import HashMap from '@ohos.util.HashMap';
import { ResponseDTO, WDHttp } from 'wdNetwork';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { Logger, SPHelper } from 'wdKit';
import { MineMainSettingFunctionItem } from '../viewmodel/MineMainSettingFunctionItem';
import { SpConstants } from 'wdConstant/Index';
import { CheckSetPasswordItem } from '../viewmodel/CheckSetPasswordItem';
const TAG = "MineSettingDatasModel"
... ... @@ -108,6 +109,33 @@ class MineSettingDatasModel{
// })
// }
/**
* 判断是否设置过密码
*/
checkSetPassword(): Promise<CheckSetPasswordItem> {
return new Promise<CheckSetPasswordItem>((success, error) => {
Logger.info(TAG, `checkSetPassword start`);
this.fetchCheckSetPassword().then((navResDTO: ResponseDTO<CheckSetPasswordItem>) => {
if (!navResDTO || navResDTO.code != 0) {
error(null)
return
}
Logger.info(TAG, "checkSetPassword then,checkSetPasswordResDTO.timeStamp:" + navResDTO.timestamp);
let navigationBean = navResDTO.data as CheckSetPasswordItem
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `checkSetPassword catch, error.name : ${err.name}, error.message:${err.message}`);
error(null)
})
})
}
fetchCheckSetPassword() {
let url = HttpUrlUtils.checkSetPassword()
return WDHttp.get<ResponseDTO<CheckSetPasswordItem>>(url)
};
}
const mineSettingDatasModel = MineSettingDatasModel.getInstance()
... ...
export class CheckSetPasswordItem{
hasSet: string = "0" //是否设置过密码,0未设置,1已设置
}
\ No newline at end of file
... ...
... ... @@ -122,6 +122,26 @@ struct ForgetPasswordPage {
return
}
if(this.pageType == 0 && this.phoneContent.indexOf("****")!=-1){
//设置密码 忘记密码跳转过来的 需要使用上面方法
this.loginViewModel.sendVerifyCodeByToken().then(()=>{
this.showToastTip("已发送")
this.codeStateSuccess=true
this.isCodeSend=false
}).catch((message: string)=>{
let netStatus = NetworkUtil.isNetConnected()
if (netStatus) {
this.showToastTip(message)
} else {
this.showToastTip("验证码获取失败,请重新尝试")
}
this.codeStateSuccess=false
this.isCodeSend=false
})
return
}
this.loginViewModel.sendVerifyCode(this.phoneContent).then((verifyCode) => {
this.showToastTip("已发送")
this.codeStateSuccess=true
... ... @@ -166,6 +186,22 @@ struct ForgetPasswordPage {
})
return
}
if(this.pageType == 0 && this.phoneContent.indexOf("****")!=-1){
this.loginViewModel.checkVerifyCodeByToken(this.codeContent).then(()=>{
let params: SettingPasswordParams = {
pageID:'1',
phoneContent:this.phoneContent,
codeContent:this.codeContent,
pageType:1
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params)
}).catch((message: string)=>{
this.showToastTip(message)
})
return
}
this.loginViewModel.checkVerifyCode(this.phoneContent, this.codeContent).then(() => {
let params: SettingPasswordParams = {
pageID:'1',
... ...
import { SpConstants } from 'wdConstant/Index'
import { DateTimeUtils, Logger, SPHelper } from 'wdKit'
import { DateTimeUtils, Logger, SPHelper, StringUtils } from 'wdKit'
@Component
export struct LoginInputComponent {
... ... @@ -33,9 +33,15 @@ export struct LoginInputComponent {
}
async aboutToAppear(){
if (this.pageType == 1) {
if (this.pageType == 1 ) {
this.phoneContent = await SPHelper.default.get(SpConstants.USER_PHONE,"") as string;
}
if(this.pageType == 0 ){
let phone = await SPHelper.default.get(SpConstants.USER_PHONE,"") as string
if(StringUtils.isNotEmpty(phone)){
this.phoneContent = phone
}
}
}
@Builder
addCodeLayout() {
... ... @@ -60,33 +66,55 @@ export struct LoginInputComponent {
}
})
}else{
TextInput({text: this.phoneContent, placeholder: "请输入手机号" })
.fontSize(16)
.height(48)
.placeholderColor("#CCCCCC")
.maxLength(11)
.margin({ top: 36 })
.backgroundColor("#F5F5F5")
.borderRadius(4)
.type(InputType.Number)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4)
if(this.isNeedProtocol){
if (content.length >= 11 && this.protocolState) {
//修改密码 里面的 忘记密码(已登录)
if(StringUtils.isNotEmpty(this.phoneContent) && this.phoneContent.indexOf("****")!=-1 && this.pageType == 0){
TextInput({ text: this.securityPhone(this.phoneContent) })
.fontColor("#333333")
.fontSize(16)
.height(48)
.maxLength(11)
.margin({ top: 36 })
.borderRadius(4)
.focusable(false)
.type(InputType.PhoneNumber)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4)
if (content.length >= 11) {
this.codeBtnState = true
} else {
this.codeBtnState = false
}
}else{
if (content.length >= 11 ) {
this.codeBtnState = true
} else {
this.codeBtnState = false
})
}else {
TextInput({text: this.phoneContent, placeholder: "请输入手机号" })
.fontSize(16)
.height(48)
.placeholderColor("#CCCCCC")
.maxLength(11)
.margin({ top: 36 })
.backgroundColor("#F5F5F5")
.borderRadius(4)
.type(InputType.Number)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4)
if(this.isNeedProtocol){
if (content.length >= 11 && this.protocolState) {
this.codeBtnState = true
} else {
this.codeBtnState = false
}
}else{
if (content.length >= 11 ) {
this.codeBtnState = true
} else {
this.codeBtnState = false
}
}
}
})
})
}
}
... ...
import HashMap from '@ohos.util.HashMap';
import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO } from 'wdNetwork';
import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { Logger } from 'wdKit';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { LoginBean } from './LoginBean';
import { CheckVerifyBean } from './CheckVerifyBean';
import { UserDetail } from 'wdBean/Index';
import { ModifyPasswordRequestItem } from './ModifyPasswordRequestItem';
const TAG = 'LoginModel'
... ... @@ -312,5 +313,30 @@ export class LoginModel {
})
}
/**
* 修改密码
*/
modifyPassword(obj:ModifyPasswordRequestItem): Promise<String> {
return new Promise<String>((success, error) => {
Logger.info(TAG, `modifyPassword start`);
this.fetchModifyPassword(obj).then((navResDTO: ResponseDTO<String>) => {
if (!navResDTO || navResDTO.code != 0) {
error(navResDTO.message)
return
}
Logger.info(TAG, "modifyPassword then,modifyPasswordResDTO.timeStamp:" + navResDTO.timestamp);
success("0");
}).catch((err: Error) => {
Logger.error(TAG, `modifyPassword catch, error.name : ${err.name}, error.message:${err.message}`);
error("出错了,请稍后重试")
})
})
}
fetchModifyPassword(obj:ModifyPasswordRequestItem) {
let url = HttpUrlUtils.getResetPassworddUrl()
return WDHttp.post<ResponseDTO<String>>(url,obj)
};
}
... ...
... ... @@ -159,6 +159,7 @@ export class LoginViewModel {
SPHelper.default.saveSync(SpConstants.USER_STATUS, '')
SPHelper.default.saveSync(SpConstants.USER_Type, '')
SPHelper.default.saveSync(SpConstants.USER_NAME, '')
SPHelper.default.saveSync(SpConstants.USER_PHONE, '')
UserDataLocal.clearUserData()
success(data)
}).catch((message: string) => {
... ...
import { CustomToast} from 'wdKit/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { LoginModel } from './LoginModel';
import { LoginViewModel } from './LoginViewModel';
import { ModifyPasswordRequestItem } from './ModifyPasswordRequestItem';
import { router } from '@kit.ArkUI';
import { encryptMessage } from '../../utils/cryptoUtil';
/**
* 修改密码页面
* */
@Entry
@Component
struct ModifyPasswordPage {
password_old: string = '';
password_new: string = '';
password_new_repeat: string = '';
@State btnStatus: boolean = false;
@State toastText:string = ""
loginModel = new LoginModel()
dialogToast: CustomDialogController = new CustomDialogController({
builder: CustomToast({
msg: this.toastText,
}),
autoCancel: false,
alignment: DialogAlignment.Center,
offset: { dx: 0, dy: -20 },
gridCount: 1,
customStyle: true,
maskColor:"#00000000"
})
build() {
Row() {
Column() {
this.ModifyPasswordLayout()
}
.width('100%')
.height('100%')
}.width('100%')
.height('100%')
}
@Builder ModifyPasswordLayout(){
Navigation() {
Column(){
Column() {
Text("修改密码").fontWeight(FontWeight.Bold).fontSize(20).maxLines(1)
}
.width('100%')
.height('75lpx')
.alignItems(HorizontalAlign.Start)
Row() {
Row() {
TextInput({ placeholder: "请输入原密码" })
.placeholderColor("#CCCCCC")
.type(InputType.Password)
.showPasswordIcon(true)
.backgroundColor('#00000000')
.onChange((value: string) => {
this.password_old = value
this.inputTextChange()
})
}
.alignItems(VerticalAlign.Center)
.height('80lpx')
.backgroundColor('#f5f5f5')
.borderRadius('4vp')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
Row() {
Row() {
TextInput({ placeholder: "请输入新密码" })
.placeholderColor("#CCCCCC")
.type(InputType.Password)
.showPasswordIcon(true)
.backgroundColor('#00000000')
.onChange((value: string) => {
this.password_new = value
this.inputTextChange()
})
}
.alignItems(VerticalAlign.Center)
.height('80lpx')
.backgroundColor('#f5f5f5')
.borderRadius('4vp')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
Row() {
Row() {
TextInput({ placeholder: "请再请输入原密码" })
.placeholderColor("#CCCCCC")
.type(InputType.Password)
.showPasswordIcon(true)
.backgroundColor('#00000000')
.onChange((value: string) => {
this.password_new_repeat = value
this.inputTextChange()
})
}
.alignItems(VerticalAlign.Center)
.height('80lpx')
.backgroundColor('#f5f5f5')
.borderRadius('4vp')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
Column() {
Text("提示:密码长度6-20位,需答谢字母、小写字母、数字、特殊字符中组合三种及三种以上组成").fontSize(12).maxLines(3).fontColor(0x999999).padding({top:'10lpx'})
}
.width('100%')
.height('85lpx')
.alignItems(HorizontalAlign.Start)
Row() {
Button("确认", { type: ButtonType.Normal, stateEffect: true })
.width('100%')
.height('80lpx')
.backgroundColor(this.btnStatus ? '#da3e22' : '#e5856d')
.fontColor('#fff')
.borderRadius('4vp')
.onClick(() => {
if(this.btnStatus){
this.submit()
}
})
}
.padding({top:'25lpx'})
.alignItems(VerticalAlign.Center)
.width('100%')
.height('120lpx')
Column() {
Text("忘记密码").fontSize(12).maxLines(3).fontColor(0x999999).padding({top:'10lpx'})
.onClick(()=>{
let pageType = { 'pageType': 0 } as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
})
}
.width('100%')
.height('85lpx')
.alignItems(HorizontalAlign.Center)
}.padding({top:"92lpx",left:"48lpx",right:"48lpx"})
}.titleMode(NavigationTitleMode.Mini)
.title('')
}
inputTextChange(){
if ((this.password_old.length >= 6 && this.password_old.length <= 20) && (this.password_new.length >= 6 && this.password_new.length <= 20)&& (this.password_new_repeat.length >= 6 && this.password_new_repeat.length <= 20)) {
this.btnStatus = true;
} else {
this.btnStatus = false;
}
}
async submit(){
if(this.password_new != this.password_new_repeat ){
this.showToastTip("两次输入的密码不一致,请重新输入")
return
}
let old = await encryptMessage(this.password_old)
let newValue = await encryptMessage(this.password_new)
let c = new ModifyPasswordRequestItem(old,newValue)
this.loginModel.modifyPassword(c).then((value) => {
if (value != null) {
if(value == "0"){
this.showToastTip("修改成功")
router.back()
}
}
}).catch((err: string) => {
this.showToastTip(err)
})
}
showToastTip(msg:string){
this.toastText = msg
this.dialogToast.open()
}
}
\ No newline at end of file
... ...
export class ModifyPasswordRequestItem{
oldPassword:string = ""
newPassword:string = ""
constructor(oldPassword:string , newPassword:string) {
this.oldPassword = oldPassword
this.newPassword = newPassword
}
}
\ No newline at end of file
... ...
... ... @@ -7,6 +7,7 @@
"pages/login/SettingPasswordPage",
"pages/login/SettingPasswordLayout",
"pages/guide/GuidePages",
"pages/login/OneKeyLoginPage"
"pages/login/OneKeyLoginPage",
"pages/login/ModifyPasswordPage"
]
}
}
\ No newline at end of file
... ...