<template>
	<view class="content">
		<view class="header-box">
			<view class="status_bar"></view>
			<view class="title"><text>管配件，就用</text>修配一码通</view>
		</view>
		<view class="body-box">
			<!-- 滚动区域 -->
			<view class="scroll-list">
				<scrollBox :list="list"></scrollBox>
			</view>
			<!-- 保证金 -->
			<view class="notices flex align_center" v-if="bondRecord" @click="toPayBondAmount">
				<view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有一笔保证金待支付 ￥{{bondRecord.bondAmount}}</view> <text>立即支付>></text>
			</view>
			<!-- 名片 -->
			<view class="userCard flex align_center justify_between" @click="toUser">
				<view class="userCard-info flex align_center justify_between">
					<view>
						<u-image v-if="!hasLogin" src="/static/def_personal_avatar.png" width="60" height="60"></u-image>
						<open-data v-else type="userAvatarUrl" class="user-photo"></open-data>
					</view>
					<view>
						<view v-if="!hasLogin" style="font-size: 40rpx;">
							请点击登录/注册
						</view>
						<view v-else>
							<view>王杰</view>
							<view>宇博极速汽车维修养护中心</view>
						</view>
					</view>
				</view>
				<view>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<!-- 扫描按钮 -->
			<view class="scanButton flex align_center" @click="openCamera">
				<u-icon name="scan" size="40"></u-icon><text class="ml10">扫描VIN</text>
			</view>
			<!-- 扫描记录 -->
			<u-cell-group :border="false">
				<u-cell-item title="扫描记录" @click="toAllRecord" :title-style="{fontSize:'1.1em'}" value="查看全部">
					<u-icon slot="icon" size="38" color="#00aaff" style="margin-right: 0.3em;" name="order"></u-icon>
				</u-cell-item>
			</u-cell-group>
		</view>
		<!-- 扫描记录 -->
		<view class="list-box">
			<u-cell-group :border="false">
				<u-cell-item v-for="item in 10" title="LBVNU79049SB81489" :title-style="{fontSize:'1em'}" value="宝马 54646d">
					<text slot="icon"></text>
				</u-cell-item>
			</u-cell-group>
			<view class="des">仅展示最近10条记录，点击“全部”查看更多</view>
		</view>
	</view>
</template>

<script>
	import {
	    mapState,
	    mapMutations
	} from 'vuex'
	import scrollBox from '@/components/scrollBox.vue'
	import { shelfBondRecordWaitPayRecord, findStoreShelf } from '@/api/shelf.js'
	export default {
		components: {
			scrollBox
		},
		data() {
			return {
				bondRecord: null, // 保证金
				list:[
				{
					userName: '一部'
				},
				{
					userName: '夏利我'
				},
				{
					userName: '离散'
				},
				{
					userName: '网络'
				},
				{
					userName: '撒打发'
				},
				{
					userName: 'ipho23'
				}
			]
			}
		},
		computed: {
			...mapState(['hasLogin']),
			hasShelf(){
				return this.$store.state.vuex_storeShelf
			}
		},
		onLoad() {
			this.getStoreShelf()
		},
		methods: {
			// 查询是否支持数字货架
			getStoreShelf(){
				findStoreShelf().then(res => {
						console.log(res)
						this.$store.state.vuex_storeShelf = res.data;
						if(res.data){
							// 保证金查询
							this.getShelfBWPayRecord()
						}
				})
			},
			// 获取保证金金额
			getShelfBWPayRecord(){
				const data = this.$store.state.vuex_storeShelf
				shelfBondRecordWaitPayRecord({shelfSn: data.shelfSn, storeSn: data.storeSn}).then(res => {
					console.log(res,'获取保证金金额')
					this.bondRecord = res.data
				})
			},
			// 保证金支付
			toPayBondAmount(){
				 
			},
			// 去扫描
			openCamera(){
				uni.navigateTo({
					url: "/pages/scan-frame/scan-frame"
				})
			},
			// 查看扫描记录
			toAllRecord(){
				uni.navigateTo({
					url: "/pages/vinRecord/vinRecord"
				})
			},
			toUser(){
				uni.navigateTo({
					url: this.hasLogin ? '/pages/personData/personData' : '/pages/login/login'
				})
			}
		}
	}
</script>

<style lang="less">
	.content {
		margin: 0;
		padding: 0;
		height: 100vh;
		display: flex;
		flex-direction: column;
		background-image: linear-gradient(#86defa 0%,#cdeff9 25%,#ffffff 40%);
		.header-box{
			padding: 0.3em 1em;
			.status_bar {
				height: var(--status-bar-height);
				width: 100%;
			 }
			 .title{
				 padding-top: 0.4em;
				 font-size: 1.5em;
				 color: #000;
				 text{
					 color: #0077fd;
				 }
			 }
		}
		.body-box{
			flex-grow: 1;
			padding: 0.5em 1em;
			.notices{
				padding: 0.5em 0 0;
				view{
					color: #f2a557;
				}
				text{
					color: #0077fd;
					margin-left: 1em;
				}
			}
			.userCard{
				margin-top: 0.8em;
				padding:0.8em;
				background: #fff;
				border-radius: 1em;
				box-shadow: 0.2em 0.3em 0.8em #cdeff9;
				.userCard-info{
					> view{
						&:last-child{
							margin-left: 0.5em;
							>view{
								padding: 0.2em;
							}
						}
					}
				}
				.user-photo{
					display: block;
					width: 120rpx;
					height: 120rpx;
					border-radius: 50%;
					overflow: hidden;
				}
			}
			.scanButton{
				margin: 0.6em 0;
				padding: 0.5em;
				background: #1283d4;
				color: #fff;
				font-size: 1.5em;
				border-radius: 5em;
				justify-content: center;
				&:active{
					opacity: 0.8;
				}
			}
			.ml10{
				margin-left: 0.2em;
			}
		}
		.list-box{
			padding: 0 1em;
			overflow: auto;
			.des{
				text-align: center;
				padding: 1em 0;
				color: #999;
				font-size: 0.8em;
			}
		}
	}
</style>
