<template>
	<view class="container">
		<view class="user-info-box">
			<view class="detail flex">
				<view class="portrait-box"><image class="portrait" :src=" userInfo.avatar || '../../static/error/missing-face.png'"></image></view>
				<view class="info-box">
					<view class="username">{{userInfo.nickname||"游客"}}</view>
					<view class="font-size-sm">{{userInfo.mobile || ''}}</view>
				</view>
			</view>
			<view class="config iconfont"><text class="setting iconsetting" @click="navTo('/pages/set/userinfo')"></text></view>
		</view>
		<view class="vip-box" @click="navTo('/pages/user/upgrade')"><image src="../../static/img/vip.png" mode=""></image></view>

		<view class="tt">
			<view class="tt-box" @click="navTo('/pages/user/promotion')">
				<image src="../../static/img/tuiguang.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="navTo('/pages/user/team')">
				<image src="../../static/img/team.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="navTo('/pages/user/shareQrCode')">
				<image src="../../static/img/share.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="open()">
				<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>
		<uni-popup ref="popup" type="center">
			<view class="popup-box">
				<view class="img"><image src="../../static/img/img009.png" mode=""></image></view>
				<view class="mian">
					<view class="delivery">
						<view class="title">已经为您定制专属客服</view>
						<image src="../../static/img/img010.png" mode=""></image>
					</view>
					<view class="nocancel">客服电话: {{ text }}</view>
					<view class="comfirm-box">
						<view class="cancel" @click="cancel">取消</view>
						<view class="comfirm" @click="comfirm(text)">拨打电话</view>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
import uniPopup from '@/components/uni-popup/uni-popup.vue';
import uniCopy from '@/utils/uni-copy.js';

import { mapState, mapMutations } from 'vuex';
import { saveUrl, interceptor } from '@/utils/loginUtils.js';
import {  getUserInfo } from '@/api/user.js';
export default {
	data() {
		return {
			text:'123456789'
		};
	},
	computed:{
		...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
	},
	onShow() {
		//判断是否已经登录
		if (this.hasLogin) {
			this.loadBaseData();
		} else {
			uni.showModal({
				title: '登录',
				content: '您未登录，是否马上登陆?',
				success: e => {
					if (e.confirm) {
						interceptor();
					}
				},
				fail: e => {
					console.log(e);
				}
			});
		}
	},
	methods: {
		...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
		loadBaseData() {
			getUserInfo({})
				.then(({ data }) => {
					console.log(data,'UserInfo+++++++++++++++++')
					this.setUserInfo(data);
				})
				.catch(e => {
					console.log(e);
				});
		},
		navTo(url) {
			if (!this.hasLogin) {
				// 保存地址
				saveUrl();
				// 登录拦截
				interceptor();
			} else {
			uni.navigateTo({
				url
			});
			}
		},
		open() {
			console.log('点击出现弹窗');
			this.$refs.popup.open();
		},
		// 客服弹窗 - 取消
		cancel() {
			this.$refs.popup.close();
		}
	}
};
</script>

<style lang="scss">
page,
.container {
	background: #000;
	height: 100%;
}
.user-info-box {
	padding: 40rpx 46rpx 0;
	height: 180rpx;
	color: white;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: relative;
	z-index: 1;
	.detail {
		height: 130rpx;
		.portrait-box {
			height: 100%;
			.portrait {
				width: 130rpx;
				height: 100%;
				border: 5rpx solid #fff;
				border-radius: 50%;
			}
		}
		.info-box {
			margin-left: 20rpx;
			line-height: 1.5;
			.username {
				font-size: $font-lg + 6rpx;
				height: 100%;
			}
		}
	}
	.config {
		font-size: 48rpx;
	}
}
.vip-box {
	width: 690rpx;
	height: 200rpx;
	margin: 60rpx auto 0;
	image {
		width: 100%;
		height: 100%;
	}
}

.tt {
	margin: 0 auto;
	width: 750rpx;
	padding: 40rpx 70rpx;
	background-color: #000;

	.tt-box {
		padding: 20rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		border-bottom: 1px solid #838383;
		.tt-icon1 {
			width: 42rpx;
			height: 37rpx;
		}
		.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 {
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #ffffff;
			margin-left: 36rpx;
			color: #ffffff;
			flex: 1;
		}

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

	.border-b {
		border-bottom: 1px solid #f0f0f0;
	}
}
.popup-box {
	width: 522rpx;
	height: 605rpx;
	background-color: #ffffff;
	border-radius: 20rpx;
	position: relative;
	.img {
		position: relative;
		top: -56rpx;
		left: 0;
		width: 522rpx;
		height: 132rpx;
		display: flex;
		justify-content: center;
		image {
			border-radius: 20rpx 20rpx 0 0;
			width: 450rpx;
			height: 132rpx;
		}
	}

	.mian {
		margin-top: -44rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		// padding: 32rpx 32rpx;
		background-color: #ffffff;
		border-radius: 0 0 20rpx 20rpx;
		text-align: center;

		.delivery {
			font-size: 40rpx;
			color: #333333;
			display: flex;
			align-items: center;
			flex-direction: column;
			.title {
			}
			image {
				margin-top: 48rpx;
				width: 172rpx;
				height: 160rpx;
			}
		}

		.nocancel {
			font-size: 32rpx;
			color: #333333;
			margin-top: 14rpx;
		}

		.comfirm-box {
			margin-top: 52rpx;
			display: flex;
			// margin-bottom: 32rpx;

			// justify-content: space-around;
			.cancel {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 197rpx;
				height: 74rpx;
				border: 1px solid #dcc786;
				border-radius: 38rpx;

				font-size: 32rpx;
				color: #605128;
			}

			.comfirm {
				margin-left: 32rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				width: 197rpx;
				height: 74rpx;
				background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
				border-radius: 38px;
				font-size: 32rpx;
				color: #605128;
			}
		}
	}
}
</style>
