shishuangxi

设置注销页面

Showing 19 changed files with 748 additions and 83 deletions
... ... @@ -9,8 +9,14 @@ export class SpConstants{
static USER_LONG_TIME_NO_LOGIN_MARK="longTimeNoLoginMark"
static USER_STATUS="user_status"
static USER_TEMP_TOKEN="tempToken"
static USER_PHONE = "user_phone"
//协议相关
static USER_PROTOCOL = "user_protocol" //用户协议
static PRIVATE_PROTOCOL = "private_protocol" //隐私协议
//设置页面
static SETTING_WIFI_IMAGE_SWITCH = "setting_wifi_switch" //wifi 图片开关
static SETTING_WIFI_VIDEO_SWITCH = "setting_wifi_switch" //wifi 视频开关
static SETTING_SUSPENSION_SWITCH = "setting_suspension_switch" //悬浮窗 开关
static SETTING_PUSH_SWITCH = "setting_push_switch" //推送 开关
}
\ No newline at end of file
... ...
... ... @@ -36,4 +36,6 @@ export { UserDataLocal } from './src/main/ets/utils/UserDataLocal'
export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils'
// export { PermissionUtils } from './src/main/ets/utils/PermissionUtils'
\ No newline at end of file
// export { PermissionUtils } from './src/main/ets/utils/PermissionUtils'
export { ErrorToastUtils } from './src/main/ets/utils/ErrorToastUtils'
\ No newline at end of file
... ...
import { ToastUtils } from './ToastUtils'
export namespace ErrorToastUtils {
export enum ErrorType {
NET_CORE_NO_NETWORK, //当前无网络,请重试
NET_CORE_WEAK_NETWORK, //当前无网络,请重试
NET_CORE_PAGE_ERROR_NETWORK, //网络出小差了,请检查网络后重试
NET_CORE_LOAD_ERROR_NETWORK, //加载失败,请重试
NET_CORE_ENTER_ERROR_NETWORK, //很抱歉,当前内容无法加载,请点击重试
LIVE_CORE_NO_NETWORK, //网络出小差了,请检查下网络
}
export class ErrorToast {
static showToast(type: ErrorType) {
switch (type) {
case ErrorType.NET_CORE_NO_NETWORK:
ToastUtils.shortToast($r('app.string.net_core_no_network'))
break
case ErrorType.NET_CORE_WEAK_NETWORK:
ToastUtils.shortToast($r('app.string.net_core_no_network'))
break
case ErrorType.NET_CORE_PAGE_ERROR_NETWORK:
ToastUtils.shortToast($r('app.string.net_core_page_error_network'))
break
case ErrorType.NET_CORE_LOAD_ERROR_NETWORK:
ToastUtils.shortToast($r('app.string.net_core_load_fail_network'))
break
case ErrorType.NET_CORE_ENTER_ERROR_NETWORK:
ToastUtils.shortToast($r('app.string.net_core_enter_fail_network'))
break
case ErrorType.LIVE_CORE_NO_NETWORK:
ToastUtils.shortToast($r('app.string.live_core_no_network'))
break
}
}
}
}
... ...
... ... @@ -3,6 +3,30 @@
{
"name": "shared_desc",
"value": "全局工具包"
} ,
{
"name": "net_core_no_network",
"value": "当前无网络,请重试"
} ,
{
"name": "net_core_weak_network",
"value": "当前无网络,请重试"
} ,
{
"name": "net_core_page_error_network",
"value": "网络出小差了,请检查下网络"
},
{
"name": "net_core_load_fail_network",
"value": "加载失败,请重试"
},
{
"name": "net_core_enter_fail_network",
"value": "很抱歉,当前内容无法加载,请点击重试"
},
{
"name": "live_core_no_network",
"value": "网络出小差了,请检查下网络"
}
]
}
\ No newline at end of file
... ...
... ... @@ -460,6 +460,18 @@ export class HttpUrlUtils {
return url;
}
//账户注销
static accountLogoutUrl() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/logoff";
return url;
}
//更换手机号绑定
static changeBindPhone() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/userPhoneChange";
return url;
}
static getAppointmentListDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH
return url
... ...
... ... @@ -68,6 +68,8 @@ export class WDRouterPage {
static aboutPage = new WDRouterPage("wdComponent", "ets/components/page/SettingAboutPage");
// 设置页
static settingPage = new WDRouterPage("wdComponent", "ets/components/page/SettingPage");
// 设置页
static logoutPage = new WDRouterPage("wdComponent", "ets/components/setting/LogoutPage");
// 设置密码页、设置手机号页等等 (需要传参)
static settingPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/SettingPasswordPage");
//其他普通用户 主页
... ...
import { BottomNavi, CommonConstants } from 'wdConstant';
import { Logger } from 'wdKit';
import { BottomNavi, CommonConstants, SpConstants } from 'wdConstant';
import { Logger, SPHelper, ToastUtils, UserDataLocal } from 'wdKit';
import { TopNavigationComponent } from '../page/TopNavigationComponent';
import PageViewModel from '../../viewmodel/PageViewModel';
import {MineMainSettingFunctionItem} from '../../viewmodel/MineMainSettingFunctionItem';
... ... @@ -15,6 +15,8 @@ import { SettingPasswordParams } from 'wdLogin';
import { LoginViewModel } from 'wdLogin/src/main/ets/pages/login/LoginViewModel';
import { Router } from '@ohos.arkui.UIContext';
import promptAction from '@ohos.promptAction';
import { LogoutViewModel } from '../../viewmodel/LogoutViewModel';
import { CustomLogoutDialog } from './CustomLogoutDialog';
export { SettingPasswordParams } from "wdLogin"
... ... @@ -23,28 +25,82 @@ export struct AccountAndSecurityLayout {
@State listData: Array<MineMainSettingFunctionItem> = new Array;
@State privacySwitch: boolean = false
@State cacheSice: number = 0
@State protocolState: boolean = false //协议勾选状态
@State isAccountPage: boolean = true
logoutViewModel = new LogoutViewModel()
dialogController: CustomDialogController = new CustomDialogController({
builder: CustomLogoutDialog({
cancel: () => {
},
confirm: () => {
this.requestLogout()
}
}),
customStyle: true,
alignment: DialogAlignment.Center
})
aboutToAppear() {
// 获取设置页面数据
this.getAccountAndSecurityData()
}
getAccountAndSecurityData() {
this.listData = MineSettingDatasModel.getAccountAndSecuritySettingData()
async getAccountAndSecurityData() {
let oldList = MineSettingDatasModel.getAccountAndSecuritySettingData();
let phone = await SPHelper.default.get(SpConstants.USER_PHONE, '') as string
if (phone != '') {
oldList[0].subTitle = this.securityPhone(phone)
}
this.listData = oldList
}
build() {
Navigation() {
//滑动区域
this.settingList()
}.titleMode(NavigationTitleMode.Mini)
.title('账号与安全')
Column(){
if(this.isAccountPage){
this.settingList()
}else {
this.logoutLayout()
}
}
}
// 页面布局
@Builder settingList() {
Stack({ alignContent: Alignment.Bottom }) {
Column() {
RelativeContainer() {
Text('账户与安全')
.fontColor('#FF333333')
.fontSize(18)
.textAlign(TextAlign.Center)
.height(44)
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start },
right: { anchor: "__container__", align: HorizontalAlign.End },
})
.id('titleContent')
Image($r('app.media.back_icon'))
.objectFit(ImageFit.Auto)
.height(24)
.width(24)
.margin({
left: 16, top: 8
})
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start },
})
.onClick(() => {
router.back()
})
.id('backImage')
}.height(44)
List() {
ForEach(this.listData, (item: MineMainSettingFunctionItem, index: number) => {
ListItem() {
... ... @@ -69,6 +125,9 @@ export struct AccountAndSecurityLayout {
let pageType = {'pageType': 1} as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
}else if (index == 8) {
this.isAccountPage=false
// WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
}
})
... ... @@ -104,8 +163,7 @@ export struct AccountAndSecurityLayout {
// })
})
}
}
}
}
@Builder itemHead(text: string) {
... ... @@ -115,6 +173,147 @@ export struct AccountAndSecurityLayout {
}
}
@Builder logoutLayout(){
RelativeContainer() {
Column() {
RelativeContainer() {
Text('注销账号')
.fontColor('#FF333333')
.fontSize(18)
.textAlign(TextAlign.Center)
.height(44)
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start },
right: { anchor: "__container__", align: HorizontalAlign.End },
})
.id('titleContent')
Image($r('app.media.back_icon'))
.objectFit(ImageFit.Auto)
.height(24)
.width(24)
.margin({
left: 16, top: 8
})
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start },
})
.onClick(() => {
this.isAccountPage=true
this.protocolState=false
})
.id('backImage')
}.height(44)
Text('为保证您的账号安全,在您提交的注销申请生效前,需同时满足以下几个条件:')
.fontColor('#FF222222')
.fontSize(16)
.fontWeight(600)
.padding({ top:17,left: 16, right: 16 })
.width('100%')
Text('1. 账号处于安全状态')
.fontColor('#FF222222')
.fontSize(16)
.fontWeight(600)
.padding({ top: 24, left: 16 })
.width('100%')
Text('账号处于正常使用状态,无被盗风险。')
.fontColor('#FF666666')
.fontSize(14)
.fontWeight(400)
.padding({ top: 8, left: 16 })
.width('100%')
Text('2. 账号权限解除')
.fontColor('#FF222222')
.fontSize(16)
.fontWeight(600)
.padding({ top: 24, left: 16 })
.width('100%')
Text('账号已解除与其他产品的授权登录或绑定关系。')
.fontColor('#FF666666')
.fontSize(14)
.fontWeight(400)
.padding({ top: 8, left: 16 })
.width('100%')
Text('3. 账号无任何纠纷,包括举报投诉')
.fontColor('#FF222222')
.fontSize(16)
.fontWeight(600)
.padding({ top: 24, left: 16 })
.width('100%')
Text('请注意:注销后7天内不能再次注册人民日报客户端,需要等到账号冷静期结束才能再次登录注册')
.fontColor('#FFED2800')
.fontSize(14)
.fontWeight(400)
.padding({ top: 32, left: 16, right: 16 })
.width('100%')
}.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start },
})
.width('100%')
.id('title')
Column() {
Row() {
Image(this.protocolState ? $r("app.media.logout_checkbox_select") : $r("app.media.logout_checkbox_unselected"))
.width(15)
.height(15)
.onClick(() => {
this.protocolState = !this.protocolState
})
Text() {
Span("我已阅读并同意").fontColor("#999999").fontSize(12)
Span("《用户注销协议》").fontColor("#ED2800").fontSize(12).onClick(() => {
let bean = { contentID: "3", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
})
}
}.alignItems(VerticalAlign.Center)
Row() {
Text("登录")
.borderRadius(4)
.fontColor(this.protocolState ? "#FFFFFFFF" : "#66FFFFFF")
.fontSize(18)
.fontWeight(FontWeight.Medium)
.margin({ top: 20 })
.height(44)
.textAlign(TextAlign.Center)
.width("100%")
.backgroundColor(this.protocolState ? "#FFED2800" : "#99ED2800")
.onClick(() => {
if (!this.protocolState) {
return
}
this.dialogController.open()
})
}.padding({ left: 25, right: 25 }).width('100%')
}.alignRules({
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
left: { anchor: "__container__", align: HorizontalAlign.Start },
right: { anchor: "__container__", align: HorizontalAlign.End },
})
.margin({ bottom: 15 })
.id('bottom')
}.width('100%')
}
// 右侧开关cell
@Builder getSwitchCell(item: MineMainSettingFunctionItem) {
Column() {
... ... @@ -189,4 +388,20 @@ export struct AccountAndSecurityLayout {
}
.height('54lpx')
}
//注销账号
requestLogout() {
this.logoutViewModel.requestLogout().then(()=>{
ToastUtils.shortToast("注销成功")
router.back()
})
}
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
... ...
@CustomDialog
export struct CustomCacheDialog {
controller: CustomDialogController
cancel: () => void = () => {
}
confirm: () => void = () => {
}
build() {
Column() {
Text("清理缓存")
.fontColor("#222222")
.fontSize(18)
.width("100%")
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Center)
.margin({ top: 20 })
Text('是否确认清理此App的缓存') {
}.margin({ top: 12, left: 16, right: 16 })
Divider().color("#999999").width("100%").margin({ top: 14 }).height('1vp')
Row() {
Text('取消')
.fontSize(16)
.fontColor("#999999")
.layoutWeight(1)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.onClick(() => {
this.controller.close()
if (this.cancel) {
this.cancel()
}
})
.height('100%')
// Divider().color("#999999").height('100%').width('0.5vp')
Text('确认')
.fontSize(16)
.fontColor("#ED2800")
.layoutWeight(1)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.border({
width: { left: 1 },
color: "#999999",
style: { left: BorderStyle.Solid }
})
.onClick(() => {
this.controller.close()
if (this.confirm) {
this.confirm()
}
})
.height('100%')
}.layoutWeight(1).justifyContent(FlexAlign.Center)
}.height(161).backgroundColor(Color.White).borderRadius(6).width('74%')
}
}
\ No newline at end of file
... ...
@CustomDialog
export struct CustomLogoutDialog {
controller: CustomDialogController
cancel: () => void = () => {
}
confirm: () => void = () => {
}
build() {
Column() {
Text("温馨提示")
.fontColor("#222222")
.fontSize(18)
.width("100%")
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Center)
.margin({ top: 20 })
Text('注销后7天内无法重新登录注册人民日报app,是否确认注销?') {
}.margin({ top: 12, left: 16, right: 16 })
Divider().color("#999999").width("100%").margin({ top: 14 }).height('1vp')
Row() {
Text('放弃')
.fontSize(16)
.fontColor("#999999")
.layoutWeight(1)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.onClick(() => {
this.controller.close()
if (this.cancel) {
this.cancel()
}
})
.height('100%')
// Divider().color("#999999").height('100%').width('0.5vp')
Text('同意注销')
.fontSize(16)
.fontColor("#ED2800")
.layoutWeight(1)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.border({
width: { left: 1 },
color: "#999999",
style: { left: BorderStyle.Solid }
})
.onClick(() => {
this.controller.close()
if (this.confirm) {
this.confirm()
}
})
.height('100%')
}.layoutWeight(1).justifyContent(FlexAlign.Center)
}.height(161).backgroundColor(Color.White).borderRadius(6).width('74%')
}
}
\ No newline at end of file
... ...
import { BottomNavi, CommonConstants } from 'wdConstant';
import { Logger } from 'wdKit';
import { BottomNavi, CommonConstants, SpConstants } from 'wdConstant';
import { Logger, SPHelper } from 'wdKit';
import PageViewModel from '../../viewmodel/PageViewModel';
import storageStatistics from "@ohos.file.storageStatistics";
import { BusinessError } from '@ohos.base';
import router from '@ohos.router';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { Params } from 'wdBean';
import { common } from '@kit.AbilityKit';
import fs from '@ohos.file.fs';
import { CustomCacheDialog } from './CustomCacheDialog';
import MineSettingDatasModel from '../../model/MineSettingDatasModel';
import { MineMainSettingFunctionItem } from '../../viewmodel/MineMainSettingFunctionItem';
@Component
export struct MineSettingComponent {
@State listData: Array<string | Array<string>> = new Array();
// @State listData: Array<string | Array<string>> = new Array();
@State listData: Array<MineMainSettingFunctionItem> = new Array;
@State privacySwitch: boolean = false
@State cacheSice: number = 0
@State cacheSize: number = 0
@State accountState:boolean=false
dialogController: CustomDialogController = new CustomDialogController({
builder: CustomCacheDialog({
cancel: () => {
},
confirm: () => {
this.deleteCache()
}
}),
customStyle: true,
alignment: DialogAlignment.Center
})
aboutToAppear() {
// 获取设置页面数据
this.getSettingPageData()
// 获取缓存数据
storageStatistics.getCurrentBundleStats((err: BusinessError, bundleStats: storageStatistics.BundleStats) => {
if (err) {
console.error(`Invoke getCurrentBundleStats failed, code is ${err.code}, message is ${err.message}`);
} else {
this.cacheSice = bundleStats.cacheSize / 1024.00 / 1024.00;
}
});
this.getCacheSize()
this.getAccountState()
}
getSettingPageData() {
let listArr = [['账户与安全', '接收推送', '隐私设罝', '仅WiFi网络加载图片', 'WiFi网络情况下自动播放视频', '开户播放器悬浮窗'], ['清除缓存', '去评分']];
this.listData = listArr;
async getAccountState(){
let userId=await SPHelper.default.get(SpConstants.USER_ID,'') as string
if(userId==''){
this.accountState=false
}else {
this.accountState=true
}
}
async getSettingPageData() {
let oldList = MineSettingDatasModel.getMineMainSettingFunctionItemData();
let userId=await SPHelper.default.get(SpConstants.USER_ID,'') as string
if(userId==''){
this.listData=oldList.slice(1,oldList.length)
}else {
this.listData = oldList;
}
}
build() {
... ... @@ -41,53 +70,88 @@ export struct MineSettingComponent {
.title('设置')
}
// // 页面布局
// @Builder settingList() {
// Column() {
// List() {
// // 循环渲染ListItemGroup,contactsGroups为多个分组联系人contacts和标题title的数据集合
// ForEach(this.listData, (item: Array<string>, index: number) => {
// ListItemGroup({ header: index === 0 ? this.itemHead("") : this.itemHead("1") }) {
// // 循环渲染ListItem
// ForEach(item, (subItem: string, subIndex: number) => {
// ListItem() {
// if (subIndex == 6) {
// this.getArrowCell(subItem, subIndex, index)
// } else if (subIndex == 1 || subIndex == 3 || subIndex == 4 || subIndex == 5) {
// if (subIndex == 1 && index == 1) {
// this.getArrowCell(subItem, subIndex, index)
// } else {
// this.getSwitchCell(subItem, subIndex)
// }
//
// } else {
// this.getArrowCell(subItem, subIndex, index)
// }
//
// }.padding({ left: '27lpx' })
// .onClick(() => {
//
// // // 在Home页面中
// // let paramsInfo: object = {
// // pageId: 123,
// // pageType:'AccountAndSecurityLayout'
// // };
// console.log(subIndex + "")
// if (subIndex == 0 && index == 0) {
//
// let params: Params = {
// pageID: 'AccountAndSecurityLayout'
// }
// WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
// }else if (subIndex == 2 && index == 0) {
// WDRouterRule.jumpWithPage(WDRouterPage.privacySettingPage)
// }else if (subIndex == 0 && index == 1) {
// this.dialogController.open()
// }
//
// })
// .height('117lpx')
// })
// }
// .divider({
// strokeWidth: 1,
// startMargin: 15,
// endMargin: 10,
// color: '#f0f0f0'
// })
// })
// }.onScrollFrameBegin((offset, state) => {
// return { offsetRemain: 0 }
// })
// }
// .backgroundColor(Color.White)
// .borderRadius(8)
// }
// 页面布局
@Builder settingList() {
Column() {
List() {
// 循环渲染ListItemGroup,contactsGroups为多个分组联系人contacts和标题title的数据集合
ForEach(this.listData, (item: Array<string>, index: number) => {
ListItemGroup({ header: index === 0 ? this.itemHead("") : this.itemHead("1") }) {
// 循环渲染ListItem
ForEach(item, (subItem: string, subIndex: number) => {
ListItem() {
if (subIndex == 6) {
this.getArrowCell(subItem, subIndex, index)
} else if (subIndex == 1 || subIndex == 3 || subIndex == 4 || subIndex == 5) {
this.getSwitchCell(subItem, subIndex)
} else {
this.getArrowCell(subItem, subIndex, index)
}
}.padding({ left: '27lpx' })
.onClick(() => {
// // 在Home页面中
// let paramsInfo: object = {
// pageId: 123,
// pageType:'AccountAndSecurityLayout'
// };
console.log(subIndex + "")
if (subIndex == 0 && index == 0) {
let params: Params = {
pageID: 'AccountAndSecurityLayout'
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
}else if (subIndex == 2 && index == 0) {
WDRouterRule.jumpWithPage(WDRouterPage.privacySettingPage)
}
})
.height('117lpx')
})
ForEach(this.listData, (item: MineMainSettingFunctionItem, index: number) => {
ListItem() {
if (item.type == 0) {
Column() {
this.getArrowCell(item,index)
}.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center)
} else if (item.type == 1) {
Column() {
this.getSwitchCell(item,index)
}.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center)
} else {
Column().width('100%').height('15lpx').backgroundColor(0xf0f0f0)
}
}
.divider({
strokeWidth: 1,
startMargin: 15,
endMargin: 10,
color: '#f0f0f0'
})
})
}.onScrollFrameBegin((offset, state) => {
return { offsetRemain: 0 }
... ... @@ -105,7 +169,7 @@ export struct MineSettingComponent {
}
// 右侧开关cell
@Builder getSwitchCell(item:string, index:number) {
@Builder getSwitchCell(item:MineMainSettingFunctionItem, index:number) {
Column() {
Row() {
// 左侧logo和标题
... ... @@ -116,13 +180,13 @@ export struct MineSettingComponent {
.height('38lpx')
.margin({ right: '5lpx' })
Text(`${item}`)
Text(`${item.title}`)
.margin({ top: '8lpx' })
.height('38lpx')
.fontColor('#333333')
.fontSize('29lpx')
} else {
Text(`${item}`)
Text(`${item.title}`)
.margin({ top: '8lpx' })
.height('38lpx')
.fontColor('#333333')
... ... @@ -137,7 +201,16 @@ export struct MineSettingComponent {
.margin({ left: '81lpx', right: '29lpx' })
.selectedColor(Color.Pink)
.onChange((isOn: boolean) => {
this.privacySwitch = isOn;
if(item.title=='接收推送'){
//推送
SPHelper.default.save(SpConstants.SETTING_PUSH_SWITCH,isOn)
}else if(item.title=='仅WiFi网络加载图片'){
//wifi 图片
SPHelper.default.save(SpConstants.SETTING_WIFI_IMAGE_SWITCH,isOn)
}else if(item.title=='WiFi网络情况下自动播放视频'){
//wifi 视频
SPHelper.default.save(SpConstants.SETTING_WIFI_VIDEO_SWITCH,isOn)
}
})
}.width('40%')
.margin({ right: '29lpx' })
... ... @@ -150,7 +223,7 @@ export struct MineSettingComponent {
}
// 右文字+箭头cell
@Builder getArrowCell(item:string, index:number, mainIndex:number) {
@Builder getArrowCell(item:MineMainSettingFunctionItem, index:number) {
Column() {
Row() {
... ... @@ -162,7 +235,7 @@ export struct MineSettingComponent {
// .height('38lpx')
// .margin({ right: '5lpx' })
// }
Text(`${item}`)
Text(`${item.title}`)
.margin({ top: '8lpx' })
.height('38lpx')
.fontColor('#333333')
... ... @@ -171,7 +244,7 @@ export struct MineSettingComponent {
// 右侧文案和右箭头
Row() {
Text((index == 0 && mainIndex != 0) ? this.cacheSice.toFixed(2) + 'MB' : '')
Text((item.title=='清除缓存') ? this.cacheSize.toFixed(2) + 'MB' : '')
.fontColor('#999999')
.maxLines(1)
Image($r('app.media.mine_user_arrow'))
... ... @@ -189,5 +262,45 @@ export struct MineSettingComponent {
}
.height('54lpx')
.onClick(() => {
if (item.title == '账户与安全') {
let params: Params = {
pageID: 'AccountAndSecurityLayout'
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
} else if (item.title == '隐私设罝') {
WDRouterRule.jumpWithPage(WDRouterPage.privacySettingPage)
} else if (item.title == '清除缓存') {
this.dialogController.open()
}
})
}
//删除缓存
deleteCache() {
let context = getContext(this) as common.UIAbilityContext
let application = context.getApplicationContext();
let appPath = application.cacheDir
Logger.debug("MineSettingComponent", appPath)
fs.rmdir(appPath).then(() => {
this.getCacheSize()
})
let path = context.cacheDir
Logger.debug("MineSettingComponent", path)
fs.rmdir(path).then(() => {
this.getCacheSize()
})
}
getCacheSize() {
// 获取缓存数据
storageStatistics.getCurrentBundleStats((err: BusinessError, bundleStats: storageStatistics.BundleStats) => {
if (err) {
console.error(`Invoke getCurrentBundleStats failed, code is ${err.code}, message is ${err.message}`);
} else {
this.cacheSize = bundleStats.cacheSize / 1024.00 / 1024.00;
}
});
}
}
\ No newline at end of file
... ...
import HashMap from '@ohos.util.HashMap';
import { UserDataLocal } from 'wdKit/Index';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
export class LogoutModel{
requestLogout(){
let bean: Record<string, string> = {};
bean['refreshToken'] = UserDataLocal.USER_REFRESH_TOKEN
bean['refreshToken'] = 'ddrqreeee'
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<string>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.accountLogoutUrl(), 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())
})
})
}
}
\ No newline at end of file
... ...
... ... @@ -48,7 +48,7 @@ class MineSettingDatasModel{
this.mainSettingData.push(new MineMainSettingFunctionItem(null, '开户播放器悬浮窗', null, 1, false))
this.mainSettingData.push(new MineMainSettingFunctionItem(null, null, null, 2, null))
this.mainSettingData.push(new MineMainSettingFunctionItem(null, '清除缓存', '32MB', 0, false))
this.mainSettingData.push(new MineMainSettingFunctionItem(null, '去评分', null, 0, false))
this.mainSettingData.push(new MineMainSettingFunctionItem(null, '评价我们', null, 0, false))
return this.mainSettingData
}
... ...
import { SpConstants } from 'wdConstant/Index'
import { SPHelper } from 'wdKit/Index'
import { HttpUrlUtils } from 'wdNetwork/Index'
import { LogoutModel } from '../model/LogoutModel'
export class LogoutViewModel{
private logout:LogoutModel
constructor() {
this.logout = new LogoutModel()
}
requestLogout(){
return new Promise<string>((success, fail) => {
this.logout.requestLogout().then((data) => {
SPHelper.default.save(SpConstants.USER_FIRST_MARK, '')
SPHelper.default.save(SpConstants.USER_ID, '')
SPHelper.default.save(SpConstants.USER_JWT_TOKEN, '')
SPHelper.default.save(SpConstants.USER_LONG_TIME_NO_LOGIN_MARK, '')
SPHelper.default.save(SpConstants.USER_REFRESH_TOKEN, '')
SPHelper.default.save(SpConstants.USER_STATUS, '')
SPHelper.default.save(SpConstants.USER_Type, '')
SPHelper.default.save(SpConstants.USER_NAME, '')
SPHelper.default.save(SpConstants.USER_PHONE, '')
HttpUrlUtils.setUserId("")
HttpUrlUtils.setUserType("")
HttpUrlUtils.setUserToken('')
success(data)
}).catch((message: string) => {
fail(message)
})
})
}
}
\ No newline at end of file
... ...
... ... @@ -7,6 +7,7 @@ import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/
import { WDRouterRule, WDRouterPage } from 'wdRouter';
import { SettingPasswordParams } from './SettingPasswordLayout'
import { Router } from '@ohos.arkui.UIContext'
import { ToastUtils } from 'wdKit/Index'
const TAG = 'ForgetPasswordPage'
... ... @@ -22,7 +23,7 @@ struct ForgetPasswordPage {
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 = '找回密码';
@State pageTitle:string = '找回密码';
onCodeSend() {
if (this.isCodeSend) {
this.sendVerifyCode()
... ... @@ -59,8 +60,11 @@ struct ForgetPasswordPage {
.backgroundColor(this.isSubmit ?"#ED2800":"#99ED2800")
.enabled(this.isSubmit ? true : false)
.onClick(() => {
this.checkVerifyCode()
if(this.pageType==2){
this.changeBindPhone()
}else {
this.checkVerifyCode()
}
})
}.padding({ left: 25, right: 25 }).width('100%')
... ... @@ -68,13 +72,16 @@ struct ForgetPasswordPage {
}
aboutToAppear() {
if (router.getParams()) {
let params = router.getParams() as Record<string, number>
this.pageType = params['pageType']
Logger.info(TAG, 'params.contentID:' + params.contentID);
}
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) {
... ... @@ -127,4 +134,20 @@ struct ForgetPasswordPage {
isEmpty(obj: undefined|null|string): boolean {
return (obj == undefined || obj == null || obj == '');
}
changeBindPhone(){
if (!this.isSubmit) {
return
}
if (this.isEmpty(this.phoneContent)) {
return
}
if (this.isEmpty(this.codeContent)) {
return
}
this.loginViewModel.changeBindPhone(this.phoneContent,this.codeContent).then(()=>{
ToastUtils.shortToast('绑定成功')
router.back()
})
}
}
\ No newline at end of file
... ...
... ... @@ -247,5 +247,30 @@ export class LoginModel {
})
}
//更换绑定手机号
changeBindPhone(phone: string, verificationCode: string){
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let bean: Record<string, Object> = {};
bean['phone'] = phone
bean['verifyCode'] = verificationCode
return new Promise<LoginBean>((success, fail) => {
HttpRequest.post<ResponseDTO<LoginBean>>(HttpUrlUtils.changeBindPhone(), bean, headers).then((data: ResponseDTO<LoginBean>) => {
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) => {
fail(error.message)
Logger.debug("LoginViewModel:error2 ", error.toString())
})
})
}
}
... ...
... ... @@ -4,7 +4,7 @@ import router from '@ohos.router'
import { LoginViewModel } from './LoginViewModel'
import { LoginInputComponent } from './LoginInputComponent'
import promptAction from '@ohos.promptAction'
import { SPHelper } from 'wdKit'
import { ErrorToastUtils, SPHelper } from 'wdKit'
import { WDRouterPage } from 'wdRouter/src/main/ets/router/WDRouterPage';
import { WDRouterRule } from 'wdRouter/src/main/ets/router/WDRouterRule';
import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/src/main/ets/bean/content/Params'
... ... @@ -254,7 +254,11 @@ struct LoginPage {
Row() {
Row() {
Image($r('app.media.login_wx'))
.width(20).height(20)
.width(20).height(20).onClick(()=>{
Logger.debug("测试",'开始'+Logger.isDebug)
ErrorToastUtils.ErrorToast.showToast(ErrorToastUtils.ErrorType.NET_CORE_NO_NETWORK)
Logger.debug("测试",'开始2'+Logger.isDebug)
})
}.backgroundImage($r('app.media.login_other_left'), ImageRepeat.NoRepeat)
.otherStyle()
... ...
... ... @@ -56,6 +56,7 @@ export class LoginViewModel {
SPHelper.default.save(SpConstants.USER_STATUS, data.status)
SPHelper.default.save(SpConstants.USER_Type, data.userType)
SPHelper.default.save(SpConstants.USER_NAME, data.userName)
SPHelper.default.save(SpConstants.USER_PHONE, phone)
HttpUrlUtils.setUserId(data.id+"")
HttpUrlUtils.setUserType(data.userType+"")
HttpUrlUtils.setUserToken(data.jwtToken)
... ... @@ -80,6 +81,7 @@ export class LoginViewModel {
SPHelper.default.save(SpConstants.USER_STATUS, data.status)
SPHelper.default.save(SpConstants.USER_Type, data.userType)
SPHelper.default.save(SpConstants.USER_NAME, data.userName)
SPHelper.default.save(SpConstants.USER_PHONE, phone)
HttpUrlUtils.setUserId(data.id+"")
HttpUrlUtils.setUserType(data.userType+"")
HttpUrlUtils.setUserToken(data.jwtToken)
... ... @@ -168,6 +170,16 @@ export class LoginViewModel {
})
}
changeBindPhone(phone: string, verificationCode: string) {
return new Promise<LoginBean>((success, fail) => {
this.loginModel.changeBindPhone(phone, verificationCode).then((data: LoginBean) => {
success(data)
}).catch(() => {
fail()
})
})
}
async doMd(content: string): Promise<string> {
... ...