提交 26ae58f8 编写于 作者: DCloud_JSON's avatar DCloud_JSON

优化引导打开相册权限,因为ios已经集成不需要另外写

上级 ffa90a8b
...@@ -59,32 +59,30 @@ export default function() { ...@@ -59,32 +59,30 @@ export default function() {
uni.addInterceptor('chooseImage', { uni.addInterceptor('chooseImage', {
fail(e) { // 失败回调拦截 fail(e) { // 失败回调拦截
console.log(e); console.log(e);
if ( if(uni.getSystemInfoSync().platform == "android" && e.errMsg == 'chooseImage:fail No Permission'){
e.errCode === 11 && uni.getSystemInfoSync().platform == "android" || if(e.code === 11){
e.errCode === 2 && uni.getSystemInfoSync().platform == "ios" uni.showModal({
){ title:"无法访问摄像头",
uni.showModal({ content: "当前无摄像头访问权限,建议前往设置",
title:"无法访问摄像头", confirmText: "前往设置",
content: "当前无摄像头访问权限,建议前往设置", success(e) {
confirmText: "前往设置", if (e.confirm) {
success(e) { openAppPermissionSetting()
if (e.confirm) { }
openAppPermissionSetting()
} }
} });
}); }else{
} uni.showModal({
if(e.errCode === 12 && uni.getSystemInfoSync().platform == "android"){ title:"无法访问相册",
uni.showModal({ content: "当前无系统相册访问权限,建议前往设置",
title:"无法访问相册", confirmText: "前往设置",
content: "当前无系统相册访问权限,建议前往设置", success(e) {
confirmText: "前往设置", if (e.confirm) {
success(e) { openAppPermissionSetting()
if (e.confirm) { }
openAppPermissionSetting()
} }
} });
}); }
} }
} }
}) })
...@@ -141,4 +139,30 @@ function initAppVersion() { ...@@ -141,4 +139,30 @@ function initAppVersion() {
// 检查更新 // 检查更新
checkUpdate(); checkUpdate();
// #endif // #endif
}
function openAppPermissionSetting(){
// 跳转到**应用**的权限页面
if (uni.getSystemInfoSync().platform == "ios") {
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);
}
} }
\ No newline at end of file
<template> <template>
<view> <view>
<!-- #ifndef H5 --> <!-- #ifdef APP-PLUS -->
<uni-nav-bar :border="false"></uni-nav-bar> <statusBar></statusBar>
<!-- #endif --> <!-- #endif -->
<!-- 搜索功能 --> <!-- 搜索功能 -->
<uni-search-bar @click="searchClick" class="uni-search-box" v-model="keyword" ref="searchBar" radius="100" cancelButton="none" disabled/> <uni-search-bar @click="searchClick" class="uni-search-box" v-model="keyword" ref="searchBar" radius="100" cancelButton="none" disabled/>
...@@ -57,8 +57,10 @@ ...@@ -57,8 +57,10 @@
</template> </template>
<script> <script>
var cdbRef, currentWebview; var cdbRef, currentWebview;
export default { import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
export default {
components: { statusBar },
data() { data() {
return { return {
where: "", where: "",
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
border-radius: 6rpx; border-radius: 6rpx;
} }
.send-btn{ .send-btn{
height: 85rpx;
width: 100%; width: 100%;
margin-top:15px; margin-top:15px;
border-radius: 6rpx; border-radius: 6rpx;
......
...@@ -130,7 +130,6 @@ ...@@ -130,7 +130,6 @@
} }
}, },
setAvatar() { setAvatar() {
console.log('点击编辑信息');
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
success: (res) => { success: (res) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册