Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
shishuangxi
2024-04-19 18:07:12 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d80affbba3d72c8747ffb25cc34da6c5c57dcaf9
d80affbb
1 parent
c363d612
登录问题修复
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
105 additions
and
10 deletions
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpBizUtil.ets
sight_harmony/features/wdComponent/src/main/ets/components/setting/AccountAndSecurityLayout.ets
sight_harmony/features/wdComponent/src/main/ets/components/setting/ConfirmLogoutDialog.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginModel.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginPage.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpBizUtil.ets
View file @
d80affb
...
...
@@ -62,7 +62,7 @@ export class HttpBizUtil {
Logger.debug(TAG, 'post: ' + resDTO.code)
Logger.debug(TAG, 'post: ' + resDTO.message)
// 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
if (resDTO.code ==
0
|| resDTO.code == 406) {
if (resDTO.code ==
403
|| resDTO.code == 406) {
HttpBizUtil.refreshToken().then((token: string) => {
if (headers) {
headers.replace('RMRB-X-TOKEN', token)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/setting/AccountAndSecurityLayout.ets
View file @
d80affb
...
...
@@ -18,6 +18,7 @@ import promptAction from '@ohos.promptAction';
import { LogoutViewModel } from '../../viewmodel/LogoutViewModel';
import { CustomLogoutDialog } from './CustomLogoutDialog';
import { emitter } from '@kit.BasicServicesKit';
import { ConfirmLogoutDialog } from './ConfirmLogoutDialog';
export { SettingPasswordParams } from "wdLogin"
...
...
@@ -42,6 +43,19 @@ export struct AccountAndSecurityLayout {
alignment: DialogAlignment.Center
})
confirmDialogController: CustomDialogController = new CustomDialogController({
builder: ConfirmLogoutDialog({
cancel: () => {
},
confirm: () => {
this.logout()
}
}),
customStyle: true,
alignment: DialogAlignment.Center
})
aboutToAppear() {
// 获取设置页面数据
...
...
@@ -172,11 +186,8 @@ export struct AccountAndSecurityLayout {
Column() {
Button('退出登录',{ stateEffect: true ,type: ButtonType.Normal}).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').borderRadius('8lpx').onClick(()=>{
let login = new LoginViewModel;
promptAction.showToast({ message: '退出登录' })
login.logOut();
router.back();
router.back();
this.confirmDialogController.open()
// AlertDialog.show({
// title: '🥟id : ' + "button",
// message: '标题:' + '退出登录',
...
...
@@ -415,6 +426,16 @@ export struct AccountAndSecurityLayout {
.height('54lpx')
}
logout(){
let login = new LoginViewModel;
login.logOut().then(()=>{
promptAction.showToast({ message: '退出登录' })
router.back();
router.back();
}).catch((error:string)=>{
promptAction.showToast({ message: error })
});
}
//注销账号
requestLogout() {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/setting/ConfirmLogoutDialog.ets
0 → 100644
View file @
d80affb
/**退出登录确认弹框*/
@CustomDialog
export struct ConfirmLogoutDialog {
controller: CustomDialogController
cancel: () => void = () => {
}
confirm: () => void = () => {
}
build() {
Column() {
Text("确认退出登录吗?")
.fontColor("#222222")
.fontSize(18)
.width("100%")
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Center)
.margin({ top: 20 })
Divider().color("#999999").width("100%").margin({ top: 20 }).height('1vp')
Row() {
Text('确认')
.fontSize(16)
.fontColor("#648DF2")
.layoutWeight(1)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.onClick(() => {
this.controller.close()
if (this.confirm) {
this.confirm()
}
})
.height('100%')
// Divider().color("#999999").height('100%').width('0.5vp')
Text('取消')
.fontSize(16)
.fontColor("#648DF2")
.layoutWeight(1)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.border({
width: { left: 1 },
color: "#999999",
style: { left: BorderStyle.Solid }
})
.onClick(() => {
this.controller.close()
if (this.cancel) {
this.cancel()
}
})
.height('100%')
}.layoutWeight(1).justifyContent(FlexAlign.Center)
}.height(110).backgroundColor(Color.White).borderRadius(6).width('74%')
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginModel.ets
View file @
d80affb
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { Http
BizUtil, Http
UrlUtils, ResponseDTO } from 'wdNetwork';
import { Logger, SPHelper, StringUtils } from 'wdKit';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { LoginBean } from './LoginBean';
...
...
@@ -224,7 +224,7 @@ export class LoginModel {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<string>((success, fail) => {
Http
Request.post<ResponseDTO<string>>(HttpUrlUtils.getLogoutUrl(), bean, headers).then((data: ResponseDTO<string>) =>
{
Http
BizUtil.post<string>(HttpUrlUtils.getLogoutUrl(), bean, headers).then((data: ResponseDTO<string>)=>
{
if (!data) {
fail("数据为空")
return
...
...
@@ -234,10 +234,24 @@ export class LoginModel {
return
}
success('')
}
, (error: Error) =>
{
}
).catch((error:Error)=>
{
fail(error.message)
Logger.debug("LoginViewModel:error ", error.toString())
})
// HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getLogoutUrl(), bean, headers).then((data: ResponseDTO<string>) => {
// if (!data) {
// fail("数据为空")
// return
// }
// if (data.code != 0) {
// fail(data.message)
// return
// }
// success('')
// }, (error: Error) => {
// fail(error.message)
// Logger.debug("LoginViewModel:error ", error.toString())
// })
})
}
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginPage.ets
View file @
d80affb
...
...
@@ -185,7 +185,7 @@ struct LoginPage {
.height(48)
.backgroundColor("#F5F5F5")
.borderRadius(4)
.type(InputType.
PhoneNumber
)
.type(InputType.
Normal
)
.onChange((content) => {
this.accountContent = content
this.isSubmit = (this.accountContent.length >= 11 && this.passwordContent.length >= 6)
...
...
Please
register
or
login
to post a comment