<template>
	<view class="container">
		<view class="top">
			<view class="bg"><image class="imgBg" src="../../static/img/user-bg.png" mode=""></image></view>
			<view class="user">
				<view class="avtor"><image class="portrait" :src="userInfo.avatar || '/static/img/missing-face.png'"></image></view>
				<view class="name">{{ userInfo.nickname || '游客' }}</view>
			</view>
		</view>
		<view class="main">
			<view class="title">我的工具</view>
			<view class="tt">
				<view class="tt-box" @click="nav('/pages/assets/myPing')">
					<image src="../../static/img/pinggou.png" class="tt-icon1" mode=""></image>
					<view class="tt-txt">我的拼购</view>
					<image src="../../static/img/jiantou.png" class="next-icon" mode=""></image>
				</view>
				<view class="tt-box" @click="nav('/pages/user/extension')">
					<image src="../../static/img/myTeam.png" class="tt-icon2" mode=""></image>
					<view class="tt-txt">我的团队</view>
					<image src="../../static/img/jiantou.png" class="next-icon" mode=""></image>
				</view>
				<view class="tt-box" @click="nav('/pages/user/shareQrCode')">
					<image src="../../static/img/share.png" class="tt-icon3" mode=""></image>
					<view class="tt-txt">团队邀请</view>
					<image src="../../static/img/jiantou.png" class="next-icon" mode=""></image>
				</view>
				<view class="tt-box" @click="nav('/pages/money/payment')">
					<image src="../../static/img/zfpwd.png" class="tt-icon4" mode=""></image>
					<view class="tt-txt">支付密码</view>
					<image src="../../static/img/jiantou.png" class="next-icon" mode=""></image>
				</view>
				<view class="tt-box" @click="nav('/pages/public/forget')">
					<image src="../../static/img/pwd.png" class="tt-icon1" mode=""></image>
					<view class="tt-txt">登录密码</view>
					<image src="../../static/img/jiantou.png" class="next-icon" mode=""></image>
				</view>
				<view class="tt-box" @click="server()">
					<image src="../../static/img/kefu.png" class="tt-icon1" mode=""></image>
					<view class="tt-txt">联系客服</view>
					<image src="../../static/img/jiantou.png" class="next-icon" mode=""></image>
				</view>
				<view class="tt-box" @click="nav('/pages/set/userinfo')">
					<image src="../../static/img/set.png" class="tt-icon5" mode=""></image>
					<view class="tt-txt">设置</view>
					<image src="../../static/img/jiantou.png" class="next-icon" mode=""></image>
				</view>
			</view>
		</view>
		
		<uni-popup ref="popup" type="center">
			<view class="popup">
				<view class="popup-dox">
					<image class="popup-logo" src="../../static/img/lianxi.png"></image>
					<view class="pop-title">已为您定制专属客服</view>
					<image class="popup-text" src=""></image>
					<view class="pop-tip flex"><view class="weixin"><image src="../../static/img/weixin.png" mode=""></image></view><view>长按识别咨询客服</view></view>
				</view>
			</view>
			<view class="close_icon" @click="close"><image src="../../static/img/Close.png"></image></view>
		</uni-popup>
	</view>
</template>
<script>
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 } from '@/api/user.js';
import { saveUrl, interceptor } from '@/utils/loginUtils.js';
import uniPopup from '@/components/uni-popup/uni-popup.vue';
export default {
	components: {
		uniList,
		uniListItem,
		uniPopup
	},
	data() {
		return {};
	},
	onShow() {
		//判断是否已经登录
		if (this.hasLogin) {
			this.loadBaseData();
		}else{
			uni.showModal({
				title: '登录',
				content: '您未登录,是否马上登陆?',
				success: e => {
					if (e.confirm) {
						interceptor();
					}
				},
				fail: e => {
					console.log(e);
				}
			});
		}
	},
	computed: {
		...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
	},
	methods: {
		...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
		loadBaseData() {
			getUserInfo({}).then(({
				data
			}) => {
				this.setUserInfo(data);
			});
		},
		server(){
			this.$refs.popup.open();
		},
		close(){
			this.$refs.popup.close();
		},
		nav(url) {
			// 判断是否已经登录
			// if (this.hasLogin) {
				console.log(url)
				uni.navigateTo({
					url: url,
					fail() {
						uni.switchTab({
							url:url
						})
					}
				})
			// }else {
			// 	uni.showModal({
			// 		title: '登录',
			// 		content: '您未登录,是否马上登陆?',
			// 		success: e => {
			// 			if (e.confirm) {
			// 				interceptor();
			// 			}
			// 		},
			// 		fail: e => {{}
			// 			console.log(e);
			// 		}
			// 	});
			// }

		}
	}
};
</script>
<style lang="scss">
page {
	height: 100%;
	background: #ffffff;
}
.container {
	height: 100%;
	background: #ffffff;
}
.top {
	width: 100%;
	height: 320rpx;
	position: relative;
	.bg {
		position: absolute;
		width: 100%;
		height: 320rpx;
		left: 0;
		top: 0;
		right: 0;
		image {
			width: 100%;
			height: 100%;
		}
	}
	.user {
		position: relative;
		padding-top: 98rpx;
		padding-left: 34rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		z-index: 10;
		.avtor {
			width: 102rpx;
			height: 102rpx;
			border-radius: 50%;
			.portrait {
				width: 100%;
				height: 100%;
				border-radius: 50%;
			}
		}
		.name {
			margin-left: 30rpx;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #ffffff;
		}
	}
}
.main {
	position: relative;
	z-index: 11;
	width: 100%;
	height: 100%;
	background: #ffffff;
	margin-top: -70rpx;
	border-top-left-radius: 60rpx;
	border-top-right-radius: 60rpx;
	.title {
		padding-top: 65rpx;
		padding-left: 36rpx;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;
	}
	.tt {
		margin: 0 auto;
		width: 750rpx;
		padding: 40rpx 70rpx;
		border-radius: 10rpx;
		background-color: #ffffff;

		.tt-box {
			height: 100rpx;
			display: flex;
			align-items: center;
			border-bottom: 1px solid #f0f0f0;
			.tt-icon1 {
				width: 42rpx;
				height: 42rpx;
			}
			.tt-icon2 {
				width: 49rpx;
				height: 38rpx;
			}
			.tt-icon3 {
				width: 46rpx;
				height: 40rpx;
			}
			.tt-icon4 {
				width: 40rpx;
				height: 42rpx;
			}
			.tt-icon5 {
				width: 44rpx;
				height: 40rpx;
			}

			.tt-txt {
				margin-left: 36rpx;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
				flex: 1;
			}

			.next-icon {
				width: 16rpx;
				height: 25rpx;
			}
		}

		.border-b {
			border-bottom: 1px solid #f1f1f1;
		}
	}
}
.popup {
	width: 640rpx;
	background-color: #FFFFFF;
	border-radius: 15rpx;
	text-align: center;
	.popup-dox{
		position: relative;
		top: -60rpx;
		.popup-logo {
			width: 460rpx;
			height: 132rpx;
		}
		.pop-title{
			font-size: 40rpx;
			font-weight: bold;
			color: #333333;
			padding: 25rpx 0rpx;
			margin-bottom: 50rpx;
		}
		.popup-text{
			width: 400rpx;
			height: 400rpx;
			margin-bottom: 50rpx;
		}
		.pop-tip{
			font-size: 30rpx;
			font-weight: 500;
			color: #333333;
			justify-content: center;
			
			.weixin {
				width: 48rpx;
				height: 40rpx;
				margin-right: 14rpx;
				image{
					width: 48rpx;
					height: 40rpx;
				}
			}
		}
	}
}
.close_icon {
	width: 60rpx;
	height: 60rpx;
	margin: 88rpx auto 0;
	image {
		width: 100%;
		height: 100%;
	}
}
</style>