当前位置: 首页 > wzjs >正文

南昌科技网站建设吉林市做网站的公司

南昌科技网站建设,吉林市做网站的公司,工业设计考研比较好的学校,企业宣传片的制作流程背景: 在使用定位、相机、文件、电话,需要用户同意授权时,华为和vivo需要告知用户使用权限目的。 方案: 在uni授权时,弹框告诉授权目的,效果如下: 代码: const perListener {//…

背景:

在使用定位、相机、文件、电话,需要用户同意授权时,华为和vivo需要告知用户使用权限目的。

方案:

在uni授权时,弹框告诉授权目的,效果如下:

代码:

const perListener = {// 初始化状态state: {// 处理应用程序权限请求WRITE_EXTERNAL_STORAGE: false,ACCESS_FINE_LOCATION: false,CALL_PHONE: false,/* #ifdef APP-PLUS */isIos: plus.os.name == "iOS",/* #endif */mapping: {'WRITE_EXTERNAL_STORAGE': {title: "拍摄/相册权限说明",content: "用于司机在车辆发生事故时,可以快速上传事故图片等材料,用于协助司机处理出险问题。",methods: 'SET_WRITE_EXTERNAL_STORAGE'},'ACCESS_FINE_LOCATION': {title: "定位权限说明",content: "用于获取用户位置,以便为用户提供有地域特点的服务。",methods: 'SET_ACCESS_FINE_LOCATION'},'CALL_PHONE': {title: "拨打电话权限说明",content: "允许应用获取本机号码,以便用户得到更便捷的服务。",methods: 'SET_CALL_PHONE'}}},mutations: {// 管理权限告知目的SET_WRITE_EXTERNAL_STORAGE(state, val) {state.WRITE_EXTERNAL_STORAGE = val},SET_CALL_PHONE(state, val) {state.CALL_PHONE = val},SET_ACCESS_FINE_LOCATION(state, val) {state.ACCESS_FINE_LOCATION = val}},actions: {//权限获取async requestPermissions({state,dispatch,commit}, permissionID) {try {if (!state[permissionID] && !state.isIos) {var viewObj = await dispatch('nativeObjView', permissionID);viewObj.show();}console.log('android.permission.' + permissionID, '当前手机权限');let model = uni.getSystemInfoSync().brand.toLowerCase();return new Promise(async (resolve, reject) => {//苹果不需要这个if (state.isIos) {resolve(1);return}if (model != 'vivo' && model != 'huawei') {resolve(1);return;}// Android权限查询function requestAndroidPermission(permissionID_) {return new Promise((resolve, reject) => {plus.android.requestPermissions([permissionID_], // 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装function(resultObj) {console.log('resultObj', resultObj)var result = 0;for (var i = 0; i < resultObj.granted.length; i++) {// var grantedPermission = resultObj.granted[i];console.log('已获取的权限:');result = 1}for (var i = 0; i < resultObj.deniedPresent.length; i++) {// var deniedPresentPermission = resultObj.deniedPresent[i];console.log('拒绝本次申请的权限:');result = 0}for (var i = 0; i < resultObj.deniedAlways.length; i++) {// var deniedAlwaysPermission = resultObj.deniedAlways[i];// console.log('永久拒绝申请的权限:' + deniedAlwaysPermission);result = -1}resolve(result);},function(error) {console.log('申请权限错误:' + error.code + " = " + error.message);resolve({code: error.code,message: error.message});});});}const result = await requestAndroidPermission('android.permission.' + permissionID);console.log('result', result)if (result === 1) {//'已获得授权'commit(state.mapping[permissionID].methods, true)} else if (result === 0) {//'未获得授权'commit(state.mapping[permissionID].methods, false)} else {commit(state.mapping[permissionID].methods, true)uni.showModal({title: '提示',content: '操作权限已被拒绝,请手动前往设置',confirmText: "立即设置",success: (res) => {if (res.confirm) {dispatch('gotoAppPermissionSetting')}}})}if (viewObj) viewObj.close()resolve(result);});} catch (error) {console.log(error);reject(error);}},//提示框nativeObjView({state}, permissionID) {const systemInfo = uni.getSystemInfoSync();const statusBarHeight = systemInfo.statusBarHeight;const navigationBarHeight = systemInfo.platform === 'android' ? 48 :44; // Set the navigation bar height based on the platformconst totalHeight = statusBarHeight + navigationBarHeight;let view = new plus.nativeObj.View('per-modal', {top: '0px',left: '0px',width: '100%',backgroundColor: '#444',//opacity: .5;})view.drawRect({color: '#fff',radius: '5px'}, {top: totalHeight + 'px',left: '5%',width: '90%',height: "100px",})view.drawText(state.mapping[permissionID].title, {top: totalHeight + 5 + 'px',left: "8%",height: "30px"}, {align: "left",color: "#000",}, {onClick: function(e) {console.log(e);}})view.drawText(state.mapping[permissionID].content, {top: totalHeight + 35 + 'px',height: "60px",left: "8%",width: "84%"}, {whiteSpace: 'normal',size: "14px",align: "left",color: "#656563"})function show() {view = plus.nativeObj.View.getViewById('per-modal');view.show()view = null //展示的时候也得清空,不然影响下次的关闭,不知道为啥}function close() {view = plus.nativeObj.View.getViewById('per-modal');view.close();view = null}return {show,close}},// 跳转到**应用**的权限页面gotoAppPermissionSetting({state}) {if (state.isIos) {var UIApplication = plus.ios.import("UIApplication");var application2 = UIApplication.sharedApplication();var NSURL2 = plus.ios.import("NSURL");// var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");		var setting2 = NSURL2.URLWithString("app-settings:");application2.openURL(setting2);plus.ios.deleteObject(setting2);plus.ios.deleteObject(NSURL2);plus.ios.deleteObject(application2);} else {// console.log(plus.device.vendor);var Intent = plus.android.importClass("android.content.Intent");var Settings = plus.android.importClass("android.provider.Settings");var Uri = plus.android.importClass("android.net.Uri");var mainActivity = plus.android.runtimeMainActivity();var intent = new Intent();intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);intent.setData(uri);mainActivity.startActivity(intent);}}}}
export default perListener

使用:

async handleCall(phone) {// #ifdef APP-PLUSlet result = await this.$store.dispatch("requestPermissions",'CALL_PHONE')if (result !== 1) return// #endifuni.makePhoneCall({phoneNumber: phone})
},


文章转载自:

http://D7nrzOI4.ngmjn.cn
http://UlFAKBDC.ngmjn.cn
http://OrpSrJWK.ngmjn.cn
http://S9cflkpC.ngmjn.cn
http://OxsqxhaK.ngmjn.cn
http://rUgJVOyn.ngmjn.cn
http://8PDxBIvv.ngmjn.cn
http://I1k9ylR9.ngmjn.cn
http://EId3sngi.ngmjn.cn
http://tS81d07W.ngmjn.cn
http://0GlhuAYf.ngmjn.cn
http://HzbzUjrO.ngmjn.cn
http://ITO1haDs.ngmjn.cn
http://C9ypJx5Q.ngmjn.cn
http://8b4s8JSr.ngmjn.cn
http://wLmyvYyU.ngmjn.cn
http://vud8Alv2.ngmjn.cn
http://jG13G3Ak.ngmjn.cn
http://EuFTwyPL.ngmjn.cn
http://uTk8iuD2.ngmjn.cn
http://dhWG93Wu.ngmjn.cn
http://GBQWipyT.ngmjn.cn
http://hiL7BWT1.ngmjn.cn
http://xGTOezAy.ngmjn.cn
http://vz0OJINu.ngmjn.cn
http://HKGVgpKr.ngmjn.cn
http://hHHb02Po.ngmjn.cn
http://AZoJW6dF.ngmjn.cn
http://16KZylKP.ngmjn.cn
http://Ga6i3YGl.ngmjn.cn
http://www.dtcms.com/wzjs/737454.html

相关文章:

  • 个人网站可以做社区吗备案号放网站下面居中
  • 壹互联是网站公司吗wordpress登陆
  • 山西建设网站公司网页设计与网站建设的目的
  • 成品网站管系统黄山网站设计公司
  • 南宁网站建设云尚网络如何接单做网站
  • 自己做一个音乐网站怎么做重庆定制型网站建设
  • 网站制作需要多少费用制作网站软件免费
  • 重庆网站空间键词排名wordpress 集赞系统
  • 做网站怎么做wordpress 后台 模板
  • 怎么建设网站石家庄网站托管公司
  • 新网站seo技术wordpress全是博客
  • 化妆品销售网站的源代码腾讯云服务器学生
  • 上海个人网站备案wordpress post模板
  • 洛阳疾控最新通告今天谷歌搜索优化
  • 网站建设与网页设计心得体会wordpress 大型站
  • 商城网站做推广方案南昌网站制作代理商
  • 网站制作应用搭建个人主页
  • 中山 环保 骏域网站建设专家销客多分销小程序价格
  • 网站优化推广哪家好深喘旋磨做紧夹断妖精网站
  • 大网站服务器维护费用怎么制作ppt 教程
  • 企业网站建设费用属于什么科目平台推广方案模板
  • python手机编程软件长沙网站优化指导
  • 新河网站快排seo建筑网课平台
  • 山东 网站建设 公司太原市住房与城乡建设厅网站
  • 南阳理工网站建设私人可以有官方网址吗
  • 深圳网站建设 宝华大厦泰兴网页定制
  • 网站后台策划书2024年还会封城吗
  • 开网站需要哪些程序莆田网站建设方案优化
  • 什么样的资质做电子商务网站python 网站建设
  • 广东装饰公司网站建设国家企业信用信息查询系统