<template>
	<view style="background-color: white;">
		<view class="img">
			<image slot="icon" src="@/static/order/扫一扫核销@2x.png" style="width: 400rpx; height: 400rpx" />
		</view>
		<view class="but">
			<button @click='scanCode()'>扫一扫核销</button>
		</view>
		<view class="bot">
			<view class="tab" @click="toUrl()">
				<image src="@/static/order/查询核销@2x.png" style="width: 150rpx; height: 150rpx"></image>
				<view>查询核销</view>
			</view>
			<view class="tab" @click="verificationList()">
				<image src="@/static/order/核销记录@2x.png" style="width: 150rpx; height: 150rpx"></image>
				<view>核销记录</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getVerificationApi
	} from '@/api/merchant/order'
	// import {
	// 	mapGetters
	// } from 'vuex';
	export default {
		data() {
			return {

			}
		},
		// computed: {
		// 	...mapGetters(['userId']),
		// },
		methods: {
			toUrl(){
				console.log("sadas")
				uni.navigateTo({
					url: '/pageMerchant/storeModule/components/queryWriteOff',
				});
			},
			verificationList(){
				uni.navigateTo({
					url: '/pageMerchant/storeModule/components/verificationList',
				});
			},
			async getOrderList(id) {
				let result = Object.assign({}, {
					paging: `${this.params.pageNum},${this.params.pageSize}`,
					status: 0,
					orderSn: id
				}, );
				let res = await getOrderListApi({
					...result
				});
				if (res.code === 'OK' && res.data.records) {
					uni.navigateTo({
						url: `/pageMerchant/components/toBeVerified?list=${JSON.stringify(res.data.records)}`
					})
				} else {
					uni.showToast({
						title: "没有该订单信息",
						dration: 2000,
					});
				}
			},
			scanCode() {
				const this1 = this;
				uni.scanCode({
					success: function(res) {
						this1.getOrderList(res.result)
						// uni.navigateTo({
						// 	url:`/pageMerchant/components/toBeVerified?id=${res.result}`
						// })
						
						// getVerificationApi(res.result, )
						// 	.then(response => {
						// 		if(response.code == "OK"){
									
						// 			uni.navigateTo({
						// 				url:`/pageMerchant/components/orderDetail?id=${}`
						// 			})
									
						// 			uni.showToast({
						// 			  title: "核销成功",
						// 			  icon: 'success',
						// 			  dration: 2000,
						// 			});
						// 		}
						// 	})
						console.log(res, "res")
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.img {
		margin-top: 100rpx;
		image {
			display: block;
			margin: 0 auto;
		}
	}

	.but {
		margin-top: 20rpx;
		padding-left: 100rpx;
		padding-right: 100rpx;

		button {
			background-color: blue;
			color: aliceblue;
		}
	}

	.bot {
		color: blue;
		margin-top: 100rpx;
		padding-left: 200rpx;
		padding-right: 200rpx;
		display: flex;
		justify-content: space-between;

		.tab {
			text-align: center;

			image {
				display: block;
				margin: 0 auto;
			}

			// height: 400rpx;
		}
	}
</style>