Showing
19 changed files
with
748 additions
and
83 deletions
| @@ -9,8 +9,14 @@ export class SpConstants{ | @@ -9,8 +9,14 @@ export class SpConstants{ | ||
| 9 | static USER_LONG_TIME_NO_LOGIN_MARK="longTimeNoLoginMark" | 9 | static USER_LONG_TIME_NO_LOGIN_MARK="longTimeNoLoginMark" |
| 10 | static USER_STATUS="user_status" | 10 | static USER_STATUS="user_status" |
| 11 | static USER_TEMP_TOKEN="tempToken" | 11 | static USER_TEMP_TOKEN="tempToken" |
| 12 | + static USER_PHONE = "user_phone" | ||
| 12 | //协议相关 | 13 | //协议相关 |
| 13 | static USER_PROTOCOL = "user_protocol" //用户协议 | 14 | static USER_PROTOCOL = "user_protocol" //用户协议 |
| 14 | static PRIVATE_PROTOCOL = "private_protocol" //隐私协议 | 15 | static PRIVATE_PROTOCOL = "private_protocol" //隐私协议 |
| 16 | + //设置页面 | ||
| 17 | + static SETTING_WIFI_IMAGE_SWITCH = "setting_wifi_switch" //wifi 图片开关 | ||
| 18 | + static SETTING_WIFI_VIDEO_SWITCH = "setting_wifi_switch" //wifi 视频开关 | ||
| 19 | + static SETTING_SUSPENSION_SWITCH = "setting_suspension_switch" //悬浮窗 开关 | ||
| 20 | + static SETTING_PUSH_SWITCH = "setting_push_switch" //推送 开关 | ||
| 15 | 21 | ||
| 16 | } | 22 | } |
| @@ -36,4 +36,6 @@ export { UserDataLocal } from './src/main/ets/utils/UserDataLocal' | @@ -36,4 +36,6 @@ export { UserDataLocal } from './src/main/ets/utils/UserDataLocal' | ||
| 36 | 36 | ||
| 37 | export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils' | 37 | export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils' |
| 38 | 38 | ||
| 39 | -// export { PermissionUtils } from './src/main/ets/utils/PermissionUtils' | ||
| 39 | +// export { PermissionUtils } from './src/main/ets/utils/PermissionUtils' | ||
| 40 | + | ||
| 41 | +export { ErrorToastUtils } from './src/main/ets/utils/ErrorToastUtils' |
| 1 | +import { ToastUtils } from './ToastUtils' | ||
| 2 | + | ||
| 3 | +export namespace ErrorToastUtils { | ||
| 4 | + export enum ErrorType { | ||
| 5 | + NET_CORE_NO_NETWORK, //当前无网络,请重试 | ||
| 6 | + NET_CORE_WEAK_NETWORK, //当前无网络,请重试 | ||
| 7 | + NET_CORE_PAGE_ERROR_NETWORK, //网络出小差了,请检查网络后重试 | ||
| 8 | + NET_CORE_LOAD_ERROR_NETWORK, //加载失败,请重试 | ||
| 9 | + NET_CORE_ENTER_ERROR_NETWORK, //很抱歉,当前内容无法加载,请点击重试 | ||
| 10 | + LIVE_CORE_NO_NETWORK, //网络出小差了,请检查下网络 | ||
| 11 | + | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + export class ErrorToast { | ||
| 15 | + static showToast(type: ErrorType) { | ||
| 16 | + switch (type) { | ||
| 17 | + case ErrorType.NET_CORE_NO_NETWORK: | ||
| 18 | + ToastUtils.shortToast($r('app.string.net_core_no_network')) | ||
| 19 | + break | ||
| 20 | + case ErrorType.NET_CORE_WEAK_NETWORK: | ||
| 21 | + ToastUtils.shortToast($r('app.string.net_core_no_network')) | ||
| 22 | + break | ||
| 23 | + case ErrorType.NET_CORE_PAGE_ERROR_NETWORK: | ||
| 24 | + ToastUtils.shortToast($r('app.string.net_core_page_error_network')) | ||
| 25 | + break | ||
| 26 | + case ErrorType.NET_CORE_LOAD_ERROR_NETWORK: | ||
| 27 | + ToastUtils.shortToast($r('app.string.net_core_load_fail_network')) | ||
| 28 | + break | ||
| 29 | + case ErrorType.NET_CORE_ENTER_ERROR_NETWORK: | ||
| 30 | + ToastUtils.shortToast($r('app.string.net_core_enter_fail_network')) | ||
| 31 | + break | ||
| 32 | + case ErrorType.LIVE_CORE_NO_NETWORK: | ||
| 33 | + ToastUtils.shortToast($r('app.string.live_core_no_network')) | ||
| 34 | + break | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + | ||
| 41 | +} | ||
| 42 | + |
| @@ -3,6 +3,30 @@ | @@ -3,6 +3,30 @@ | ||
| 3 | { | 3 | { |
| 4 | "name": "shared_desc", | 4 | "name": "shared_desc", |
| 5 | "value": "全局工具包" | 5 | "value": "全局工具包" |
| 6 | + } , | ||
| 7 | + { | ||
| 8 | + "name": "net_core_no_network", | ||
| 9 | + "value": "当前无网络,请重试" | ||
| 10 | + } , | ||
| 11 | + { | ||
| 12 | + "name": "net_core_weak_network", | ||
| 13 | + "value": "当前无网络,请重试" | ||
| 14 | + } , | ||
| 15 | + { | ||
| 16 | + "name": "net_core_page_error_network", | ||
| 17 | + "value": "网络出小差了,请检查下网络" | ||
| 18 | + }, | ||
| 19 | + { | ||
| 20 | + "name": "net_core_load_fail_network", | ||
| 21 | + "value": "加载失败,请重试" | ||
| 22 | + }, | ||
| 23 | + { | ||
| 24 | + "name": "net_core_enter_fail_network", | ||
| 25 | + "value": "很抱歉,当前内容无法加载,请点击重试" | ||
| 26 | + }, | ||
| 27 | + { | ||
| 28 | + "name": "live_core_no_network", | ||
| 29 | + "value": "网络出小差了,请检查下网络" | ||
| 6 | } | 30 | } |
| 7 | ] | 31 | ] |
| 8 | } | 32 | } |
| @@ -460,6 +460,18 @@ export class HttpUrlUtils { | @@ -460,6 +460,18 @@ export class HttpUrlUtils { | ||
| 460 | return url; | 460 | return url; |
| 461 | } | 461 | } |
| 462 | 462 | ||
| 463 | + //账户注销 | ||
| 464 | + static accountLogoutUrl() { | ||
| 465 | + let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/logoff"; | ||
| 466 | + return url; | ||
| 467 | + } | ||
| 468 | + | ||
| 469 | + //更换手机号绑定 | ||
| 470 | + static changeBindPhone() { | ||
| 471 | + let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/userPhoneChange"; | ||
| 472 | + return url; | ||
| 473 | + } | ||
| 474 | + | ||
| 463 | static getAppointmentListDataUrl() { | 475 | static getAppointmentListDataUrl() { |
| 464 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH | 476 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH |
| 465 | return url | 477 | return url |
| @@ -68,6 +68,8 @@ export class WDRouterPage { | @@ -68,6 +68,8 @@ export class WDRouterPage { | ||
| 68 | static aboutPage = new WDRouterPage("wdComponent", "ets/components/page/SettingAboutPage"); | 68 | static aboutPage = new WDRouterPage("wdComponent", "ets/components/page/SettingAboutPage"); |
| 69 | // 设置页 | 69 | // 设置页 |
| 70 | static settingPage = new WDRouterPage("wdComponent", "ets/components/page/SettingPage"); | 70 | static settingPage = new WDRouterPage("wdComponent", "ets/components/page/SettingPage"); |
| 71 | + // 设置页 | ||
| 72 | + static logoutPage = new WDRouterPage("wdComponent", "ets/components/setting/LogoutPage"); | ||
| 71 | // 设置密码页、设置手机号页等等 (需要传参) | 73 | // 设置密码页、设置手机号页等等 (需要传参) |
| 72 | static settingPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/SettingPasswordPage"); | 74 | static settingPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/SettingPasswordPage"); |
| 73 | //其他普通用户 主页 | 75 | //其他普通用户 主页 |
| 1 | 1 | ||
| 2 | -import { BottomNavi, CommonConstants } from 'wdConstant'; | ||
| 3 | -import { Logger } from 'wdKit'; | 2 | +import { BottomNavi, CommonConstants, SpConstants } from 'wdConstant'; |
| 3 | +import { Logger, SPHelper, ToastUtils, UserDataLocal } from 'wdKit'; | ||
| 4 | import { TopNavigationComponent } from '../page/TopNavigationComponent'; | 4 | import { TopNavigationComponent } from '../page/TopNavigationComponent'; |
| 5 | import PageViewModel from '../../viewmodel/PageViewModel'; | 5 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 6 | import {MineMainSettingFunctionItem} from '../../viewmodel/MineMainSettingFunctionItem'; | 6 | import {MineMainSettingFunctionItem} from '../../viewmodel/MineMainSettingFunctionItem'; |
| @@ -15,6 +15,8 @@ import { SettingPasswordParams } from 'wdLogin'; | @@ -15,6 +15,8 @@ import { SettingPasswordParams } from 'wdLogin'; | ||
| 15 | import { LoginViewModel } from 'wdLogin/src/main/ets/pages/login/LoginViewModel'; | 15 | import { LoginViewModel } from 'wdLogin/src/main/ets/pages/login/LoginViewModel'; |
| 16 | import { Router } from '@ohos.arkui.UIContext'; | 16 | import { Router } from '@ohos.arkui.UIContext'; |
| 17 | import promptAction from '@ohos.promptAction'; | 17 | import promptAction from '@ohos.promptAction'; |
| 18 | +import { LogoutViewModel } from '../../viewmodel/LogoutViewModel'; | ||
| 19 | +import { CustomLogoutDialog } from './CustomLogoutDialog'; | ||
| 18 | 20 | ||
| 19 | export { SettingPasswordParams } from "wdLogin" | 21 | export { SettingPasswordParams } from "wdLogin" |
| 20 | 22 | ||
| @@ -23,28 +25,82 @@ export struct AccountAndSecurityLayout { | @@ -23,28 +25,82 @@ export struct AccountAndSecurityLayout { | ||
| 23 | @State listData: Array<MineMainSettingFunctionItem> = new Array; | 25 | @State listData: Array<MineMainSettingFunctionItem> = new Array; |
| 24 | @State privacySwitch: boolean = false | 26 | @State privacySwitch: boolean = false |
| 25 | @State cacheSice: number = 0 | 27 | @State cacheSice: number = 0 |
| 28 | + @State protocolState: boolean = false //协议勾选状态 | ||
| 29 | + @State isAccountPage: boolean = true | ||
| 30 | + logoutViewModel = new LogoutViewModel() | ||
| 31 | + dialogController: CustomDialogController = new CustomDialogController({ | ||
| 32 | + builder: CustomLogoutDialog({ | ||
| 33 | + cancel: () => { | ||
| 34 | + | ||
| 35 | + }, | ||
| 36 | + confirm: () => { | ||
| 37 | + this.requestLogout() | ||
| 38 | + } | ||
| 39 | + }), | ||
| 40 | + customStyle: true, | ||
| 41 | + alignment: DialogAlignment.Center | ||
| 42 | + }) | ||
| 26 | 43 | ||
| 27 | aboutToAppear() { | 44 | aboutToAppear() { |
| 28 | // 获取设置页面数据 | 45 | // 获取设置页面数据 |
| 29 | this.getAccountAndSecurityData() | 46 | this.getAccountAndSecurityData() |
| 30 | } | 47 | } |
| 31 | 48 | ||
| 32 | - getAccountAndSecurityData() { | ||
| 33 | - this.listData = MineSettingDatasModel.getAccountAndSecuritySettingData() | 49 | + async getAccountAndSecurityData() { |
| 50 | + let oldList = MineSettingDatasModel.getAccountAndSecuritySettingData(); | ||
| 51 | + let phone = await SPHelper.default.get(SpConstants.USER_PHONE, '') as string | ||
| 52 | + if (phone != '') { | ||
| 53 | + oldList[0].subTitle = this.securityPhone(phone) | ||
| 54 | + } | ||
| 55 | + this.listData = oldList | ||
| 56 | + | ||
| 34 | } | 57 | } |
| 35 | 58 | ||
| 36 | build() { | 59 | build() { |
| 37 | - Navigation() { | ||
| 38 | - //滑动区域 | ||
| 39 | - this.settingList() | ||
| 40 | - }.titleMode(NavigationTitleMode.Mini) | ||
| 41 | - .title('账号与安全') | 60 | + Column(){ |
| 61 | + if(this.isAccountPage){ | ||
| 62 | + this.settingList() | ||
| 63 | + }else { | ||
| 64 | + this.logoutLayout() | ||
| 65 | + } | ||
| 66 | + } | ||
| 42 | } | 67 | } |
| 43 | 68 | ||
| 44 | // 页面布局 | 69 | // 页面布局 |
| 45 | @Builder settingList() { | 70 | @Builder settingList() { |
| 46 | Stack({ alignContent: Alignment.Bottom }) { | 71 | Stack({ alignContent: Alignment.Bottom }) { |
| 47 | Column() { | 72 | Column() { |
| 73 | + RelativeContainer() { | ||
| 74 | + Text('账户与安全') | ||
| 75 | + .fontColor('#FF333333') | ||
| 76 | + .fontSize(18) | ||
| 77 | + .textAlign(TextAlign.Center) | ||
| 78 | + .height(44) | ||
| 79 | + .alignRules({ | ||
| 80 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 81 | + left: { anchor: "__container__", align: HorizontalAlign.Start }, | ||
| 82 | + right: { anchor: "__container__", align: HorizontalAlign.End }, | ||
| 83 | + | ||
| 84 | + }) | ||
| 85 | + .id('titleContent') | ||
| 86 | + Image($r('app.media.back_icon')) | ||
| 87 | + .objectFit(ImageFit.Auto) | ||
| 88 | + .height(24) | ||
| 89 | + .width(24) | ||
| 90 | + .margin({ | ||
| 91 | + left: 16, top: 8 | ||
| 92 | + }) | ||
| 93 | + .alignRules({ | ||
| 94 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 95 | + left: { anchor: "__container__", align: HorizontalAlign.Start }, | ||
| 96 | + }) | ||
| 97 | + .onClick(() => { | ||
| 98 | + router.back() | ||
| 99 | + }) | ||
| 100 | + .id('backImage') | ||
| 101 | + | ||
| 102 | + }.height(44) | ||
| 103 | + | ||
| 48 | List() { | 104 | List() { |
| 49 | ForEach(this.listData, (item: MineMainSettingFunctionItem, index: number) => { | 105 | ForEach(this.listData, (item: MineMainSettingFunctionItem, index: number) => { |
| 50 | ListItem() { | 106 | ListItem() { |
| @@ -69,6 +125,9 @@ export struct AccountAndSecurityLayout { | @@ -69,6 +125,9 @@ export struct AccountAndSecurityLayout { | ||
| 69 | 125 | ||
| 70 | let pageType = {'pageType': 1} as Record<string, number>; | 126 | let pageType = {'pageType': 1} as Record<string, number>; |
| 71 | WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType) | 127 | WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType) |
| 128 | + }else if (index == 8) { | ||
| 129 | + this.isAccountPage=false | ||
| 130 | + // WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType) | ||
| 72 | } | 131 | } |
| 73 | }) | 132 | }) |
| 74 | 133 | ||
| @@ -104,8 +163,7 @@ export struct AccountAndSecurityLayout { | @@ -104,8 +163,7 @@ export struct AccountAndSecurityLayout { | ||
| 104 | // }) | 163 | // }) |
| 105 | }) | 164 | }) |
| 106 | } | 165 | } |
| 107 | - | ||
| 108 | - } | 166 | + } |
| 109 | } | 167 | } |
| 110 | 168 | ||
| 111 | @Builder itemHead(text: string) { | 169 | @Builder itemHead(text: string) { |
| @@ -115,6 +173,147 @@ export struct AccountAndSecurityLayout { | @@ -115,6 +173,147 @@ export struct AccountAndSecurityLayout { | ||
| 115 | } | 173 | } |
| 116 | } | 174 | } |
| 117 | 175 | ||
| 176 | + @Builder logoutLayout(){ | ||
| 177 | + RelativeContainer() { | ||
| 178 | + Column() { | ||
| 179 | + RelativeContainer() { | ||
| 180 | + Text('注销账号') | ||
| 181 | + .fontColor('#FF333333') | ||
| 182 | + .fontSize(18) | ||
| 183 | + .textAlign(TextAlign.Center) | ||
| 184 | + .height(44) | ||
| 185 | + .alignRules({ | ||
| 186 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 187 | + left: { anchor: "__container__", align: HorizontalAlign.Start }, | ||
| 188 | + right: { anchor: "__container__", align: HorizontalAlign.End }, | ||
| 189 | + | ||
| 190 | + }) | ||
| 191 | + .id('titleContent') | ||
| 192 | + Image($r('app.media.back_icon')) | ||
| 193 | + .objectFit(ImageFit.Auto) | ||
| 194 | + .height(24) | ||
| 195 | + .width(24) | ||
| 196 | + .margin({ | ||
| 197 | + left: 16, top: 8 | ||
| 198 | + }) | ||
| 199 | + .alignRules({ | ||
| 200 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 201 | + left: { anchor: "__container__", align: HorizontalAlign.Start }, | ||
| 202 | + }) | ||
| 203 | + .onClick(() => { | ||
| 204 | + this.isAccountPage=true | ||
| 205 | + this.protocolState=false | ||
| 206 | + }) | ||
| 207 | + .id('backImage') | ||
| 208 | + | ||
| 209 | + }.height(44) | ||
| 210 | + | ||
| 211 | + Text('为保证您的账号安全,在您提交的注销申请生效前,需同时满足以下几个条件:') | ||
| 212 | + .fontColor('#FF222222') | ||
| 213 | + .fontSize(16) | ||
| 214 | + .fontWeight(600) | ||
| 215 | + .padding({ top:17,left: 16, right: 16 }) | ||
| 216 | + .width('100%') | ||
| 217 | + | ||
| 218 | + Text('1. 账号处于安全状态') | ||
| 219 | + .fontColor('#FF222222') | ||
| 220 | + .fontSize(16) | ||
| 221 | + .fontWeight(600) | ||
| 222 | + .padding({ top: 24, left: 16 }) | ||
| 223 | + .width('100%') | ||
| 224 | + | ||
| 225 | + Text('账号处于正常使用状态,无被盗风险。') | ||
| 226 | + .fontColor('#FF666666') | ||
| 227 | + .fontSize(14) | ||
| 228 | + .fontWeight(400) | ||
| 229 | + .padding({ top: 8, left: 16 }) | ||
| 230 | + .width('100%') | ||
| 231 | + | ||
| 232 | + Text('2. 账号权限解除') | ||
| 233 | + .fontColor('#FF222222') | ||
| 234 | + .fontSize(16) | ||
| 235 | + .fontWeight(600) | ||
| 236 | + .padding({ top: 24, left: 16 }) | ||
| 237 | + .width('100%') | ||
| 238 | + | ||
| 239 | + Text('账号已解除与其他产品的授权登录或绑定关系。') | ||
| 240 | + .fontColor('#FF666666') | ||
| 241 | + .fontSize(14) | ||
| 242 | + .fontWeight(400) | ||
| 243 | + .padding({ top: 8, left: 16 }) | ||
| 244 | + .width('100%') | ||
| 245 | + | ||
| 246 | + Text('3. 账号无任何纠纷,包括举报投诉') | ||
| 247 | + .fontColor('#FF222222') | ||
| 248 | + .fontSize(16) | ||
| 249 | + .fontWeight(600) | ||
| 250 | + .padding({ top: 24, left: 16 }) | ||
| 251 | + .width('100%') | ||
| 252 | + | ||
| 253 | + Text('请注意:注销后7天内不能再次注册人民日报客户端,需要等到账号冷静期结束才能再次登录注册') | ||
| 254 | + .fontColor('#FFED2800') | ||
| 255 | + .fontSize(14) | ||
| 256 | + .fontWeight(400) | ||
| 257 | + .padding({ top: 32, left: 16, right: 16 }) | ||
| 258 | + .width('100%') | ||
| 259 | + | ||
| 260 | + }.alignRules({ | ||
| 261 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 262 | + left: { anchor: "__container__", align: HorizontalAlign.Start }, | ||
| 263 | + }) | ||
| 264 | + .width('100%') | ||
| 265 | + .id('title') | ||
| 266 | + | ||
| 267 | + | ||
| 268 | + Column() { | ||
| 269 | + Row() { | ||
| 270 | + Image(this.protocolState ? $r("app.media.logout_checkbox_select") : $r("app.media.logout_checkbox_unselected")) | ||
| 271 | + .width(15) | ||
| 272 | + .height(15) | ||
| 273 | + .onClick(() => { | ||
| 274 | + this.protocolState = !this.protocolState | ||
| 275 | + | ||
| 276 | + }) | ||
| 277 | + | ||
| 278 | + Text() { | ||
| 279 | + Span("我已阅读并同意").fontColor("#999999").fontSize(12) | ||
| 280 | + Span("《用户注销协议》").fontColor("#ED2800").fontSize(12).onClick(() => { | ||
| 281 | + let bean = { contentID: "3", pageID: "" } as Params | ||
| 282 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean) | ||
| 283 | + }) | ||
| 284 | + } | ||
| 285 | + }.alignItems(VerticalAlign.Center) | ||
| 286 | + | ||
| 287 | + Row() { | ||
| 288 | + Text("登录") | ||
| 289 | + .borderRadius(4) | ||
| 290 | + .fontColor(this.protocolState ? "#FFFFFFFF" : "#66FFFFFF") | ||
| 291 | + .fontSize(18) | ||
| 292 | + .fontWeight(FontWeight.Medium) | ||
| 293 | + .margin({ top: 20 }) | ||
| 294 | + .height(44) | ||
| 295 | + .textAlign(TextAlign.Center) | ||
| 296 | + .width("100%") | ||
| 297 | + .backgroundColor(this.protocolState ? "#FFED2800" : "#99ED2800") | ||
| 298 | + .onClick(() => { | ||
| 299 | + if (!this.protocolState) { | ||
| 300 | + return | ||
| 301 | + } | ||
| 302 | + this.dialogController.open() | ||
| 303 | + | ||
| 304 | + }) | ||
| 305 | + }.padding({ left: 25, right: 25 }).width('100%') | ||
| 306 | + }.alignRules({ | ||
| 307 | + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 308 | + left: { anchor: "__container__", align: HorizontalAlign.Start }, | ||
| 309 | + right: { anchor: "__container__", align: HorizontalAlign.End }, | ||
| 310 | + | ||
| 311 | + }) | ||
| 312 | + .margin({ bottom: 15 }) | ||
| 313 | + .id('bottom') | ||
| 314 | + }.width('100%') | ||
| 315 | + } | ||
| 316 | + | ||
| 118 | // 右侧开关cell | 317 | // 右侧开关cell |
| 119 | @Builder getSwitchCell(item: MineMainSettingFunctionItem) { | 318 | @Builder getSwitchCell(item: MineMainSettingFunctionItem) { |
| 120 | Column() { | 319 | Column() { |
| @@ -189,4 +388,20 @@ export struct AccountAndSecurityLayout { | @@ -189,4 +388,20 @@ export struct AccountAndSecurityLayout { | ||
| 189 | } | 388 | } |
| 190 | .height('54lpx') | 389 | .height('54lpx') |
| 191 | } | 390 | } |
| 391 | + | ||
| 392 | + | ||
| 393 | + //注销账号 | ||
| 394 | + requestLogout() { | ||
| 395 | + this.logoutViewModel.requestLogout().then(()=>{ | ||
| 396 | + ToastUtils.shortToast("注销成功") | ||
| 397 | + router.back() | ||
| 398 | + }) | ||
| 399 | + } | ||
| 400 | + | ||
| 401 | + securityPhone(phoneNum:string):string{ | ||
| 402 | + let securityNum:string; | ||
| 403 | + let needSecurityString = phoneNum.substring(3, phoneNum.length - 4); | ||
| 404 | + securityNum = phoneNum.replace(needSecurityString,'****') | ||
| 405 | + return securityNum; | ||
| 406 | + } | ||
| 192 | } | 407 | } |
| 1 | +@CustomDialog | ||
| 2 | +export struct CustomCacheDialog { | ||
| 3 | + controller: CustomDialogController | ||
| 4 | + cancel: () => void = () => { | ||
| 5 | + } | ||
| 6 | + confirm: () => void = () => { | ||
| 7 | + } | ||
| 8 | + | ||
| 9 | + build() { | ||
| 10 | + Column() { | ||
| 11 | + Text("清理缓存") | ||
| 12 | + .fontColor("#222222") | ||
| 13 | + .fontSize(18) | ||
| 14 | + .width("100%") | ||
| 15 | + .fontWeight(FontWeight.Bold) | ||
| 16 | + .textAlign(TextAlign.Center) | ||
| 17 | + .margin({ top: 20 }) | ||
| 18 | + Text('是否确认清理此App的缓存') { | ||
| 19 | + | ||
| 20 | + }.margin({ top: 12, left: 16, right: 16 }) | ||
| 21 | + | ||
| 22 | + Divider().color("#999999").width("100%").margin({ top: 14 }).height('1vp') | ||
| 23 | + Row() { | ||
| 24 | + Text('取消') | ||
| 25 | + .fontSize(16) | ||
| 26 | + .fontColor("#999999") | ||
| 27 | + .layoutWeight(1) | ||
| 28 | + .fontWeight(FontWeight.Medium) | ||
| 29 | + .textAlign(TextAlign.Center) | ||
| 30 | + .onClick(() => { | ||
| 31 | + this.controller.close() | ||
| 32 | + if (this.cancel) { | ||
| 33 | + this.cancel() | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + }) | ||
| 37 | + .height('100%') | ||
| 38 | + // Divider().color("#999999").height('100%').width('0.5vp') | ||
| 39 | + Text('确认') | ||
| 40 | + .fontSize(16) | ||
| 41 | + .fontColor("#ED2800") | ||
| 42 | + .layoutWeight(1) | ||
| 43 | + .fontWeight(FontWeight.Medium) | ||
| 44 | + .textAlign(TextAlign.Center) | ||
| 45 | + .border({ | ||
| 46 | + width: { left: 1 }, | ||
| 47 | + color: "#999999", | ||
| 48 | + style: { left: BorderStyle.Solid } | ||
| 49 | + | ||
| 50 | + }) | ||
| 51 | + .onClick(() => { | ||
| 52 | + this.controller.close() | ||
| 53 | + if (this.confirm) { | ||
| 54 | + this.confirm() | ||
| 55 | + } | ||
| 56 | + }) | ||
| 57 | + .height('100%') | ||
| 58 | + }.layoutWeight(1).justifyContent(FlexAlign.Center) | ||
| 59 | + }.height(161).backgroundColor(Color.White).borderRadius(6).width('74%') | ||
| 60 | + } | ||
| 61 | +} |
sight_harmony/features/wdComponent/src/main/ets/components/setting/CustomLogoutDialog.ets
0 → 100644
| 1 | +@CustomDialog | ||
| 2 | +export struct CustomLogoutDialog { | ||
| 3 | + controller: CustomDialogController | ||
| 4 | + cancel: () => void = () => { | ||
| 5 | + } | ||
| 6 | + confirm: () => void = () => { | ||
| 7 | + } | ||
| 8 | + | ||
| 9 | + build() { | ||
| 10 | + Column() { | ||
| 11 | + Text("温馨提示") | ||
| 12 | + .fontColor("#222222") | ||
| 13 | + .fontSize(18) | ||
| 14 | + .width("100%") | ||
| 15 | + .fontWeight(FontWeight.Bold) | ||
| 16 | + .textAlign(TextAlign.Center) | ||
| 17 | + .margin({ top: 20 }) | ||
| 18 | + Text('注销后7天内无法重新登录注册人民日报app,是否确认注销?') { | ||
| 19 | + | ||
| 20 | + }.margin({ top: 12, left: 16, right: 16 }) | ||
| 21 | + | ||
| 22 | + Divider().color("#999999").width("100%").margin({ top: 14 }).height('1vp') | ||
| 23 | + Row() { | ||
| 24 | + Text('放弃') | ||
| 25 | + .fontSize(16) | ||
| 26 | + .fontColor("#999999") | ||
| 27 | + .layoutWeight(1) | ||
| 28 | + .fontWeight(FontWeight.Medium) | ||
| 29 | + .textAlign(TextAlign.Center) | ||
| 30 | + .onClick(() => { | ||
| 31 | + this.controller.close() | ||
| 32 | + if (this.cancel) { | ||
| 33 | + this.cancel() | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + }) | ||
| 37 | + .height('100%') | ||
| 38 | + // Divider().color("#999999").height('100%').width('0.5vp') | ||
| 39 | + Text('同意注销') | ||
| 40 | + .fontSize(16) | ||
| 41 | + .fontColor("#ED2800") | ||
| 42 | + .layoutWeight(1) | ||
| 43 | + .fontWeight(FontWeight.Medium) | ||
| 44 | + .textAlign(TextAlign.Center) | ||
| 45 | + .border({ | ||
| 46 | + width: { left: 1 }, | ||
| 47 | + color: "#999999", | ||
| 48 | + style: { left: BorderStyle.Solid } | ||
| 49 | + | ||
| 50 | + }) | ||
| 51 | + .onClick(() => { | ||
| 52 | + this.controller.close() | ||
| 53 | + if (this.confirm) { | ||
| 54 | + this.confirm() | ||
| 55 | + } | ||
| 56 | + }) | ||
| 57 | + .height('100%') | ||
| 58 | + }.layoutWeight(1).justifyContent(FlexAlign.Center) | ||
| 59 | + }.height(161).backgroundColor(Color.White).borderRadius(6).width('74%') | ||
| 60 | + } | ||
| 61 | +} |
| 1 | -import { BottomNavi, CommonConstants } from 'wdConstant'; | ||
| 2 | -import { Logger } from 'wdKit'; | 1 | +import { BottomNavi, CommonConstants, SpConstants } from 'wdConstant'; |
| 2 | +import { Logger, SPHelper } from 'wdKit'; | ||
| 3 | import PageViewModel from '../../viewmodel/PageViewModel'; | 3 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 4 | import storageStatistics from "@ohos.file.storageStatistics"; | 4 | import storageStatistics from "@ohos.file.storageStatistics"; |
| 5 | import { BusinessError } from '@ohos.base'; | 5 | import { BusinessError } from '@ohos.base'; |
| 6 | import router from '@ohos.router'; | 6 | import router from '@ohos.router'; |
| 7 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; | 7 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; |
| 8 | import { Params } from 'wdBean'; | 8 | import { Params } from 'wdBean'; |
| 9 | +import { common } from '@kit.AbilityKit'; | ||
| 10 | +import fs from '@ohos.file.fs'; | ||
| 11 | +import { CustomCacheDialog } from './CustomCacheDialog'; | ||
| 12 | +import MineSettingDatasModel from '../../model/MineSettingDatasModel'; | ||
| 13 | +import { MineMainSettingFunctionItem } from '../../viewmodel/MineMainSettingFunctionItem'; | ||
| 9 | 14 | ||
| 10 | 15 | ||
| 11 | @Component | 16 | @Component |
| 12 | export struct MineSettingComponent { | 17 | export struct MineSettingComponent { |
| 13 | - @State listData: Array<string | Array<string>> = new Array(); | 18 | + // @State listData: Array<string | Array<string>> = new Array(); |
| 19 | + @State listData: Array<MineMainSettingFunctionItem> = new Array; | ||
| 14 | @State privacySwitch: boolean = false | 20 | @State privacySwitch: boolean = false |
| 15 | - @State cacheSice: number = 0 | 21 | + @State cacheSize: number = 0 |
| 22 | + @State accountState:boolean=false | ||
| 23 | + dialogController: CustomDialogController = new CustomDialogController({ | ||
| 24 | + builder: CustomCacheDialog({ | ||
| 25 | + cancel: () => { | ||
| 16 | 26 | ||
| 27 | + }, | ||
| 28 | + confirm: () => { | ||
| 29 | + this.deleteCache() | ||
| 30 | + } | ||
| 31 | + }), | ||
| 32 | + customStyle: true, | ||
| 33 | + alignment: DialogAlignment.Center | ||
| 34 | + }) | ||
| 17 | aboutToAppear() { | 35 | aboutToAppear() { |
| 18 | // 获取设置页面数据 | 36 | // 获取设置页面数据 |
| 19 | this.getSettingPageData() | 37 | this.getSettingPageData() |
| 20 | 38 | ||
| 21 | - // 获取缓存数据 | ||
| 22 | - storageStatistics.getCurrentBundleStats((err: BusinessError, bundleStats: storageStatistics.BundleStats) => { | ||
| 23 | - if (err) { | ||
| 24 | - console.error(`Invoke getCurrentBundleStats failed, code is ${err.code}, message is ${err.message}`); | ||
| 25 | - } else { | ||
| 26 | - this.cacheSice = bundleStats.cacheSize / 1024.00 / 1024.00; | ||
| 27 | - } | ||
| 28 | - }); | 39 | + this.getCacheSize() |
| 40 | + | ||
| 41 | + this.getAccountState() | ||
| 42 | + | ||
| 29 | } | 43 | } |
| 30 | 44 | ||
| 31 | - getSettingPageData() { | ||
| 32 | - let listArr = [['账户与安全', '接收推送', '隐私设罝', '仅WiFi网络加载图片', 'WiFi网络情况下自动播放视频', '开户播放器悬浮窗'], ['清除缓存', '去评分']]; | ||
| 33 | - this.listData = listArr; | 45 | + async getAccountState(){ |
| 46 | + let userId=await SPHelper.default.get(SpConstants.USER_ID,'') as string | ||
| 47 | + if(userId==''){ | ||
| 48 | + this.accountState=false | ||
| 49 | + }else { | ||
| 50 | + this.accountState=true | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + async getSettingPageData() { | ||
| 55 | + let oldList = MineSettingDatasModel.getMineMainSettingFunctionItemData(); | ||
| 56 | + let userId=await SPHelper.default.get(SpConstants.USER_ID,'') as string | ||
| 57 | + if(userId==''){ | ||
| 58 | + this.listData=oldList.slice(1,oldList.length) | ||
| 59 | + }else { | ||
| 60 | + this.listData = oldList; | ||
| 61 | + } | ||
| 62 | + | ||
| 34 | } | 63 | } |
| 35 | 64 | ||
| 36 | build() { | 65 | build() { |
| @@ -41,53 +70,88 @@ export struct MineSettingComponent { | @@ -41,53 +70,88 @@ export struct MineSettingComponent { | ||
| 41 | .title('设置') | 70 | .title('设置') |
| 42 | } | 71 | } |
| 43 | 72 | ||
| 73 | + // // 页面布局 | ||
| 74 | + // @Builder settingList() { | ||
| 75 | + // Column() { | ||
| 76 | + // List() { | ||
| 77 | + // // 循环渲染ListItemGroup,contactsGroups为多个分组联系人contacts和标题title的数据集合 | ||
| 78 | + // ForEach(this.listData, (item: Array<string>, index: number) => { | ||
| 79 | + // ListItemGroup({ header: index === 0 ? this.itemHead("") : this.itemHead("1") }) { | ||
| 80 | + // // 循环渲染ListItem | ||
| 81 | + // ForEach(item, (subItem: string, subIndex: number) => { | ||
| 82 | + // ListItem() { | ||
| 83 | + // if (subIndex == 6) { | ||
| 84 | + // this.getArrowCell(subItem, subIndex, index) | ||
| 85 | + // } else if (subIndex == 1 || subIndex == 3 || subIndex == 4 || subIndex == 5) { | ||
| 86 | + // if (subIndex == 1 && index == 1) { | ||
| 87 | + // this.getArrowCell(subItem, subIndex, index) | ||
| 88 | + // } else { | ||
| 89 | + // this.getSwitchCell(subItem, subIndex) | ||
| 90 | + // } | ||
| 91 | + // | ||
| 92 | + // } else { | ||
| 93 | + // this.getArrowCell(subItem, subIndex, index) | ||
| 94 | + // } | ||
| 95 | + // | ||
| 96 | + // }.padding({ left: '27lpx' }) | ||
| 97 | + // .onClick(() => { | ||
| 98 | + // | ||
| 99 | + // // // 在Home页面中 | ||
| 100 | + // // let paramsInfo: object = { | ||
| 101 | + // // pageId: 123, | ||
| 102 | + // // pageType:'AccountAndSecurityLayout' | ||
| 103 | + // // }; | ||
| 104 | + // console.log(subIndex + "") | ||
| 105 | + // if (subIndex == 0 && index == 0) { | ||
| 106 | + // | ||
| 107 | + // let params: Params = { | ||
| 108 | + // pageID: 'AccountAndSecurityLayout' | ||
| 109 | + // } | ||
| 110 | + // WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params) | ||
| 111 | + // }else if (subIndex == 2 && index == 0) { | ||
| 112 | + // WDRouterRule.jumpWithPage(WDRouterPage.privacySettingPage) | ||
| 113 | + // }else if (subIndex == 0 && index == 1) { | ||
| 114 | + // this.dialogController.open() | ||
| 115 | + // } | ||
| 116 | + // | ||
| 117 | + // }) | ||
| 118 | + // .height('117lpx') | ||
| 119 | + // }) | ||
| 120 | + // } | ||
| 121 | + // .divider({ | ||
| 122 | + // strokeWidth: 1, | ||
| 123 | + // startMargin: 15, | ||
| 124 | + // endMargin: 10, | ||
| 125 | + // color: '#f0f0f0' | ||
| 126 | + // }) | ||
| 127 | + // }) | ||
| 128 | + // }.onScrollFrameBegin((offset, state) => { | ||
| 129 | + // return { offsetRemain: 0 } | ||
| 130 | + // }) | ||
| 131 | + // } | ||
| 132 | + // .backgroundColor(Color.White) | ||
| 133 | + // .borderRadius(8) | ||
| 134 | + // } | ||
| 135 | + | ||
| 44 | // 页面布局 | 136 | // 页面布局 |
| 45 | @Builder settingList() { | 137 | @Builder settingList() { |
| 46 | Column() { | 138 | Column() { |
| 47 | List() { | 139 | List() { |
| 48 | // 循环渲染ListItemGroup,contactsGroups为多个分组联系人contacts和标题title的数据集合 | 140 | // 循环渲染ListItemGroup,contactsGroups为多个分组联系人contacts和标题title的数据集合 |
| 49 | - ForEach(this.listData, (item: Array<string>, index: number) => { | ||
| 50 | - ListItemGroup({ header: index === 0 ? this.itemHead("") : this.itemHead("1") }) { | ||
| 51 | - // 循环渲染ListItem | ||
| 52 | - ForEach(item, (subItem: string, subIndex: number) => { | ||
| 53 | - ListItem() { | ||
| 54 | - if (subIndex == 6) { | ||
| 55 | - this.getArrowCell(subItem, subIndex, index) | ||
| 56 | - } else if (subIndex == 1 || subIndex == 3 || subIndex == 4 || subIndex == 5) { | ||
| 57 | - this.getSwitchCell(subItem, subIndex) | ||
| 58 | - } else { | ||
| 59 | - this.getArrowCell(subItem, subIndex, index) | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - }.padding({ left: '27lpx' }) | ||
| 63 | - .onClick(() => { | ||
| 64 | - | ||
| 65 | - // // 在Home页面中 | ||
| 66 | - // let paramsInfo: object = { | ||
| 67 | - // pageId: 123, | ||
| 68 | - // pageType:'AccountAndSecurityLayout' | ||
| 69 | - // }; | ||
| 70 | - console.log(subIndex + "") | ||
| 71 | - if (subIndex == 0 && index == 0) { | ||
| 72 | - | ||
| 73 | - let params: Params = { | ||
| 74 | - pageID: 'AccountAndSecurityLayout' | ||
| 75 | - } | ||
| 76 | - WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params) | ||
| 77 | - }else if (subIndex == 2 && index == 0) { | ||
| 78 | - WDRouterRule.jumpWithPage(WDRouterPage.privacySettingPage) | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - }) | ||
| 82 | - .height('117lpx') | ||
| 83 | - }) | 141 | + ForEach(this.listData, (item: MineMainSettingFunctionItem, index: number) => { |
| 142 | + ListItem() { | ||
| 143 | + if (item.type == 0) { | ||
| 144 | + Column() { | ||
| 145 | + this.getArrowCell(item,index) | ||
| 146 | + }.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center) | ||
| 147 | + } else if (item.type == 1) { | ||
| 148 | + Column() { | ||
| 149 | + this.getSwitchCell(item,index) | ||
| 150 | + }.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center) | ||
| 151 | + } else { | ||
| 152 | + Column().width('100%').height('15lpx').backgroundColor(0xf0f0f0) | ||
| 153 | + } | ||
| 84 | } | 154 | } |
| 85 | - .divider({ | ||
| 86 | - strokeWidth: 1, | ||
| 87 | - startMargin: 15, | ||
| 88 | - endMargin: 10, | ||
| 89 | - color: '#f0f0f0' | ||
| 90 | - }) | ||
| 91 | }) | 155 | }) |
| 92 | }.onScrollFrameBegin((offset, state) => { | 156 | }.onScrollFrameBegin((offset, state) => { |
| 93 | return { offsetRemain: 0 } | 157 | return { offsetRemain: 0 } |
| @@ -105,7 +169,7 @@ export struct MineSettingComponent { | @@ -105,7 +169,7 @@ export struct MineSettingComponent { | ||
| 105 | } | 169 | } |
| 106 | 170 | ||
| 107 | // 右侧开关cell | 171 | // 右侧开关cell |
| 108 | - @Builder getSwitchCell(item:string, index:number) { | 172 | + @Builder getSwitchCell(item:MineMainSettingFunctionItem, index:number) { |
| 109 | Column() { | 173 | Column() { |
| 110 | Row() { | 174 | Row() { |
| 111 | // 左侧logo和标题 | 175 | // 左侧logo和标题 |
| @@ -116,13 +180,13 @@ export struct MineSettingComponent { | @@ -116,13 +180,13 @@ export struct MineSettingComponent { | ||
| 116 | .height('38lpx') | 180 | .height('38lpx') |
| 117 | .margin({ right: '5lpx' }) | 181 | .margin({ right: '5lpx' }) |
| 118 | 182 | ||
| 119 | - Text(`${item}`) | 183 | + Text(`${item.title}`) |
| 120 | .margin({ top: '8lpx' }) | 184 | .margin({ top: '8lpx' }) |
| 121 | .height('38lpx') | 185 | .height('38lpx') |
| 122 | .fontColor('#333333') | 186 | .fontColor('#333333') |
| 123 | .fontSize('29lpx') | 187 | .fontSize('29lpx') |
| 124 | } else { | 188 | } else { |
| 125 | - Text(`${item}`) | 189 | + Text(`${item.title}`) |
| 126 | .margin({ top: '8lpx' }) | 190 | .margin({ top: '8lpx' }) |
| 127 | .height('38lpx') | 191 | .height('38lpx') |
| 128 | .fontColor('#333333') | 192 | .fontColor('#333333') |
| @@ -137,7 +201,16 @@ export struct MineSettingComponent { | @@ -137,7 +201,16 @@ export struct MineSettingComponent { | ||
| 137 | .margin({ left: '81lpx', right: '29lpx' }) | 201 | .margin({ left: '81lpx', right: '29lpx' }) |
| 138 | .selectedColor(Color.Pink) | 202 | .selectedColor(Color.Pink) |
| 139 | .onChange((isOn: boolean) => { | 203 | .onChange((isOn: boolean) => { |
| 140 | - this.privacySwitch = isOn; | 204 | + if(item.title=='接收推送'){ |
| 205 | + //推送 | ||
| 206 | + SPHelper.default.save(SpConstants.SETTING_PUSH_SWITCH,isOn) | ||
| 207 | + }else if(item.title=='仅WiFi网络加载图片'){ | ||
| 208 | + //wifi 图片 | ||
| 209 | + SPHelper.default.save(SpConstants.SETTING_WIFI_IMAGE_SWITCH,isOn) | ||
| 210 | + }else if(item.title=='WiFi网络情况下自动播放视频'){ | ||
| 211 | + //wifi 视频 | ||
| 212 | + SPHelper.default.save(SpConstants.SETTING_WIFI_VIDEO_SWITCH,isOn) | ||
| 213 | + } | ||
| 141 | }) | 214 | }) |
| 142 | }.width('40%') | 215 | }.width('40%') |
| 143 | .margin({ right: '29lpx' }) | 216 | .margin({ right: '29lpx' }) |
| @@ -150,7 +223,7 @@ export struct MineSettingComponent { | @@ -150,7 +223,7 @@ export struct MineSettingComponent { | ||
| 150 | } | 223 | } |
| 151 | 224 | ||
| 152 | // 右文字+箭头cell | 225 | // 右文字+箭头cell |
| 153 | - @Builder getArrowCell(item:string, index:number, mainIndex:number) { | 226 | + @Builder getArrowCell(item:MineMainSettingFunctionItem, index:number) { |
| 154 | Column() { | 227 | Column() { |
| 155 | 228 | ||
| 156 | Row() { | 229 | Row() { |
| @@ -162,7 +235,7 @@ export struct MineSettingComponent { | @@ -162,7 +235,7 @@ export struct MineSettingComponent { | ||
| 162 | // .height('38lpx') | 235 | // .height('38lpx') |
| 163 | // .margin({ right: '5lpx' }) | 236 | // .margin({ right: '5lpx' }) |
| 164 | // } | 237 | // } |
| 165 | - Text(`${item}`) | 238 | + Text(`${item.title}`) |
| 166 | .margin({ top: '8lpx' }) | 239 | .margin({ top: '8lpx' }) |
| 167 | .height('38lpx') | 240 | .height('38lpx') |
| 168 | .fontColor('#333333') | 241 | .fontColor('#333333') |
| @@ -171,7 +244,7 @@ export struct MineSettingComponent { | @@ -171,7 +244,7 @@ export struct MineSettingComponent { | ||
| 171 | 244 | ||
| 172 | // 右侧文案和右箭头 | 245 | // 右侧文案和右箭头 |
| 173 | Row() { | 246 | Row() { |
| 174 | - Text((index == 0 && mainIndex != 0) ? this.cacheSice.toFixed(2) + 'MB' : '') | 247 | + Text((item.title=='清除缓存') ? this.cacheSize.toFixed(2) + 'MB' : '') |
| 175 | .fontColor('#999999') | 248 | .fontColor('#999999') |
| 176 | .maxLines(1) | 249 | .maxLines(1) |
| 177 | Image($r('app.media.mine_user_arrow')) | 250 | Image($r('app.media.mine_user_arrow')) |
| @@ -189,5 +262,45 @@ export struct MineSettingComponent { | @@ -189,5 +262,45 @@ export struct MineSettingComponent { | ||
| 189 | 262 | ||
| 190 | } | 263 | } |
| 191 | .height('54lpx') | 264 | .height('54lpx') |
| 265 | + .onClick(() => { | ||
| 266 | + if (item.title == '账户与安全') { | ||
| 267 | + let params: Params = { | ||
| 268 | + pageID: 'AccountAndSecurityLayout' | ||
| 269 | + } | ||
| 270 | + WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params) | ||
| 271 | + } else if (item.title == '隐私设罝') { | ||
| 272 | + WDRouterRule.jumpWithPage(WDRouterPage.privacySettingPage) | ||
| 273 | + } else if (item.title == '清除缓存') { | ||
| 274 | + this.dialogController.open() | ||
| 275 | + } | ||
| 276 | + }) | ||
| 277 | + | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + //删除缓存 | ||
| 281 | + deleteCache() { | ||
| 282 | + let context = getContext(this) as common.UIAbilityContext | ||
| 283 | + let application = context.getApplicationContext(); | ||
| 284 | + let appPath = application.cacheDir | ||
| 285 | + Logger.debug("MineSettingComponent", appPath) | ||
| 286 | + fs.rmdir(appPath).then(() => { | ||
| 287 | + this.getCacheSize() | ||
| 288 | + }) | ||
| 289 | + let path = context.cacheDir | ||
| 290 | + Logger.debug("MineSettingComponent", path) | ||
| 291 | + fs.rmdir(path).then(() => { | ||
| 292 | + this.getCacheSize() | ||
| 293 | + }) | ||
| 294 | + } | ||
| 295 | + | ||
| 296 | + getCacheSize() { | ||
| 297 | + // 获取缓存数据 | ||
| 298 | + storageStatistics.getCurrentBundleStats((err: BusinessError, bundleStats: storageStatistics.BundleStats) => { | ||
| 299 | + if (err) { | ||
| 300 | + console.error(`Invoke getCurrentBundleStats failed, code is ${err.code}, message is ${err.message}`); | ||
| 301 | + } else { | ||
| 302 | + this.cacheSize = bundleStats.cacheSize / 1024.00 / 1024.00; | ||
| 303 | + } | ||
| 304 | + }); | ||
| 192 | } | 305 | } |
| 193 | } | 306 | } |
| 1 | +import HashMap from '@ohos.util.HashMap'; | ||
| 2 | +import { UserDataLocal } from 'wdKit/Index'; | ||
| 3 | +import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; | ||
| 4 | +import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | ||
| 5 | + | ||
| 6 | +export class LogoutModel{ | ||
| 7 | + | ||
| 8 | + requestLogout(){ | ||
| 9 | + let bean: Record<string, string> = {}; | ||
| 10 | + bean['refreshToken'] = UserDataLocal.USER_REFRESH_TOKEN | ||
| 11 | + bean['refreshToken'] = 'ddrqreeee' | ||
| 12 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 13 | + return new Promise<string>((success, fail) => { | ||
| 14 | + HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.accountLogoutUrl(), bean, headers).then((data: ResponseDTO<string>) => { | ||
| 15 | + if (!data || !data.data) { | ||
| 16 | + fail("数据为空") | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + if (data.code != 0) { | ||
| 20 | + fail(data.message) | ||
| 21 | + return | ||
| 22 | + } | ||
| 23 | + success(data.data) | ||
| 24 | + }, (error: Error) => { | ||
| 25 | + fail(error.message) | ||
| 26 | + // Logger.debug("LoginViewModel:error ", error.toString()) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | +} |
| @@ -48,7 +48,7 @@ class MineSettingDatasModel{ | @@ -48,7 +48,7 @@ class MineSettingDatasModel{ | ||
| 48 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '开户播放器悬浮窗', null, 1, false)) | 48 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '开户播放器悬浮窗', null, 1, false)) |
| 49 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, null, null, 2, null)) | 49 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, null, null, 2, null)) |
| 50 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '清除缓存', '32MB', 0, false)) | 50 | this.mainSettingData.push(new MineMainSettingFunctionItem(null, '清除缓存', '32MB', 0, false)) |
| 51 | - this.mainSettingData.push(new MineMainSettingFunctionItem(null, '去评分', null, 0, false)) | 51 | + this.mainSettingData.push(new MineMainSettingFunctionItem(null, '评价我们', null, 0, false)) |
| 52 | 52 | ||
| 53 | return this.mainSettingData | 53 | return this.mainSettingData |
| 54 | } | 54 | } |
| 1 | +import { SpConstants } from 'wdConstant/Index' | ||
| 2 | +import { SPHelper } from 'wdKit/Index' | ||
| 3 | +import { HttpUrlUtils } from 'wdNetwork/Index' | ||
| 4 | +import { LogoutModel } from '../model/LogoutModel' | ||
| 5 | + | ||
| 6 | +export class LogoutViewModel{ | ||
| 7 | + private logout:LogoutModel | ||
| 8 | + constructor() { | ||
| 9 | + this.logout = new LogoutModel() | ||
| 10 | + } | ||
| 11 | + requestLogout(){ | ||
| 12 | + return new Promise<string>((success, fail) => { | ||
| 13 | + this.logout.requestLogout().then((data) => { | ||
| 14 | + SPHelper.default.save(SpConstants.USER_FIRST_MARK, '') | ||
| 15 | + SPHelper.default.save(SpConstants.USER_ID, '') | ||
| 16 | + SPHelper.default.save(SpConstants.USER_JWT_TOKEN, '') | ||
| 17 | + SPHelper.default.save(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, '') | ||
| 18 | + SPHelper.default.save(SpConstants.USER_REFRESH_TOKEN, '') | ||
| 19 | + SPHelper.default.save(SpConstants.USER_STATUS, '') | ||
| 20 | + SPHelper.default.save(SpConstants.USER_Type, '') | ||
| 21 | + SPHelper.default.save(SpConstants.USER_NAME, '') | ||
| 22 | + SPHelper.default.save(SpConstants.USER_PHONE, '') | ||
| 23 | + HttpUrlUtils.setUserId("") | ||
| 24 | + HttpUrlUtils.setUserType("") | ||
| 25 | + HttpUrlUtils.setUserToken('') | ||
| 26 | + success(data) | ||
| 27 | + }).catch((message: string) => { | ||
| 28 | + fail(message) | ||
| 29 | + }) | ||
| 30 | + }) | ||
| 31 | + } | ||
| 32 | +} |
sight_harmony/features/wdComponent/src/main/resources/base/media/logout_checkbox_select.png
0 → 100644
861 Bytes
sight_harmony/features/wdComponent/src/main/resources/base/media/logout_checkbox_unselected.png
0 → 100644
1015 Bytes
| @@ -7,6 +7,7 @@ import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/ | @@ -7,6 +7,7 @@ import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/ | ||
| 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 | import { Router } from '@ohos.arkui.UIContext' |
| 10 | +import { ToastUtils } from 'wdKit/Index' | ||
| 10 | 11 | ||
| 11 | 12 | ||
| 12 | const TAG = 'ForgetPasswordPage' | 13 | const TAG = 'ForgetPasswordPage' |
| @@ -22,7 +23,7 @@ struct ForgetPasswordPage { | @@ -22,7 +23,7 @@ struct ForgetPasswordPage { | ||
| 22 | loginViewModel: LoginViewModel = new LoginViewModel() | 23 | loginViewModel: LoginViewModel = new LoginViewModel() |
| 23 | @State @Watch('onCodeSend') isCodeSend: boolean = false //验证码点击发送事件 | 24 | @State @Watch('onCodeSend') isCodeSend: boolean = false //验证码点击发送事件 |
| 24 | pageType:number = (router.getParams() as Record<string, number>)['pageType']; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2 | 25 | pageType:number = (router.getParams() as Record<string, number>)['pageType']; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2 |
| 25 | - pageTitle = '找回密码'; | 26 | + @State pageTitle:string = '找回密码'; |
| 26 | onCodeSend() { | 27 | onCodeSend() { |
| 27 | if (this.isCodeSend) { | 28 | if (this.isCodeSend) { |
| 28 | this.sendVerifyCode() | 29 | this.sendVerifyCode() |
| @@ -59,8 +60,11 @@ struct ForgetPasswordPage { | @@ -59,8 +60,11 @@ struct ForgetPasswordPage { | ||
| 59 | .backgroundColor(this.isSubmit ?"#ED2800":"#99ED2800") | 60 | .backgroundColor(this.isSubmit ?"#ED2800":"#99ED2800") |
| 60 | .enabled(this.isSubmit ? true : false) | 61 | .enabled(this.isSubmit ? true : false) |
| 61 | .onClick(() => { | 62 | .onClick(() => { |
| 62 | - this.checkVerifyCode() | ||
| 63 | - | 63 | + if(this.pageType==2){ |
| 64 | + this.changeBindPhone() | ||
| 65 | + }else { | ||
| 66 | + this.checkVerifyCode() | ||
| 67 | + } | ||
| 64 | }) | 68 | }) |
| 65 | }.padding({ left: 25, right: 25 }).width('100%') | 69 | }.padding({ left: 25, right: 25 }).width('100%') |
| 66 | 70 | ||
| @@ -68,13 +72,16 @@ struct ForgetPasswordPage { | @@ -68,13 +72,16 @@ struct ForgetPasswordPage { | ||
| 68 | } | 72 | } |
| 69 | 73 | ||
| 70 | aboutToAppear() { | 74 | aboutToAppear() { |
| 75 | + if (router.getParams()) { | ||
| 76 | + let params = router.getParams() as Record<string, number> | ||
| 77 | + this.pageType = params['pageType'] | ||
| 78 | + Logger.info(TAG, 'params.contentID:' + params.contentID); | ||
| 79 | + } | ||
| 71 | if (this.pageType == 0){ | 80 | if (this.pageType == 0){ |
| 72 | this.pageTitle = '找回密码' | 81 | this.pageTitle = '找回密码' |
| 73 | }else if (this.pageType == 1){ | 82 | }else if (this.pageType == 1){ |
| 74 | this.pageTitle = '验证当前手机号' | 83 | this.pageTitle = '验证当前手机号' |
| 75 | }else if (this.pageType == 2){ | 84 | }else if (this.pageType == 2){ |
| 76 | - this.pageTitle = '验证当前手机号' | ||
| 77 | - }else if (this.pageType == 2){ | ||
| 78 | this.pageTitle = '更换手机号' | 85 | this.pageTitle = '更换手机号' |
| 79 | } | 86 | } |
| 80 | if (this.isCodeSend) { | 87 | if (this.isCodeSend) { |
| @@ -127,4 +134,20 @@ struct ForgetPasswordPage { | @@ -127,4 +134,20 @@ struct ForgetPasswordPage { | ||
| 127 | isEmpty(obj: undefined|null|string): boolean { | 134 | isEmpty(obj: undefined|null|string): boolean { |
| 128 | return (obj == undefined || obj == null || obj == ''); | 135 | return (obj == undefined || obj == null || obj == ''); |
| 129 | } | 136 | } |
| 137 | + | ||
| 138 | + changeBindPhone(){ | ||
| 139 | + if (!this.isSubmit) { | ||
| 140 | + return | ||
| 141 | + } | ||
| 142 | + if (this.isEmpty(this.phoneContent)) { | ||
| 143 | + return | ||
| 144 | + } | ||
| 145 | + if (this.isEmpty(this.codeContent)) { | ||
| 146 | + return | ||
| 147 | + } | ||
| 148 | + this.loginViewModel.changeBindPhone(this.phoneContent,this.codeContent).then(()=>{ | ||
| 149 | + ToastUtils.shortToast('绑定成功') | ||
| 150 | + router.back() | ||
| 151 | + }) | ||
| 152 | + } | ||
| 130 | } | 153 | } |
| @@ -247,5 +247,30 @@ export class LoginModel { | @@ -247,5 +247,30 @@ export class LoginModel { | ||
| 247 | }) | 247 | }) |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | +//更换绑定手机号 | ||
| 251 | + changeBindPhone(phone: string, verificationCode: string){ | ||
| 252 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 253 | + let bean: Record<string, Object> = {}; | ||
| 254 | + bean['phone'] = phone | ||
| 255 | + bean['verifyCode'] = verificationCode | ||
| 256 | + return new Promise<LoginBean>((success, fail) => { | ||
| 257 | + HttpRequest.post<ResponseDTO<LoginBean>>(HttpUrlUtils.changeBindPhone(), bean, headers).then((data: ResponseDTO<LoginBean>) => { | ||
| 258 | + Logger.debug("LoginViewModel:success2 ", data.message) | ||
| 259 | + if (!data || !data.data) { | ||
| 260 | + fail("数据为空") | ||
| 261 | + return | ||
| 262 | + } | ||
| 263 | + if (data.code != 0) { | ||
| 264 | + fail(data.message) | ||
| 265 | + return | ||
| 266 | + } | ||
| 267 | + success(data.data) | ||
| 268 | + }, (error: Error) => { | ||
| 269 | + fail(error.message) | ||
| 270 | + Logger.debug("LoginViewModel:error2 ", error.toString()) | ||
| 271 | + }) | ||
| 272 | + }) | ||
| 273 | + } | ||
| 274 | + | ||
| 250 | } | 275 | } |
| 251 | 276 |
| @@ -4,7 +4,7 @@ import router from '@ohos.router' | @@ -4,7 +4,7 @@ import router from '@ohos.router' | ||
| 4 | import { LoginViewModel } from './LoginViewModel' | 4 | import { LoginViewModel } from './LoginViewModel' |
| 5 | import { LoginInputComponent } from './LoginInputComponent' | 5 | import { LoginInputComponent } from './LoginInputComponent' |
| 6 | import promptAction from '@ohos.promptAction' | 6 | import promptAction from '@ohos.promptAction' |
| 7 | -import { SPHelper } from 'wdKit' | 7 | +import { ErrorToastUtils, SPHelper } from 'wdKit' |
| 8 | import { WDRouterPage } from 'wdRouter/src/main/ets/router/WDRouterPage'; | 8 | import { WDRouterPage } from 'wdRouter/src/main/ets/router/WDRouterPage'; |
| 9 | import { WDRouterRule } from 'wdRouter/src/main/ets/router/WDRouterRule'; | 9 | import { WDRouterRule } from 'wdRouter/src/main/ets/router/WDRouterRule'; |
| 10 | import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/src/main/ets/bean/content/Params' | 10 | import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/src/main/ets/bean/content/Params' |
| @@ -254,7 +254,11 @@ struct LoginPage { | @@ -254,7 +254,11 @@ struct LoginPage { | ||
| 254 | Row() { | 254 | Row() { |
| 255 | Row() { | 255 | Row() { |
| 256 | Image($r('app.media.login_wx')) | 256 | Image($r('app.media.login_wx')) |
| 257 | - .width(20).height(20) | 257 | + .width(20).height(20).onClick(()=>{ |
| 258 | + Logger.debug("测试",'开始'+Logger.isDebug) | ||
| 259 | + ErrorToastUtils.ErrorToast.showToast(ErrorToastUtils.ErrorType.NET_CORE_NO_NETWORK) | ||
| 260 | + Logger.debug("测试",'开始2'+Logger.isDebug) | ||
| 261 | + }) | ||
| 258 | }.backgroundImage($r('app.media.login_other_left'), ImageRepeat.NoRepeat) | 262 | }.backgroundImage($r('app.media.login_other_left'), ImageRepeat.NoRepeat) |
| 259 | .otherStyle() | 263 | .otherStyle() |
| 260 | 264 |
| @@ -56,6 +56,7 @@ export class LoginViewModel { | @@ -56,6 +56,7 @@ export class LoginViewModel { | ||
| 56 | SPHelper.default.save(SpConstants.USER_STATUS, data.status) | 56 | SPHelper.default.save(SpConstants.USER_STATUS, data.status) |
| 57 | SPHelper.default.save(SpConstants.USER_Type, data.userType) | 57 | SPHelper.default.save(SpConstants.USER_Type, data.userType) |
| 58 | SPHelper.default.save(SpConstants.USER_NAME, data.userName) | 58 | SPHelper.default.save(SpConstants.USER_NAME, data.userName) |
| 59 | + SPHelper.default.save(SpConstants.USER_PHONE, phone) | ||
| 59 | HttpUrlUtils.setUserId(data.id+"") | 60 | HttpUrlUtils.setUserId(data.id+"") |
| 60 | HttpUrlUtils.setUserType(data.userType+"") | 61 | HttpUrlUtils.setUserType(data.userType+"") |
| 61 | HttpUrlUtils.setUserToken(data.jwtToken) | 62 | HttpUrlUtils.setUserToken(data.jwtToken) |
| @@ -80,6 +81,7 @@ export class LoginViewModel { | @@ -80,6 +81,7 @@ export class LoginViewModel { | ||
| 80 | SPHelper.default.save(SpConstants.USER_STATUS, data.status) | 81 | SPHelper.default.save(SpConstants.USER_STATUS, data.status) |
| 81 | SPHelper.default.save(SpConstants.USER_Type, data.userType) | 82 | SPHelper.default.save(SpConstants.USER_Type, data.userType) |
| 82 | SPHelper.default.save(SpConstants.USER_NAME, data.userName) | 83 | SPHelper.default.save(SpConstants.USER_NAME, data.userName) |
| 84 | + SPHelper.default.save(SpConstants.USER_PHONE, phone) | ||
| 83 | HttpUrlUtils.setUserId(data.id+"") | 85 | HttpUrlUtils.setUserId(data.id+"") |
| 84 | HttpUrlUtils.setUserType(data.userType+"") | 86 | HttpUrlUtils.setUserType(data.userType+"") |
| 85 | HttpUrlUtils.setUserToken(data.jwtToken) | 87 | HttpUrlUtils.setUserToken(data.jwtToken) |
| @@ -168,6 +170,16 @@ export class LoginViewModel { | @@ -168,6 +170,16 @@ export class LoginViewModel { | ||
| 168 | }) | 170 | }) |
| 169 | } | 171 | } |
| 170 | 172 | ||
| 173 | + changeBindPhone(phone: string, verificationCode: string) { | ||
| 174 | + return new Promise<LoginBean>((success, fail) => { | ||
| 175 | + this.loginModel.changeBindPhone(phone, verificationCode).then((data: LoginBean) => { | ||
| 176 | + success(data) | ||
| 177 | + }).catch(() => { | ||
| 178 | + fail() | ||
| 179 | + }) | ||
| 180 | + }) | ||
| 181 | + } | ||
| 182 | + | ||
| 171 | 183 | ||
| 172 | 184 | ||
| 173 | async doMd(content: string): Promise<string> { | 185 | async doMd(content: string): Promise<string> { |
-
Please register or login to post a comment