shishuangxi

登录问题修复

@@ -62,7 +62,7 @@ export class HttpBizUtil { @@ -62,7 +62,7 @@ export class HttpBizUtil {
62 Logger.debug(TAG, 'post: ' + resDTO.code) 62 Logger.debug(TAG, 'post: ' + resDTO.code)
63 Logger.debug(TAG, 'post: ' + resDTO.message) 63 Logger.debug(TAG, 'post: ' + resDTO.message)
64 // 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面 64 // 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
65 - if (resDTO.code == 0 || resDTO.code == 406) { 65 + if (resDTO.code == 403 || resDTO.code == 406) {
66 HttpBizUtil.refreshToken().then((token: string) => { 66 HttpBizUtil.refreshToken().then((token: string) => {
67 if (headers) { 67 if (headers) {
68 headers.replace('RMRB-X-TOKEN', token) 68 headers.replace('RMRB-X-TOKEN', token)
@@ -18,6 +18,7 @@ import promptAction from '@ohos.promptAction'; @@ -18,6 +18,7 @@ import promptAction from '@ohos.promptAction';
18 import { LogoutViewModel } from '../../viewmodel/LogoutViewModel'; 18 import { LogoutViewModel } from '../../viewmodel/LogoutViewModel';
19 import { CustomLogoutDialog } from './CustomLogoutDialog'; 19 import { CustomLogoutDialog } from './CustomLogoutDialog';
20 import { emitter } from '@kit.BasicServicesKit'; 20 import { emitter } from '@kit.BasicServicesKit';
  21 +import { ConfirmLogoutDialog } from './ConfirmLogoutDialog';
21 22
22 export { SettingPasswordParams } from "wdLogin" 23 export { SettingPasswordParams } from "wdLogin"
23 24
@@ -42,6 +43,19 @@ export struct AccountAndSecurityLayout { @@ -42,6 +43,19 @@ export struct AccountAndSecurityLayout {
42 alignment: DialogAlignment.Center 43 alignment: DialogAlignment.Center
43 }) 44 })
44 45
  46 + confirmDialogController: CustomDialogController = new CustomDialogController({
  47 + builder: ConfirmLogoutDialog({
  48 + cancel: () => {
  49 +
  50 + },
  51 + confirm: () => {
  52 + this.logout()
  53 + }
  54 + }),
  55 + customStyle: true,
  56 + alignment: DialogAlignment.Center
  57 + })
  58 +
45 59
46 aboutToAppear() { 60 aboutToAppear() {
47 // 获取设置页面数据 61 // 获取设置页面数据
@@ -172,11 +186,8 @@ export struct AccountAndSecurityLayout { @@ -172,11 +186,8 @@ export struct AccountAndSecurityLayout {
172 186
173 Column() { 187 Column() {
174 Button('退出登录',{ stateEffect: true ,type: ButtonType.Normal}).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').borderRadius('8lpx').onClick(()=>{ 188 Button('退出登录',{ stateEffect: true ,type: ButtonType.Normal}).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').borderRadius('8lpx').onClick(()=>{
175 - let login = new LoginViewModel;  
176 - promptAction.showToast({ message: '退出登录' })  
177 - login.logOut();  
178 - router.back();  
179 - router.back(); 189 + this.confirmDialogController.open()
  190 +
180 // AlertDialog.show({ 191 // AlertDialog.show({
181 // title: '🥟id : ' + "button", 192 // title: '🥟id : ' + "button",
182 // message: '标题:' + '退出登录', 193 // message: '标题:' + '退出登录',
@@ -415,6 +426,16 @@ export struct AccountAndSecurityLayout { @@ -415,6 +426,16 @@ export struct AccountAndSecurityLayout {
415 .height('54lpx') 426 .height('54lpx')
416 } 427 }
417 428
  429 + logout(){
  430 + let login = new LoginViewModel;
  431 + login.logOut().then(()=>{
  432 + promptAction.showToast({ message: '退出登录' })
  433 + router.back();
  434 + router.back();
  435 + }).catch((error:string)=>{
  436 + promptAction.showToast({ message: error })
  437 + });
  438 + }
418 439
419 //注销账号 440 //注销账号
420 requestLogout() { 441 requestLogout() {
  1 +/**退出登录确认弹框*/
  2 +
  3 +@CustomDialog
  4 +export struct ConfirmLogoutDialog {
  5 + controller: CustomDialogController
  6 + cancel: () => void = () => {
  7 + }
  8 + confirm: () => void = () => {
  9 + }
  10 +
  11 + build() {
  12 + Column() {
  13 + Text("确认退出登录吗?")
  14 + .fontColor("#222222")
  15 + .fontSize(18)
  16 + .width("100%")
  17 + .fontWeight(FontWeight.Bold)
  18 + .textAlign(TextAlign.Center)
  19 + .margin({ top: 20 })
  20 +
  21 + Divider().color("#999999").width("100%").margin({ top: 20 }).height('1vp')
  22 + Row() {
  23 + Text('确认')
  24 + .fontSize(16)
  25 + .fontColor("#648DF2")
  26 + .layoutWeight(1)
  27 + .fontWeight(FontWeight.Medium)
  28 + .textAlign(TextAlign.Center)
  29 + .onClick(() => {
  30 + this.controller.close()
  31 + if (this.confirm) {
  32 + this.confirm()
  33 + }
  34 +
  35 + })
  36 + .height('100%')
  37 + // Divider().color("#999999").height('100%').width('0.5vp')
  38 + Text('取消')
  39 + .fontSize(16)
  40 + .fontColor("#648DF2")
  41 + .layoutWeight(1)
  42 + .fontWeight(FontWeight.Medium)
  43 + .textAlign(TextAlign.Center)
  44 + .border({
  45 + width: { left: 1 },
  46 + color: "#999999",
  47 + style: { left: BorderStyle.Solid }
  48 +
  49 + })
  50 + .onClick(() => {
  51 + this.controller.close()
  52 + if (this.cancel) {
  53 + this.cancel()
  54 + }
  55 + })
  56 + .height('100%')
  57 + }.layoutWeight(1).justifyContent(FlexAlign.Center)
  58 + }.height(110).backgroundColor(Color.White).borderRadius(6).width('74%')
  59 + }
  60 +}
1 import HashMap from '@ohos.util.HashMap'; 1 import HashMap from '@ohos.util.HashMap';
2 -import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; 2 +import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork';
3 import { Logger, SPHelper, StringUtils } from 'wdKit'; 3 import { Logger, SPHelper, StringUtils } 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';
@@ -224,7 +224,7 @@ export class LoginModel { @@ -224,7 +224,7 @@ export class LoginModel {
224 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 224 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
225 225
226 return new Promise<string>((success, fail) => { 226 return new Promise<string>((success, fail) => {
227 - HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getLogoutUrl(), bean, headers).then((data: ResponseDTO<string>) => { 227 + HttpBizUtil.post<string>(HttpUrlUtils.getLogoutUrl(), bean, headers).then((data: ResponseDTO<string>)=>{
228 if (!data) { 228 if (!data) {
229 fail("数据为空") 229 fail("数据为空")
230 return 230 return
@@ -234,10 +234,24 @@ export class LoginModel { @@ -234,10 +234,24 @@ export class LoginModel {
234 return 234 return
235 } 235 }
236 success('') 236 success('')
237 - }, (error: Error) => { 237 + }).catch((error:Error)=>{
238 fail(error.message) 238 fail(error.message)
239 Logger.debug("LoginViewModel:error ", error.toString()) 239 Logger.debug("LoginViewModel:error ", error.toString())
240 }) 240 })
  241 + // HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getLogoutUrl(), bean, headers).then((data: ResponseDTO<string>) => {
  242 + // if (!data) {
  243 + // fail("数据为空")
  244 + // return
  245 + // }
  246 + // if (data.code != 0) {
  247 + // fail(data.message)
  248 + // return
  249 + // }
  250 + // success('')
  251 + // }, (error: Error) => {
  252 + // fail(error.message)
  253 + // Logger.debug("LoginViewModel:error ", error.toString())
  254 + // })
241 }) 255 })
242 } 256 }
243 257
@@ -185,7 +185,7 @@ struct LoginPage { @@ -185,7 +185,7 @@ struct LoginPage {
185 .height(48) 185 .height(48)
186 .backgroundColor("#F5F5F5") 186 .backgroundColor("#F5F5F5")
187 .borderRadius(4) 187 .borderRadius(4)
188 - .type(InputType.PhoneNumber) 188 + .type(InputType.Normal)
189 .onChange((content) => { 189 .onChange((content) => {
190 this.accountContent = content 190 this.accountContent = content
191 this.isSubmit = (this.accountContent.length >= 11 && this.passwordContent.length >= 6) 191 this.isSubmit = (this.accountContent.length >= 11 && this.passwordContent.length >= 6)