<template>
	<view>
		<!-- <view class="topTabBar" :style="{position:headerPosition,top:headerTop}">
			<view class="grid" v-for="(grid,tbIndex) in businType" :key="tbIndex" @tap="showType(tbIndex)">
				<view class="text" :class="[tbIndex==tabbarIndex?'on':'']">{{grid}}</view>
			</view>

		</view> -->
		<view class="width100 mart60 fotct" @click="scan">
			<image style="width: 120px;height: 120px;"
				src="data:image/png;base64,[encoded data, 9416 characters]">
			</image>
		</view>
	</view>
</template>

<script>
	import {
		useCouponCode
	} from '../../../Utils/Api.js';
	let app = getApp();
	export default {
		data() {
			return {
				businType: ['扫码消核', '消核统计'],
				tabbarIndex: 0,
				headerPosition: "fixed",
				headerTop: "0px",
			}
		},
		onPageScroll(e) {
			return;
			//兼容iOS端下拉时顶部漂移
			this.headerPosition = e.scrollTop >= 0 ? "fixed" : "absolute";
		},
		methods: {
			showType(tbIndex) {
				this.tabbarIndex = tbIndex;
			},
			scan() {
				uni.scanCode({
					success: function(res) {
						let datas = {
							"code": res.result
						}
						useCouponCode(datas).then(res => {
							if (res.return_code == '000000') {
								uni.showToast({
									title: res.return_data,
									duration: 2000
								})
							} else {
								uni.showToast({
									title: res.return_msg,
									icon: "none"
								})
							}
						})
					}
				});

			}
		}
	}
</script>

<style lang="scss">
	.topTabBar {
		width: 100%;
		position: fixed;
		top: 0;
		z-index: 10;
		background-color: #f8f8f8;
		height: 80upx;
		display: flex;
		justify-content: space-around;

		.grid {
			width: 20%;
			height: 80upx;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #444;
			font-size: 28upx;

			.text {
				height: 76upx;
				display: flex;
				align-items: center;

				&.on {
					color: #0083f5;
					border-bottom: solid 4upx #0083f5;
				}
			}

		}
	}
</style>
