<template>
	<view class="barcode">
		<text>条码类型{{scanType}}</text>
		<view class="ba1">
			<text>条码内容{{result}}</text>
		</view>
		<button type="primary" class="but" @click="sc">扫码</button>
	</view>
</template>

<script>
	export default {
		components:{
	
		},
		data() {
			return {
				scanType:"",
				result:"",
			}
		},
		onHide() {
			uni.stopBluetoothDevicesDiscovery({
			  success(res) {
			    console.log(res)
			  }
			})
			uni.closeBluetoothAdapter({
			  success(res) {
			    console.log(res)
			  }
			})
		},
		mounted() {
			
		},
		methods: {
			sc(){
				uni.scanCode({
				    success: (res) => {
				        console.log('条码类型：' + res.scanType);
						this.result = res.result
						this.scanType = res.scanType
				        console.log('条码内容：' + res.result);
				    },
					fail:(e) =>{
						console.log(e)
					}
				});
			}
		}
	}
</script>
<style scoped lang="scss">
	.barcode {
		padding:60rpx 20rpx;
		.ba1{
			margin:30rpx 0;
		}
	}
	.but{
		margin:50rpx;
	}
</style>
