安卓扫码器
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.
 
 
 
 

80 lines
1.8 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">
<tn-button @click="openPermission()" :backgroundColor="btnBackgroundColor" :fontColor="btnFontColor" width="300rpx" height="100rpx"
:fontSize="btnFontSize">Allow</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'
}
},
async onLoad() {
this.openPermission();
},
onHide() {
},
methods: {
//打开授权
async openPermission(){
let that = this;
var result = await permision.requestAndroidPermission('android.permission.CAMERA')
console.log('打开授权结果为:',result)
if (result == '1') {
//有权限,跳转到扫码界面
that.jumpToRights('/pages/scan/Scan',1);
}else if(result == '-1') {
//禁止权限,跳转到权限设置页面
that.jumpToRights('/pages/rights/RightsSetting',0);
}
},
//跳转到授权设置页面
jumpToRights(url,type){
if(type == 1){
uni.switchTab({
url: url
})
}else{
uni.reLaunch({
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>