yangsunyue_wd

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

Showing 49 changed files with 1419 additions and 95 deletions
@@ -8,10 +8,13 @@ import router from '@ohos.router'; @@ -8,10 +8,13 @@ import router from '@ohos.router';
8 struct SettingPage { 8 struct SettingPage {
9 @State message: string = 'Hello World 02' 9 @State message: string = 'Hello World 02'
10 @State pageType: string = ''; 10 @State pageType: string = '';
  11 + @State params:any = router.getParams();
11 12
12 onPageShow() { 13 onPageShow() {
13 - const params = router.getParams(); // 获取传递过来的参数对象  
14 - this.pageType = 'mainSetting';// 获取info属性的值 14 +
  15 + this.pageType = this.params.pageType;
  16 +
  17 + // this.pageType = 'mainSetting';// 获取info属性的值
15 } 18 }
16 19
17 build() { 20 build() {
@@ -4,11 +4,11 @@ @@ -4,11 +4,11 @@
4 "pages/MainPage", 4 "pages/MainPage",
5 "pages/ColumnPage", 5 "pages/ColumnPage",
6 "pages/TestPage", 6 "pages/TestPage",
7 - "pages/SettingPage",  
8 - "pages/PrivacySettingPage",  
9 - "pages/SettingAboutPage", 7 + "components/page/SettingPage",
  8 + "components/page/PrivacySettingPage",
  9 + "components/page/SettingAboutPage",
10 "pages/AppointmentListPage", 10 "pages/AppointmentListPage",
11 - "pages/SettingPasswordPage", 11 + "components/page/SettingPasswordPage",
12 "pages/FollowListPage" 12 "pages/FollowListPage"
13 ] 13 ]
14 } 14 }
@@ -12,6 +12,7 @@ import { MineMainSettingFunctionItem } from '../viewmodel/MineMainSettingFunctio @@ -12,6 +12,7 @@ import { MineMainSettingFunctionItem } from '../viewmodel/MineMainSettingFunctio
12 import storageStatistics from "@ohos.file.storageStatistics"; 12 import storageStatistics from "@ohos.file.storageStatistics";
13 import { BusinessError } from '@ohos.base'; 13 import { BusinessError } from '@ohos.base';
14 import ArrayList from '@ohos.util.ArrayList'; 14 import ArrayList from '@ohos.util.ArrayList';
  15 +import router from '@ohos.router';
15 16
16 17
17 @Component 18 @Component
@@ -58,7 +59,12 @@ export struct AccountAndSecurityLayout { @@ -58,7 +59,12 @@ export struct AccountAndSecurityLayout {
58 } 59 }
59 .onClick(() => { 60 .onClick(() => {
60 console.log(index + "") 61 console.log(index + "")
61 - RouteManager.jumpNewPage("pages/SettingPasswordPage") // 调用跳转方法,跳转新页面 62 + if (index == 1) {
  63 + router.pushUrl({
  64 + url:"pages/SettingPasswordPage",
  65 + params : {'currentType' : 4}
  66 + })
  67 + }
62 }) 68 })
63 69
64 }, item => item) 70 }, item => item)
@@ -11,6 +11,7 @@ import RouteManager from '../../utils/RouteManager' @@ -11,6 +11,7 @@ import RouteManager from '../../utils/RouteManager'
11 import storageStatistics from "@ohos.file.storageStatistics"; 11 import storageStatistics from "@ohos.file.storageStatistics";
12 import { BusinessError } from '@ohos.base'; 12 import { BusinessError } from '@ohos.base';
13 import RouteManager from '../../utils/RouteManager' 13 import RouteManager from '../../utils/RouteManager'
  14 +import router from '@ohos.router';
14 15
15 16
16 @Component 17 @Component
@@ -67,15 +68,25 @@ export struct MineSettingComponent { @@ -67,15 +68,25 @@ export struct MineSettingComponent {
67 }.padding({ left: '27lpx' }) 68 }.padding({ left: '27lpx' })
68 .onClick(() => { 69 .onClick(() => {
69 70
70 - // 在Home页面中  
71 - let paramsInfo: object = {  
72 - pageId: 123,  
73 - pageType:'AccountAndSecurityLayout'  
74 - };  
75 - RouteManager.jumpNewPage("pages/SettingPasswordPage") // 调用跳转方法,跳转新页面  
76 - 71 + // // 在Home页面中
  72 + // let paramsInfo: object = {
  73 + // pageId: 123,
  74 + // pageType:'AccountAndSecurityLayout'
  75 + // };
77 console.log(subIndex + "") 76 console.log(subIndex + "")
78 - if (subIndex == 2) { 77 + if (subIndex == 0) {
  78 + // router.pushUrl({
  79 + // url:"pages/SettingPasswordPage",
  80 + // params : {'currentType' : 4}
  81 + // })
  82 +
  83 + router.pushUrl({
  84 + url:"pages/SettingPage",
  85 + params : {'pageType' : 'AccountAndSecurityLayout'}
  86 + })
  87 + //SettingPage
  88 + // RouteManager.jumpNewPage("pages/SettingPasswordPage", {'currentType' : 4}) // 调用跳转方法,跳转新页面
  89 + }else if (subIndex == 2) {
79 // RouteManager.jumpNewPage("pages/SettingPage") // 调用跳转方法,跳转新页面 90 // RouteManager.jumpNewPage("pages/SettingPage") // 调用跳转方法,跳转新页面
80 RouteManager.jumpNewPage("pages/PrivacySettingPage") 91 RouteManager.jumpNewPage("pages/PrivacySettingPage")
81 } 92 }
@@ -2,7 +2,7 @@ import dataPreferences from '@ohos.data.preferences'; @@ -2,7 +2,7 @@ import dataPreferences from '@ohos.data.preferences';
2 import { PermissionUtil } from 'wdKit' 2 import { PermissionUtil } from 'wdKit'
3 import { SPHelper } from 'wdKit' 3 import { SPHelper } from 'wdKit'
4 import hilog from '@ohos.hilog'; 4 import hilog from '@ohos.hilog';
5 -import {PrivacySettingModel} from '../../viewmodel/PrivacySettingModel' 5 +import { PrivacySettingModel } from '../../viewmodel/PrivacySettingModel'
6 6
7 const TAG = 'PrivacySettingComponents'; 7 const TAG = 'PrivacySettingComponents';
8 8
@@ -31,7 +31,7 @@ export struct PrivacySettingComponents { @@ -31,7 +31,7 @@ export struct PrivacySettingComponents {
31 // this.listData.push(model1, model2, model3, model4, model5); 31 // this.listData.push(model1, model2, model3, model4, model5);
32 // } 32 // }
33 33
34 - async getPermissionStatus(){ 34 + async getPermissionStatus() {
35 const permissionUtil = new PermissionUtil(); 35 const permissionUtil = new PermissionUtil();
36 for (const element of this.listData) { 36 for (const element of this.listData) {
37 if (!element.permissionKey) { 37 if (!element.permissionKey) {
@@ -55,17 +55,17 @@ export struct PrivacySettingComponents { @@ -55,17 +55,17 @@ export struct PrivacySettingComponents {
55 @Builder PrivacySettingComponentsUI() { 55 @Builder PrivacySettingComponentsUI() {
56 Column() { 56 Column() {
57 57
58 - List({space:'23lpx'}){  
59 - ForEach(this.listData, (item:PrivacySettingModel, index) =>{ 58 + List({ space: '23lpx' }) {
  59 + ForEach(this.listData, (item: PrivacySettingModel, index) => {
60 ListItem() { 60 ListItem() {
61 if (index == 0) { 61 if (index == 0) {
62 - getTuiJianCell({item, index});  
63 - }else{  
64 - getArrowCell({item, index}); 62 + getTuiJianCell({ item, index });
  63 + } else {
  64 + getArrowCell({ item, index });
65 } 65 }
66 - }.onClick(()=>{ 66 + }.onClick(() => {
67 if (index != 0) { 67 if (index != 0) {
68 - if (!item.permission){ 68 + if (!item.permission) {
69 //跳转权限设置 69 //跳转权限设置
70 const permissionUtil = new PermissionUtil(); 70 const permissionUtil = new PermissionUtil();
71 PermissionUtil.reqPermissionsFromUser([item.permissionKey]); 71 PermissionUtil.reqPermissionsFromUser([item.permissionKey]);
@@ -74,27 +74,26 @@ export struct PrivacySettingComponents { @@ -74,27 +74,26 @@ export struct PrivacySettingComponents {
74 }) 74 })
75 }, item => item) 75 }, item => item)
76 } 76 }
77 - .padding({left:'29lpx', right:'29lpx'})  
78 - .margin({top:'38lpx'}) 77 + .padding({ left: '29lpx', right: '29lpx' })
  78 + .margin({ top: '38lpx' })
79 79
80 - Row(){ 80 + Row() {
81 Text(this.tips) 81 Text(this.tips)
82 .fontSize('25lpx') 82 .fontSize('25lpx')
83 .textAlign(TextAlign.Start) 83 .textAlign(TextAlign.Start)
84 .fontColor($r("app.color.color_666666")) 84 .fontColor($r("app.color.color_666666"))
85 - .margin({left:'29lpx', top:'46lpx'}) 85 + .margin({ left: '29lpx', top: '46lpx' })
86 // .backgroundColor(Color.Orange) 86 // .backgroundColor(Color.Orange)
87 Text(this.privacyTips) 87 Text(this.privacyTips)
88 .fontSize('25lpx') 88 .fontSize('25lpx')
89 .textAlign(TextAlign.Start) 89 .textAlign(TextAlign.Start)
90 .fontColor('#ED2800') 90 .fontColor('#ED2800')
91 - .margin({top:'46lpx'})  
92 - .onClick(()=>{ 91 + .margin({ top: '46lpx' })
  92 + .onClick(() => {
93 //跳转隐私政策 93 //跳转隐私政策
94 }) 94 })
95 } 95 }
96 96
97 -  
98 } 97 }
99 .width('100%') 98 .width('100%')
100 .height('100%') 99 .height('100%')
@@ -141,9 +140,10 @@ struct getArrowCell { @@ -141,9 +140,10 @@ struct getArrowCell {
141 } 140 }
142 141
143 @Component 142 @Component
144 -struct getTuiJianCell{  
145 - @ObjectLink item :PrivacySettingModel; 143 +struct getTuiJianCell {
  144 + @ObjectLink item: PrivacySettingModel;
146 index; 145 index;
  146 +
147 build() { 147 build() {
148 //@Builder getTuiJianCell(item:PrivacySettingModel, index) 148 //@Builder getTuiJianCell(item:PrivacySettingModel, index)
149 Column() { 149 Column() {
1 import MinePageMoreFunctionModel from '../../../viewmodel/MinePageMoreFunctionModel' 1 import MinePageMoreFunctionModel from '../../../viewmodel/MinePageMoreFunctionModel'
2 import RouteManager from '../../../utils/RouteManager' 2 import RouteManager from '../../../utils/RouteManager'
  3 +import router from '@ohos.router'
3 4
4 @Component 5 @Component
5 export default struct MinePageMoreFunctionUI{ 6 export default struct MinePageMoreFunctionUI{
@@ -66,18 +67,14 @@ export default struct MinePageMoreFunctionUI{ @@ -66,18 +67,14 @@ export default struct MinePageMoreFunctionUI{
66 .onClick(()=>{ 67 .onClick(()=>{
67 console.log(index+"") 68 console.log(index+"")
68 if (index == 3) { 69 if (index == 3) {
69 - RouteManager.jumpNewPage("pages/SettingPage") 70 + router.pushUrl({
  71 + url:"pages/SettingPage",
  72 + params : {'pageType' : 'mainSetting'}
  73 + })
70 } else if (index == 2) { 74 } else if (index == 2) {
71 - RouteManager.jumpNewPage("pages/PrivacySettingPage") 75 + // RouteManager.jumpNewPage("pages/PrivacySettingPage")
72 } else if (index == 4) { 76 } else if (index == 4) {
73 RouteManager.jumpNewPage("pages/SettingAboutPage") 77 RouteManager.jumpNewPage("pages/SettingAboutPage")
74 - }else {  
75 - // 在Home页面中  
76 - let paramsInfo: object = {  
77 - pageId: 123,  
78 - pageType:'mainSetting'  
79 - };  
80 - RouteManager.jumpNewPage("pages/PrivacySettingPage",paramsInfo)  
81 } 78 }
82 79
83 }) 80 })
1 1
2 -import MinePagePersonalFunctionsItem from '../viewmodel/MinePagePersonalFunctionsItem'  
3 -import MinePageCreatorFunctionsItem from '../viewmodel/MinePageCreatorFunctionsItem'  
4 -import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel';  
5 -import { HttpUrlUtils } from '../network/HttpUrlUtils'; 2 +import MinePagePersonalFunctionsItem from '../../../../../../../../PeopleDaily_Harmony/wdComponent/src/main/ets/viewmodel/MinePagePersonalFunctionsItem'
  3 +import MinePageCreatorFunctionsItem from '../../../../../../../../PeopleDaily_Harmony/wdComponent/src/main/ets/viewmodel/MinePageCreatorFunctionsItem'
  4 +import MinePageMoreFunctionModel from '../../../../../../../../PeopleDaily_Harmony/wdComponent/src/main/ets/viewmodel/MinePageMoreFunctionModel';
  5 +import { HttpUrlUtils } from '../../../../../../../../PeopleDaily_Harmony/wdComponent/src/main/ets/network/HttpUrlUtils';
6 import HashMap from '@ohos.util.HashMap'; 6 import HashMap from '@ohos.util.HashMap';
7 import { ResponseDTO, WDHttp } from 'wdNetwork'; 7 import { ResponseDTO, WDHttp } from 'wdNetwork';
8 import { Logger } from 'wdKit'; 8 import { Logger } from 'wdKit';
9 -import { MineMainSettingFunctionItem } from '../viewmodel/MineMainSettingFunctionItem' 9 +import { MineMainSettingFunctionItem } from '../../../../../../../../PeopleDaily_Harmony/wdComponent/src/main/ets/viewmodel/MineMainSettingFunctionItem'
10 10
11 const TAG = "MineSettingDatasModel" 11 const TAG = "MineSettingDatasModel"
12 12
@@ -68,10 +68,10 @@ class MineSettingDatasModel{ @@ -68,10 +68,10 @@ class MineSettingDatasModel{
68 this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '更换手机号', '18888888888', 0, false)) 68 this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '更换手机号', '18888888888', 0, false))
69 this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '设置密码', null, 0, false)) 69 this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '设置密码', null, 0, false))
70 this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, null, null, 2, null)) 70 this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, null, null, 2, null))
71 - this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.mine_order_icon'), '绑定QQ', '立即绑定', 0, false))  
72 - this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.mine_order_icon'), '绑定微信', '立即绑定', 0, false))  
73 - this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.mine_order_icon'), '绑定新浪微博', '立即绑定', 0, false))  
74 - this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, 'Apple ID', null, 0, false)) 71 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_qqicon'), '绑定QQ', '立即绑定', 0, false))
  72 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_wechaticon'), '绑定微信', '立即绑定', 0, false))
  73 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_weiboicon'), '绑定新浪微博', '立即绑定', 0, false))
  74 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_appleicon'), 'Apple ID', null, 0, false))
75 this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, null, null, 2, null)) 75 this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, null, null, 2, null))
76 76
77 this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '注销账号', null, 0, false)) 77 this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '注销账号', null, 0, false))
@@ -5,13 +5,13 @@ @@ -5,13 +5,13 @@
5 "name": "default", 5 "name": "default",
6 "type": "HarmonyOS", 6 "type": "HarmonyOS",
7 "material": { 7 "material": {
8 - "certpath": "C:\\Users\\PC\\.ohos\\config\\default_sight_harmony_vDjosN2opayZneQDLiBs3Lc0sT1uPzRAYaDxxv2LWEQ=.cer",  
9 - "storePassword": "0000001A87430EDC6C0D1CD6A6473A6D385177DBFF70325BBD48C7E491A0D9B37F91920FD46D82B2436B", 8 + "certpath": "/Users/ysy/.ohos/config/auto_debug_sight_harmony_com.wondertek.sight_30086000745972390.cer",
  9 + "storePassword": "0000001AD1ABE6FB1D5AEC538066BBDCACCDF8DFB85BA89D4A7B163112F48FDFAD37222DD5D2FBC6738C",
10 "keyAlias": "debugKey", 10 "keyAlias": "debugKey",
11 - "keyPassword": "0000001A8E615E1CB276AA122C291AFBCDFF792FEE8AA618B186EE7C99220C7F549B8C2ED6A209703D75",  
12 - "profile": "C:\\Users\\PC\\.ohos\\config\\default_sight_harmony_vDjosN2opayZneQDLiBs3Lc0sT1uPzRAYaDxxv2LWEQ=.p7b", 11 + "keyPassword": "0000001AA4301CF4CB6CD92BFD749A3C09BC771B02A1E544A47EBBC557DB27E8150CB2AB5CB13029999D",
  12 + "profile": "/Users/ysy/.ohos/config/auto_debug_sight_harmony_com.wondertek.sight_30086000745972390.p7b",
13 "signAlg": "SHA256withECDSA", 13 "signAlg": "SHA256withECDSA",
14 - "storeFile": "C:\\Users\\PC\\.ohos\\config\\default_sight_harmony_vDjosN2opayZneQDLiBs3Lc0sT1uPzRAYaDxxv2LWEQ=.p12" 14 + "storeFile": "/Users/ysy/.ohos/config/auto_debug_sight_harmony_com.wondertek.sight_30086000745972390.p12"
15 } 15 }
16 } 16 }
17 ], 17 ],
@@ -29,3 +29,5 @@ export { DeviceUtil } from './src/main/ets/utils/DeviceUtil' @@ -29,3 +29,5 @@ export { DeviceUtil } from './src/main/ets/utils/DeviceUtil'
29 export { DisplayUtils } from './src/main/ets/utils/DisplayUtils' 29 export { DisplayUtils } from './src/main/ets/utils/DisplayUtils'
30 30
31 export { SystemUtils } from './src/main/ets/utils/SystemUtils' 31 export { SystemUtils } from './src/main/ets/utils/SystemUtils'
  32 +
  33 +export { PermissionUtil } from './src/main/ets/utils/PermissionUtil'
  1 +import bundleManager from '@ohos.bundle.bundleManager';
  2 +import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
  3 +import common from '@ohos.app.ability.common';
  4 +import featureAbility from '@ohos.ability.featureAbility';
  5 +import wantConstant from '@ohos.ability.wantConstant';
  6 +
  7 +export class PermissionUtil {
  8 + async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> {
  9 + let atManager = abilityAccessCtrl.createAtManager();
  10 + let grantStatus: abilityAccessCtrl.GrantStatus = abilityAccessCtrl.GrantStatus.PERMISSION_DENIED;
  11 +
  12 + // 获取应用程序的accessTokenID
  13 + let tokenId: number = 0;
  14 + try {
  15 + let bundleInfo: bundleManager.BundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
  16 + let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo;
  17 + tokenId = appInfo.accessTokenId;
  18 + } catch (err) {
  19 + console.error(`getBundleInfoForSelf failed, code is ${err.code}, message is ${err.message}`);
  20 + }
  21 +
  22 + // 校验应用是否被授予权限
  23 + try {
  24 + grantStatus = await atManager.checkAccessToken(tokenId, permission);
  25 + } catch (err) {
  26 + console.error(`checkAccessToken failed, code is ${err.code}, message is ${err.message}`);
  27 + }
  28 +
  29 + return grantStatus;
  30 + }
  31 +
  32 + async checkPermissions(permission: Permissions): Promise<boolean> {
  33 + let hasPermissions = false;
  34 + let grantStatus: abilityAccessCtrl.GrantStatus = await this.checkAccessToken(permission);
  35 +
  36 + if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
  37 + // 已经授权,可以继续访问目标操作
  38 + hasPermissions = true;
  39 + } else {
  40 + hasPermissions = false;
  41 + // 申请日历权限
  42 + }
  43 + return hasPermissions;
  44 + }
  45 +
  46 + static reqPermissionsFromUser(permissions: Array<Permissions>): void {
  47 + // let context = getContext(this) as common.UIAbilityContext;
  48 + // let atManager = abilityAccessCtrl.createAtManager();
  49 + // // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗
  50 + // atManager.requestPermissionsFromUser(context, permissions).then((data) => {
  51 + // let grantStatus: Array<number> = data.authResults;
  52 + // let length: number = grantStatus.length;
  53 + // for (let i = 0; i < length; i++) {
  54 + // if (grantStatus[i] === 0) {
  55 + // // 用户授权,可以继续访问目标操作
  56 + //
  57 + // } else {
  58 + //
  59 + // this.jumpSetting();
  60 + // // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限
  61 + // AlertDialog.show({
  62 + // title: '权限设置',
  63 + // message: '到系统设置中打开相应的权限',
  64 + // confirm: {
  65 + // value: "OK",
  66 + // action: () => {
  67 + //
  68 + // },
  69 + // }
  70 + // })
  71 + // return;
  72 + // }
  73 + // }
  74 + // // 授权成功
  75 + // }).catch((err) => {
  76 + // console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`);
  77 + // })
  78 + }
  79 +
  80 +
  81 + static jumpSetting() {
  82 +
  83 + }
  84 +}
@@ -42,4 +42,16 @@ export class WDRouterPage { @@ -42,4 +42,16 @@ export class WDRouterPage {
42 static followListPage = new WDRouterPage("wdComponent", "ets/components/page/FollowListPage"); 42 static followListPage = new WDRouterPage("wdComponent", "ets/components/page/FollowListPage");
43 43
44 static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview"); 44 static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
  45 +
  46 + // 隐私设置页
  47 + static privacySettingPage = new WDRouterPage("wdComponent", "ets/components/page/PrivacySettingPage");
  48 + // 关于页
  49 + static aboutPage = new WDRouterPage("wdComponent", "ets/components/page/SettingAboutPage");
  50 + // 设置页
  51 + static settingPage = new WDRouterPage("wdComponent", "ets/components/page/SettingPage");
  52 + // 账户与安全页
  53 + // static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
  54 + // 设置密码页、设置手机号页等等 (需要传参)
  55 + // static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
  56 +
45 } 57 }
1 import MinePageMoreFunctionModel from '../../viewmodel/MinePageMoreFunctionModel' 1 import MinePageMoreFunctionModel from '../../viewmodel/MinePageMoreFunctionModel'
  2 +import { WDRouterRule, WDRouterPage } from 'wdRouter'
  3 +import { Action, Params } from 'wdBean';
  4 +import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO';
2 5
3 @Component 6 @Component
4 -export default struct MinePageMoreFunctionUI{  
5 - @Link moreData:MinePageMoreFunctionModel[] 7 +export default struct MinePageMoreFunctionUI {
  8 + @Link moreData: MinePageMoreFunctionModel[]
6 9
7 - build(){  
8 - Column(){  
9 - Column(){ 10 + build() {
  11 + Column() {
  12 + Column() {
10 Text(`更多功能`) 13 Text(`更多功能`)
11 .width('456lpx') 14 .width('456lpx')
12 .height('38lpx') 15 .height('38lpx')
13 .fontColor($r('app.color.color_666666')) 16 .fontColor($r('app.color.color_666666'))
14 .fontSize('29lpx') 17 .fontSize('29lpx')
15 - .margin({left:"31lpx"}) 18 + .margin({ left: "31lpx" })
16 .fontWeight(600) 19 .fontWeight(600)
17 }.height('92lpx') 20 }.height('92lpx')
18 .width('100%') 21 .width('100%')
@@ -23,17 +26,17 @@ export default struct MinePageMoreFunctionUI{ @@ -23,17 +26,17 @@ export default struct MinePageMoreFunctionUI{
23 .width('100%') 26 .width('100%')
24 .height('1lpx') 27 .height('1lpx')
25 28
26 - List(){  
27 - ForEach(this.moreData,(item:MinePageMoreFunctionModel,index:number)=>{  
28 - ListItem(){  
29 - Column(){  
30 - Column(){  
31 - Row(){  
32 - if(item.imgSrc){ 29 + List() {
  30 + ForEach(this.moreData, (item: MinePageMoreFunctionModel, index: number) => {
  31 + ListItem() {
  32 + Column() {
  33 + Column() {
  34 + Row() {
  35 + if (item.imgSrc) {
33 Image(item.imgSrc) 36 Image(item.imgSrc)
34 .width('38lpx') 37 .width('38lpx')
35 .height('38lpx') 38 .height('38lpx')
36 - .margin({right:'15lpx'}) 39 + .margin({ right: '15lpx' })
37 } 40 }
38 Text(`${item.msg}`) 41 Text(`${item.msg}`)
39 .width('456lpx') 42 .width('456lpx')
@@ -47,27 +50,36 @@ export default struct MinePageMoreFunctionUI{ @@ -47,27 +50,36 @@ export default struct MinePageMoreFunctionUI{
47 .width('27lpx') 50 .width('27lpx')
48 .height('27lpx') 51 .height('27lpx')
49 .objectFit(ImageFit.Auto) 52 .objectFit(ImageFit.Auto)
50 - .margin({left:'81lpx',right:'29lpx'}) 53 + .margin({ left: '81lpx', right: '29lpx' })
51 }.alignItems(VerticalAlign.Center) 54 }.alignItems(VerticalAlign.Center)
52 .justifyContent(FlexAlign.Center) 55 .justifyContent(FlexAlign.Center)
53 }.height('108lpx') 56 }.height('108lpx')
54 .justifyContent(FlexAlign.Center) 57 .justifyContent(FlexAlign.Center)
55 .alignItems(HorizontalAlign.Start) 58 .alignItems(HorizontalAlign.Start)
56 - .padding({left:'27lpx'}) 59 + .padding({ left: '27lpx' })
57 60
58 - if(index != this.moreData.length -1 ){ 61 + if (index != this.moreData.length - 1) {
59 Text().backgroundColor($r('app.color.color_F5F5F5')) 62 Text().backgroundColor($r('app.color.color_F5F5F5'))
60 .width('612lpx') 63 .width('612lpx')
61 .height('1lpx') 64 .height('1lpx')
62 } 65 }
63 } 66 }
64 } 67 }
65 - .onClick(()=>{  
66 - console.log(index+"")  
67 - if (index == 3) {  
68 - // RouteManager.jumpNewPage("pages/SettingPage")  
69 - } else {  
70 - // RouteManager.jumpNewPage("pages/PrivacySettingPage") 68 + .onClick(() => {
  69 + console.log(index + "")
  70 + if (index == 0) {
  71 + // WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  72 + } else if (index == 1) {
  73 + // WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  74 + } else if (index == 2) {
  75 +
  76 + } else if (index == 3) { //设置
  77 + let params: Params = {
  78 + pageID: 'mainSetting'
  79 + }
  80 + WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
  81 + }else if (index == 4) { // 关于
  82 + WDRouterRule.jumpWithPage(WDRouterPage.aboutPage)
71 } 83 }
72 }) 84 })
73 .height('117lpx') 85 .height('117lpx')
@@ -78,6 +90,6 @@ export default struct MinePageMoreFunctionUI{ @@ -78,6 +90,6 @@ export default struct MinePageMoreFunctionUI{
78 } 90 }
79 .backgroundColor($r('app.color.white')) 91 .backgroundColor($r('app.color.white'))
80 .borderRadius(8) 92 .borderRadius(8)
81 - .margin({left:'23lpx',right:'23lpx',top:"19lpx"}) 93 + .margin({ left: '23lpx', right: '23lpx', top: "19lpx" })
82 } 94 }
83 } 95 }
  1 +
  2 +import { PrivacySettingComponents } from '../setting/PrivacySettingComponents';
  3 +@Entry
  4 +@Component
  5 +struct PrivacySettingPage {
  6 + build() {
  7 + Column(){
  8 + PrivacySettingComponents()
  9 + }
  10 + }
  11 +}
  1 +import { AboutPageUI } from '../setting/AboutPageUI';
  2 +
  3 +@Entry
  4 +@Component
  5 +struct SettingAboutPage {
  6 + build() {
  7 + Column(){
  8 + AboutPageUI()
  9 + }
  10 + }
  11 +}
  1 +import ArrayList from '@ohos.util.ArrayList'
  2 +import { MineSettingComponent } from '../setting/MineSettingComponent';
  3 +import { AccountAndSecurityLayout } from '../setting/AccountAndSecurityLayout';
  4 +import router from '@ohos.router';
  5 +import { Action, Params } from 'wdBean';
  6 +
  7 +@Entry
  8 +@Component
  9 +struct SettingPage {
  10 + @State message: string = 'Hello World 02'
  11 + @State pageType: string = 'mainSetting';
  12 + @State params:Params = router.getParams() as Params;
  13 +
  14 + onPageShow() {
  15 +
  16 + this.pageType = this.params.pageID;
  17 +
  18 + }
  19 +
  20 + build() {
  21 + Column() {
  22 + if (this.pageType == 'mainSetting') {
  23 + MineSettingComponent()
  24 + } else {
  25 + AccountAndSecurityLayout()
  26 + }
  27 + }.setFullWidth()
  28 + }
  29 +
  30 + // 私有方法
  31 + @Styles setFullWidth(){
  32 + .width('100%')
  33 + }
  34 +}
  35 +
  36 +export { SettingPage };
  37 +
  38 +/*
  39 +
  40 +* */
  1 +const TAG = 'AboutPageUI';
  2 +
  3 +@Component
  4 +export struct AboutPageUI {
  5 + @State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议'];
  6 + @State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.'
  7 + @State version: string = '版本号:v8.0.1.1'
  8 +
  9 +
  10 + build() {
  11 + Navigation() {
  12 + //滑动区域
  13 + this.aboutUi()
  14 + }.titleMode(NavigationTitleMode.Mini)
  15 + .title('关于')
  16 + }
  17 +
  18 + @Builder aboutUi() {
  19 + Column() {
  20 + Image($r('app.media.setting_about_logo'))
  21 + .width('278lpx')
  22 + .height('154lpx')
  23 + .margin({top:'173lpx',bottom:'154lpx'})
  24 +
  25 + // Row(){
  26 + //
  27 + // }.backgroundColor(Color.Yellow)
  28 + // .width('100%')
  29 + // .height('97lpx')
  30 +
  31 + // Row(){
  32 + //
  33 + // }.backgroundColor(Color.Yellow)
  34 + // .width('100%')
  35 + // .height('97lpx')
  36 +
  37 +
  38 +
  39 +
  40 + List(){
  41 + ForEach(this.listData, (item:string, index : number) =>{
  42 + ListItem() {
  43 + this.getArrowCell(item, index)
  44 + }
  45 + })
  46 + }.divider({
  47 + strokeWidth: 1,
  48 + startMargin: '29lpx',
  49 + endMargin: '29lpx',
  50 + color: '#EDEDED'
  51 + })
  52 +
  53 + Blank()
  54 +
  55 + Image($r('app.media.app_icon'))
  56 + .width('192lpx')
  57 + .height('192lpx')
  58 +
  59 + Text(this.version)
  60 + .fontSize('25lpx')
  61 + .textAlign(TextAlign.Center)
  62 + .fontColor($r("app.color.color_666666"))
  63 + .margin({bottom:'31lpx'})
  64 +
  65 + Text(this.message)
  66 + .fontSize('19lpx')
  67 + .textAlign(TextAlign.Center)
  68 + .fontColor($r("app.color.color_999999"))
  69 + .margin({bottom:'35lpx'})
  70 + }
  71 + .width('100%')
  72 + .height('100%')
  73 + }
  74 +
  75 +
  76 +
  77 + // 右文字+箭头cell
  78 + @Builder getArrowCell(item:string, index:number) {
  79 +
  80 + Row() {
  81 + // 左侧标题
  82 + Text(`${item}`)
  83 + .fontColor('#666666')
  84 + .fontSize('31lpx')
  85 +
  86 + Image($r('app.media.mine_user_arrow'))
  87 + .width('27lpx')
  88 + .height('27lpx')
  89 + .objectFit(ImageFit.Auto)
  90 + }
  91 + .alignItems(VerticalAlign.Center)
  92 + .justifyContent(FlexAlign.SpaceBetween)
  93 + .height('97lpx')
  94 + .width('100%')
  95 + .padding({left:'29lpx',right:'29lpx'})
  96 + }
  97 +
  98 +
  99 +}
  100 +
  101 +
  1 +
  2 +import { BottomNavi, CommonConstants } from 'wdConstant';
  3 +import { Logger } from 'wdKit';
  4 +import { TopNavigationComponent } from '../page/TopNavigationComponent';
  5 +// import { BottomNavDTO } from '../../repository/bean/BottomNavDTO';
  6 +// import { UIUtils } from '../../repository/UIUtils';
  7 +// import { MinePageComponent } from './MinePageComponent';
  8 +import PageViewModel from '../../viewmodel/PageViewModel';
  9 +import {MineMainSettingFunctionItem} from '../../viewmodel/MineMainSettingFunctionItem';
  10 +import MineSettingDatasModel from '../../model/MineSettingDatasModel';
  11 +// import MineMainSettingFunctionItem from '../../model/MineSettingDatasModel';
  12 +// import { MineMainSettingFunctionItem } from '../setting/MineSettingDatasModel'
  13 +
  14 +import storageStatistics from "@ohos.file.storageStatistics";
  15 +import { BusinessError } from '@ohos.base';
  16 +import ArrayList from '@ohos.util.ArrayList';
  17 +import router from '@ohos.router';
  18 +
  19 +
  20 +@Component
  21 +export struct AccountAndSecurityLayout {
  22 + @State listData: Array<MineMainSettingFunctionItem> = new Array;
  23 + @State privacySwitch: boolean = false
  24 + @State cacheSice: number = 0
  25 +
  26 + aboutToAppear() {
  27 + // 获取设置页面数据
  28 + this.getAccountAndSecurityData()
  29 + }
  30 +
  31 + getAccountAndSecurityData() {
  32 + this.listData = MineSettingDatasModel.getAccountAndSecuritySettingData()
  33 + }
  34 +
  35 + build() {
  36 + Navigation() {
  37 + //滑动区域
  38 + this.settingList()
  39 + }.titleMode(NavigationTitleMode.Mini)
  40 + .title('账号与安全')
  41 + }
  42 +
  43 + // 页面布局
  44 + @Builder settingList() {
  45 + Stack({ alignContent: Alignment.Bottom }) {
  46 + Column() {
  47 + List() {
  48 + ForEach(this.listData, (item: MineMainSettingFunctionItem, index: number) => {
  49 + ListItem() {
  50 + if (item.type == 0) {
  51 + Column() {
  52 + this.getArrowCell(item)
  53 + }.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center)
  54 + } else if (item.type == 1) {
  55 + Column() {
  56 + this.getSwitchCell(item)
  57 + }.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center)
  58 + } else {
  59 + Column().width('100%').height('15lpx').backgroundColor(0xf0f0f0)
  60 + }
  61 + }
  62 + .onClick(() => {
  63 + console.log(index + "")
  64 + if (index == 1) {
  65 + router.pushUrl({
  66 + url:"pages/SettingPasswordPage",
  67 + params : {'currentType' : 4}
  68 + })
  69 + }
  70 + })
  71 +
  72 + })
  73 + }
  74 + .divider({
  75 + strokeWidth: 1,
  76 + startMargin: 15,
  77 + endMargin: 10,
  78 + color: '#f0f0f0'
  79 + })
  80 + .onScrollFrameBegin((offset, state) => {
  81 + return { offsetRemain: 0 }
  82 + })
  83 + }.height("100%")
  84 +
  85 + Column() {
  86 + Button('退出登录',{ stateEffect: true }).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').onClick(()=>{
  87 + AlertDialog.show({
  88 + title: '🥟id : ' + "button",
  89 + message: '标题:' + '退出登录',
  90 + confirm: {
  91 + value: "OK",
  92 + action: () => {
  93 +
  94 + },
  95 + }
  96 + })
  97 + })
  98 + }
  99 +
  100 + }
  101 + }
  102 +
  103 + @Builder itemHead(text: string) {
  104 + // 列表分组的头部组件,对应联系人分组A、B等位置的组件
  105 + if (text.length > 0) {
  106 + Row().width('100%').height('20lpx').backgroundColor(0xf0f0f0)
  107 + }
  108 + }
  109 +
  110 + // 右侧开关cell
  111 + @Builder getSwitchCell(item: MineMainSettingFunctionItem) {
  112 + Column() {
  113 + Row() {
  114 + // 左侧logo和标题
  115 + Row() {
  116 + // 判断有没有图片
  117 + if (item.imgSrc) {
  118 + Image(item.imgSrc).height('38lpx').margin({ right: '5lpx' })
  119 + Text(`${item.title}`).margin({ top: '8lpx' }).height('38lpx').fontColor('#333333').fontSize('29lpx')
  120 + } else {
  121 + Text(`${item.title}`).margin({ top: '8lpx' }).height('38lpx').fontColor('#333333').fontSize('29lpx')
  122 + }
  123 + }.width('60%')
  124 +
  125 + // 右侧文案和右箭头
  126 + Row() {
  127 + Toggle({ type: ToggleType.Switch, isOn: item.switchState })
  128 + .height('50lpx')
  129 + .margin({ left: '81lpx', right: '29lpx' })
  130 + .selectedColor(Color.Pink)
  131 + .onChange((isOn: boolean) => {
  132 + this.privacySwitch = isOn;
  133 + })
  134 + }.width('40%')
  135 + .margin({ right: '29lpx' })
  136 + .justifyContent(FlexAlign.End)
  137 +
  138 + }
  139 + .alignItems(VerticalAlign.Center)
  140 + .justifyContent(FlexAlign.SpaceBetween)
  141 + }.height('54lpx')
  142 + }
  143 +
  144 + // 右文字+箭头cell
  145 + @Builder getArrowCell(item: MineMainSettingFunctionItem) {
  146 + Column() {
  147 + Row() {
  148 + // 左侧logo和标题
  149 + Row() {
  150 + // 判断有没有图片
  151 + if (item.imgSrc) {
  152 + Image(item.imgSrc)
  153 + .height('38lpx')
  154 + .margin({ right: '5lpx' })
  155 + }
  156 + Text(`${item.title}`)
  157 + .margin({ top: '8lpx' })
  158 + .height('38lpx')
  159 + .fontColor('#333333')
  160 + .fontSize('29lpx')
  161 + }.width('60%')
  162 +
  163 + // 右侧文案和右箭头
  164 + Row() {
  165 + Text(item.subTitle ? item.subTitle : '')
  166 + .fontColor('#999999')
  167 + .maxLines(1)
  168 + Image($r('app.media.mine_user_arrow'))
  169 + .width('27lpx')
  170 + .height('27lpx')
  171 + .objectFit(ImageFit.Auto)
  172 + Column().width('29lpx')
  173 + }.width('40%')
  174 + .margin({ right: '29lpx' })
  175 + .justifyContent(FlexAlign.End)
  176 +
  177 + }
  178 + .alignItems(VerticalAlign.Center)
  179 + .justifyContent(FlexAlign.SpaceBetween)
  180 +
  181 + }
  182 + .height('54lpx')
  183 + }
  184 +}
  1 +import { BottomNavi, CommonConstants } from 'wdConstant';
  2 +import { Logger } from 'wdKit';
  3 +import PageViewModel from '../../viewmodel/PageViewModel';
  4 +import storageStatistics from "@ohos.file.storageStatistics";
  5 +import { BusinessError } from '@ohos.base';
  6 +import router from '@ohos.router';
  7 +import { WDRouterPage, WDRouterRule } from 'wdRouter';
  8 +import { Params } from 'wdBean';
  9 +
  10 +
  11 +@Component
  12 +export struct MineSettingComponent {
  13 + @State listData: Array<string | Array<string>> = new Array();
  14 + @State privacySwitch: boolean = false
  15 + @State cacheSice: number = 0
  16 +
  17 + aboutToAppear() {
  18 + // 获取设置页面数据
  19 + this.getSettingPageData()
  20 +
  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.appSize / 1024.00 / 1024.00;
  27 + }
  28 + });
  29 + }
  30 +
  31 + getSettingPageData() {
  32 + let listArr = [['账户与安全', '接收推送', '隐私设罝', '仅WiFi网络加载图片', 'WiFi网络情况下自动播放视频', '开户播放器悬浮窗'], ['清除缓存', '去评分']];
  33 + this.listData = listArr;
  34 + }
  35 +
  36 + build() {
  37 + Navigation() {
  38 + //滑动区域
  39 + this.settingList()
  40 + }.titleMode(NavigationTitleMode.Mini)
  41 + .title('设置')
  42 + }
  43 +
  44 + // 页面布局
  45 + @Builder settingList() {
  46 + Column() {
  47 + List() {
  48 + // 循环渲染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) {
  72 +
  73 + let params: Params = {
  74 + pageID: 'AccountAndSecurityLayout'
  75 + }
  76 + WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
  77 + }else if (subIndex == 2) {
  78 + WDRouterRule.jumpWithPage(WDRouterPage.privacySettingPage)
  79 + }
  80 +
  81 + })
  82 + .height('117lpx')
  83 + })
  84 + }
  85 + .divider({
  86 + strokeWidth: 1,
  87 + startMargin: 15,
  88 + endMargin: 10,
  89 + color: '#f0f0f0'
  90 + })
  91 + })
  92 + }.onScrollFrameBegin((offset, state) => {
  93 + return { offsetRemain: 0 }
  94 + })
  95 + }
  96 + .backgroundColor(Color.White)
  97 + .borderRadius(8)
  98 + }
  99 +
  100 + @Builder itemHead(text: string) {
  101 + // 列表分组的头部组件,对应联系人分组A、B等位置的组件
  102 + if (text.length > 0) {
  103 + Row().width('100%').height('20lpx').backgroundColor(0xf0f0f0)
  104 + }
  105 + }
  106 +
  107 + // 右侧开关cell
  108 + @Builder getSwitchCell(item:string, index:number) {
  109 + Column() {
  110 + Row() {
  111 + // 左侧logo和标题
  112 + Row() {
  113 + // 判断有没有图片
  114 + if (0) {
  115 + Image('https://pic.rmb.bdstatic.com/e182cf67c341d1128d2a6cc05886bf62.jpeg@s_0,h_2000')
  116 + .height('38lpx')
  117 + .margin({ right: '5lpx' })
  118 +
  119 + Text(`${item}`)
  120 + .margin({ top: '8lpx' })
  121 + .height('38lpx')
  122 + .fontColor('#333333')
  123 + .fontSize('29lpx')
  124 + } else {
  125 + Text(`${item}`)
  126 + .margin({ top: '8lpx' })
  127 + .height('38lpx')
  128 + .fontColor('#333333')
  129 + .fontSize('29lpx')
  130 + }
  131 + }.width('60%')
  132 +
  133 + // 右侧文案和右箭头
  134 + Row() {
  135 + Toggle({ type: ToggleType.Switch, isOn: false })
  136 + .height('50lpx')
  137 + .margin({ left: '81lpx', right: '29lpx' })
  138 + .selectedColor(Color.Pink)
  139 + .onChange((isOn: boolean) => {
  140 + this.privacySwitch = isOn;
  141 + })
  142 + }.width('40%')
  143 + .margin({ right: '29lpx' })
  144 + .justifyContent(FlexAlign.End)
  145 +
  146 + }
  147 + .alignItems(VerticalAlign.Center)
  148 + .justifyContent(FlexAlign.SpaceBetween)
  149 + }.height('54lpx')
  150 + }
  151 +
  152 + // 右文字+箭头cell
  153 + @Builder getArrowCell(item:string, index:number, mainIndex:number) {
  154 + Column() {
  155 +
  156 + Row() {
  157 + // 左侧logo和标题
  158 + Row() {
  159 + // 判断有没有图片
  160 + if (this.privacySwitch) {
  161 + Image('https://pic.rmb.bdstatic.com/e182cf67c341d1128d2a6cc05886bf62.jpeg@s_0,h_2000')
  162 + .height('38lpx')
  163 + .margin({ right: '5lpx' })
  164 + }
  165 + Text(`${item}`)
  166 + .margin({ top: '8lpx' })
  167 + .height('38lpx')
  168 + .fontColor('#333333')
  169 + .fontSize('29lpx')
  170 + }.width('60%')
  171 +
  172 + // 右侧文案和右箭头
  173 + Row() {
  174 + Text((index == 0 && mainIndex != 0) ? this.cacheSice.toFixed(2) + 'MB' : '')
  175 + .fontColor('#999999')
  176 + .maxLines(1)
  177 + Image($r('app.media.mine_user_arrow'))
  178 + .width('27lpx')
  179 + .height('27lpx')
  180 + .objectFit(ImageFit.Auto)
  181 + Column().width('29lpx')
  182 + }.width('40%')
  183 + .margin({ right: '29lpx' })
  184 + .justifyContent(FlexAlign.End)
  185 +
  186 + }
  187 + .alignItems(VerticalAlign.Center)
  188 + .justifyContent(FlexAlign.SpaceBetween)
  189 +
  190 + }
  191 + .height('54lpx')
  192 + }
  193 +}
  1 +import dataPreferences from '@ohos.data.preferences';
  2 +import { PermissionUtil } from 'wdKit'
  3 +import { SPHelper } from 'wdKit'
  4 +import hilog from '@ohos.hilog';
  5 +import { PrivacySettingModel } from '../../model/PrivacySettingModel'
  6 +
  7 +const TAG = 'PrivacySettingComponents';
  8 +
  9 +@Component
  10 +export struct PrivacySettingComponents {
  11 + @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')];
  12 + @State tips: string = '设置前可查阅'
  13 + @State privacyTips: string = '《隐私政策》'
  14 +
  15 + aboutToAppear() {
  16 + // 获取权限=
  17 + // SPHelper.default.save('sdf','sdf');
  18 + // this.initListData();
  19 + this.getPermissionStatus();
  20 + // RefreshStatus;
  21 +
  22 + }
  23 +
  24 + async getPermissionStatus() {
  25 + const permissionUtil = new PermissionUtil();
  26 + for (const element of this.listData) {
  27 + if (element.privacyName = '开启个性推荐') {
  28 + continue;
  29 + }
  30 + const result = await permissionUtil.checkPermissions(element.permissionKey);
  31 + element.permission = result;
  32 + }
  33 + }
  34 +
  35 + build() {
  36 + Navigation() {
  37 + //滑动区域
  38 + this.PrivacySettingComponentsUI()
  39 +
  40 + }.titleMode(NavigationTitleMode.Mini)
  41 + .title('隐私设置')
  42 + .backgroundColor('#F8F8F8')
  43 + }
  44 +
  45 + @Builder PrivacySettingComponentsUI() {
  46 + Column() {
  47 +
  48 + List({ space: '23lpx' }) {
  49 + ForEach(this.listData, (item: PrivacySettingModel, index:number) => {
  50 + ListItem() {
  51 + if (index == 0) {
  52 + getTuiJianCell({ item:item, index:index });
  53 + } else {
  54 + getArrowCell({ item:item, index:index });
  55 + }
  56 + }.onClick(() => {
  57 + if (index != 0) {
  58 + if (!item.permission) {
  59 + //跳转权限设置
  60 + const permissionUtil = new PermissionUtil();
  61 + PermissionUtil.reqPermissionsFromUser([item.permissionKey]);
  62 + }
  63 + }
  64 + })
  65 + })
  66 + }
  67 + .padding({ left: '29lpx', right: '29lpx' })
  68 + .margin({ top: '38lpx' })
  69 +
  70 + Row() {
  71 + Text(this.tips)
  72 + .fontSize('25lpx')
  73 + .textAlign(TextAlign.Start)
  74 + .fontColor($r("app.color.color_666666"))
  75 + .margin({ left: '29lpx', top: '46lpx' })
  76 + // .backgroundColor(Color.Orange)
  77 + Text(this.privacyTips)
  78 + .fontSize('25lpx')
  79 + .textAlign(TextAlign.Start)
  80 + .fontColor('#ED2800')
  81 + .margin({ top: '46lpx' })
  82 + .onClick(() => {
  83 + //跳转隐私政策
  84 + })
  85 + }
  86 +
  87 + }
  88 + .width('100%')
  89 + .height('100%')
  90 + .backgroundColor('#F8F8F8')
  91 + .alignItems(HorizontalAlign.Start)
  92 + }
  93 +}
  94 +
  95 +
  96 +@Component
  97 +struct getArrowCell {
  98 + @ObjectLink item: PrivacySettingModel;
  99 + index:number = 0;
  100 + // 右文字+箭头cell
  101 + // @Builder getArrowCell(item:PrivacySettingModel, index) {
  102 + build() {
  103 + Row() {
  104 + // 左侧标题
  105 + Text(this.item.privacyName)
  106 + .fontColor('#666666')
  107 + .fontSize('31lpx')
  108 +
  109 + Row() {
  110 + Text(this.item.permission ? '已开启' : '去设置')
  111 + .fontColor(this.item.permission ? '#666666' : '#CCCCCC')
  112 + .fontSize('31lpx')
  113 + .margin({ right: '8lpx' })
  114 +
  115 + Image($r('app.media.mine_user_arrow'))
  116 + .width('27lpx')
  117 + .height('27lpx')
  118 + .objectFit(ImageFit.Auto)
  119 + }
  120 +
  121 + }
  122 + .alignItems(VerticalAlign.Center)
  123 + .justifyContent(FlexAlign.SpaceBetween)
  124 + .height('97lpx')
  125 + .width('100%')
  126 + .padding({ left: '29lpx', right: '29lpx' })
  127 + .backgroundColor('#FFFFFF')
  128 + .borderRadius('8lpx')
  129 + }
  130 +}
  131 +
  132 +@Component
  133 +struct getTuiJianCell {
  134 + @ObjectLink item: PrivacySettingModel;
  135 + index:number = 0;
  136 + build() {
  137 + Column() {
  138 +
  139 + Row() {
  140 + // 左侧标题
  141 + Text(this.item.privacyName)
  142 + .fontColor('#666666')
  143 + .fontSize('31lpx')
  144 +
  145 + Row() {
  146 + Toggle({ type: ToggleType.Switch, isOn: this.item.permission })
  147 + .height('58lpx')
  148 + .width('96lpx')
  149 + // .selectedColor(Color.Pink)
  150 + .onChange((isOn: boolean) => {
  151 + // this.privacySwitch = isOn;
  152 + })
  153 + }
  154 +
  155 + }
  156 + .alignItems(VerticalAlign.Center)
  157 + .justifyContent(FlexAlign.SpaceBetween)
  158 + .height('97lpx')
  159 + .width('100%')
  160 +
  161 +
  162 + Blank()
  163 + .backgroundColor('#EDEDED')
  164 + .height('1lpx')
  165 +
  166 + Text('关闭后,将无法看到个性化推荐的服务')
  167 + .fontColor('#999999')
  168 + .fontSize('23lpx')
  169 + .margin({ right: '8lpx' })
  170 + .height('69lpx')
  171 +
  172 + }
  173 + .alignItems(HorizontalAlign.Start)
  174 + .backgroundColor('#FFFFFF')
  175 + .borderRadius('8lpx')
  176 + .padding({ left: '29lpx', right: '29lpx' })
  177 + }
  178 +}
  1 +
  2 +import HashMap from '@ohos.util.HashMap';
  3 +import { ResponseDTO, WDHttp } from 'wdNetwork';
  4 +import { Logger } from 'wdKit';
  5 +import { MineMainSettingFunctionItem } from '../viewmodel/MineMainSettingFunctionItem';
  6 +
  7 +
  8 +const TAG = "MineSettingDatasModel"
  9 +
  10 +/**
  11 + * 我的设置页面 所有数据 获取封装类
  12 + */
  13 +class MineSettingDatasModel{
  14 + private static instance: MineSettingDatasModel;
  15 + mainSettingData:Array<MineMainSettingFunctionItem> = []
  16 + accountAndSecurityData:Array<MineMainSettingFunctionItem> = []
  17 +
  18 + private constructor() { }
  19 +
  20 + /**
  21 + * 单例模式
  22 + * @returns
  23 + */
  24 + public static getInstance(): MineSettingDatasModel {
  25 + if (!MineSettingDatasModel.instance) {
  26 + MineSettingDatasModel.instance = new MineSettingDatasModel();
  27 + }
  28 + return MineSettingDatasModel.instance;
  29 + }
  30 +
  31 +
  32 +
  33 +
  34 + /**
  35 + * 评论 关注 收藏 等7个数据
  36 + * 包含名字和图标
  37 + */
  38 + getMineMainSettingFunctionItemData():MineMainSettingFunctionItem[]{
  39 + if(this.mainSettingData.length === 7){
  40 + return this.mainSettingData
  41 + }
  42 + this.mainSettingData = []
  43 + this.mainSettingData.push(new MineMainSettingFunctionItem(null, '账户与安全', '18888888888', 0, false))
  44 + this.mainSettingData.push(new MineMainSettingFunctionItem(null, '接收推送', null, 1, false))
  45 + this.mainSettingData.push(new MineMainSettingFunctionItem(null, '隐私设罝', null, 0, false))
  46 + this.mainSettingData.push(new MineMainSettingFunctionItem(null, '仅WiFi网络加载图片', null, 1, false))
  47 + this.mainSettingData.push(new MineMainSettingFunctionItem(null, 'WiFi网络情况下自动播放视频', null, 1, false))
  48 + this.mainSettingData.push(new MineMainSettingFunctionItem(null, '开户播放器悬浮窗', null, 1, false))
  49 + this.mainSettingData.push(new MineMainSettingFunctionItem(null, null, null, 2, null))
  50 + this.mainSettingData.push(new MineMainSettingFunctionItem(null, '清除缓存', '32MB', 0, false))
  51 + this.mainSettingData.push(new MineMainSettingFunctionItem(null, '去评分', null, 0, false))
  52 +
  53 + return this.mainSettingData
  54 + }
  55 +
  56 + /**
  57 + * 评论 关注 收藏 等7个数据
  58 + * 包含名字和图标
  59 + */
  60 + getAccountAndSecuritySettingData():MineMainSettingFunctionItem[]{
  61 + if(this.accountAndSecurityData.length === 7){
  62 + return this.accountAndSecurityData
  63 + }
  64 + this.accountAndSecurityData = []
  65 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '更换手机号', '18888888888', 0, false))
  66 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '设置密码', null, 0, false))
  67 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, null, null, 2, null))
  68 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_qqicon'), '绑定QQ', '立即绑定', 0, false))
  69 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_wechaticon'), '绑定微信', '立即绑定', 0, false))
  70 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_weiboicon'), '绑定新浪微博', '立即绑定', 0, false))
  71 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem($r('app.media.account_appleicon'), 'Apple ID', null, 0, false))
  72 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, null, null, 2, null))
  73 +
  74 + this.accountAndSecurityData.push(new MineMainSettingFunctionItem(null, '注销账号', null, 0, false))
  75 +
  76 + return this.accountAndSecurityData
  77 + }
  78 +
  79 +
  80 +
  81 + // 网络请求设置数据
  82 + fetchAppointmentListData(pageSize:string,pageNum:string) {
  83 + // let url = HttpUrlUtils.getAppointmentListDataUrl()+ `?pageSize=${pageSize}&pageNum=${pageNum}`
  84 + // let headers: HashMap<string, string> = HttpUrlUtils.getYcgCommonHeaders();
  85 + // return WDHttp.get<ResponseDTO<MineAppointmentListItem>>(url, headers)
  86 + };
  87 +
  88 + // getAppointmentListData(pageSize:string,pageNum:string): Promise<MineAppointmentListItem> {
  89 + // return new Promise<MineAppointmentListItem>((success, error) => {
  90 + // Logger.info(TAG, `getAppointmentList start`);
  91 + // this.fetchAppointmentListData(pageSize,pageNum).then((navResDTO: ResponseDTO<MineAppointmentListItem>) => {
  92 + // if (!navResDTO) {
  93 + // error("page data invalid");
  94 + // return
  95 + // }
  96 + // Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
  97 + // let navigationBean = navResDTO.data
  98 + // success(navigationBean);
  99 + // }).catch((err: Error) => {
  100 + // Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
  101 + // error(err);
  102 + // })
  103 + // })
  104 + // }
  105 +
  106 +}
  107 +
  108 +const mineSettingDatasModel = MineSettingDatasModel.getInstance()
  109 +export default mineSettingDatasModel as MineSettingDatasModel
  110 +// export default MineMainSettingFunctionItem as MineMainSettingFunctionItem
  1 +import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
  2 +@Observed
  3 +export class PrivacySettingModel{
  4 + privacyName: string
  5 + permission: boolean
  6 + permissionKey: Permissions
  7 +
  8 + constructor(privacyName: string, permission: boolean, permissionKey: Permissions) {
  9 + this.privacyName = privacyName;
  10 + this.permission = permission;
  11 + this.permissionKey = permissionKey;
  12 + }
  13 +}
  1 +
  2 +@Observed
  3 +export class MineMainSettingFunctionItem {
  4 + imgSrc?:Resource // 图标
  5 + title?:string // 标题
  6 + subTitle?:string // 副标题
  7 + type?:number // 数据类型 0默认箭头类型,1右侧switch按钮类型
  8 + switchState?:boolean // 右侧switch按钮状态
  9 +
  10 +
  11 + constructor(imgSrc:Resource|null,title:string|null,subTitle:string|null,type:number|null,switchState:boolean|null){
  12 + if (imgSrc) {
  13 + this.imgSrc = imgSrc
  14 + }
  15 + if (title) {
  16 + this.title = title
  17 + }
  18 + if (subTitle) {
  19 + this.subTitle = subTitle
  20 + }
  21 + if (type != null) {
  22 + this.type = type
  23 + }
  24 + if (switchState != null) {
  25 + this.switchState = switchState
  26 + }
  27 +
  28 + }
  29 +}
@@ -2,7 +2,10 @@ @@ -2,7 +2,10 @@
2 "src": [ 2 "src": [
3 "components/MorningEveningPaper/MorningEveningPaperComponent", 3 "components/MorningEveningPaper/MorningEveningPaperComponent",
4 "components/page/AppointmentListPage", 4 "components/page/AppointmentListPage",
5 - "components/page/FollowListPage" 5 + "components/page/FollowListPage",
  6 + "components/page/SettingPage",
  7 + "components/page/SettingAboutPage",
  8 + "components/page/PrivacySettingPage"
6 ] 9 ]
7 } 10 }
8 11
@@ -7,10 +7,10 @@ @@ -7,10 +7,10 @@
7 "main": "Index.ets", 7 "main": "Index.ets",
8 "version": "1.0.0", 8 "version": "1.0.0",
9 "dependencies": { 9 "dependencies": {
  10 + "wdPlayer": "file:../../features/wdPlayer",
10 "wdKit": "file:../../commons/wdKit", 11 "wdKit": "file:../../commons/wdKit",
11 "wdBean": "file:../../features/wdBean", 12 "wdBean": "file:../../features/wdBean",
12 "wdRouter": "file:../../commons/wdRouter", 13 "wdRouter": "file:../../commons/wdRouter",
13 - "wdNetwork": "file:../../commons/wdNetwork",  
14 - "wdPlayer": "file:../../features/wdPlayer" 14 + "wdNetwork": "file:../../commons/wdNetwork"
15 } 15 }
16 } 16 }
1 { 1 {
  2 + "license": "Apache-2.0",
  3 + "devDependencies": {},
  4 + "author": "",
2 "name": "wdlogin", 5 "name": "wdlogin",
3 - "version": "1.0.0",  
4 "description": "Please describe the basic information.", 6 "description": "Please describe the basic information.",
5 "main": "Index.ets", 7 "main": "Index.ets",
6 - "author": "",  
7 - "license": "Apache-2.0", 8 + "version": "1.0.0",
8 "dependencies": { 9 "dependencies": {
9 "wdConstant": "file:../../commons/wdConstant", 10 "wdConstant": "file:../../commons/wdConstant",
10 "wdKit": "file:../../commons/wdKit", 11 "wdKit": "file:../../commons/wdKit",
  1 +import ArrayList from '@ohos.util.ArrayList';
  2 +import promptAction from '@ohos.promptAction';
  3 +
  4 +export default class AccoutPageDataModel {
  5 + // 页面数据
  6 + compType: number // 0:标题 / 1:密码输入框 / 2:验证码输入框 / 3:desc描述 / 4:按钮 / 5:logo / 6:子标题 7:手机号输入框 7:空白
  7 + compLogo: string
  8 + compTitle: string
  9 + // compSubTitle: string
  10 + compDesc: string
  11 + compButtonTitle: string
  12 + inputPlacholder: string
  13 + inputTag: number
  14 +
  15 + constructor(compType: number, compTitle: string, compLogo: string, compDesc: string, compButtonTitle: string, inputPlacholder: string, inputTag: number) {
  16 + this.compType = compType
  17 + this.compTitle = compTitle
  18 + this.compLogo = compLogo
  19 + this.compDesc = compDesc
  20 + this.compButtonTitle = compButtonTitle
  21 + this.inputPlacholder = inputPlacholder
  22 + this.inputTag = inputTag
  23 + }
  24 +}
  25 +
  26 +@Component
  27 +export struct SettingPasswordLayout {
  28 + @State listData: Array<AccoutPageDataModel> = new Array(); // 页面配置数据
  29 + @State btnStatus: boolean = false
  30 + password01: string = '';
  31 + password02: string = '';
  32 + passwordOri: string = '';
  33 +
  34 + aboutToAppear() {
  35 + this.getPageListData(4)
  36 + }
  37 +
  38 + getPageListData(pageId:number) {
  39 + switch (pageId) {
  40 + case 0:
  41 + // 验证/更换手机号
  42 + this.listData.push(new AccoutPageDataModel(0, '更换手机号', '', '', '', '', 0))
  43 + this.listData.push(new AccoutPageDataModel(7, '', '', '', '', '请输入手机号', 10010))
  44 + this.listData.push(new AccoutPageDataModel(2, '', '', '', '', '验证码', 10088))
  45 + this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
  46 + break;
  47 +
  48 + case 1:
  49 + // 设置密码
  50 + this.listData.push(new AccoutPageDataModel(0, '设置密码', '', '', '', '', 0))
  51 + this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入密码', 10086))
  52 + this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '再次输入密码', 10087))
  53 + this.listData.push(new AccoutPageDataModel(4, '', '', '提示:密码长度6-20位,需答谢字母、小写字母、数字、特殊字符中组合三种及三种以上组成', '', '', 0))
  54 + this.listData.push(new AccoutPageDataModel(5, '', '', '', '确认', '', 0))
  55 + break;
  56 +
  57 + case 2:
  58 + // 修改密码
  59 + this.listData.push(new AccoutPageDataModel(0, '修改密码', '', '', '', '', 0))
  60 + this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入原密码', 10010))
  61 + this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入新密码', 10086))
  62 + this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请再请输入原密码', 10087))
  63 + this.listData.push(new AccoutPageDataModel(3, '', '', '提示:密码长度6-20位,需答谢字母、小写字母、数字、特殊字符中组合三种及三种以上组成', '', '', 0))
  64 + this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
  65 + this.listData.push(new AccoutPageDataModel(3, '', '', '忘记密码', '', '', 0))
  66 + break;
  67 +
  68 + case 3:
  69 + // 绑定手机号
  70 + this.listData.push(new AccoutPageDataModel(0, '绑定手机号', '', '', '', '', 0))
  71 + this.listData.push(new AccoutPageDataModel(7, '', '', '', '', '请输入手机号', 10010))
  72 + this.listData.push(new AccoutPageDataModel(2, '', '', '', '', '验证码', 10088))
  73 + this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
  74 + break;
  75 +
  76 + case 4:
  77 + // 有logo的
  78 + 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))
  79 + this.listData.push(new AccoutPageDataModel(0, '修改密码', '', '', '', '', 0))
  80 + this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入原密码', 10010))
  81 + this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请输入新密码', 10086))
  82 + this.listData.push(new AccoutPageDataModel(1, '', '', '', '', '请再请输入原密码', 10087))
  83 + this.listData.push(new AccoutPageDataModel(2, '', '', '', '', '验证码', 10088))
  84 + this.listData.push(new AccoutPageDataModel(3, '', '', '提示:密码长度6-20位,需答谢字母、小写字母、数字、特殊字符中组合三种及三种以上组成', '', '', 0))
  85 + this.listData.push(new AccoutPageDataModel(4, '', '', '', '确认', '', 0))
  86 + this.listData.push(new AccoutPageDataModel(3, '', '', '忘记密码', '', '', 0))
  87 + break;
  88 +
  89 + default:
  90 + break;
  91 + }
  92 + }
  93 +
  94 + build() {
  95 + Navigation() {
  96 + this.settingList() //滑动区域
  97 + }.titleMode(NavigationTitleMode.Mini)
  98 + .title('')
  99 + }
  100 +
  101 + // 页面布局
  102 + @Builder settingList() {
  103 + Column() {
  104 + List() {
  105 + ForEach(this.listData, (item: AccoutPageDataModel, index: number) => {
  106 + ListItem() {
  107 + if (item.compType == 0) {
  108 + this.getTitleCell(item, HorizontalAlign.Start)
  109 + } else if (item.compType == 1) {
  110 + this.getPasswordCell(item)
  111 + } else if (item.compType == 2) {
  112 + this.getCodeCell(item)
  113 + } else if (item.compType == 3) {
  114 + if (index == this.listData.length - 1) {
  115 + this.getDescCell(item, HorizontalAlign.Center)
  116 + } else {
  117 + this.getDescCell(item, HorizontalAlign.Start)
  118 + }
  119 + } else if (item.compType == 4) {
  120 + this.getButtonCell(item)
  121 + } else if (item.compType == 5) {
  122 + this.getLogoCell(item)
  123 + } else if (item.compType == 7) {
  124 + this.getPhoneCell(item)
  125 + } else {
  126 + Text('' + item.compType)
  127 + }
  128 + }
  129 + })
  130 + }
  131 + // .divider({
  132 + // strokeWidth: 1,
  133 + // startMargin: 15,
  134 + // endMargin: 10,
  135 + // color: '#f0f0f0'
  136 + // })
  137 + }.width('100%').padding('30lpx')
  138 + }
  139 +
  140 + /***************************** UI元素 ******************************************/
  141 +
  142 + // 标题
  143 + @Builder getTitleCell(item: AccoutPageDataModel, alignTitle: HorizontalAlign) {
  144 + Column() {
  145 + Text(item.compTitle).fontWeight(FontWeight.Bold).fontSize(20).maxLines(1)
  146 + }
  147 + .width('100%')
  148 + .height('75lpx')
  149 + .alignItems(alignTitle)
  150 + }
  151 +
  152 + // 密码输入框
  153 + @Builder getPasswordCell(item: AccoutPageDataModel) {
  154 + Row() {
  155 + Row() {
  156 + TextInput({ placeholder: item.inputPlacholder })
  157 + .type(InputType.Password)
  158 + .backgroundColor('#00000000')
  159 + .onChange((value: string) => {
  160 + this.inputTextChange(value, item.inputTag)
  161 + })
  162 + .onSubmit((EnterKeyType) => {
  163 + promptAction.showToast({ message: 'submit' })
  164 + })
  165 + }
  166 + .alignItems(VerticalAlign.Center)
  167 + .height('80lpx')
  168 + .backgroundColor('#f5f5f5')
  169 + .borderRadius('4vp')
  170 + }
  171 + .width('100%')
  172 + .height('110lpx')
  173 + .backgroundColor(0xffffff0)
  174 + .alignItems(VerticalAlign.Center)
  175 + }
  176 +
  177 + // 手机号输入框
  178 + @Builder getPhoneCell(item: AccoutPageDataModel) {
  179 + Row() {
  180 + Row() {
  181 + TextInput({ placeholder: item.inputPlacholder })
  182 + .backgroundColor('#00000000')
  183 + .onChange((value: string) => {
  184 + this.inputTextChange(value, item.inputTag)
  185 + })
  186 + .onSubmit((EnterKeyType) => {
  187 + promptAction.showToast({ message: 'submit' })
  188 + })
  189 + }
  190 + .alignItems(VerticalAlign.Center)
  191 + .height('80lpx')
  192 + .backgroundColor('#f5f5f5')
  193 + .borderRadius('4vp')
  194 + }
  195 + .width('100%')
  196 + .height('110lpx')
  197 + .backgroundColor(0xffffff0)
  198 + .alignItems(VerticalAlign.Center)
  199 + }
  200 +
  201 + // 验证码码输入框
  202 + @Builder getCodeCell(item: AccoutPageDataModel) {
  203 + Row() {
  204 + Stack() {
  205 + Image($r('app.media.get_code_bg')).width('100%').borderRadius('4vp')
  206 + Row() {
  207 + TextInput({ placeholder: item.inputPlacholder })
  208 + .backgroundColor('#00000000')
  209 + .width('67.28%')
  210 + .onChange((value: string) => {
  211 + this.inputTextChange(value, item.inputTag)
  212 + })
  213 + Button('发送验证码')
  214 + .width('32.71%')
  215 + .backgroundColor('#00000000')
  216 + .fontColor('#da3e22')
  217 + }
  218 + .width('100%')
  219 + }.height('80lpx')
  220 + }
  221 + .width('100%')
  222 + .height('110lpx')
  223 + .backgroundColor(0xffffff0)
  224 + .alignItems(VerticalAlign.Center)
  225 + }
  226 +
  227 + // desc
  228 + @Builder getDescCell(item: AccoutPageDataModel, alignTitle: HorizontalAlign) {
  229 + Column() {
  230 + Text(item.compDesc).fontSize(12).maxLines(3).fontColor(0x999999).padding({top:'10lpx'})
  231 + .onClick(()=>{
  232 + if (item.compDesc == '忘记密码') {
  233 + promptAction.showToast({ message: '密码不符合密码规范' })
  234 + }
  235 + })
  236 + }
  237 + .width('100%')
  238 + .height('85lpx')
  239 + .alignItems(alignTitle)
  240 + }
  241 +
  242 + // 按钮
  243 + @Builder getButtonCell(item: AccoutPageDataModel) {
  244 + Row() {
  245 + Button(item.compButtonTitle, { type: ButtonType.Normal, stateEffect: true })
  246 + .width('100%')
  247 + .height('80lpx')
  248 + .backgroundColor(this.btnStatus ? '#da3e22' : '#e5856d')
  249 + .fontColor('#fff')
  250 + .borderRadius('4vp')
  251 + .onClick(() => {
  252 + this.buttonClick()
  253 + })
  254 + }
  255 + .padding({top:'25lpx'})
  256 + .alignItems(VerticalAlign.Center)
  257 + .width('100%')
  258 + .height('120lpx')
  259 + }
  260 +
  261 + // 标题
  262 + @Builder getLogoCell(item: AccoutPageDataModel) {
  263 + Column() {
  264 + Image(item.compLogo).height('150lpx').width('150lpx')
  265 + }
  266 + .width('100%')
  267 + .height('200lpx')
  268 + }
  269 +
  270 + /***************************** 事件处理 ******************************************/
  271 + // 提交按钮点击事件
  272 + buttonClick() {
  273 + if (this.btnStatus) {
  274 + // 需要+手机号校验
  275 + if (this.password01.length < 6 || this.password01.length > 20) {
  276 + promptAction.showToast({ message: '密码不符合密码规范' })
  277 + return
  278 + }
  279 +
  280 + promptAction.showToast({ message: '请求接口' })
  281 + }
  282 + }
  283 +
  284 + // 输入框数据变动:输入数据处理
  285 + inputTextChange(text: string, tag: number) {
  286 + if (tag == 10086) {
  287 + this.password01 = text;
  288 + } else if (tag == 10087) {
  289 + this.password02 = text;
  290 + } else {
  291 + this.passwordOri = text;
  292 + }
  293 +
  294 + if (this.password01) {
  295 + if (this.password01 == this.password02 && this.password01.length >= 6 && this.password01.length <= 20) {
  296 + this.btnStatus = true;
  297 + } else {
  298 + this.btnStatus = false;
  299 + }
  300 + }
  301 + }
  302 +}
  1 +import { SettingPasswordLayout } from './SettingPasswordLayout';
  2 +
  3 +@Entry
  4 +@Component
  5 +struct SettingPasswordPage {
  6 + @State message: string = 'Hello World'
  7 +
  8 + build() {
  9 + Row() {
  10 + Column() {
  11 + SettingPasswordLayout()
  12 + }
  13 + .width('100%')
  14 + }
  15 + .height('100%')
  16 + }
  17 +}
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 "pages/Index", 3 "pages/Index",
4 "pages/login/LoginPage", 4 "pages/login/LoginPage",
5 "pages/login/ForgetPasswordPage", 5 "pages/login/ForgetPasswordPage",
6 - "pages/login/LoginProtocolWebview" 6 + "pages/login/LoginProtocolWebview",
  7 + "pages/login/SettingPasswordPage"
7 ] 8 ]
8 } 9 }
1 { 1 {
2 - "name": "sight_harmony",  
3 - "version": "1.0.0",  
4 - "description": "Please describe the basic information.",  
5 - "main": "",  
6 - "author": "",  
7 "license": "", 2 "license": "",
8 - "dependencies": {  
9 - },  
10 "devDependencies": { 3 "devDependencies": {
11 "@ohos/hypium": "1.0.16" 4 "@ohos/hypium": "1.0.16"
12 - } 5 + },
  6 + "author": "",
  7 + "name": "sight_harmony",
  8 + "description": "Please describe the basic information.",
  9 + "main": "",
  10 + "version": "1.0.0",
  11 + "dependencies": {}
13 } 12 }