yangsunyue_wd

desc:bug修改

@@ -77,18 +77,32 @@ export class PermissionUtil { @@ -77,18 +77,32 @@ export class PermissionUtil {
77 } 77 }
78 78
79 79
80 - static openPermissionsInSystemSettings(component: Object): void {  
81 - let context = getContext(component) as common.UIAbilityContext;  
82 - let wantInfo:Want = {  
83 - action: 'action.settings.app.info', 80 + /**跳转设置页面*/
  81 + static openPermissionsInSystemSettings(context: Object): void {
  82 + let uiContext = getContext(context) as common.UIAbilityContext;
  83 + let wantInfo: Want = {
  84 + bundleName: 'com.huawei.hmos.settings',
  85 + abilityName: 'com.huawei.hmos.settings.MainAbility',
  86 + uri: 'application_info_entry',
84 parameters: { 87 parameters: {
85 - settingsParamBundleName: AppUtils.getPackageName(context) // 打开指定应用的详情页面 88 + pushParams: AppUtils.getPackageName(uiContext) // 打开指定应用的设置页面
86 } 89 }
87 } 90 }
88 - context.startAbility(wantInfo).then(() => {  
89 - // ...  
90 - }).catch((err:Error) => {  
91 - // ...  
92 - }) 91 + uiContext.startAbility(wantInfo)
93 } 92 }
  93 +
  94 + // static openPermissionsInSystemSettings(component: Object): void {
  95 + // let context = getContext(component) as common.UIAbilityContext;
  96 + // let wantInfo:Want = {
  97 + // action: 'action.settings.app.info',
  98 + // parameters: {
  99 + // settingsParamBundleName: AppUtils.getPackageName(context) // 打开指定应用的详情页面
  100 + // }
  101 + // }
  102 + // context.startAbility(wantInfo).then(() => {
  103 + // // ...
  104 + // }).catch((err:Error) => {
  105 + // // ...
  106 + // })
  107 + // }
94 } 108 }
@@ -174,7 +174,7 @@ export struct QualityCommentsComponent { @@ -174,7 +174,7 @@ export struct QualityCommentsComponent {
174 // ListItemGroup({ header: this.titleHeader() }) 174 // ListItemGroup({ header: this.titleHeader() })
175 LazyForEach(this.allDatas, (item: commentItemModel, index: number) => { 175 LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
176 ListItem() { 176 ListItem() {
177 - QualityCommentItem({ item: item }).margin({ left: 12, right: 12 }) 177 + QualityCommentItem({ item: item, index:index }).margin({ left: 12, right: 12 })
178 } 178 }
179 }) 179 })
180 ListItem() { 180 ListItem() {
@@ -217,6 +217,7 @@ export struct QualityCommentsComponent { @@ -217,6 +217,7 @@ export struct QualityCommentsComponent {
217 @Component 217 @Component
218 struct QualityCommentItem { 218 struct QualityCommentItem {
219 @ObjectLink item: commentItemModel 219 @ObjectLink item: commentItemModel
  220 + index:number = 0
220 221
221 build() { 222 build() {
222 Column() { 223 Column() {
@@ -326,6 +327,7 @@ struct QualityCommentItem { @@ -326,6 +327,7 @@ struct QualityCommentItem {
326 } 327 }
327 }.onClick(() => { 328 }.onClick(() => {
328 this.item.api_status = !this.item.api_status 329 this.item.api_status = !this.item.api_status
  330 +
329 // commentViewModel.commnetLikeChange(this.item) 331 // commentViewModel.commnetLikeChange(this.item)
330 commentViewModel.commentLike(this.item).then(() => { 332 commentViewModel.commentLike(this.item).then(() => {
331 333
  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 +import { Params } from 'wdBean';
  7 +import { WDRouterPage, WDRouterRule } from 'wdRouter';
  8 +
  9 +const TAG = 'PrivacySettingPage';
  10 +const DiyString = '开启个性化推荐'
  11 +const DiyCloseTipsString = '关闭后,将不会使用你的偏好进行内容推荐'
1 12
2 -import { PrivacySettingComponents } from '../setting/PrivacySettingComponents';  
3 @Entry 13 @Entry
4 @Component 14 @Component
5 -struct PrivacySettingPage { 15 +export struct PrivacySettingPage {
  16 + @State listData: Array<PrivacySettingModel> = [new PrivacySettingModel(DiyString, false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'), new PrivacySettingModel('定位权限', false, 'ohos.permission.APPROXIMATELY_LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')];
  17 + tips: string = '设置前可查阅'
  18 + privacyTips: string = '《隐私政策》'
  19 + tipsEnd = '中相应权限使用规则'
  20 +
  21 + onPageShow(): void {
  22 + this.getPermissionStatus();
  23 + }
  24 +
  25 + aboutToAppear() {
  26 + // 获取权限=
  27 + // SPHelper.default.save('sdf','sdf');
  28 + // this.initListData();
  29 + this.getPermissionStatus();
  30 + // RefreshStatus;
  31 +
  32 + }
  33 +
  34 + async getPermissionStatus() {
  35 + const permissionUtil = new PermissionUtil();
  36 + for (const element of this.listData) {
  37 + if (element.privacyName == DiyString) {
  38 + element.queryUserDetail();
  39 + // element.permission = true;
  40 + continue;
  41 + }
  42 + const result = await permissionUtil.checkPermissions(element.permissionKey);
  43 + element.permission = result;
  44 + }
  45 + }
  46 +
  47 + build() {
  48 + Navigation() {
  49 + //滑动区域
  50 + this.PrivacySettingComponentsUI()
  51 +
  52 + }.titleMode(NavigationTitleMode.Mini)
  53 + .title('隐私设置')
  54 + .backgroundColor('#F8F8F8')
  55 + }
  56 +
  57 + @Builder PrivacySettingComponentsUI() {
  58 + Column() {
  59 +
  60 + List({ space: '23lpx' }) {
  61 + ForEach(this.listData, (item: PrivacySettingModel, index:number) => {
  62 + ListItem() {
  63 + if (index == 0) {
  64 + getTuiJianCell({ item:item, index:index });
  65 + } else {
  66 + getArrowCell({ item:item, index:index });
  67 + }
  68 + }.onClick(() => {
  69 + if (index != 0) {
  70 + if (!item.permission) {
  71 + //跳转权限设置
  72 + const permissionUtil = new PermissionUtil();
  73 + PermissionUtil.reqPermissionsFromUser([item.permissionKey], this).then((res)=>{
  74 + item.permission = res;
  75 + });
  76 + }
  77 + }
  78 + })
  79 + })
  80 + }
  81 + .padding({ left: '29lpx', right: '29lpx' })
  82 + .margin({ top: '38lpx' })
  83 +
  84 + Row() {
  85 + Text(this.tips)
  86 + .fontSize('25lpx')
  87 + .textAlign(TextAlign.Start)
  88 + .fontColor($r("app.color.color_666666"))
  89 + .margin({ left: '29lpx', top: '46lpx' })
  90 + // .backgroundColor(Color.Orange)
  91 + Text(this.privacyTips)
  92 + .fontSize('25lpx')
  93 + .textAlign(TextAlign.Start)
  94 + .fontColor('#ED2800')
  95 + .margin({ top: '46lpx' })
  96 + .onClick(() => {
  97 + //跳转隐私政策
  98 + let bean={contentId:"2",pageID:""} as Params
  99 + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean)
  100 + })
  101 + Text(this.tipsEnd)
  102 + .fontSize('25lpx')
  103 + .textAlign(TextAlign.Start)
  104 + .fontColor($r("app.color.color_666666"))
  105 + .margin({ top: '46lpx' })
  106 + }
  107 +
  108 + }
  109 + .width('100%')
  110 + .height('100%')
  111 + .backgroundColor('#F8F8F8')
  112 + .alignItems(HorizontalAlign.Start)
  113 + }
  114 +}
  115 +
  116 +
  117 +@Component
  118 +struct getArrowCell {
  119 + @ObjectLink item: PrivacySettingModel;
  120 + index:number = 0;
  121 + // 右文字+箭头cell
  122 + // @Builder getArrowCell(item:PrivacySettingModel, index) {
  123 + build() {
  124 + Row() {
  125 + // 左侧标题
  126 + Text(this.item.privacyName)
  127 + .fontColor('#666666')
  128 + .fontSize('31lpx')
  129 +
  130 + Row() {
  131 + Text(this.item.permission ? '已开启' : '去设置')
  132 + .fontColor(this.item.permission ? '#666666' : '#CCCCCC')
  133 + .fontSize('31lpx')
  134 + .margin({ right: '8lpx' })
  135 +
  136 + Image($r('app.media.mine_user_arrow'))
  137 + .width('27lpx')
  138 + .height('27lpx')
  139 + .objectFit(ImageFit.Auto)
  140 + }
  141 +
  142 + }
  143 + .alignItems(VerticalAlign.Center)
  144 + .justifyContent(FlexAlign.SpaceBetween)
  145 + .height('97lpx')
  146 + .width('100%')
  147 + .padding({ left: '29lpx', right: '29lpx' })
  148 + .backgroundColor('#FFFFFF')
  149 + .borderRadius('8lpx')
  150 + }
  151 +}
  152 +
  153 +@Component
  154 +struct getTuiJianCell {
  155 + @ObjectLink item: PrivacySettingModel;
  156 + index:number = 0;
6 build() { 157 build() {
7 - Column(){  
8 - PrivacySettingComponents() 158 + Column() {
  159 +
  160 + Row() {
  161 + // 左侧标题
  162 + Text(this.item.privacyName)
  163 + .fontColor('#666666')
  164 + .fontSize('31lpx')
  165 +
  166 + Row() {
  167 + Toggle({ type: ToggleType.Switch, isOn: this.item.permission })
  168 + .height('58lpx')
  169 + .width('96lpx')
  170 + // .selectedColor(Color.Pink)
  171 + .onChange((isOn: boolean) => {
  172 + // this.privacySwitch = isOn;
  173 + this.item.editUserDetail(isOn?'1':'0');
  174 + })
  175 + }
  176 +
  177 + }
  178 + .alignItems(VerticalAlign.Center)
  179 + .justifyContent(FlexAlign.SpaceBetween)
  180 + .height('97lpx')
  181 + .width('100%')
  182 +
  183 +
  184 + Blank()
  185 + .backgroundColor('#EDEDED')
  186 + .height('1lpx')
  187 +
  188 + Text(DiyCloseTipsString)
  189 + .fontColor('#999999')
  190 + .fontSize('23lpx')
  191 + .margin({ right: '8lpx' })
  192 + .height('69lpx')
  193 +
9 } 194 }
  195 + .alignItems(HorizontalAlign.Start)
  196 + .backgroundColor('#FFFFFF')
  197 + .borderRadius('8lpx')
  198 + .padding({ left: '29lpx', right: '29lpx' })
10 } 199 }
11 } 200 }
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 -import { Params } from 'wdBean';  
7 -import { WDRouterPage, WDRouterRule } from 'wdRouter';  
8 -  
9 -const TAG = 'PrivacySettingComponents';  
10 -  
11 -@Component  
12 -export struct PrivacySettingComponents {  
13 - @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.APPROXIMATELY_LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')];  
14 - @State tips: string = '设置前可查阅'  
15 - @State privacyTips: string = '《隐私政策》'  
16 -  
17 - aboutToAppear() {  
18 - // 获取权限=  
19 - // SPHelper.default.save('sdf','sdf');  
20 - // this.initListData();  
21 - this.getPermissionStatus();  
22 - // RefreshStatus;  
23 -  
24 - }  
25 -  
26 - async getPermissionStatus() {  
27 - const permissionUtil = new PermissionUtil();  
28 - for (const element of this.listData) {  
29 - if (element.privacyName == '开启个性推荐') {  
30 - element.queryUserDetail();  
31 - // element.permission = true;  
32 - continue;  
33 - }  
34 - const result = await permissionUtil.checkPermissions(element.permissionKey);  
35 - element.permission = result;  
36 - }  
37 - }  
38 -  
39 - build() {  
40 - Navigation() {  
41 - //滑动区域  
42 - this.PrivacySettingComponentsUI()  
43 -  
44 - }.titleMode(NavigationTitleMode.Mini)  
45 - .title('隐私设置')  
46 - .backgroundColor('#F8F8F8')  
47 - }  
48 -  
49 - @Builder PrivacySettingComponentsUI() {  
50 - Column() {  
51 -  
52 - List({ space: '23lpx' }) {  
53 - ForEach(this.listData, (item: PrivacySettingModel, index:number) => {  
54 - ListItem() {  
55 - if (index == 0) {  
56 - getTuiJianCell({ item:item, index:index });  
57 - } else {  
58 - getArrowCell({ item:item, index:index });  
59 - }  
60 - }.onClick(() => {  
61 - if (index != 0) {  
62 - if (!item.permission) {  
63 - //跳转权限设置  
64 - const permissionUtil = new PermissionUtil();  
65 - PermissionUtil.reqPermissionsFromUser([item.permissionKey], this).then((res)=>{  
66 - item.permission = res;  
67 - });  
68 - }  
69 - }  
70 - })  
71 - })  
72 - }  
73 - .padding({ left: '29lpx', right: '29lpx' })  
74 - .margin({ top: '38lpx' })  
75 -  
76 - Row() {  
77 - Text(this.tips)  
78 - .fontSize('25lpx')  
79 - .textAlign(TextAlign.Start)  
80 - .fontColor($r("app.color.color_666666"))  
81 - .margin({ left: '29lpx', top: '46lpx' })  
82 - // .backgroundColor(Color.Orange)  
83 - Text(this.privacyTips)  
84 - .fontSize('25lpx')  
85 - .textAlign(TextAlign.Start)  
86 - .fontColor('#ED2800')  
87 - .margin({ top: '46lpx' })  
88 - .onClick(() => {  
89 - //跳转隐私政策  
90 - let bean={contentId:"2",pageID:""} as Params  
91 - WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean)  
92 - })  
93 - }  
94 -  
95 - }  
96 - .width('100%')  
97 - .height('100%')  
98 - .backgroundColor('#F8F8F8')  
99 - .alignItems(HorizontalAlign.Start)  
100 - }  
101 -}  
102 -  
103 -  
104 -@Component  
105 -struct getArrowCell {  
106 - @ObjectLink item: PrivacySettingModel;  
107 - index:number = 0;  
108 - // 右文字+箭头cell  
109 - // @Builder getArrowCell(item:PrivacySettingModel, index) {  
110 - build() {  
111 - Row() {  
112 - // 左侧标题  
113 - Text(this.item.privacyName)  
114 - .fontColor('#666666')  
115 - .fontSize('31lpx')  
116 -  
117 - Row() {  
118 - Text(this.item.permission ? '已开启' : '去设置')  
119 - .fontColor(this.item.permission ? '#666666' : '#CCCCCC')  
120 - .fontSize('31lpx')  
121 - .margin({ right: '8lpx' })  
122 -  
123 - Image($r('app.media.mine_user_arrow'))  
124 - .width('27lpx')  
125 - .height('27lpx')  
126 - .objectFit(ImageFit.Auto)  
127 - }  
128 -  
129 - }  
130 - .alignItems(VerticalAlign.Center)  
131 - .justifyContent(FlexAlign.SpaceBetween)  
132 - .height('97lpx')  
133 - .width('100%')  
134 - .padding({ left: '29lpx', right: '29lpx' })  
135 - .backgroundColor('#FFFFFF')  
136 - .borderRadius('8lpx')  
137 - }  
138 -}  
139 -  
140 -@Component  
141 -struct getTuiJianCell {  
142 - @ObjectLink item: PrivacySettingModel;  
143 - index:number = 0;  
144 - build() {  
145 - Column() {  
146 -  
147 - Row() {  
148 - // 左侧标题  
149 - Text(this.item.privacyName)  
150 - .fontColor('#666666')  
151 - .fontSize('31lpx')  
152 -  
153 - Row() {  
154 - Toggle({ type: ToggleType.Switch, isOn: this.item.permission })  
155 - .height('58lpx')  
156 - .width('96lpx')  
157 - // .selectedColor(Color.Pink)  
158 - .onChange((isOn: boolean) => {  
159 - // this.privacySwitch = isOn;  
160 - this.item.editUserDetail(isOn?'1':'0');  
161 - })  
162 - }  
163 -  
164 - }  
165 - .alignItems(VerticalAlign.Center)  
166 - .justifyContent(FlexAlign.SpaceBetween)  
167 - .height('97lpx')  
168 - .width('100%')  
169 -  
170 -  
171 - Blank()  
172 - .backgroundColor('#EDEDED')  
173 - .height('1lpx')  
174 -  
175 - Text('关闭后,将无法看到个性化推荐的服务')  
176 - .fontColor('#999999')  
177 - .fontSize('23lpx')  
178 - .margin({ right: '8lpx' })  
179 - .height('69lpx')  
180 -  
181 - }  
182 - .alignItems(HorizontalAlign.Start)  
183 - .backgroundColor('#FFFFFF')  
184 - .borderRadius('8lpx')  
185 - .padding({ left: '29lpx', right: '29lpx' })  
186 - }  
187 -}