<template>
	<view>
		<scan @getCode="getScanCode"></scan>
	</view>
</template>

<script>
	import scan from '@/components/scan.vue'
	export default {
		components:{
			scan
		},
		data() {
			return {
				bol: true
			};
		},
		mounted () {
			uni.$on('setBol', (data) => {
				this.$nextTick(() => {
					this.bol = data.bol
				})
				uni.$emit('setShow', {
					bol: data.bol
				})
			})
		},
		onLoad () {
			plus.key.addEventListener('backbutton', function () {
				uni.reLaunch({
					url: '../index/index'
				})
				return true
			});
		},
		onBackPress () {
			plus.key.removeEventListener('backbutton', function () {
				return true
			});
		},
		beforeDestroy() {
			uni.$off('setBol')
		},
		methods:{
			//获取扫码控件
			getScanCode(val){
				this.scanValue(val)
			},
			async scanValue (str) {
                uni.redirectTo({ url: `/pages/info/info?code=${str}`})
			}
		}
	}
</script>