Commit 05e3ab25 authored by jyx's avatar jyx

添加权限校验弹框

parent 35777462
<template> <template>
<view class="body"> <view class="body">
<camera id="camera" resolution="high" device-position="back" flash="off" @error="error" @initdone="initdone" <view style="position:absolute;width:100%;height:100%;">
style="position:absolute;width:100%;height:100%;"> <camera v-if="showCamera" id="camera" resolution="high" device-position="back" flash="off" @error="error"
</camera> @initdone="initdone" style="width:100%;height:100%;">
</camera>
</view>
<image class="icon_center" mode="aspectFit" src="../../static/ic_center.png" /> <image class="icon_center" mode="aspectFit" src="../../static/ic_center.png" />
...@@ -36,7 +39,12 @@ ...@@ -36,7 +39,12 @@
} from "@/utils/utils.js" } from "@/utils/utils.js"
import { import {
redirectTo, openSetting,
} from '@/utils/utils.js';
import {
redirectTo,
navigateTo, navigateTo,
navigateBack navigateBack
} from '@/utils/fun'; } from '@/utils/fun';
...@@ -55,6 +63,7 @@ ...@@ -55,6 +63,7 @@
items: [], items: [],
showPicker: false, showPicker: false,
userBean: {}, userBean: {},
showCamera: true
} }
}, },
onLoad(options) { onLoad(options) {
...@@ -78,9 +87,15 @@ ...@@ -78,9 +87,15 @@
this.userBean = data; this.userBean = data;
} }
}); });
this.showCamera = true
}, },
methods: { methods: {
takePhoto() { takePhoto() {
if (!this.showCamera) {
this.showCamera = true
}
if (this.isMeasureHeight == 1 && !this.isClickTwo) { if (this.isMeasureHeight == 1 && !this.isClickTwo) {
this.isClickTwo = true this.isClickTwo = true
this.scanPosition = "顶部" this.scanPosition = "顶部"
...@@ -96,6 +111,24 @@ ...@@ -96,6 +111,24 @@
}, },
error(e) { error(e) {
console.log(e.detail); console.log(e.detail);
this.showCamera = false
this.goAuthSetting()
},
goAuthSetting() {
tt.showModal({
title: `获取权限失败`,
content: `未授权,请在设置页授权`,
success(res) {
if (res.confirm) {
openSetting()
} else if (res.cancel) {
uni.showToast({
title: '取消授权'
})
}
},
});
}, },
initdone({ initdone({
detail: { detail: {
......
<template> <template>
<view class="body"> <view class="body">
<camera id="camera" resolution="high" device-position="back" flash="off" @error="error" @initdone="initdone" <view style="position:relative;width:100%;height:70%;">
style="position:relative;width:100%;height:70%;"> <camera v-if="showCamera" id="camera" resolution="high" device-position="back" flash="off" @error="error"
</camera> @initdone="initdone" style="width:100%;height:100%;">
</camera>
</view>
<view class="hint" v-if="current==0">请保持水平清晰</view> <view class="hint" v-if="current==0">请保持水平清晰</view>
<view class="card" v-if="current==1" @click="showPop"> <view class="card" v-if="current==1" @click="showPop">
...@@ -56,6 +59,10 @@ ...@@ -56,6 +59,10 @@
reLaunch reLaunch
} from '@/utils/fun'; } from '@/utils/fun';
import {
openSetting,
} from '@/utils/utils.js';
const app = getApp(); const app = getApp();
export default { export default {
...@@ -89,13 +96,21 @@ ...@@ -89,13 +96,21 @@
}, ], }, ],
list: ['身份证正面', '身份证反面'], list: ['身份证正面', '身份证反面'],
cardType: ScanTypeBean.idcard_front, cardType: ScanTypeBean.idcard_front,
showCamera: true
} }
}, },
onLoad(option) { onLoad(option) {
this.current = option.type this.current = option.type
}, },
onShow() {
this.showCamera = true
},
methods: { methods: {
takePhoto() { takePhoto() {
if (!this.showCamera) {
this.showCamera = true
}
uni.showLoading({ uni.showLoading({
title: '加载中...' title: '加载中...'
}) })
...@@ -107,10 +122,10 @@ ...@@ -107,10 +122,10 @@
quality: 'high', quality: 'high',
success(res) { success(res) {
uni.hideLoading() uni.hideLoading()
navigateTo(`/pagesC/edit/edit`, { navigateTo(`/pagesC/edit/edit`, {
uri: res.tempImagePath, uri: res.tempImagePath,
type: that.current, type: that.current,
cardType: that.cardType cardType: that.cardType
}) })
}, },
fail(err) { fail(err) {
...@@ -129,14 +144,37 @@ ...@@ -129,14 +144,37 @@
success: (res) => { success: (res) => {
navigateTo(`/pagesC/edit/edit`, { navigateTo(`/pagesC/edit/edit`, {
uri: res.tempFilePaths, uri: res.tempFilePaths,
type: that.current, type: that.current,
cardType: that.cardType cardType: that.cardType
}) })
},
fail: (res) => {
setTimeout(() => {
that.goAuthSetting()
}, 500)
} }
}); });
}, },
error(e) { error(e) {
console.log(e.detail); console.log(e.detail);
this.showCamera = false
this.goAuthSetting()
},
goAuthSetting() {
tt.showModal({
title: `获取权限失败`,
content: `未授权,请在设置页授权`,
success(res) {
if (res.confirm) {
openSetting()
} else if (res.cancel) {
uni.showToast({
title: '取消授权'
})
}
},
});
}, },
initdone({ initdone({
detail: { detail: {
...@@ -151,6 +189,10 @@ ...@@ -151,6 +189,10 @@
}, },
handleChange(res) { handleChange(res) {
this.current = res.value this.current = res.value
if (!this.showCamera) {
this.showCamera = true
}
}, },
showPop() { showPop() {
this.$refs.popup.open('bottom') this.$refs.popup.open('bottom')
...@@ -245,7 +287,7 @@ ...@@ -245,7 +287,7 @@
flex-direction: column; flex-direction: column;
// align-items: center; // align-items: center;
// justify-content: center; // justify-content: center;
padding: 15px; padding: 15px;
font-size: 36rpx; font-size: 36rpx;
background-color: #fff; background-color: #fff;
} }
......
...@@ -334,4 +334,15 @@ export function getSubList(length, list) { ...@@ -334,4 +334,15 @@ export function getSubList(length, list) {
} }
} }
return subList return subList
}
export function openSetting() {
tt.openSetting({
success: res => {
console.log('调起设置页面成功');
},
fail: err => {
console.log('调起设置页面失败');
}
});
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment