安卓扫码器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

100 lines
2.6 KiB

<template>
<view class="content">
<view class="textBoard">
<text style="color: #fff; font-size: 48rpx;">Need permissions?</text>
</view>
<view class="textBoard">
<text style="color: #fff; font-size: 36rpx;">Camera permission is requeired to</text>
</view>
<view class="textBoard">
<text style="color: #0186FF; font-size: 36rpx;">QR Code Scanner & barcode Reader.</text>
</view>
<view class="textBoard">
<text style="color: #fff; font-size: 36rpx;">1.Open settings</text>
</view>
<view class="textBoard">
<text style="color: #fff; font-size: 36rpx;">2.Tap permissions</text>
</view>
<view class="textBoard">
<text style="color: #fff; font-size: 36rpx;">3.Turn on Camera</text>
</view>
<view class="textBoard">
<tn-button @click="setPermission()" :backgroundColor="btnBackgroundColor" :fontColor="btnFontColor" width="300rpx" height="100rpx"
:fontSize="btnFontSize">Open settings</tn-button>
</view>
</view>
</template>
<script>
import permision from "@/js_sdk/wa-permission/permission.js"
export default {
data() {
return {
btnFontSize: 36,
btnBackgroundColor: '#0186ff',
btnFontColor: '#fff',
hasRequestedPermission: false
}
},
async onShow(){
let that = this;
if (!that.hasRequestedPermission) {
console.log('进入了判断setting权限',that.hasRequestedPermission)
await that.requestAndroidPermission('android.permission.CAMERA');
}
// else{
// console.log('setting权限状态已变更为true,进入扫码页',that.hasRequestedPermission)
// that.jumpToRights('/pages/scan/Scan');
// }
},
onHide() {
this.hasRequestedPermission = false;
console.log('onHide')
},
onUnload(){
console.log('onUnload')
},
methods: {
//打开设置权限界面
setPermission(){
permision.gotoAppPermissionSetting();
},
//判断是否有相机权限
async requestAndroidPermission(permisionID) {
let that = this;
var result = await permision.requestAndroidPermission(permisionID)
console.log('setting判断权限结果',result)
that.hasRequestedPermission = true;
if (result == 1) {
//有权限,跳转到扫码界面
that.jumpToRights('/pages/scan/Scan');
}
},
//跳转到授权设置页面
jumpToRights(url){
uni.switchTab({
url: url
})
}
}
}
</script>
<style lang="scss">
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #1F222B;
height:100vh;
}
.textBoard{
margin-top: 1vh;
}
</style>