<template>
	<view class="user">
		<view class="user-base-info">
			<img src="../../static/usercenter/user-top-bg.png" alt="" style="width: 100%;"/>
			<view class="box">
				<view class="user-base-info-top">
					<!-- 一般是凤尾鱼 -->
				</view>
				<view class="user-base-body">
					<img src="../../static/usercenter/user-pic@3x.png" alt="" />
					<view class="user-info">
						<view class="user-name">
							{{ userInfo.account }} 
						</view>
						<view class="user-name">
							code：{{ userInfo.invitationCode}}
						</view>
						<view class="vip">
							vip
						</view>
						
					</view>
				</view>
			</view>
		</view>
		<view class="account-info">
			<u-row customStyle="margin-bottom: 10px">
				<u-col span="5" @click="toBalance">
					<view>
						{{ $t('page.user.balance') + " " + userInfo.money || 0 }}
					</view>
					<view>
						<!-- 证券 -->
					</view>
				</u-col>
				<u-col span="3.5" @click="toBalance">
					<image class="purse-img" src="../../static/usercenter/purse 1024@3x.png"></image>
					<view>{{ $t('page.user.purse') }}</view>
				</u-col>
				<u-col span="3.5" @click="toBankCard">
					<image class="card-img" src="../../static/usercenter/card@3x.png"></image>
					<view>{{ $t('page.user.cardCase') }}</view>
				</u-col>
			</u-row>
		</view>
		<view class="speedy">
		<!-- 	<view class="speedy-top">
				<text>Bon hàng cùa tói</text>
				<view class="more">
					Xem thèm don hàng
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view> -->
			<view class="speedy-list">
				<view class="speedy-item">
					<view @click="toOrder(0)" class="feature">
						<image src="../../static/usercenter/recharge@3x.png" mode="aspectFit"></image>
						<text>{{ $t('page.user.pendingPayment') }}</text>
					</view>
					<view @click="toOrder(1)" class="feature">
						<image src="../../static/usercenter/withdraw@3x.png" mode="aspectFit"></image>
						<text>{{ $t('page.user.pendingShipment') }}</text>
					</view>
					<view @click="toOrder(2)" class="feature">
						<image src="../../static/usercenter/Delivery-address@3x.png" mode="aspectFit"></image>
						<text>{{ $t('page.user.pendingReceipt') }}</text>
					</view>
					<view @click="toOrder(3)" class="feature">
						<image src="../../static/usercenter/Recharge- record@3x.png" mode="aspectFit"></image>
						<text>{{ $t('page.user.completed') }}</text>
					</view>
				</view>
				<view class="speedy-item">
					<view class="feature" @click="toCollect">
						<image src="../../static/usercenter/Collect@3x.png" mode="aspectFit"></image>
						<text>{{ $t('page.user.collect') }}</text>
					</view>
					<view class="feature" @click="toAddress">
						<image src="../../static/usercenter/address@3x.png" mode="aspectFit"></image>
						<text>{{ $t('page.user.address') }}</text>
					</view>
					<view class="feature" @click="toAuth">
						<image src="../../static/usercenter/standing@3x.png" mode="aspectFit"></image>
						<text>{{ $t('page.user.standing') }}</text>
					</view>
					<view class="feature" @click="toSetting">
						<image src="../../static/usercenter/Settings@3x.png" mode="aspectFit"></image>
						<text>{{ $t('page.user.settings') }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo : {
					account : localStorage.getItem('account'),
					money : localStorage.getItem('money'),invitationCode:localStorage.getItem('invitationCode'),
				}
			}
		},
		onShow(){
			this.userInfo = {
				account : localStorage.getItem('account'),
				money : localStorage.getItem('money'),
				invitationCode:localStorage.getItem('invitationCode'),
				
			}
			this.getInfo()
		},
		methods: {
			getInfo(){
				this.request('getInfo')
				.then(res => {
					if(res.code == 200){
						localStorage.setItem('uid', res.result.id)
						localStorage.setItem('money', res.result.money  || 0)
						localStorage.setItem('account', res.result.account)
						localStorage.setItem('invitationCode',res.result.invitationCode)
					}
				})
			},
			toBalance(){
				uni.navigateTo({
					url : '/pages/balance/balance'
				})
			},
			toAddress(){
				uni.navigateTo({
					url : '/pages/user/address/address'
				})
			},
			toCollect(){
				uni.reLaunch({
					url : '/pages/collect/collect'
				})
			},
			toAuth(){
				uni.navigateTo({
					url : '/pages/user/IdentityAuthentication/IdentityAuthentication'
				})
			},
			toOrder(id){
				localStorage.setItem('orderIndex', id)
				uni.switchTab({
					url : '/pages/order/order'
				})
			},
			toBankCard(){
				uni.navigateTo({
					url : '/pages/user/bankCart/bankCart'
				})
			},
			toSetting(){
				uni.navigateTo({
					url : '/pages/setting/setting'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user {
		.user-base-info {
			position: relative;
			background: white;
			img{
				vertical-align: middle;
			}
			.box{
				height: 100%;
				width: 100%;
				position: absolute;
				left: 0;
				top: 0;
				.user-base-info-top {
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 16px;
					height: 30%;
					color: #F3F3F3;
					font-size: 30rpx;
				}
				
				.user-base-body {
					box-sizing: border-box;
					padding: 0px 15px;
					display: flex;
					align-items: flex-start;
					height: 70%;
				
					img {
						width: 70px;
						height: 70px;
						margin-right: 20px;
					}
				
					.user-info {
						.user-name {
							color: #F3F3F3;
							font-size: 14px;
						}
				
						.vip {
							background: #FCCC92;
							height: 20px;
							line-height: 20px;
							width: 46px;
							border-radius: 10px;
							text-align: center;
							color: #FA6239;
							margin-top: 10px;
						}
					}
				}
			}
		}
		.account-info{
			height: 100px;
			background: white;
			font-size: 25rpx;
			.u-row{
				box-sizing: border-box;
				display: flex;
				align-items: center;
				height: 100%;
				.u-col{
					display: flex;
					height: 71px;
					align-items: center !important;
					justify-content: center !important;
					border-right: 2px solid #ccc;
					&:nth-child(3n){
						border-right: none;
					}
					image{
						width: 35px;
						height: 35px;
					}
				}
			}
		}
		.speedy{
			box-sizing: border-box;
			margin-top: 20px;
			.speedy-top{
				display: flex;
				height: 60px;
				background: white;
				align-items: center;
				justify-content: space-between;
				padding: 0px 15px;
				.more{
					display: flex;
				}
			}
			.speedy-list{
				.speedy-item{
					display: flex;
					flex-wrap: wrap;
					justify-content: center;
					margin-bottom: 15px;
					background: white;
					padding: 15px 15px;
					font-size: 25rpx;
					.feature{
						flex:1;
						text-align: center;
						image{
							width: 35px;
							height: 35px;
						}
						text{
							display: block;
						}
					}
				}
			}
		}
	}
</style>