更新云信相关代码

This commit is contained in:
XiuYun CHEN
2025-07-10 08:57:32 +08:00
parent a297e0452f
commit 5954f51701
523 changed files with 61546 additions and 1488 deletions
@@ -7,8 +7,12 @@ export struct PerfactInputSheet {
@Prop inputTitle:string = '';
@Prop inputPlaceholder:string = ''
@State inputText:string = ''
@State style:string = '0'//默认类型为注册时候的弹窗//1为普通确认取消输入框//2未普通弹框
// 添加回调函数属性
@State okColor:ResourceStr='#000000'
@State cancelColor:ResourceStr='#333333'
@State okText:ResourceStr='确定'
@State cancelText:ResourceStr='取消'
private inputCallBack: (input: string,title:string) => void = () => {};
// 修改构造函数
@@ -19,59 +23,176 @@ export struct PerfactInputSheet {
}
build() {
Column() {
// 操作按钮区域
Row() {
Button('取消')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor('#EEEEEE')
.width('15%')
.fontSize(15)
.onClick(() => {
this.controller.close()
})
if(this.style=='0')
{
Column() {
// 操作按钮区域
Row() {
Button('取消')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor('#EEEEEE')
.width('15%')
.fontSize(15)
.onClick(() => {
this.controller.close()
})
Text(this.inputTitle)
.width('65%')
.fontSize(15)
.fontColor('#333333')
.textAlign(TextAlign.Center)
Text(this.inputTitle)
.width('65%')
.fontSize(15)
.fontColor('#333333')
.textAlign(TextAlign.Center)
Button('确定')
.layoutWeight(1)
.fontSize(15)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor('#EEEEEE')
.width('15%')
.onClick(() => {
if (this.inputText.length <= 0) {
promptAction.showToast({ message: '输入不能为空', duration: 1000 })
return;
}
this.controller.close()
this.inputCallBack(this.inputText, this.inputTitle);
Button('确定')
.layoutWeight(1)
.fontSize(15)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor('#EEEEEE')
.width('15%')
.onClick(() => {
if (this.inputText.length <= 0) {
promptAction.showToast({ message: '输入不能为空', duration: 1000 })
return;
}
this.controller.close()
this.inputCallBack(this.inputText, this.inputTitle);
})
}
.height(30)
Row(){
TextInput({
placeholder: this.inputPlaceholder
})
.height(50)
.fontColor(Color.Black)
.backgroundColor(Color.White)
.onChange((value: string) => {
this.inputText = value;
})
}
.backgroundColor(Color.White)
}
.height(30)
.width('100%')
.height(100)
.backgroundColor('#EEEEEE')
}
else if(this.style=='1')
{
Row(){
Column() {
Text(this.inputTitle)
.fontSize(18)
.textAlign(TextAlign.Start)
.margin({ top: 20,bottom:20,left:20 })
.width('100%')
.fontColor('#12AAE2')
Row(){
TextInput({
placeholder: this.inputPlaceholder
})
.height(40)
.fontColor(Color.Black)
.backgroundColor(Color.White)
.onChange((value: string) => {
this.inputText = value;
})
}
.backgroundColor(Color.White)
.borderWidth(1)
.borderRadius(4)
.borderColor('#12AAE2')
Text('').height(1).width('100%')
.backgroundColor($r('app.color.home_gray')).margin({top:20})
Row({ space: 20 }) {
Text('取消')
.fontSize(15)
.fontColor('#666666')
.textAlign(TextAlign.Center)
.width('45%').height(30)
.onClick(() => {
this.controller.close()
})
Text('').height(30).width(1)
.backgroundColor($r('app.color.home_gray'))
Text('确定')
.fontColor('#000000')
.fontSize(15)
.textAlign(TextAlign.Center)
.onClick(() => {
if (this.inputText.length <= 0) {
promptAction.showToast({ message: '输入不能为空', duration: 1000 })
return;
}
this.controller.close()
this.inputCallBack(this.inputText, this.inputTitle);
})
.width('45%').height(30)
}.margin({ top: 10, bottom: 10 })
}
.width('80%').backgroundColor(Color.White)
}.borderRadius(24)
}
else if(this.style=='2')
{
Row(){
TextInput({
placeholder: this.inputPlaceholder
})
.height(50)
.fontColor(Color.Black)
Column() {
Text(this.inputTitle)
.fontSize(18)
.padding(20)
.width('100%')
.textAlign(TextAlign.Center)
.fontColor('#444444')
Row(){
Text(this.inputPlaceholder)
.fontColor('#444444')
.backgroundColor(Color.White)
.padding({left:10,right:10})
}
.backgroundColor(Color.White)
.onChange((value: string) => {
this.inputText = value;
})
}
.backgroundColor(Color.White)
Text('').height(1).width('100%')
.backgroundColor($r('app.color.home_gray')).margin({top:10})
Row({ space: 20 }) {
Text(this.cancelText)
.fontSize(15)
.fontColor(this.cancelColor)
.textAlign(TextAlign.Center)
.width('45%').height(30)
.onClick(() => {
this.controller.close()
})
Text('').height(30).width(1)
.backgroundColor($r('app.color.home_gray'))
Text(this.okText)
.textAlign(TextAlign.Center)
.fontColor(this.okColor)
.fontSize(15)
.onClick(() => {
this.controller.close()
this.inputCallBack(this.inputText, this.inputTitle);
})
.width('45%').height(30)
}.margin({ top: 10, bottom: 10 })
}
.width('80%').backgroundColor(Color.White)
}.borderRadius(24)
}
.width('100%')
.height(100)
.backgroundColor('#EEEEEE')
}
}
@@ -10,10 +10,11 @@ export struct PhotoActionSheet {
controller: CustomDialogController;
// 添加回调函数属性
private onPhotoSelected: (uri: string) => void = () => {};
private onPhotoSelected: (uris: string[] | string) => void = () => {};
@Prop maxSelectNumber:number=1//选择张数
// 修改构造函数
constructor(controller: CustomDialogController, onPhotoSelected: (uri: string) => void) {
constructor(controller: CustomDialogController, onPhotoSelected: (uris: string[] | string) => void) {
super();
this.controller = controller;
this.onPhotoSelected = onPhotoSelected;
@@ -117,6 +118,7 @@ export struct PhotoActionSheet {
if (result.resultCode === 0) {
console.log('Photo URI:', result.resultUri);
// 处理拍摄结果
this.onPhotoSelected(result.resultUri);
}
} catch (error) {
console.error('Camera error:', error.code);
@@ -127,7 +129,7 @@ export struct PhotoActionSheet {
private selectPhoto() {
let photoSelectOptions = new picker.PhotoSelectOptions();
photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
photoSelectOptions.maxSelectNumber = 1;
photoSelectOptions.maxSelectNumber = this.maxSelectNumber;
let photoViewPicker = new picker.PhotoViewPicker();
photoViewPicker.select(photoSelectOptions)
@@ -135,7 +137,15 @@ export struct PhotoActionSheet {
console.info('PhotoViewPicker.select successfully, photoSelectResult uri: ' +
JSON.stringify(photoSelectResult));
if (photoSelectResult.photoUris && photoSelectResult.photoUris.length > 0) {
this.onPhotoSelected(photoSelectResult.photoUris[0]);
if(this.maxSelectNumber==1)
{
this.onPhotoSelected(photoSelectResult.photoUris[0]);
}
else
{
this.onPhotoSelected(photoSelectResult.photoUris);
}
}
})
.catch((err: BusinessError) => {
@@ -0,0 +1,232 @@
import { router } from "@kit.ArkUI";
import http from '@ohos.net.http'
import fileio from '@ohos.fileio'
import prompt from '@ohos.promptAction'
import { abilityAccessCtrl, common, Permissions } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { BasicConstant } from "../constants/BasicConstant";
import { ViewImageInfo } from "../models/ViewImageInfo";
import { PermissionsUtils } from "../utils/PermissionsUtils";
@Component
export struct PreviewPhotos {
@State
imgList: ViewImageInfo[]=[] // 传入图片数组
@State params:paramPhoto= router.getParams() as paramPhoto
@State previewIndex: number = 0
@State downLoad:boolean=true
// 检查存储权限
async checkStoragePermission(): Promise<boolean> {
try {
const atManager = abilityAccessCtrl.createAtManager();
const grantStatus = await atManager.checkAccessToken(
globalThis.abilityContext.applicationInfo.accessTokenId,
'ohos.permission.WRITE_MEDIA'
);
return grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED;
} catch (error) {
console.error('检查权限失败:', error);
return false;
}
}
// 申请存储权限
async requestStoragePermission(): Promise<boolean> {
try {
const context = getContext(this) as common.UIAbilityContext;
const result = await PermissionsUtils.reqPermissionsFromUser(['ohos.permission.WRITE_MEDIA'], context);
return result.grantStatus || false;
} catch (error) {
console.error('申请权限失败:', error);
return false;
}
}
// 下载图片方法(伪代码,需根据实际API实现)
async downloadImage(url: string) {
try {
// 1. 检查权限
const hasPermission = await this.checkStoragePermission();
if (!hasPermission) {
// 申请权限
const granted = await this.requestStoragePermission();
if (!granted) {
prompt.showToast({ message: $r('app.string.netease_permission_denied_tips') });
return;
}
}
// 显示下载中提示
prompt.showToast({ message: $r('app.string.netease_saving_image_tips') });
// 2. 下载图片
const httpRequest = http.createHttp()
const response = await httpRequest.request(url, {
method: http.RequestMethod.GET,
expectDataType: http.HttpDataType.ARRAY_BUFFER,
connectTimeout: 30000, // 30秒连接超时
readTimeout: 30000, // 30秒读取超时
})
httpRequest.destroy()
if (response.responseCode !== 200) {
prompt.showToast({ message: $r('app.string.netease_download_failed_tips') })
return
}
// 3. 写入到公共图片目录
const fileName = 'img_' + Date.now() + '.jpg'
const filePath = '/storage/media/100/local/photos/' + fileName
try {
const fd = await fileio.open(filePath, 0o2 | 0o100) // 写入+创建
await fileio.write(fd, new Uint8Array(response.result as ArrayBuffer))
await fileio.close(fd)
prompt.showToast({ message: $r('app.string.netease_save_success_tips') })
} catch (fileError) {
console.error('文件写入失败:', fileError);
prompt.showToast({ message: $r('app.string.netease_save_failed_tips') })
}
} catch (e) {
console.error('下载图片失败:', e);
prompt.showToast({ message: $r('app.string.netease_save_error_tips') })
}
}
aboutToAppear(): void {
this.imgList= this.params.imgList
this.previewIndex=this.params.previewIndex
this.downLoad=this.params.downLoad
}
dialog = new CustomDialogController({
builder: SaveDialog(
{
CallBack:()=>{
}
}
),
cornerRadius: 4,
width: '70%',
})
build() {
RelativeContainer() {
// 遮罩层
Stack() {
// 半透明背景
Text().backgroundColor(Color.Black).width('100%').height('100%')
// 大图浏览
Column({ space: 16 }) {
// 角标
// 可滑动大图
Swiper() {
ForEach(this.imgList, (item: ViewImageInfo, idx: number) => {
Image(item.url?(BasicConstant.urlHtml +item.url):item.uri)
.width('100%')
// .objectFit(ImageFit.Contain)
.gesture(
LongPressGesture({
duration: 1000, // 设置长按触发时间为1秒
repeat: true // 允许连续触发回调
})
.onAction((event: GestureEvent) => {
this.dialog.open()
})
)
})
}
.indicator(false)
.loop(false) // 禁用循环滑动
.onChange((index: number) => {
this.previewIndex = index
})
}
.align(Alignment.Center)
}
.width('100%')
.height('100%')
.onClick(() => {
router.back()
})
Row()
{
Image($r('app.media.ic_topbar_save')).width(30).height(30)
.onClick(()=>{
this.downloadImage( this.imgList[this.previewIndex].url?(BasicConstant.urlHtml + this.imgList[this.previewIndex].url): this.imgList[this.previewIndex].url)
})
Blank()
Text(`${this.previewIndex + 1}/${this.imgList.length}`)
.fontSize(18)
.fontColor($r('app.color.top_title'))
}
.visibility(this.downLoad?Visibility.Visible:Visibility.Hidden)
.height(30)
.width('100%')
.padding({ left:20,right:20 })
.margin({bottom:40})
.alignRules({bottom: { anchor: "__container__", align: VerticalAlign.Bottom }} )
}
.width('100%')
.height('100%')
}
}
interface paramPhoto
{
previewIndex:number ,
imgList:ViewImageInfo[],
downLoad:boolean
}
@CustomDialog
struct SaveDialog {
controller: CustomDialogController
CallBack: () => void = () => {};
build() {
Column() {
Text('提示')
.fontSize(17)
.fontColor('#444444')
.padding(15)
Text('').height(1).width('100%')
.backgroundColor($r('app.color.home_gray'))
Text('保存到手机')
.fontSize(16).fontColor($r('app.color.common_gray_03'))
.padding(10).width('100%').textAlign(TextAlign.Start)
.onClick(() => {
if (this.controller != undefined) {
this.controller.close()
this.CallBack();
}
})
Text('').height(1).width('100%')
.backgroundColor($r('app.color.home_gray'))
.margin({bottom:10})
}
.backgroundColor($r('app.color.white'))
}
}
@@ -0,0 +1,78 @@
import { router } from "@kit.ArkUI"
import { BasicConstant } from "../constants/BasicConstant"
import { ViewImageInfo } from "../models/ViewImageInfo"
@Component
export struct ChangePhotoGrids {
@Prop
imgList: ViewImageInfo[] // 传入图片数组
@State previewIndex: number = 0
@Prop maxSelectNumber:number
@Link addImg: boolean;
@Link removeImg: boolean;
@Link removeIndex: number;
@State downLoad:boolean=false
build() {
Column() {
// 八宫格
Grid() {
ForEach(this.imgList, (item: ViewImageInfo, index: number) => {
GridItem() {
Stack() {
Image(item.url ? (BasicConstant.urlHtml + item.url) : item.uri)
.width(80)
.height(80)
.objectFit(ImageFit.Fill)
.onClick(() => {
this.previewIndex = index
router.pushUrl({
url: 'pages/Netease/PreviewPhotoPage',
params: { previewIndex: this.previewIndex, imgList: this.imgList, downLoad:this.downLoad }
});
})
Image($r('app.media.iv_delete_new'))
.width(20).height(20)
.position({ x: 55, y: 5 })
.onClick(() => {
this.removeImg=!this.removeImg
this.removeIndex=index
})
}
}
})
GridItem()
{
// 添加按钮(未满9张时显示)
if (this.imgList.length < this.maxSelectNumber) {
Image($r('app.media.new_selected'))
.width(80).height(80)
.objectFit(ImageFit.Fill)
.borderRadius(8)
.onClick(() => {
this.addImg=!this.addImg
})
}
}
}
.columnsTemplate('1fr 1fr 1fr 1fr')
.rowsGap(8)
.columnsGap(8)
}
.padding({left:10,right:10})
}
}
@@ -23,6 +23,9 @@ export struct HdList {
// options
lw: number = 0
@State strokeWidth: Length =0
@State dividerColor:ResourceStr=$r('app.color.efefef');
@Builder
defaultListContent() {
}
@@ -87,6 +90,10 @@ export struct HdList {
.width('100%')
.height('100%')
.padding({ left: BasicConstant.SPACE_LG, right: BasicConstant.SPACE_LG })
.divider({
strokeWidth: this.strokeWidth, // 线宽
color: this.dividerColor, // 颜色
})
// .divider({
// strokeWidth: $r('app.float.common_border_width'),
// color: $r('app.color.common_gray_border')
@@ -0,0 +1,48 @@
import { router } from "@kit.ArkUI"
import { BasicConstant } from "../constants/BasicConstant"
import { ViewImageInfo } from "../models/ViewImageInfo"
@Component
export struct PhotoGrids {
@Prop
imgList: ViewImageInfo[] // 传入图片数组
@State previewIndex: number = 0
@State downLoad:boolean=true
build() {
Column() {
// 八宫格
Grid() {
ForEach(this.imgList, (item: ViewImageInfo, index: number) => {
GridItem()
{
Image( item.url?(BasicConstant.urlHtml +item.url):item.uri)
.width('100%')
.height(100)
.objectFit(ImageFit.Fill)
.onClick(() => {
this.previewIndex = index
router.pushUrl({
url: 'pages/Netease/PreviewPhotoPage',
params: { previewIndex: this.previewIndex ,imgList:this.imgList,downLoad:this.downLoad}
});
})
}
})
}
.columnsTemplate('1fr 1fr 1fr 1fr')
.rowsGap(8)
.columnsGap(8)
}
.padding({left:10,right:10})
}
}
@@ -6,22 +6,22 @@ export class BasicConstant {
static readonly getzcxy = "https://doc.igandan.com/app/integral/hmos_expert_zcxy.html";// 注册协议正式地址
//测试环境
// static readonly urlExpertAPI = "https://dev-app.igandan.com/app/expertAPI/";
// static readonly urlExpertApp = "https://dev-app.igandan.com/app/expertApp/"
// static readonly urlHtml = "http://dev-doc.igandan.com/app/"
// static readonly urlImage = "https://dev-doc.igandan.com/app/"
// static readonly urlExpert = "https://dev-app.igandan.com/app/expert/"
// static readonly wxUrl = "https://dev-wx.igandan.com/";
// static readonly polvId = "11";//保利威视学员id
static readonly urlExpertAPI = "https://dev-app.igandan.com/app/expertAPI/";
static readonly urlExpertApp = "https://dev-app.igandan.com/app/expertApp/"
static readonly urlHtml = "http://dev-doc.igandan.com/app/"
static readonly urlImage = "https://dev-doc.igandan.com/app/"
static readonly urlExpert = "https://dev-app.igandan.com/app/expert/"
static readonly wxUrl = "https://dev-wx.igandan.com/";
static readonly polvId = "11";//保利威视学员id
//正式环境
static readonly urlExpertAPI = "https://app.igandan.com/app/expertAPI/";
static readonly urlExpertApp = "http://app.igandan.com/app/expertApp/"
static readonly urlHtml = "http://doc.igandan.com/app/"
static readonly urlImage = "http://doc.igandan.com/app/"
static readonly urlExpert = "http://app.igandan.com/app/expert/"
static readonly wxUrl = "https://wx.igandan.com/";// 微信服务器地址
static readonly polvId = "21";//保利威视学员id
// static readonly urlExpertAPI = "https://app.igandan.com/app/expertAPI/";
// static readonly urlExpertApp = "http://app.igandan.com/app/expertApp/"
// static readonly urlHtml = "http://doc.igandan.com/app/"
// static readonly urlImage = "http://doc.igandan.com/app/"
// static readonly urlExpert = "http://app.igandan.com/app/expert/"
// static readonly wxUrl = "https://wx.igandan.com/";// 微信服务器地址
// static readonly polvId = "21";//保利威视学员id
static readonly getStartpage=BasicConstant.urlExpertApp + "startpage";
@@ -46,7 +46,23 @@ export class BasicConstant {
static readonly updatePwd = BasicConstant.urlExpertAPI+'updatePwd'
static readonly read = BasicConstant.urlExpert+'read'//视频阅读数
static readonly POLVID ='PolvId'//保利观众id
static readonly QuickReplyList = BasicConstant.urlExpert+'QuickReplyList'//快捷回复
static readonly addQuickReply = BasicConstant.urlExpert+'addQuickReply'//添加快捷回复
static readonly deleteQuickReply = BasicConstant.urlExpert+'deleteQuickReply'//删除快捷回复
static readonly stopOutPatientList = BasicConstant.urlExpertApp+'stopOutPatientList'//停诊
static readonly listOutPatient = BasicConstant.urlExpertApp+'listOutPatient'//出诊
static readonly urlOutpatientnew = BasicConstant.wxUrl+"wxPatient/index.htm#/outPatient?link=share&expertUuid=";//出诊
static readonly getNewWa="https://wx.igandan.com/shop_notify/";//肝胆商城妞娃购买链接
static readonly patientDetail= BasicConstant.urlExpert + "patientDetail";// 患者详情
static readonly newConsultList = BasicConstant.urlExpertAPI + "newConsultList";// 新的公益咨询列表
static readonly consultListHis = BasicConstant.urlExpertAPI +"consultListHis";// 公益咨询历史列表
static readonly consultDetail = BasicConstant.urlExpertAPI + "consultDetail";// 公益咨询详情
static readonly countConsult= BasicConstant.urlExpert + "countConsult";// 回答患者次数
static readonly resConsult= BasicConstant.urlExpert +"resConsult";// 抢答公益咨询
static readonly listNewInterrogation = BasicConstant.urlExpertAPI +"listNewInterrogation";// 一问多答 新的一问多答列表
static readonly listMyAnsweredInterrogation = BasicConstant.urlExpertAPI +"listMyAnsweredInterrogation";// 一问多答 我回答的一问多答列表
static readonly getInterrogation = BasicConstant.urlExpertAPI +"getInterrogation";// 一问多答 详情页
static readonly InterrogationPatientInfo = BasicConstant.urlExpertAPI +"InterrogationPatientInfo";// 一问多答 患者详情页
static readonly province=['全国','北京市','天津市','河北省','山西省'
,'内蒙古自治区','辽宁省','吉林省','黑龙江省','上海市','江苏省','浙江省'
,'安徽省','福建省','江西省','山东省','河南省','湖北省','湖南省','广东省',
@@ -57,5 +73,16 @@ export class BasicConstant {
static readonly notification_back_refreshData = 250529;//返回上页通知刷新数据
//首页tabContent切换事件通知
static readonly notification_home_tab_change = 25060413;
static readonly YX_accid='YX_accid'//云信
static readonly YX_token='YX_token'//云信
static readonly Teach="[图文科普]";
static readonly VideoTeach="[视频科普]";
static readonly VisitTeach="[门诊公告]";
static readonly CouTeach="[公益咨询]";
static readonly Shopping="[肝胆商城]";
static readonly Hostipal="[互联网医院]";
}
@@ -53,4 +53,9 @@ export interface Data{
realName:string;
specialy:Array<object>;
}
export interface BaseBean{
code:string;
message:string;
}
@@ -0,0 +1,6 @@
export interface ViewImageInfo{
url:string,
uri:string
}
@@ -172,4 +172,13 @@ export class ChangeUtil {
static isOnline(): boolean {
return connection.hasDefaultNetSync();
}
//length转化为数字
static parseLengthToNumber(length: Length): number {
if (typeof length === "string") {
// 移除单位并转换
const numericPart = parseFloat(length.replace(/[^0-9.]/g, ''));
return isNaN(numericPart) ? 0 : numericPart;
}
return length as number; // 已经是数值类型
}
}
@@ -22,4 +22,26 @@ export function formatDate(date: Date,pattern:DateFormat = 'YYYY-MM-DD'): string
default:
throw new Error(`Unsupported format pattern: ${pattern}`);
}
}
//计算年龄
export function calculateExactAge(birthDate: Date) {
const today = new Date();
let years = today.getFullYear() - birthDate.getFullYear();
let months = today.getMonth() - birthDate.getMonth();
let days = today.getDate() - birthDate.getDate();
if (days < 0) {
months--;
// 获取上月最后一天
const lastDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 0).getDate();
days += lastDayOfMonth;
}
if (months < 0) {
years--;
months += 12;
}
return years;
}
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2022 NetEase, Inc. All rights reserved.
* Use of this source code is governed by a MIT license that can be
* found in the LICENSE file.
*
*/
// found in the LICENSE file.
import { abilityAccessCtrl, common, Permissions } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
export class PermissionsRequestResult {
// 错误信息
public error?: BusinessError;
// 是否授权
public grantStatus?: boolean;
}
export class PermissionsUtils {
static async reqPermissionsFromUser(permissions: Array<Permissions>,
context: common.UIAbilityContext): Promise<PermissionsRequestResult> {
const result: PermissionsRequestResult = await new Promise((resolve: Function) => {
console.log("net ease reqPermissionsFromUser")
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
// requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗
atManager.requestPermissionsFromUser(context, permissions).then((data) => {
let grantStatus: Array<number> = data.authResults;
let length: number = grantStatus.length;
let permissionsRequestResult = new PermissionsRequestResult();
if (grantStatus.length > 0) {
const grant = grantStatus[0];
if (grant === 0) {
// 用户授权,可以继续访问目标操作
permissionsRequestResult.grantStatus = true;
} else {
// 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限
permissionsRequestResult.grantStatus = false;
}
}
resolve(permissionsRequestResult);
}).catch((err: BusinessError) => {
console.error(`netease Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`);
let permissionsRequestResult = new PermissionsRequestResult();
permissionsRequestResult.error = err;
resolve(permissionsRequestResult);
})
});
return result
}
}
@@ -59,6 +59,14 @@
{
"name": "main_color",
"value": "#923C35"
},
{
"name": "efefef",
"value": "#efefef"
},
{
"name": "999999",
"value": "#999999"
}
]
}
@@ -35,6 +35,46 @@
{
"name": "hd_clock_in",
"value": "打卡"
},
{
"name": "cancellation",
"value": "账号已注销"
},
{
"name": "page_show",
"value": "page from package"
},
{
"name": "netease_permission_write_media_desc",
"value": "用于保存图片到相册"
},
{
"name": "netease_permission_read_media_desc",
"value": "用于读取相册中的图片"
},
{
"name": "netease_permission_denied_tips",
"value": "需要存储权限才能保存图片,请在设置中开启权限"
},
{
"name": "netease_saving_image_tips",
"value": "正在保存图片..."
},
{
"name": "netease_download_failed_tips",
"value": "图片下载失败,请检查网络连接"
},
{
"name": "netease_save_success_tips",
"value": "图片已保存到相册"
},
{
"name": "netease_save_failed_tips",
"value": "保存失败,请检查存储空间"
},
{
"name": "netease_save_error_tips",
"value": "保存失败,请稍后重试"
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB