shishuangxi

新增权限说明弹框

@@ -34,6 +34,7 @@ export class SpConstants{ @@ -34,6 +34,7 @@ export class SpConstants{
34 //定位相关 34 //定位相关
35 static LOCATION_CITY_NAME = "location_city_name" //定位 35 static LOCATION_CITY_NAME = "location_city_name" //定位
36 static LOCATION_CITY_CODE = "location_city_code" //定位 36 static LOCATION_CITY_CODE = "location_city_code" //定位
  37 + static LOCATION_PERMISSION_REFUSE = "location_permission_refuse" //定位
37 38
38 //启动页数据存储key 39 //启动页数据存储key
39 static APP_LAUNCH_PAGE_DATA_MODEL = 'app_launch_page_data_model' 40 static APP_LAUNCH_PAGE_DATA_MODEL = 'app_launch_page_data_model'
@@ -10,5 +10,7 @@ export enum EmitterEventId { @@ -10,5 +10,7 @@ export enum EmitterEventId {
10 NETWORK_DISCONNECTED = 3, 10 NETWORK_DISCONNECTED = 3,
11 // 跳转首页指定频道,事件id 11 // 跳转首页指定频道,事件id
12 JUMP_HOME_CHANNEL = 4, 12 JUMP_HOME_CHANNEL = 4,
  13 +
  14 + LOCATION = 5
13 } 15 }
14 16
@@ -79,6 +79,8 @@ export { LiveCommentComponent } from "./src/main/ets/components/comment/view/Liv @@ -79,6 +79,8 @@ export { LiveCommentComponent } from "./src/main/ets/components/comment/view/Liv
79 79
80 export { WDViewDefaultType } from "./src/main/ets/components/view/EmptyComponent" 80 export { WDViewDefaultType } from "./src/main/ets/components/view/EmptyComponent"
81 81
  82 +export { PermissionDesComponent } from "./src/main/ets/components/view/PermissionDesComponent"
  83 +
82 export { AudioRowComponent } from "./src/main/ets/components/live/AudioRowComponent" 84 export { AudioRowComponent } from "./src/main/ets/components/live/AudioRowComponent"
83 85
84 export { WDLiveViewDefaultType } from "./src/main/ets/components/view/LiveEmptyComponent" 86 export { WDLiveViewDefaultType } from "./src/main/ets/components/view/LiveEmptyComponent"
  1 +@Component
  2 +export struct PermissionDesComponent {
  3 + @State translateY: number = 0
  4 +
  5 + aboutToAppear(): void {
  6 + this.startDismiss()
  7 + }
  8 +
  9 + build() {
  10 + Column() {
  11 + Row() {
  12 + Image($r('app.media.tips')).width(20).height(20)
  13 + Text("权限使用说明").fontColor('#FF222222').fontSize(14)
  14 + .fontWeight(FontWeight.Bold)
  15 + .margin({left:4})
  16 + }.height(26)
  17 +
  18 + Text("用于为你推荐你可能感兴趣的资讯内容及附近的相关信息,以提升浏览体验。不授权该权限不影响App正常使用。")
  19 + .fontSize(14)
  20 + .fontColor('#666666')
  21 + }
  22 + .translate({ y: this.translateY })
  23 + .animation({
  24 + duration: 400,
  25 + curve: Curve.Linear,
  26 + })
  27 + .alignItems(HorizontalAlign.Start)
  28 + .width('90%')
  29 + // .height(60)
  30 + .backgroundColor('#FFFFFF')
  31 + .border({ radius: 5 })
  32 + .margin({ top: 12 })
  33 + .padding(12)
  34 + }
  35 +
  36 + startDismiss() {
  37 + setTimeout(() => {
  38 + this.translateY = -250
  39 + }, 4000)
  40 + }
  41 +}
@@ -2,7 +2,7 @@ import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit'; @@ -2,7 +2,7 @@ import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit';
2 import { BusinessError } from '@kit.BasicServicesKit'; 2 import { BusinessError } from '@kit.BasicServicesKit';
3 import { geoLocationManager } from '@kit.LocationKit'; 3 import { geoLocationManager } from '@kit.LocationKit';
4 import { SpConstants } from 'wdConstant/Index'; 4 import { SpConstants } from 'wdConstant/Index';
5 -import { Logger, PermissionUtils, ResourcesUtils, SPHelper } from 'wdKit/Index'; 5 +import { EmitterEventId, EmitterUtils, Logger, PermissionUtils, ResourcesUtils, SPHelper } from 'wdKit/Index';
6 import { ResponseDTO } from 'wdNetwork/Index'; 6 import { ResponseDTO } from 'wdNetwork/Index';
7 7
8 /** 8 /**
@@ -54,6 +54,11 @@ export class HWLocationUtils { @@ -54,6 +54,11 @@ export class HWLocationUtils {
54 return 54 return
55 } 55 }
56 let context = getContext(); 56 let context = getContext();
  57 + let per=SPHelper.default.getSync(SpConstants.LOCATION_PERMISSION_REFUSE,false)
  58 + if(!per){
  59 + EmitterUtils.sendEmptyEvent(EmitterEventId.LOCATION)
  60 + SPHelper.default.save(SpConstants.LOCATION_PERMISSION_REFUSE,true)
  61 + }
57 let requestGrant = await PermissionUtils.reqPermissionsFromUser([HWLocationUtils.APPROXIMATELY_LOCATION], context); 62 let requestGrant = await PermissionUtils.reqPermissionsFromUser([HWLocationUtils.APPROXIMATELY_LOCATION], context);
58 Logger.debug('location2 :' + requestGrant) 63 Logger.debug('location2 :' + requestGrant)
59 if (requestGrant) { 64 if (requestGrant) {
1 -import { BottomNavigationComponent, LogoutViewModel } from 'wdComponent'; 1 +import { BottomNavigationComponent, LogoutViewModel, PermissionDesComponent } from 'wdComponent';
2 import { BreakpointConstants } from 'wdConstant'; 2 import { BreakpointConstants } from 'wdConstant';
3 3
4 import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger } from 'wdKit'; 4 import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger } from 'wdKit';
@@ -16,7 +16,7 @@ struct MainPage { @@ -16,7 +16,7 @@ struct MainPage {
16 @Provide pageHide: number = -1 16 @Provide pageHide: number = -1
17 private breakpointSystem: BreakpointSystem = new BreakpointSystem() 17 private breakpointSystem: BreakpointSystem = new BreakpointSystem()
18 @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS; 18 @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS;
19 - 19 + @State isPermission: boolean = false
20 watchCurrentBreakpoint() { 20 watchCurrentBreakpoint() {
21 Logger.info(TAG, `watchCurrentBreakpoint, this.currentBreakpoint: ${this.currentBreakpoint}`); 21 Logger.info(TAG, `watchCurrentBreakpoint, this.currentBreakpoint: ${this.currentBreakpoint}`);
22 } 22 }
@@ -28,6 +28,9 @@ struct MainPage { @@ -28,6 +28,9 @@ struct MainPage {
28 EmitterUtils.receiveEvent(EmitterEventId.FORCE_USER_LOGIN_OUT, () => { 28 EmitterUtils.receiveEvent(EmitterEventId.FORCE_USER_LOGIN_OUT, () => {
29 LogoutViewModel.clearLoginInfo() 29 LogoutViewModel.clearLoginInfo()
30 }) 30 })
  31 + EmitterUtils.receiveEvent(EmitterEventId.LOCATION, () => {
  32 + this.isPermission=true
  33 + })
31 } 34 }
32 35
33 aboutToDisappear() { 36 aboutToDisappear() {
@@ -50,8 +53,11 @@ struct MainPage { @@ -50,8 +53,11 @@ struct MainPage {
50 } 53 }
51 54
52 build() { 55 build() {
53 - Column() { 56 + Stack({alignContent:Alignment.Top}) {
54 BottomNavigationComponent() 57 BottomNavigationComponent()
  58 + if(this.isPermission){
  59 + PermissionDesComponent()
  60 + }
55 } 61 }
56 } 62 }
57 } 63 }