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.
117 lines
2.7 KiB
117 lines
2.7 KiB
<template>
|
|
<view class="main">
|
|
<!-- <barcode id='1' class="barcode" autostart="true" ref="barcode" background="rgb(0,0,0)" frameColor="#1C86EE" scanbarColor="#1C86EE" :filters="fil" @marked="success1" @error="fail1"></barcode> -->
|
|
<button class="btn" @click="toStart">
|
|
开始扫码识别</button>
|
|
<button class="btn" @click="tocancel">取消扫码识别</button>
|
|
<button class="btn" @click="toFlash">开启闪光灯</button>
|
|
<button class="btn" @click="toscan">预览</button>
|
|
<button class="btn" @click="toback">
|
|
<view class="dot"></view>
|
|
3s后返回</button>
|
|
|
|
<!-- <view class="box">
|
|
<view class="dot">5515</view>
|
|
</view> -->
|
|
|
|
<view class="bottom-dot"></view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
onLoad() {
|
|
|
|
},
|
|
data() {
|
|
return {
|
|
fil: [0, 2, 1]
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
toback(){
|
|
setTimeout(()=>{
|
|
this.tocancel()
|
|
uni.navigateBack()
|
|
},3000)
|
|
},
|
|
success1(e) {
|
|
console.log("success1:" + JSON.stringify(e));
|
|
},
|
|
fail1(e) {
|
|
console.log("fail1:" + JSON.stringify(e));
|
|
},
|
|
toStart: function() {
|
|
this.$refs.barcode.start({
|
|
conserve: true,
|
|
filename: '_doc/barcode/'
|
|
});
|
|
},
|
|
tocancel:function(){
|
|
this.$refs.barcode.cancel();
|
|
},
|
|
toFlash: function() {
|
|
this.$refs.barcode.setFlash(true);
|
|
},
|
|
|
|
toscan: function() {
|
|
console.log("scan:");
|
|
const barcodeModule = uni.requireNativePlugin('barcodeScan');
|
|
barcodeModule.scan("/static/barcode1.png"
|
|
,(e)=>{
|
|
console.log("scan_error:"+JSON.stringify(e));
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.main{
|
|
.barcode {
|
|
width: 750rpx;
|
|
height: 700rpx;
|
|
background-color: #808080;
|
|
}
|
|
|
|
.btn {
|
|
top: 20rpx;
|
|
width: 730rpx;
|
|
margin-left: 10rpx;
|
|
margin-top: 10rpx;
|
|
background-color: #458B00;
|
|
border-radius: 10rpx;
|
|
position: relative;
|
|
.dot{
|
|
top: 20rpx;
|
|
left: 20rpx;
|
|
z-index:99;
|
|
position: fixed;
|
|
background-color: red;
|
|
width: 30rpx;
|
|
height: 30rpx;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
}
|
|
.box{
|
|
position: relative;
|
|
width: 750rpx;
|
|
height: 300rpx;
|
|
background-color: #009874;
|
|
|
|
}
|
|
.bottom-dot{
|
|
bottom: 0;
|
|
// left: 100rpx;
|
|
z-index:10;
|
|
position: fixed;
|
|
background-color: lightgray;
|
|
width: 750rpx;
|
|
height: 130rpx;
|
|
// border-radius: 50%;
|
|
}
|
|
}
|
|
|
|
</style>
|