<template>
	<view class="record-container">
		<view class="status_bar"><!-- 这里是状态栏 --></view>
		<headerVue :color1="color"></headerVue>
		<view class="query-content">
			<view class="query-record">
				<view class="content"><uni-search-bar cancelButton="always" v-model="searchValue" placeholder="SN" @confirm="confirm" /></view>
			</view>
			<view v-for="(item, i) in queryRecord" :key="i">
				<view class="query-list">
					<image :src="baseURL + item.goodsPicUrl" mode="scaleToFill" />
					<view class="record">
						<text class="record-text">{{ item.goodsName }}</text>
						<view class="record-center">
							<text v-if="'phoneAndTime' in queryRecord[i]">扫码手机：{{ 'phoneAndTime' in queryRecord[i] ? item.phoneAndTime[0].phone : '' }}</text>
						</view>
						<view class="record-footer">
							<text class="price">￥{{ item.goodsPrice }}</text>
							<text style="color: #ccc; margin-top: 3%;">{{ item.sameDay }}</text>
							<text v-if="item.used" style="color: #ccc; margin-top: 3%;">{{ item.strength }}人</text>
						</view>
					</view>
					<view :class="item.used ? 'tag' : 'info-tag'">{{ item.used ? '已开瓶' : '未开瓶' }}</view>
				</view>
				<text style="font-size: 26rpx; color: #313131; margin: 20rpx 60rpx">订单编号：{{ item.orderSn }}</text>
			</view>
		</view>
		<!-- <view class="footer">
			<button class="btn-footer" @click="importExcel">
				<image src="/static/msjf-picture/msjf-01.png" mode="scaleToFill"></image>
				<text class="text-left">导出Excel</text>
			</button>
			<button class="btn-footer" @click="queryPwd">
				<image src="/static/msjf-picture/msjf-02.png" mode="scaleToFill"></image>
				<text class="text-right">查询解锁密码</text>
			</button>
		</view> -->
	</view>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import headerVue from '@/pages/header/index.vue';
import { searchSnInfo } from '@/services/api';
import { baseURL } from '@/services/request';
import { onLoad } from '@dcloudio/uni-app';

let color = ref('#a27443');

let used = ref(false);

let queryRecord = ref();

let queryPwd = () => {
	uni.navigateTo({
		url: './queryPwd'
	});
};

let importExcel = () => {
	uni.navigateTo({
		url: './importExcel'
	});
};

let confirm = async (data: any) => {
	// MSJF-0000001
	if (data.value) {
		let res: any = await searchSnInfo({ code: data.value });
		if (res.data.errno == 0) {
			queryRecord.value = res.data.data;
			console.log(queryRecord.value, '查询记录');
		}
	}
};
</script>

<style lang="scss" scoped>
page {
	background-color: #f2f2f2;
}
.status_bar {
	height: var(--status-bar-height);
	width: 100%;
}
.record-container {
	.query-content {
		box-sizing: border-box;
		padding: 20rpx;
		.query-record {
			box-sizing: border-box;
			background-color: #fff;
			padding: 0 30rpx;
			.content {
				padding: 10rpx;
				width: 100%;
			}
		}

		.query-list {
			margin-top: 20rpx;
			padding: 10rpx 30rpx;
			box-sizing: border-box;
			border-radius: 10rpx;
			width: 100%;
			height: 200rpx;
			background-color: #fff;
			display: flex;
			justify-content: space-between;
			align-items: center;
			image {
				width: 160rpx;
				height: 160rpx;
				border-radius: 10px;
			}

			.record {
				box-sizing: border-box;
				height: 100%;
				padding: 9px 0;
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				align-content: space-between;
				font-size: 12px;
				.record-text {
					font-size: 15px;
					font-weight: 600;
					// margin-bottom: 20rpx;
				}
				.record-center {
					height: 20%;
					margin: 5% 0 6% 0;
				}
				.record-footer {
					display: flex;
					justify-content: space-between;
					.price {
						color: red;
						font-size: 16px;
					}
				}
			}
			.tag {
				align-self: flex-end;
				font-size: 14px;
				color: #fff;
				width: 120rpx;
				height: 50rpx;
				background-color: #172372;
				text-align: center;
				line-height: 50rpx;
				border-radius: 20rpx;
				margin-bottom: 16rpx;
			}
			.info-tag {
				align-self: flex-end;
				font-size: 14px;
				color: #fff;
				width: 120rpx;
				height: 50rpx;
				text-align: center;
				line-height: 50rpx;
				border-radius: 20rpx;
				margin-bottom: 16rpx;
				background-color: #7e7e7e;
			}
		}
	}

	.footer {
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 120rpx;
		display: flex;
		flex-direction: row;
		font-size: 14px;
		.btn-footer {
			position: relative;
			width: 50%;
			border: none;
			padding: 0;
			border-radius: 0;
			.text-left {
				position: absolute;
				top: 12%;
				left: 30%;
				color: #fff;
			}
			.text-right {
				position: absolute;
				top: 12%;
				right: 20%;
				color: #fff;
			}
		}
	}
}
</style>
