Commit 05e3ab25 authored by jyx's avatar jyx

添加权限校验弹框

parent 35777462
<template>
<view class="body">
<camera id="camera" resolution="high" device-position="back" flash="off" @error="error" @initdone="initdone"
style="position:absolute;width:100%;height:100%;">
<view style="position:absolute;width:100%;height:100%;">
<camera v-if="showCamera" id="camera" resolution="high" device-position="back" flash="off" @error="error"
@initdone="initdone" style="width:100%;height:100%;">
</camera>
</view>
<image class="icon_center" mode="aspectFit" src="../../static/ic_center.png" />
......@@ -35,6 +38,11 @@
imageCompress
} from "@/utils/utils.js"
import {
openSetting,
} from '@/utils/utils.js';
import {
redirectTo,
navigateTo,
......@@ -55,6 +63,7 @@
items: [],
showPicker: false,
userBean: {},
showCamera: true
}
},
onLoad(options) {
......@@ -78,9 +87,15 @@
this.userBean = data;
}
});
this.showCamera = true
},
methods: {
takePhoto() {
if (!this.showCamera) {
this.showCamera = true
}
if (this.isMeasureHeight == 1 && !this.isClickTwo) {
this.isClickTwo = true
this.scanPosition = "顶部"
......@@ -96,6 +111,24 @@
},
error(e) {
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({
detail: {
......
<template>
<view class="body">
<camera id="camera" resolution="high" device-position="back" flash="off" @error="error" @initdone="initdone"
style="position:relative;width:100%;height:70%;">
<view style="position:relative;width:100%;height:70%;">
<camera v-if="showCamera" id="camera" resolution="high" device-position="back" flash="off" @error="error"
@initdone="initdone" style="width:100%;height:100%;">
</camera>
</view>
<view class="hint" v-if="current==0">请保持水平清晰</view>
<view class="card" v-if="current==1" @click="showPop">
......@@ -56,6 +59,10 @@
reLaunch
} from '@/utils/fun';
import {
openSetting,
} from '@/utils/utils.js';
const app = getApp();
export default {
......@@ -89,13 +96,21 @@
}, ],
list: ['身份证正面', '身份证反面'],
cardType: ScanTypeBean.idcard_front,
showCamera: true
}
},
onLoad(option) {
this.current = option.type
},
onShow() {
this.showCamera = true
},
methods: {
takePhoto() {
if (!this.showCamera) {
this.showCamera = true
}
uni.showLoading({
title: '加载中...'
})
......@@ -132,11 +147,34 @@
type: that.current,
cardType: that.cardType
})
},
fail: (res) => {
setTimeout(() => {
that.goAuthSetting()
}, 500)
}
});
},
error(e) {
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({
detail: {
......@@ -151,6 +189,10 @@
},
handleChange(res) {
this.current = res.value
if (!this.showCamera) {
this.showCamera = true
}
},
showPop() {
this.$refs.popup.open('bottom')
......
......@@ -335,3 +335,14 @@ export function getSubList(length, list) {
}
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