<template>
	<view class="main">
		<!-- 头部开始 -->
		<view class="header box">
			<view class="header-zuo">
				<u-avatar
					:src="photo?photo:'https://qufang.oss-cn-beijing.aliyuncs.com/upload/icon/xcx/zkgj/headPicture.png'"
					size="148"></u-avatar>
			</view>
			<view class="header-you">
				<view class="userName">
					{{name}}
				</view>
				<view class="mobile">{{mobile}}</view>
			</view>
		</view>
		<view class="settingGroup box">
			<navigator class="line" url="/pages/mine/messageList">
				<view class="title" style="width: 19%;">
					<image src="/static/images/studyhot.png" style="width: 36rpx;height: 36rpx;" mode=""></image>
					消息
				</view>
				<view class="right">
					<image src="/static/images/arrow.png" style="width: 18rpx;height: 32rpx;" mode=""></image>
				</view>
			</navigator>
			<navigator class="line" url="/pages/mine/Myprofile">
				<view class="title">
					<image src="/static/images/setting.png" style="width: 36rpx;height: 36rpx;" mode=""></image>
					个人资料
				</view>
				<view class="right">
					<image src="/static/images/arrow.png" style="width: 18rpx;height: 32rpx;" mode=""></image>
				</view>
			</navigator>

			<view class="line" @click="Changehepassword">
				<view class="title">
					<image src="/static/images/password.png" style="width: 36rpx;height: 36rpx;" mode=""></image>
					修改密码
				</view>
				<view class="right">
					<image src="/static/images/arrow.png" style="width: 18rpx;height: 32rpx;" mode=""></image>
				</view>
			</view>
			
			<view class="line" @click="phone">
				<view class="title">
					<image src="/static/images/Customer.png" style="width: 36rpx;height: 36rpx;" mode=""></image>
					联系客服
				</view>
				<view class="right">
					<image src="/static/images/arrow.png" style="width: 18rpx;height: 32rpx;" mode=""></image>
				</view>
			</view>
			<view class="line" @click="scan">
				<view class="title" style="width: 220rpx;">
					<image src="/static/images/reg.png" style="width: 36rpx;height: 36rpx;" mode=""></image>
					访客登记码
				</view>
				<view class="right">
					<image src="/static/images/arrow.png" style="width: 18rpx;height: 32rpx;" mode=""></image>
				</view>
			</view>
			
			<view class="loginout" @click="logout" style="border: none;">
				<view class="title">
					<!-- <image src="/static/images/exit.png" style="width: 36rpx;height: 36rpx;" mode=""></image> -->
					退出登录
				</view>
<!-- 				<view class="right">
					<image src="/static/images/arrow.png" style="width: 18rpx;height: 32rpx;" mode=""></image>
				</view> -->
			</view>

		</view>

		<!-- 底部导航栏 -->
		<u-tabbar :isBtnTop="false" :mid-button="true" activeColor="#1296db" inactiveColor="#999999" v-model="current" :list="tabbarList"></u-tabbar>
	</view>
</template>

<script>
	var app = getApp();
	var util = require("../../utils/util.js");
	var config = require("../../config");
	import tabbarList from '@/utils/tabbar.js'
	export default {
		data() {
			return {
				// tabbar配置项
				current: 0,
				tabbarList: tabbarList,
				//--- end --- tabbar配置项
				name: "",
				photo: "",
				mobile: "",
			};
		},
		onShow: function() {
			var userInfos = uni.getStorageSync('weapp_session_userInfo_data');
			this.name = userInfos.name,
				this.photo = userInfos.avatar,
				this.mobile = userInfos.username
		},
		methods: {
			//拨打电话
			phone() {
				wx.makePhoneCall({
					phoneNumber: '4008191707,8888' //仅为示例，并非真实的电话号码
				})
			},
			scan(){
				uni.navigateTo({
					url:"../mine/registerCode"
				})
			},
			//修改密码
			Changehepassword() {
				uni.navigateTo({
					url: '/pages/mine/Changehepassword'
				});
			},
			//退出
			logout() {
				uni.showModal({
					title: '提示',
					content: '确定要退出？',
					cancelColor: "#999999",
					showCancel: true,
					success(res) {
						if (res.confirm) {
							uni.request({
								url: config.service.logout,
								header: {
									'Authorization': 'Basic dGVzdDp0ZXN0',
									'content-type': 'application/x-www-form-urlencoded'
								},
								method: "DELETE",
								success: function(result) {
									var data = result.data; //console.log("登录信息", data);
									if (data.data == true) {
										// app.Closewebsocke()
										uni.clearStorageSync(); //清除缓存
										uni.showToast({
											icon: "none",
											title: "退出成功"
										})
										uni.reLaunch({
											url: '/pages/login/index'
										});
									}
								},
								// 响应错误
								fail: function(loginResponseError) {
									util.showNone("网络异常，请重试");
									return false;
								}
							});
						}
					}
				});
			}

		}
	};
</script>
<style lang="scss" scoped>
	.main {
		min-height: calc(100vh - var(--window-top));
		display: flex;
		flex-direction: column;
		background: #F8F8F8;
	}

	.header {
		padding: 81rpx 59rpx 91rpx;
		width: 100%;
		height: 326rpx;
		flex-shrink: 0;
		display: flex;
		align-items: center;
		background: url(data:image/png;base64,[encoded data, 93156 characters]) no-repeat;
		background-size: 100% 100%;
		
		.header-zuo {
			width: 148rpx;
			height: 148rpx;
		}

		.header-you {
			margin-left: 20rpx;

			.userName {
				margin-bottom: 23rpx;
				font-size: 36rpx;
				font-weight: 500;
				color: #fff;
			}

			.mobile {
				font-size: 30rpx;
				color: #fff;
			}
		}
	}

	.settingGroup {
		position: relative;
		margin-top: 30rpx;
		flex-grow: 1;
		display: flex;
		flex-direction: column;
		color: #333333;
		font-size: 30rpx;
		border-radius: 12rpx;
		box-shadow: 0px 0px 12px 0px rgba(224, 224, 224, 0.3);
		background-color: #fff;

		.line {
			height: 110rpx;
			border-bottom: 1rpx solid #EEEEEE;
			margin: 0 38rpx 0 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.title {
				display: flex;
				align-items: center;
				width: 190rpx;
				justify-content: space-between;
			}
		}
		
		.loginout {
			position: absolute;
			left: 40rpx;
			right: 40rpx;
			bottom: 50rpx;
			width: 670rpx;
			height: 92rpx;
			background: #F8F8F8;
			border-radius: 8rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>
