<template>
	<view class="main">
		<u-navbar title="我的" :is-back="false" :background="{background: 'none'}" :border-bottom="false" title-color="#333">	</u-navbar>
		<view class="header">
			<view class="header-zuo">
				<u-avatar
					:src="photo?photo:'/static/images/avatar.png'"
					size="128"></u-avatar>
			</view>
			<view class="header-you">
				<view class="userName u-line-2">
					{{name}}
				</view>
				<view class="mobile">{{mobile}}</view>
			</view>
		</view>
		<view class="settingGroup">
<!-- 			<navigator class="line" url="/pages/mine/messageList">
				<view class="title" style="width: 19%;">
					<image src="/static/images/studyhot.png"  mode=""></image>
					消息
				</view>
				<view class="right">
					<image src="/static/images/right-arrow.png"  mode=""></image>
				</view>
			</navigator> -->
			<navigator class="line" url="/pages/mine/Myprofile">
				<view class="title">
					<image src="/static/images/setting.png"  mode=""></image>
					个人资料
				</view>
				<view class="right">
					<image src="/static/images/right-arrow.png"  mode=""></image>
				</view>
			</navigator>

			<view class="line" @click="Changehepassword">
				<view class="title">
					<image src="/static/images/password.png"  mode=""></image>
					修改密码
				</view>
				<view class="right">
					<image src="/static/images/right-arrow.png"  mode=""></image>
				</view>
			</view>
			<view class="line" @click="phone">
				<view class="title">
					<image src="/static/images/concat.png"  mode=""></image>
					联系客服
				</view>
				<view class="right">
					<image src="/static/images/right-arrow.png"  mode=""></image>
				</view>
			</view>
			<!-- <view class="line" @click="help">
				<view class="title">
					<image src="/static/images/help-icon.png"  mode=""></image>
					帮助中心
				</view>
				<view class="right">
					<image src="/static/images/right-arrow.png"  mode=""></image>
				</view>
			</view> -->
<!-- 			<view class="line" @click="scan">
				<view class="title">
					<image src="/static/images/visitCode.png"  mode=""></image>
					访客登记码
				</view>
				<view class="right">
					<image src="/static/images/right-arrow.png"  mode=""></image>
				</view>
			</view> -->
			<view class="loginout" @click="logout" style="border: none;">
				<view class="title">
					退出登录
				</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"
				})
			},
			help(){
				uni.navigateTo({
					url:"../mine/help/index"
				})
			},
			//修改密码
			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 {
		width: 750rpx;
		height: 100vh;
		display: flex;
		flex-direction: column;
		background: url('https://static.quhouse.com/efadbd8a89f94e98b37eb59dc8074f83.png') no-repeat;
		background-size: 750rpx 600rpx;
	}
	.header {
		width: 670rpx;
		height: 248rpx;
		display: flex;
		align-items: center;
		background: url('https://static.quhouse.com/10fa8f6fe7fa4104a5c4149be4735311.png') no-repeat;
		background-size: 670rpx 248rpx;
		margin: 0 40rpx 60rpx;
		border-radius: 18rpx;
		box-shadow: 0 3rpx 10rpx #999;
		.header-zuo {
			width: 128rpx;
			height: 128rpx;
			margin-left: 40rpx;
		}

		.header-you {
			margin-left: 30rpx;
			.userName {
				margin-bottom: 20rpx;
				font-size: 36rpx;
				font-weight: 500;
				color: #fff;
				font-family: PingFangSC-Medium, PingFang SC;
			}

			.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;
		.line {
			height: 44rpx;
			margin: 0 50rpx 60rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.title {
				display: flex;
				align-items: center;
				width: 300rpx;
				height:44rpx;
				line-height: 44rpx;
				font-size: 32rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				image{
					width: 36rpx;
					height: 36rpx;
					margin-right: 20rpx;
				}
			}
			.right{
				image{
					width: 12rpx;
					height: 28rpx;
				}
			}
		}
		
		.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>
