<template>
	<uni-popup ref="popup">
		<view class="popup_box">
			<view class="pop_title">
				扫描信息
				<text class="fr" @click="closeScanPopup()">关闭</text>
			</view>
			<view class="pop_tab">
				<view class="uni-flex uni-row">
					<view class="tab_tit tab_tit_active">{{title}}</view>
				</view>
				<view class="tab_info">
					<win-com-scan @getScanResult="getScanResult" :placeholder='title'></win-com-scan>
				</view>
			</view>
		</view>
	</uni-popup>
</template>

<script>
	import winComScan from '@/mycomponents/wincom/winComScan.vue'
	export default {
		name: 'winScanByCode',
		components: {
			winComScan
		},
		props: {
			title: {
				type: String,
				default: ''
			},
		},
		data() {
			return {
				code: ''
			}
		},

		created() {

		},
		methods: {
			openScanPopup() {
				this.$refs.popup.open('bottom')
			},
			closeScanPopup() {
				this.$refs.popup.close()
			},
			getScanResult(result) {
				if (result.data.scanType === 'qrcode') {
					this.code = result.data.itemCode;
				} else if (result.data.scanType === 'barcode') {
					this.code = result.data.code;
				}
				this.callBack();
			},
			callBack() {
				this.closeScanPopup();
				this.$emit("getLocationCode", this.code);
			}
		}
	}
</script>

<style>
</style>
