shishuangxi

新增权限说明弹框

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