<template>
	<view class="container">
		<view class="top">
			<view class="my">{{$t('home.d4')}}</view>
			<view class="userinfo flex">
				<view class="flex">
					<image class="image margin-r-10" src="../../static/error/missing-face.png" mode="scaleToFill">
					</image>
					<view class="info">
						<view class="infor margin-b-20">v790d7v...v469874561</view>
						<image class="in" src="../../static/shouye/huiyuan.png" mode="scaleToFill"></image>
					</view>
				</view>
				<image @click="showY" class="inf" src="../../static/shouye/userinfo.png" mode="scaleToFill"></image>
			</view>
		</view>
		<!-- 余额 -->
		<view class="body">
			<view v-if="show" class="yue">
				<view class="te">
					{{$t('user.c1')}}
				</view>
				<view class="tex">
					12356.00
				</view>
				<view class="btn flex">
					<button class="btn1" @click="navigator"> <text>{{$t('user.a7')}}</text> </button>
					<button class="btn1" @click="navigatorT"> <text>{{$t('user.a6')}}</text> </button>
				</view>
			</view>

			<view v-else class="yue1">
				<view class="tj">統計表</view>
				<view class="tj-item flex ">
					<view class="lj">{{$t('user.a4')}}{{$t('user.a7')}}</view>
					<view class="ljsu">0.000</view>
				</view>
				<view class="tj-item flex">
					<view class="lj">{{$t('user.a4')}}{{$t('user.a6')}}</view>
					<view class="ljsu">0.000</view>
				</view>
				<view class="tj-item flex">
					<view class="lj">{{$t('user.a8')}}</view>
					<view class="ljsu">0.000</view>
				</view>
				<view class="tj-item flex">
					<view class="lj">{{$t('user.a9')}}</view>
					<view class="ljsu">0.000</view>
				</view>
				<view class="tj-item flex">
					<view class="lj">{{$t('user.a10')}}</view>
					<view class="ljsu">0.000</view>
				</view>
			</view>

			<!-- 列表 -->
			<view class="gj">
				{{$t('user.b1')}}
			</view>

			<view class="user-list flex" @click="navTo('/pages/user/team')">
				<image src="../../static/shouye/yue.png" mode="scaleToFill" class="left-img"></image>
				<view class="item-name">
					{{$t('user.b2')}}
				</view>
				<image src="../../static/icon/back.png" mode="scaleToFill" class="right-img"></image>
			</view>
			<!-- 额外添加 -->
			<view class="user-list flex" @click="navTo('/pages/user/shareQrCode')">
				<image src="../../static/shouye/money.png" mode="scaleToFill" class="left-img"></image>
				<view class="item-name">
					{{$t('user.b3')}}
				</view>
				<image src="../../static/icon/back.png" mode="scaleToFill" class="right-img"></image>
			</view>
			<!-- 额外添加 -->
			<view class="user-list flex" @click="navTo('/pages/tabulation/tabulation')">
				<image src="../../static/shouye/liebiao.png" mode="scaleToFill" class="left-img"></image>
				<view class="item-name">
					{{$t('user.b4')}}
				</view>
				<image src="../../static/icon/back.png" mode="scaleToFill" class="right-img"></image>
			</view>
			<view class="user-list flex" @click="navTo('/pages/user/favorites')">
				<image src="../../static/shouye/liebiao.png" mode="scaleToFill" class="left-img"></image>
				<view class="item-name">
					{{$t('user.b5')}}
				</view>
				<image src="../../static/icon/back.png" mode="scaleToFill" class="right-img"></image>
			</view>
			<view class="user-list flex" @click="openKf()">
				<image src="../../static/shouye/liuyan.png" mode="scaleToFill" class="left-img"></image>
				<view class="item-name">
					{{$t('user.b6')}}
				</view>
				<image src="../../static/icon/back.png" mode="scaleToFill" class="right-img"></image>
			</view>
			<view class="user-list flex" @click="navTo('/pages/transaction/transaction')">
				<image src="../../static/shouye/jiaoyi.png" mode="scaleToFill" class="left-img"></image>
				<view class="item-name">
					{{$t('user.b7')}}
				</view>
				<image src="../../static/icon/back.png" mode="scaleToFill" class="right-img"></image>
			</view>
			<view class="user-list flex" @click="navTo('/pages/public/login')">
				<image src="../../static/shouye/tuichu.png" mode="scaleToFill" class="left-img"></image>
				<view class="item-name">
					{{$t('user.b8')}}
				</view>
				<image src="../../static/icon/back.png" mode="scaleToFill" class="right-img"></image>
			</view>
		</view>
		<taber tab='user'></taber>
	</view>
</template>
<script>
	import taber from "@/components/footer/footer.vue";
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import uniList from '@/components/uni-list/uni-list.vue';
	import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
	import {
		orderData,
		getUserInfo,
		// check,
		// getLevelList
	} from '@/api/user.js';
	import {
		saveUrl,
		interceptor
	} from '@/utils/loginUtils.js';
	let startY = 0,
		moveY = 0,
		pageAtTop = true;
	export default {

		components: {
			// uniList,
			// uniListItem,
			taber
		},
		data() {
			return {
				current: 2,
				store_name: '',
				achievement: '',
				code: '',
				levelList: [],
				show: true
			};
		},
		onShow() {
			// 判断是否已经登录
			// if (this.hasLogin) {
			// 	this.loadBaseData();
			// }
			this.loadBaseData();
		},
		filters: {
			phone(e) {
				var subStr1 = e.substr(0, 3);
				var subStr2 = e.substr(e.length - 4, 4);
				var subStr = subStr1 + '...' + subStr2;
				e = subStr;
				return e;
			}
		},
		onReady() {
			// 初始化获取页面宽度
			uni.createSelectorQuery()
				.select('.container')
				.fields({
						size: true
					},
					data => {
						// 计算最多下拉的高度
						this.userDowm = Math.floor((data.width / 750) * 185);
						// 计算最大触发修改高度事件
						this.userMaxDowm = Math.floor((data.width / 750) * 250);
					}
				)
				.exec();
		},
		computed: {
			...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
		},
		methods: {
			showY() {
				this.show = !this.show
			},
			navigatorT() {
				uni.navigateTo({
					url: '/pages/withdrawal/withdrawal'
				})
			},
			navigator() {
				uni.navigateTo({
					url: '/pages/recharge/recharge'
				})
			},

			// 加载初始数据
			loadBaseData() {
				const obj = this
				getUserInfo({})
					.then(({
						data
					}) => {
						obj.setUserInfo(data);

					})
					.catch(e => {
						console.log(e);
					});

			},
			/**
			 * 统一跳转接口,拦截未登录路由
			 * navigator标签现在默认没有转场动画，所以用view
			 */
			navTo(url) {
				console.log(url);
				if (!this.hasLogin) {
					// 保存地址
					saveUrl();
					// 登录拦截
					interceptor();
				} else {
					uni.navigateTo({
						url
					});
				}
			},
			close() {
				this.$refs.popuphx.close();
				this.code = '';
			},

			// 打开绑定
			open() {
				this.$refs.gspass.open();
			},
			cast() {
				set_waiter({
						uid: this.id
					})
					.then(e => {
						this.$api.msg('绑定成功');
						this.$refs.gspass.close();
						this.id = '';
					})
					.catch(err => {
						this.$refs.gspass.close();
						this.id = '';
					});
			},
			// cancelpass() {
			// 	this.$refs.gspass.close();
			// 	this.id = '';
			// }
		}
	};
</script>
<style lang="scss">
	.container {
		height: 100%;
		line-height: 1;
	}

	.top {
		height: 327rpx;
		background-color: #000000;
		padding: 0 45rpx;

		.my {
			padding-top: 40rpx;
			font-size: 48rpx;
			font-weight: 500;
			color: #FFFFFF;
		}

		.userinfo {
			padding-top: 40rpx;

			.image {
				width: 125rpx;
				height: 125rpx;
			}

			.info {
				.infor {
					font-size: 30rpx;
					font-weight: 500;
					color: #FFFFFF;
				}
			}
		}
	}



	.in {
		width: 128rpx;
		height: 45rpx;
	}

	.inf {
		margin-top: 25rpx;
		width: 48rpx;
		height: 48rpx;
	}

	//  body
	.body {
		background-color: #191a1f;
		padding: 30rpx;
		border-top-right-radius: 60rpx;
		border-top-left-radius: 60rpx;
		color: #FFFFFF;
		.yue {
			border-radius: 60rpx;
			background-color: #000000;
			text-align: center;
			padding-top: 40rpx;
			padding-bottom: 35rpx;
			.te {
				font-size: 26rpx;
				font-weight: 500;
				padding-bottom: 30rpx;
			}
			
			.tex {
				font-size: 48rpx;
				font-weight: bold;
				padding-bottom: 50rpx;
			}
			
			.btn1 {
				min-width: 270rpx;
				background: #FDB242;
				border-radius: 10rpx;
				font-size: $font-base;
			}
		}
		
		.yue1 {
			background-color: #000000;
			padding: 30rpx;
			color: #FFFFFF;
			border-radius: 60rpx;
			.tj {
				font-size: 30rpx;
				font-weight: bold;
				text-align: center;
			}
			.tj-item{
				padding-top: 26rpx;
				font-size: 24rpx;
				opacity: 0.65;
			}
		}
	}

	.gj {
		margin-top: 50rpx;
		margin-left: 20rpx;
		font-size: 36rpx;
		font-weight: bold;
		color: #FFFFFF;
		padding-bottom: 10rpx;
	}

	.user-list {
		background: #191a1f;
		box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
		margin: 0 auto;
		padding: 30rpx 25rpx;
		border-bottom: 1px solid rgba(240, 240, 240, 0.2);
		
		.left-img {
			width: 40rpx;
			height: 40rpx;
			margin-right: 20rpx;
		}

		.item-name {
			flex-grow: 1;
			font-size: 29rpx;
			font-weight: bold;
			color: #FFF;
		}

		.right-img {
			width: 18rpx;
			height: 27rpx;
		}
	}

</style>