yangsunyue_wd

desc:设置、隐私设置、关于

Showing 49 changed files with 1419 additions and 95 deletions
... ... @@ -8,10 +8,13 @@ import router from '@ohos.router';
struct SettingPage {
@State message: string = 'Hello World 02'
@State pageType: string = '';
@State params:any = router.getParams();
onPageShow() {
const params = router.getParams(); // 获取传递过来的参数对象
this.pageType = 'mainSetting';// 获取info属性的值
this.pageType = this.params.pageType;
// this.pageType = 'mainSetting';// 获取info属性的值
}
build() {
... ...
... ... @@ -4,11 +4,11 @@
"pages/MainPage",
"pages/ColumnPage",
"pages/TestPage",
"pages/SettingPage",
"pages/PrivacySettingPage",
"pages/SettingAboutPage",
"components/page/SettingPage",
"components/page/PrivacySettingPage",
"components/page/SettingAboutPage",
"pages/AppointmentListPage",
"pages/SettingPasswordPage",
"components/page/SettingPasswordPage",
"pages/FollowListPage"
]
}
... ...
... ... @@ -12,6 +12,7 @@ import { MineMainSettingFunctionItem } from '../viewmodel/MineMainSettingFunctio
import storageStatistics from "@ohos.file.storageStatistics";
import { BusinessError } from '@ohos.base';
import ArrayList from '@ohos.util.ArrayList';
import router from '@ohos.router';
@Component
... ... @@ -58,7 +59,12 @@ export struct AccountAndSecurityLayout {
}
.onClick(() => {
console.log(index + "")
RouteManager.jumpNewPage("pages/SettingPasswordPage") // 调用跳转方法,跳转新页面
if (index == 1) {
router.pushUrl({
url:"pages/SettingPasswordPage",
params : {'currentType' : 4}
})
}
})
}, item => item)
... ...
... ... @@ -11,6 +11,7 @@ import RouteManager from '../../utils/RouteManager'
import storageStatistics from "@ohos.file.storageStatistics";
import { BusinessError } from '@ohos.base';
import RouteManager from '../../utils/RouteManager'
import router from '@ohos.router';
@Component
... ... @@ -67,15 +68,25 @@ export struct MineSettingComponent {
}.padding({ left: '27lpx' })
.onClick(() => {
// 在Home页面中
let paramsInfo: object = {
pageId: 123,
pageType:'AccountAndSecurityLayout'
};
RouteManager.jumpNewPage("pages/SettingPasswordPage") // 调用跳转方法,跳转新页面
// // 在Home页面中
// let paramsInfo: object = {
// pageId: 123,
// pageType:'AccountAndSecurityLayout'
// };
console.log(subIndex + "")
if (subIndex == 2) {
if (subIndex == 0) {
// router.pushUrl({
// url:"pages/SettingPasswordPage",
// params : {'currentType' : 4}
// })
router.pushUrl({
url:"pages/SettingPage",
params : {'pageType' : 'AccountAndSecurityLayout'}
})
//SettingPage
// RouteManager.jumpNewPage("pages/SettingPasswordPage", {'currentType' : 4}) // 调用跳转方法,跳转新页面
}else if (subIndex == 2) {
// RouteManager.jumpNewPage("pages/SettingPage") // 调用跳转方法,跳转新页面
RouteManager.jumpNewPage("pages/PrivacySettingPage")
}
... ...
... ... @@ -2,7 +2,7 @@ import dataPreferences from '@ohos.data.preferences';
import { PermissionUtil } from 'wdKit'
import { SPHelper } from 'wdKit'
import hilog from '@ohos.hilog';
import {PrivacySettingModel} from '../../viewmodel/PrivacySettingModel'
import { PrivacySettingModel } from '../../viewmodel/PrivacySettingModel'
const TAG = 'PrivacySettingComponents';
... ... @@ -31,7 +31,7 @@ export struct PrivacySettingComponents {
// this.listData.push(model1, model2, model3, model4, model5);
// }
async getPermissionStatus(){
async getPermissionStatus() {
const permissionUtil = new PermissionUtil();
for (const element of this.listData) {
if (!element.permissionKey) {
... ... @@ -55,17 +55,17 @@ export struct PrivacySettingComponents {
@Builder PrivacySettingComponentsUI() {
Column() {
List({space:'23lpx'}){
ForEach(this.listData, (item:PrivacySettingModel, index) =>{
List({ space: '23lpx' }) {
ForEach(this.listData, (item: PrivacySettingModel, index) => {
ListItem() {
if (index == 0) {
getTuiJianCell({item, index});
}else{
getArrowCell({item, index});
getTuiJianCell({ item, index });
} else {
getArrowCell({ item, index });
}
}.onClick(()=>{
}.onClick(() => {
if (index != 0) {
if (!item.permission){
if (!item.permission) {
//跳转权限设置
const permissionUtil = new PermissionUtil();
PermissionUtil.reqPermissionsFromUser([item.permissionKey]);
... ... @@ -74,27 +74,26 @@ export struct PrivacySettingComponents {
})
}, item => item)
}
.padding({left:'29lpx', right:'29lpx'})
.margin({top:'38lpx'})
.padding({ left: '29lpx', right: '29lpx' })
.margin({ top: '38lpx' })
Row(){
Row() {
Text(this.tips)
.fontSize('25lpx')
.textAlign(TextAlign.Start)
.fontColor($r("app.color.color_666666"))
.margin({left:'29lpx', top:'46lpx'})
.margin({ left: '29lpx', top: '46lpx' })
// .backgroundColor(Color.Orange)
Text(this.privacyTips)
.fontSize('25lpx')
.textAlign(TextAlign.Start)
.fontColor('#ED2800')
.margin({top:'46lpx'})
.onClick(()=>{
.margin({ top: '46lpx' })
.onClick(() => {
//跳转隐私政策
})
}
}
.width('100%')
.height('100%')
... ... @@ -141,9 +140,10 @@ struct getArrowCell {
}
@Component
struct getTuiJianCell{
@ObjectLink item :PrivacySettingModel;
struct getTuiJianCell {
@ObjectLink item: PrivacySettingModel;
index;
build() {
//@Builder getTuiJianCell(item:PrivacySettingModel, index)
Column() {
... ...
import MinePageMoreFunctionModel from '../../../viewmodel/MinePageMoreFunctionModel'
import RouteManager from '../../../utils/RouteManager'
import router from '@ohos.router'
@Component
export default struct MinePageMoreFunctionUI{
... ... @@ -66,18 +67,14 @@ export default struct MinePageMoreFunctionUI{
.onClick(()=>{
console.log(index+"")
if (index == 3) {
RouteManager.jumpNewPage("pages/SettingPage")
router.pushUrl({
url:"pages/SettingPage",
params : {'pageType' : 'mainSetting'}
})
} else if (index == 2) {
RouteManager.jumpNewPage("pages/PrivacySettingPage")
// RouteManager.jumpNewPage("pages/PrivacySettingPage")
} else if (index == 4) {
RouteManager.jumpNewPage("pages/SettingAboutPage")
}else {
// 在Home页面中
let paramsInfo: object = {
pageId: 123,
pageType:'mainSetting'
};
RouteManager.jumpNewPage("pages/PrivacySettingPage",paramsInfo)
}
})
... ...
import MinePagePersonalFunctionsItem from '../viewmodel/MinePagePersonalFunctionsItem'
import MinePageCreatorFunctionsItem from '../viewmodel/MinePageCreatorFunctionsItem'
import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel';
import { HttpUrlUtils } from '../network/HttpUrlUtils';
import MinePagePersonalFunctionsItem from '../../../../../../../../PeopleDaily_Harmony/wdComponent/src/main/ets/viewmodel/MinePagePersonalFunctionsItem'
import MinePageCreatorFunctionsItem from '../../../../../../../../PeopleDaily_Harmony/wdComponent/src/main/ets/viewmodel/MinePageCreatorFunctionsItem'
import MinePageMoreFunctionModel from '../../../../../../../../PeopleDaily_Harmony/wdComponent/src/main/ets/viewmodel/MinePageMoreFunctionModel';
import { HttpUrlUtils } from '../../../../../../../../PeopleDaily_Harmony/wdComponent/src/main/ets/network/HttpUrlUtils';
import HashMap from '@ohos.util.HashMap';
import { ResponseDTO, WDHttp } from 'wdNetwork';
import { Logger } from 'wdKit';
import { MineMainSettingFunctionItem } from '../viewmodel/MineMainSettingFunctionItem'
import { MineMainSettingFunctionItem } from '../../../../../../../../PeopleDaily_Harmony/wdComponent/src/main/ets/viewmodel/MineMainSettingFunctionItem'
const TAG = "MineSettingDatasModel"
... ... @@ -68,10 +68,10 @@ class MineSettingDatasModel{
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '更换手机号', '18888888888', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '设置密码', null, 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, null, null, 2, null))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.mine_order_icon'), '绑定QQ', '立即绑定', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.mine_order_icon'), '绑定微信', '立即绑定', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.mine_order_icon'), '绑定新浪微博', '立即绑定', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, 'Apple ID', null, 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_qqicon'), '绑定QQ', '立即绑定', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_wechaticon'), '绑定微信', '立即绑定', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_weiboicon'), '绑定新浪微博', '立即绑定', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_appleicon'), 'Apple ID', null, 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, null, null, 2, null))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '注销账号', null, 0, false))
... ...
... ... @@ -5,13 +5,13 @@
"name": "default",
"type": "HarmonyOS",
"material": {
"certpath": "C:\\Users\\PC\\.ohos\\config\\default_sight_harmony_vDjosN2opayZneQDLiBs3Lc0sT1uPzRAYaDxxv2LWEQ=.cer",
"storePassword": "0000001A87430EDC6C0D1CD6A6473A6D385177DBFF70325BBD48C7E491A0D9B37F91920FD46D82B2436B",
"certpath": "/Users/ysy/.ohos/config/auto_debug_sight_harmony_com.wondertek.sight_30086000745972390.cer",
"storePassword": "0000001AD1ABE6FB1D5AEC538066BBDCACCDF8DFB85BA89D4A7B163112F48FDFAD37222DD5D2FBC6738C",
"keyAlias": "debugKey",
"keyPassword": "0000001A8E615E1CB276AA122C291AFBCDFF792FEE8AA618B186EE7C99220C7F549B8C2ED6A209703D75",
"profile": "C:\\Users\\PC\\.ohos\\config\\default_sight_harmony_vDjosN2opayZneQDLiBs3Lc0sT1uPzRAYaDxxv2LWEQ=.p7b",
"keyPassword": "0000001AA4301CF4CB6CD92BFD749A3C09BC771B02A1E544A47EBBC557DB27E8150CB2AB5CB13029999D",
"profile": "/Users/ysy/.ohos/config/auto_debug_sight_harmony_com.wondertek.sight_30086000745972390.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "C:\\Users\\PC\\.ohos\\config\\default_sight_harmony_vDjosN2opayZneQDLiBs3Lc0sT1uPzRAYaDxxv2LWEQ=.p12"
"storeFile": "/Users/ysy/.ohos/config/auto_debug_sight_harmony_com.wondertek.sight_30086000745972390.p12"
}
}
],
... ...
... ... @@ -29,3 +29,5 @@ export { DeviceUtil } from './src/main/ets/utils/DeviceUtil'
export { DisplayUtils } from './src/main/ets/utils/DisplayUtils'
export { SystemUtils } from './src/main/ets/utils/SystemUtils'
export { PermissionUtil } from './src/main/ets/utils/PermissionUtil'
... ...
import bundleManager from '@ohos.bundle.bundleManager';
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
import common from '@ohos.app.ability.common';
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
export class PermissionUtil {
async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> {
let atManager = abilityAccessCtrl.createAtManager();
let grantStatus: abilityAccessCtrl.GrantStatus = abilityAccessCtrl.GrantStatus.PERMISSION_DENIED;
// 获取应用程序的accessTokenID
let tokenId: number = 0;
try {
let bundleInfo: bundleManager.BundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo;
tokenId = appInfo.accessTokenId;
} catch (err) {
console.error(`getBundleInfoForSelf failed, code is ${err.code}, message is ${err.message}`);
}
// 校验应用是否被授予权限
try {
grantStatus = await atManager.checkAccessToken(tokenId, permission);
} catch (err) {
console.error(`checkAccessToken failed, code is ${err.code}, message is ${err.message}`);
}
return grantStatus;
}
async checkPermissions(permission: Permissions): Promise<boolean> {
let hasPermissions = false;
let grantStatus: abilityAccessCtrl.GrantStatus = await this.checkAccessToken(permission);
if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
// 已经授权,可以继续访问目标操作
hasPermissions = true;
} else {
hasPermissions = false;
// 申请日历权限
}
return hasPermissions;
}
static reqPermissionsFromUser(permissions: Array<Permissions>): void {
// let context = getContext(this) as common.UIAbilityContext;
// let atManager = abilityAccessCtrl.createAtManager();
// // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗
// atManager.requestPermissionsFromUser(context, permissions).then((data) => {
// let grantStatus: Array<number> = data.authResults;
// let length: number = grantStatus.length;
// for (let i = 0; i < length; i++) {
// if (grantStatus[i] === 0) {
// // 用户授权,可以继续访问目标操作
//
// } else {
//
// this.jumpSetting();
// // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限
// AlertDialog.show({
// title: '权限设置',
// message: '到系统设置中打开相应的权限',
// confirm: {
// value: "OK",
// action: () => {
//
// },
// }
// })
// return;
// }
// }
// // 授权成功
// }).catch((err) => {
// console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`);
// })
}
static jumpSetting() {
}
}
... ...
... ... @@ -42,4 +42,16 @@ export class WDRouterPage {
static followListPage = new WDRouterPage("wdComponent", "ets/components/page/FollowListPage");
static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
// 隐私设置页
static privacySettingPage = new WDRouterPage("wdComponent", "ets/components/page/PrivacySettingPage");
// 关于页
static aboutPage = new WDRouterPage("wdComponent", "ets/components/page/SettingAboutPage");
// 设置页
static settingPage = new WDRouterPage("wdComponent", "ets/components/page/SettingPage");
// 账户与安全页
// static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
// 设置密码页、设置手机号页等等 (需要传参)
// static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
}
... ...
import MinePageMoreFunctionModel from '../../viewmodel/MinePageMoreFunctionModel'
import { WDRouterRule, WDRouterPage } from 'wdRouter'
import { Action, Params } from 'wdBean';
import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO';
@Component
export default struct MinePageMoreFunctionUI{
@Link moreData:MinePageMoreFunctionModel[]
export default struct MinePageMoreFunctionUI {
@Link moreData: MinePageMoreFunctionModel[]
build(){
Column(){
Column(){
build() {
Column() {
Column() {
Text(`更多功能`)
.width('456lpx')
.height('38lpx')
.fontColor($r('app.color.color_666666'))
.fontSize('29lpx')
.margin({left:"31lpx"})
.margin({ left: "31lpx" })
.fontWeight(600)
}.height('92lpx')
.width('100%')
... ... @@ -23,17 +26,17 @@ export default struct MinePageMoreFunctionUI{
.width('100%')
.height('1lpx')
List(){
ForEach(this.moreData,(item:MinePageMoreFunctionModel,index:number)=>{
ListItem(){
Column(){
Column(){
Row(){
if(item.imgSrc){
List() {
ForEach(this.moreData, (item: MinePageMoreFunctionModel, index: number) => {
ListItem() {
Column() {
Column() {
Row() {
if (item.imgSrc) {
Image(item.imgSrc)
.width('38lpx')
.height('38lpx')
.margin({right:'15lpx'})
.margin({ right: '15lpx' })
}
Text(`${item.msg}`)
.width('456lpx')
... ... @@ -47,27 +50,36 @@ export default struct MinePageMoreFunctionUI{
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
.margin({left:'81lpx',right:'29lpx'})
.margin({ left: '81lpx', right: '29lpx' })
}.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
}.height('108lpx')
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Start)
.padding({left:'27lpx'})
.padding({ left: '27lpx' })
if(index != this.moreData.length -1 ){
if (index != this.moreData.length - 1) {
Text().backgroundColor($r('app.color.color_F5F5F5'))
.width('612lpx')
.height('1lpx')
}
}
}
.onClick(()=>{
console.log(index+"")
if (index == 3) {
// RouteManager.jumpNewPage("pages/SettingPage")
} else {
// RouteManager.jumpNewPage("pages/PrivacySettingPage")
.onClick(() => {
console.log(index + "")
if (index == 0) {
// WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
} else if (index == 1) {
// WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
} else if (index == 2) {
} else if (index == 3) { //设置
let params: Params = {
pageID: 'mainSetting'
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
}else if (index == 4) { // 关于
WDRouterRule.jumpWithPage(WDRouterPage.aboutPage)
}
})
.height('117lpx')
... ... @@ -78,6 +90,6 @@ export default struct MinePageMoreFunctionUI{
}
.backgroundColor($r('app.color.white'))
.borderRadius(8)
.margin({left:'23lpx',right:'23lpx',top:"19lpx"})
.margin({ left: '23lpx', right: '23lpx', top: "19lpx" })
}
}
\ No newline at end of file
... ...
import { PrivacySettingComponents } from '../setting/PrivacySettingComponents';
@Entry
@Component
struct PrivacySettingPage {
build() {
Column(){
PrivacySettingComponents()
}
}
}
\ No newline at end of file
... ...
import { AboutPageUI } from '../setting/AboutPageUI';
@Entry
@Component
struct SettingAboutPage {
build() {
Column(){
AboutPageUI()
}
}
}
\ No newline at end of file
... ...
import ArrayList from '@ohos.util.ArrayList'
import { MineSettingComponent } from '../setting/MineSettingComponent';
import { AccountAndSecurityLayout } from '../setting/AccountAndSecurityLayout';
import router from '@ohos.router';
import { Action, Params } from 'wdBean';
@Entry
@Component
struct SettingPage {
@State message: string = 'Hello World 02'
@State pageType: string = 'mainSetting';
@State params:Params = router.getParams() as Params;
onPageShow() {
this.pageType = this.params.pageID;
}
build() {
Column() {
if (this.pageType == 'mainSetting') {
MineSettingComponent()
} else {
AccountAndSecurityLayout()
}
}.setFullWidth()
}
// 私有方法
@Styles setFullWidth(){
.width('100%')
}
}
export { SettingPage };
/*
* */
\ No newline at end of file
... ...
const TAG = 'AboutPageUI';
@Component
export struct AboutPageUI {
@State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议'];
@State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.'
@State version: string = '版本号:v8.0.1.1'
build() {
Navigation() {
//滑动区域
this.aboutUi()
}.titleMode(NavigationTitleMode.Mini)
.title('关于')
}
@Builder aboutUi() {
Column() {
Image($r('app.media.setting_about_logo'))
.width('278lpx')
.height('154lpx')
.margin({top:'173lpx',bottom:'154lpx'})
// Row(){
//
// }.backgroundColor(Color.Yellow)
// .width('100%')
// .height('97lpx')
// Row(){
//
// }.backgroundColor(Color.Yellow)
// .width('100%')
// .height('97lpx')
List(){
ForEach(this.listData, (item:string, index : number) =>{
ListItem() {
this.getArrowCell(item, index)
}
})
}.divider({
strokeWidth: 1,
startMargin: '29lpx',
endMargin: '29lpx',
color: '#EDEDED'
})
Blank()
Image($r('app.media.app_icon'))
.width('192lpx')
.height('192lpx')
Text(this.version)
.fontSize('25lpx')
.textAlign(TextAlign.Center)
.fontColor($r("app.color.color_666666"))
.margin({bottom:'31lpx'})
Text(this.message)
.fontSize('19lpx')
.textAlign(TextAlign.Center)
.fontColor($r("app.color.color_999999"))
.margin({bottom:'35lpx'})
}
.width('100%')
.height('100%')
}
// 右文字+箭头cell
@Builder getArrowCell(item:string, index:number) {
Row() {
// 左侧标题
Text(`${item}`)
.fontColor('#666666')
.fontSize('31lpx')
Image($r('app.media.mine_user_arrow'))
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
.height('97lpx')
.width('100%')
.padding({left:'29lpx',right:'29lpx'})
}
}
... ...
import { BottomNavi, CommonConstants } from 'wdConstant';
import { Logger } from 'wdKit';
import { TopNavigationComponent } from '../page/TopNavigationComponent';
// import { BottomNavDTO } from '../../repository/bean/BottomNavDTO';
// import { UIUtils } from '../../repository/UIUtils';
// import { MinePageComponent } from './MinePageComponent';
import PageViewModel from '../../viewmodel/PageViewModel';
import {MineMainSettingFunctionItem} from '../../viewmodel/MineMainSettingFunctionItem';
import MineSettingDatasModel from '../../model/MineSettingDatasModel';
// import MineMainSettingFunctionItem from '../../model/MineSettingDatasModel';
// import { MineMainSettingFunctionItem } from '../setting/MineSettingDatasModel'
import storageStatistics from "@ohos.file.storageStatistics";
import { BusinessError } from '@ohos.base';
import ArrayList from '@ohos.util.ArrayList';
import router from '@ohos.router';
@Component
export struct AccountAndSecurityLayout {
@State listData: Array<MineMainSettingFunctionItem> = new Array;
@State privacySwitch: boolean = false
@State cacheSice: number = 0
aboutToAppear() {
// 获取设置页面数据
this.getAccountAndSecurityData()
}
getAccountAndSecurityData() {
this.listData = MineSettingDatasModel.getAccountAndSecuritySettingData()
}
build() {
Navigation() {
//滑动区域
this.settingList()
}.titleMode(NavigationTitleMode.Mini)
.title('账号与安全')
}
// 页面布局
@Builder settingList() {
Stack({ alignContent: Alignment.Bottom }) {
Column() {
List() {
ForEach(this.listData, (item: MineMainSettingFunctionItem, index: number) => {
ListItem() {
if (item.type == 0) {
Column() {
this.getArrowCell(item)
}.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center)
} else if (item.type == 1) {
Column() {
this.getSwitchCell(item)
}.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center)
} else {
Column().width('100%').height('15lpx').backgroundColor(0xf0f0f0)
}
}
.onClick(() => {
console.log(index + "")
if (index == 1) {
router.pushUrl({
url:"pages/SettingPasswordPage",
params : {'currentType' : 4}
})
}
})
})
}
.divider({
strokeWidth: 1,
startMargin: 15,
endMargin: 10,
color: '#f0f0f0'
})
.onScrollFrameBegin((offset, state) => {
return { offsetRemain: 0 }
})
}.height("100%")
Column() {
Button('退出登录',{ stateEffect: true }).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').onClick(()=>{
AlertDialog.show({
title: '🥟id : ' + "button",
message: '标题:' + '退出登录',
confirm: {
value: "OK",
action: () => {
},
}
})
})
}
}
}
@Builder itemHead(text: string) {
// 列表分组的头部组件,对应联系人分组A、B等位置的组件
if (text.length > 0) {
Row().width('100%').height('20lpx').backgroundColor(0xf0f0f0)
}
}
// 右侧开关cell
@Builder getSwitchCell(item: MineMainSettingFunctionItem) {
Column() {
Row() {
// 左侧logo和标题
Row() {
// 判断有没有图片
if (item.imgSrc) {
Image(item.imgSrc).height('38lpx').margin({ right: '5lpx' })
Text(`${item.title}`).margin({ top: '8lpx' }).height('38lpx').fontColor('#333333').fontSize('29lpx')
} else {
Text(`${item.title}`).margin({ top: '8lpx' }).height('38lpx').fontColor('#333333').fontSize('29lpx')
}
}.width('60%')
// 右侧文案和右箭头
Row() {
Toggle({ type: ToggleType.Switch, isOn: item.switchState })
.height('50lpx')
.margin({ left: '81lpx', right: '29lpx' })
.selectedColor(Color.Pink)
.onChange((isOn: boolean) => {
this.privacySwitch = isOn;
})
}.width('40%')
.margin({ right: '29lpx' })
.justifyContent(FlexAlign.End)
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
}.height('54lpx')
}
// 右文字+箭头cell
@Builder getArrowCell(item: MineMainSettingFunctionItem) {
Column() {
Row() {
// 左侧logo和标题
Row() {
// 判断有没有图片
if (item.imgSrc) {
Image(item.imgSrc)
.height('38lpx')
.margin({ right: '5lpx' })
}
Text(`${item.title}`)
.margin({ top: '8lpx' })
.height('38lpx')
.fontColor('#333333')
.fontSize('29lpx')
}.width('60%')
// 右侧文案和右箭头
Row() {
Text(item.subTitle ? item.subTitle : '')
.fontColor('#999999')
.maxLines(1)
Image($r('app.media.mine_user_arrow'))
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
Column().width('29lpx')
}.width('40%')
.margin({ right: '29lpx' })
.justifyContent(FlexAlign.End)
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
}
.height('54lpx')
}
}
\ No newline at end of file
... ...
import { BottomNavi, CommonConstants } from 'wdConstant';
import { Logger } 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';
@Component
export struct MineSettingComponent {
@State listData: Array<string | Array<string>> = new Array();
@State privacySwitch: boolean = false
@State cacheSice: number = 0
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.appSize / 1024.00 / 1024.00;
}
});
}
getSettingPageData() {
let listArr = [['账户与安全', '接收推送', '隐私设罝', '仅WiFi网络加载图片', 'WiFi网络情况下自动播放视频', '开户播放器悬浮窗'], ['清除缓存', '去评分']];
this.listData = listArr;
}
build() {
Navigation() {
//滑动区域
this.settingList()
}.titleMode(NavigationTitleMode.Mini)
.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) {
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) {
let params: Params = {
pageID: 'AccountAndSecurityLayout'
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
}else if (subIndex == 2) {
WDRouterRule.jumpWithPage(WDRouterPage.privacySettingPage)
}
})
.height('117lpx')
})
}
.divider({
strokeWidth: 1,
startMargin: 15,
endMargin: 10,
color: '#f0f0f0'
})
})
}.onScrollFrameBegin((offset, state) => {
return { offsetRemain: 0 }
})
}
.backgroundColor(Color.White)
.borderRadius(8)
}
@Builder itemHead(text: string) {
// 列表分组的头部组件,对应联系人分组A、B等位置的组件
if (text.length > 0) {
Row().width('100%').height('20lpx').backgroundColor(0xf0f0f0)
}
}
// 右侧开关cell
@Builder getSwitchCell(item:string, index:number) {
Column() {
Row() {
// 左侧logo和标题
Row() {
// 判断有没有图片
if (0) {
Image('https://pic.rmb.bdstatic.com/e182cf67c341d1128d2a6cc05886bf62.jpeg@s_0,h_2000')
.height('38lpx')
.margin({ right: '5lpx' })
Text(`${item}`)
.margin({ top: '8lpx' })
.height('38lpx')
.fontColor('#333333')
.fontSize('29lpx')
} else {
Text(`${item}`)
.margin({ top: '8lpx' })
.height('38lpx')
.fontColor('#333333')
.fontSize('29lpx')
}
}.width('60%')
// 右侧文案和右箭头
Row() {
Toggle({ type: ToggleType.Switch, isOn: false })
.height('50lpx')
.margin({ left: '81lpx', right: '29lpx' })
.selectedColor(Color.Pink)
.onChange((isOn: boolean) => {
this.privacySwitch = isOn;
})
}.width('40%')
.margin({ right: '29lpx' })
.justifyContent(FlexAlign.End)
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
}.height('54lpx')
}
// 右文字+箭头cell
@Builder getArrowCell(item:string, index:number, mainIndex:number) {
Column() {
Row() {
// 左侧logo和标题
Row() {
// 判断有没有图片
if (this.privacySwitch) {
Image('https://pic.rmb.bdstatic.com/e182cf67c341d1128d2a6cc05886bf62.jpeg@s_0,h_2000')
.height('38lpx')
.margin({ right: '5lpx' })
}
Text(`${item}`)
.margin({ top: '8lpx' })
.height('38lpx')
.fontColor('#333333')
.fontSize('29lpx')
}.width('60%')
// 右侧文案和右箭头
Row() {
Text((index == 0 && mainIndex != 0) ? this.cacheSice.toFixed(2) + 'MB' : '')
.fontColor('#999999')
.maxLines(1)
Image($r('app.media.mine_user_arrow'))
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
Column().width('29lpx')
}.width('40%')
.margin({ right: '29lpx' })
.justifyContent(FlexAlign.End)
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
}
.height('54lpx')
}
}
\ No newline at end of file
... ...
import dataPreferences from '@ohos.data.preferences';
import { PermissionUtil } from 'wdKit'
import { SPHelper } from 'wdKit'
import hilog from '@ohos.hilog';
import { PrivacySettingModel } from '../../model/PrivacySettingModel'
const TAG = 'PrivacySettingComponents';
@Component
export struct PrivacySettingComponents {
@State listData: Array<PrivacySettingModel> = [new PrivacySettingModel('开启个性推荐', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'), new PrivacySettingModel('定位权限', false, 'ohos.permission.LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')];
@State tips: string = '设置前可查阅'
@State privacyTips: string = '《隐私政策》'
aboutToAppear() {
// 获取权限=
// SPHelper.default.save('sdf','sdf');
// this.initListData();
this.getPermissionStatus();
// RefreshStatus;
}
async getPermissionStatus() {
const permissionUtil = new PermissionUtil();
for (const element of this.listData) {
if (element.privacyName = '开启个性推荐') {
continue;
}
const result = await permissionUtil.checkPermissions(element.permissionKey);
element.permission = result;
}
}
build() {
Navigation() {
//滑动区域
this.PrivacySettingComponentsUI()
}.titleMode(NavigationTitleMode.Mini)
.title('隐私设置')
.backgroundColor('#F8F8F8')
}
@Builder PrivacySettingComponentsUI() {
Column() {
List({ space: '23lpx' }) {
ForEach(this.listData, (item: PrivacySettingModel, index:number) => {
ListItem() {
if (index == 0) {
getTuiJianCell({ item:item, index:index });
} else {
getArrowCell({ item:item, index:index });
}
}.onClick(() => {
if (index != 0) {
if (!item.permission) {
//跳转权限设置
const permissionUtil = new PermissionUtil();
PermissionUtil.reqPermissionsFromUser([item.permissionKey]);
}
}
})
})
}
.padding({ left: '29lpx', right: '29lpx' })
.margin({ top: '38lpx' })
Row() {
Text(this.tips)
.fontSize('25lpx')
.textAlign(TextAlign.Start)
.fontColor($r("app.color.color_666666"))
.margin({ left: '29lpx', top: '46lpx' })
// .backgroundColor(Color.Orange)
Text(this.privacyTips)
.fontSize('25lpx')
.textAlign(TextAlign.Start)
.fontColor('#ED2800')
.margin({ top: '46lpx' })
.onClick(() => {
//跳转隐私政策
})
}
}
.width('100%')
.height('100%')
.backgroundColor('#F8F8F8')
.alignItems(HorizontalAlign.Start)
}
}
@Component
struct getArrowCell {
@ObjectLink item: PrivacySettingModel;
index:number = 0;
// 右文字+箭头cell
// @Builder getArrowCell(item:PrivacySettingModel, index) {
build() {
Row() {
// 左侧标题
Text(this.item.privacyName)
.fontColor('#666666')
.fontSize('31lpx')
Row() {
Text(this.item.permission ? '已开启' : '去设置')
.fontColor(this.item.permission ? '#666666' : '#CCCCCC')
.fontSize('31lpx')
.margin({ right: '8lpx' })
Image($r('app.media.mine_user_arrow'))
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
}
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
.height('97lpx')
.width('100%')
.padding({ left: '29lpx', right: '29lpx' })
.backgroundColor('#FFFFFF')
.borderRadius('8lpx')
}
}
@Component
struct getTuiJianCell {
@ObjectLink item: PrivacySettingModel;
index:number = 0;
build() {
Column() {
Row() {
// 左侧标题
Text(this.item.privacyName)
.fontColor('#666666')
.fontSize('31lpx')
Row() {
Toggle({ type: ToggleType.Switch, isOn: this.item.permission })
.height('58lpx')
.width('96lpx')
// .selectedColor(Color.Pink)
.onChange((isOn: boolean) => {
// this.privacySwitch = isOn;
})
}
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
.height('97lpx')
.width('100%')
Blank()
.backgroundColor('#EDEDED')
.height('1lpx')
Text('关闭后,将无法看到个性化推荐的服务')
.fontColor('#999999')
.fontSize('23lpx')
.margin({ right: '8lpx' })
.height('69lpx')
}
.alignItems(HorizontalAlign.Start)
.backgroundColor('#FFFFFF')
.borderRadius('8lpx')
.padding({ left: '29lpx', right: '29lpx' })
}
}
... ...
import HashMap from '@ohos.util.HashMap';
import { ResponseDTO, WDHttp } from 'wdNetwork';
import { Logger } from 'wdKit';
import { MineMainSettingFunctionItem } from '../viewmodel/MineMainSettingFunctionItem';
const TAG = "MineSettingDatasModel"
/**
* 我的设置页面 所有数据 获取封装类
*/
class MineSettingDatasModel{
private static instance: MineSettingDatasModel;
mainSettingData:Array<MineMainSettingFunctionItem> = []
accountAndSecurityData:Array<MineMainSettingFunctionItem> = []
private constructor() { }
/**
* 单例模式
* @returns
*/
public static getInstance(): MineSettingDatasModel {
if (!MineSettingDatasModel.instance) {
MineSettingDatasModel.instance = new MineSettingDatasModel();
}
return MineSettingDatasModel.instance;
}
/**
* 评论 关注 收藏 等7个数据
* 包含名字和图标
*/
getMineMainSettingFunctionItemData():MineMainSettingFunctionItem[]{
if(this.mainSettingData.length === 7){
return this.mainSettingData
}
this.mainSettingData = []
this.mainSettingData.push(new MineMainSettingFunctionItem(null, '账户与安全', '18888888888', 0, false))
this.mainSettingData.push(new MineMainSettingFunctionItem(null, '接收推送', null, 1, false))
this.mainSettingData.push(new MineMainSettingFunctionItem(null, '隐私设罝', null, 0, false))
this.mainSettingData.push(new MineMainSettingFunctionItem(null, '仅WiFi网络加载图片', null, 1, false))
this.mainSettingData.push(new MineMainSettingFunctionItem(null, 'WiFi网络情况下自动播放视频', null, 1, false))
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))
return this.mainSettingData
}
/**
* 评论 关注 收藏 等7个数据
* 包含名字和图标
*/
getAccountAndSecuritySettingData():MineMainSettingFunctionItem[]{
if(this.accountAndSecurityData.length === 7){
return this.accountAndSecurityData
}
this.accountAndSecurityData = []
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '更换手机号', '18888888888', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '设置密码', null, 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, null, null, 2, null))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_qqicon'), '绑定QQ', '立即绑定', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_wechaticon'), '绑定微信', '立即绑定', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_weiboicon'), '绑定新浪微博', '立即绑定', 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_appleicon'), 'Apple ID', null, 0, false))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, null, null, 2, null))
this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '注销账号', null, 0, false))
return this.accountAndSecurityData
}
// 网络请求设置数据
fetchAppointmentListData(pageSize:string,pageNum:string) {
// let url = HttpUrlUtils.getAppointmentListDataUrl()+ `?pageSize=${pageSize}&pageNum=${pageNum}`
// let headers: HashMap<string, string> = HttpUrlUtils.getYcgCommonHeaders();
// return WDHttp.get<ResponseDTO<MineAppointmentListItem>>(url, headers)
};
// getAppointmentListData(pageSize:string,pageNum:string): Promise<MineAppointmentListItem> {
// return new Promise<MineAppointmentListItem>((success, error) => {
// Logger.info(TAG, `getAppointmentList start`);
// this.fetchAppointmentListData(pageSize,pageNum).then((navResDTO: ResponseDTO<MineAppointmentListItem>) => {
// if (!navResDTO) {
// error("page data invalid");
// return
// }
// Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
// let navigationBean = navResDTO.data
// success(navigationBean);
// }).catch((err: Error) => {
// Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
// error(err);
// })
// })
// }
}
const mineSettingDatasModel = MineSettingDatasModel.getInstance()
export default mineSettingDatasModel as MineSettingDatasModel
// export default MineMainSettingFunctionItem as MineMainSettingFunctionItem
... ...
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
@Observed
export class PrivacySettingModel{
privacyName: string
permission: boolean
permissionKey: Permissions
constructor(privacyName: string, permission: boolean, permissionKey: Permissions) {
this.privacyName = privacyName;
this.permission = permission;
this.permissionKey = permissionKey;
}
}
\ No newline at end of file
... ...
@Observed
export class MineMainSettingFunctionItem {
imgSrc?:Resource // 图标
title?:string // 标题
subTitle?:string // 副标题
type?:number // 数据类型 0默认箭头类型,1右侧switch按钮类型
switchState?:boolean // 右侧switch按钮状态
constructor(imgSrc:Resource|null,title:string|null,subTitle:string|null,type:number|null,switchState:boolean|null){
if (imgSrc) {
this.imgSrc = imgSrc
}
if (title) {
this.title = title
}
if (subTitle) {
this.subTitle = subTitle
}
if (type != null) {
this.type = type
}
if (switchState != null) {
this.switchState = switchState
}
}
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,10 @@
"src": [
"components/MorningEveningPaper/MorningEveningPaperComponent",
"components/page/AppointmentListPage",
"components/page/FollowListPage"
"components/page/FollowListPage",
"components/page/SettingPage",
"components/page/SettingAboutPage",
"components/page/PrivacySettingPage"
]
}
... ...
... ... @@ -7,10 +7,10 @@
"main": "Index.ets",
"version": "1.0.0",
"dependencies": {
"wdPlayer": "file:../../features/wdPlayer",
"wdKit": "file:../../commons/wdKit",
"wdBean": "file:../../features/wdBean",
"wdRouter": "file:../../commons/wdRouter",
"wdNetwork": "file:../../commons/wdNetwork",
"wdPlayer": "file:../../features/wdPlayer"
"wdNetwork": "file:../../commons/wdNetwork"
}
}
... ...
{
"license": "Apache-2.0",
"devDependencies": {},
"author": "",
"name": "wdlogin",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"version": "1.0.0",
"dependencies": {
"wdConstant": "file:../../commons/wdConstant",
"wdKit": "file:../../commons/wdKit",
... ...
import ArrayList from '@ohos.util.ArrayList';
import promptAction from '@ohos.promptAction';
export default class AccoutPageDataModel {
// 页面数据
compType: number // 0:标题 / 1:密码输入框 / 2:验证码输入框 / 3:desc描述 / 4:按钮 / 5:logo / 6:子标题 7:手机号输入框 7:空白
compLogo: string
compTitle: string
// compSubTitle: string
compDesc: string
compButtonTitle: string
inputPlacholder: string
inputTag: number
constructor(compType: number, compTitle: string, compLogo: string, compDesc: string, compButtonTitle: string, inputPlacholder: string, inputTag: number) {
this.compType = compType
this.compTitle = compTitle
this.compLogo = compLogo
this.compDesc = compDesc
this.compButtonTitle = compButtonTitle
this.inputPlacholder = inputPlacholder
this.inputTag = inputTag
}
}
@Component
export struct SettingPasswordLayout {
@State listData: Array<AccoutPageDataModel> = new Array(); // 页面配置数据
@State btnStatus: boolean = false
password01: string = '';
password02: string = '';
passwordOri: string = '';
aboutToAppear() {
this.getPageListData(4)
}
getPageListData(pageId:number) {
switch (pageId) {
case 0:
// 验证/更换手机号
this.listData.push(new AccoutPageDataModel(0, '更换手机号', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(7, '', '', '', '', '请输入手机号', 10010))
this.listData.push(new AccoutPageDataModel(2, '', '', '', '', '验证码', 10088))
this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
break;
case 1:
// 设置密码
this.listData.push(new AccoutPageDataModel(0, '设置密码', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入密码', 10086))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '再次输入密码', 10087))
this.listData.push(new AccoutPageDataModel(4, '', '', '提示:密码长度6-20位,需答谢字母、小写字母、数字、特殊字符中组合三种及三种以上组成', '', '', 0))
this.listData.push(new AccoutPageDataModel(5, '', '', '', '确认', '', 0))
break;
case 2:
// 修改密码
this.listData.push(new AccoutPageDataModel(0, '修改密码', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入原密码', 10010))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入新密码', 10086))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请再请输入原密码', 10087))
this.listData.push(new AccoutPageDataModel(3, '', '', '提示:密码长度6-20位,需答谢字母、小写字母、数字、特殊字符中组合三种及三种以上组成', '', '', 0))
this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
this.listData.push(new AccoutPageDataModel(3, '', '', '忘记密码', '', '', 0))
break;
case 3:
// 绑定手机号
this.listData.push(new AccoutPageDataModel(0, '绑定手机号', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(7, '', '', '', '', '请输入手机号', 10010))
this.listData.push(new AccoutPageDataModel(2, '', '', '', '', '验证码', 10088))
this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
break;
case 4:
// 有logo的
this.listData.push(new AccoutPageDataModel(5, '', 'https://img-blog.csdnimg.cn/24f43f4d626d428891ebb2adb5c2c2e9.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5YyX5aSn5Z-55paH5byg6ICB5biI,size_20,color_FFFFFF,t_70,g_se,x_16', '', '', '' , 0))
this.listData.push(new AccoutPageDataModel(0, '修改密码', '', '', '', '', 0))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入原密码', 10010))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入新密码', 10086))
this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请再请输入原密码', 10087))
this.listData.push(new AccoutPageDataModel(2, '', '', '', '', '验证码', 10088))
this.listData.push(new AccoutPageDataModel(3, '', '', '提示:密码长度6-20位,需答谢字母、小写字母、数字、特殊字符中组合三种及三种以上组成', '', '', 0))
this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
this.listData.push(new AccoutPageDataModel(3, '', '', '忘记密码', '', '', 0))
break;
default:
break;
}
}
build() {
Navigation() {
this.settingList() //滑动区域
}.titleMode(NavigationTitleMode.Mini)
.title('')
}
// 页面布局
@Builder settingList() {
Column() {
List() {
ForEach(this.listData, (item: AccoutPageDataModel, index: number) => {
ListItem() {
if (item.compType == 0) {
this.getTitleCell(item, HorizontalAlign.Start)
} else if (item.compType == 1) {
this.getPasswordCell(item)
} else if (item.compType == 2) {
this.getCodeCell(item)
} else if (item.compType == 3) {
if (index == this.listData.length - 1) {
this.getDescCell(item, HorizontalAlign.Center)
} else {
this.getDescCell(item, HorizontalAlign.Start)
}
} else if (item.compType == 4) {
this.getButtonCell(item)
} else if (item.compType == 5) {
this.getLogoCell(item)
} else if (item.compType == 7) {
this.getPhoneCell(item)
} else {
Text('' + item.compType)
}
}
})
}
// .divider({
// strokeWidth: 1,
// startMargin: 15,
// endMargin: 10,
// color: '#f0f0f0'
// })
}.width('100%').padding('30lpx')
}
/***************************** UI元素 ******************************************/
// 标题
@Builder getTitleCell(item: AccoutPageDataModel, alignTitle: HorizontalAlign) {
Column() {
Text(item.compTitle).fontWeight(FontWeight.Bold).fontSize(20).maxLines(1)
}
.width('100%')
.height('75lpx')
.alignItems(alignTitle)
}
// 密码输入框
@Builder getPasswordCell(item: AccoutPageDataModel) {
Row() {
Row() {
TextInput({ placeholder: item.inputPlacholder })
.type(InputType.Password)
.backgroundColor('#00000000')
.onChange((value: string) => {
this.inputTextChange(value, item.inputTag)
})
.onSubmit((EnterKeyType) => {
promptAction.showToast({ message: 'submit' })
})
}
.alignItems(VerticalAlign.Center)
.height('80lpx')
.backgroundColor('#f5f5f5')
.borderRadius('4vp')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
}
// 手机号输入框
@Builder getPhoneCell(item: AccoutPageDataModel) {
Row() {
Row() {
TextInput({ placeholder: item.inputPlacholder })
.backgroundColor('#00000000')
.onChange((value: string) => {
this.inputTextChange(value, item.inputTag)
})
.onSubmit((EnterKeyType) => {
promptAction.showToast({ message: 'submit' })
})
}
.alignItems(VerticalAlign.Center)
.height('80lpx')
.backgroundColor('#f5f5f5')
.borderRadius('4vp')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
}
// 验证码码输入框
@Builder getCodeCell(item: AccoutPageDataModel) {
Row() {
Stack() {
Image($r('app.media.get_code_bg')).width('100%').borderRadius('4vp')
Row() {
TextInput({ placeholder: item.inputPlacholder })
.backgroundColor('#00000000')
.width('67.28%')
.onChange((value: string) => {
this.inputTextChange(value, item.inputTag)
})
Button('发送验证码')
.width('32.71%')
.backgroundColor('#00000000')
.fontColor('#da3e22')
}
.width('100%')
}.height('80lpx')
}
.width('100%')
.height('110lpx')
.backgroundColor(0xffffff0)
.alignItems(VerticalAlign.Center)
}
// desc
@Builder getDescCell(item: AccoutPageDataModel, alignTitle: HorizontalAlign) {
Column() {
Text(item.compDesc).fontSize(12).maxLines(3).fontColor(0x999999).padding({top:'10lpx'})
.onClick(()=>{
if (item.compDesc == '忘记密码') {
promptAction.showToast({ message: '密码不符合密码规范' })
}
})
}
.width('100%')
.height('85lpx')
.alignItems(alignTitle)
}
// 按钮
@Builder getButtonCell(item: AccoutPageDataModel) {
Row() {
Button(item.compButtonTitle, { type: ButtonType.Normal, stateEffect: true })
.width('100%')
.height('80lpx')
.backgroundColor(this.btnStatus ? '#da3e22' : '#e5856d')
.fontColor('#fff')
.borderRadius('4vp')
.onClick(() => {
this.buttonClick()
})
}
.padding({top:'25lpx'})
.alignItems(VerticalAlign.Center)
.width('100%')
.height('120lpx')
}
// 标题
@Builder getLogoCell(item: AccoutPageDataModel) {
Column() {
Image(item.compLogo).height('150lpx').width('150lpx')
}
.width('100%')
.height('200lpx')
}
/***************************** 事件处理 ******************************************/
// 提交按钮点击事件
buttonClick() {
if (this.btnStatus) {
// 需要+手机号校验
if (this.password01.length < 6 || this.password01.length > 20) {
promptAction.showToast({ message: '密码不符合密码规范' })
return
}
promptAction.showToast({ message: '请求接口' })
}
}
// 输入框数据变动:输入数据处理
inputTextChange(text: string, tag: number) {
if (tag == 10086) {
this.password01 = text;
} else if (tag == 10087) {
this.password02 = text;
} else {
this.passwordOri = text;
}
if (this.password01) {
if (this.password01 == this.password02 && this.password01.length >= 6 && this.password01.length <= 20) {
this.btnStatus = true;
} else {
this.btnStatus = false;
}
}
}
}
\ No newline at end of file
... ...
import { SettingPasswordLayout } from './SettingPasswordLayout';
@Entry
@Component
struct SettingPasswordPage {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
SettingPasswordLayout()
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
... ...
... ... @@ -3,6 +3,7 @@
"pages/Index",
"pages/login/LoginPage",
"pages/login/ForgetPasswordPage",
"pages/login/LoginProtocolWebview"
"pages/login/LoginProtocolWebview",
"pages/login/SettingPasswordPage"
]
}
... ...
)x." Mb
\ No newline at end of file
... ...
RH>8S\
\ No newline at end of file
... ...
1'PbW gpM
\ No newline at end of file
... ...
Kq )̒ c
\ No newline at end of file
... ...
{
"name": "sight_harmony",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {
},
"devDependencies": {
"@ohos/hypium": "1.0.16"
}
},
"author": "",
"name": "sight_harmony",
"description": "Please describe the basic information.",
"main": "",
"version": "1.0.0",
"dependencies": {}
}
... ...