<template>
  <view class="container">
    <!-- 用户信息 -->
    <view class="user-info">
		<view class="user-info-content">
			<image :src="avatar" ></image>
			<text class="username">{{nickName}}</text>
		</view>
    </view>

    <!-- 功能列表 -->
    <view class="menu">
      <view class="menu-item"  @click="showModal">
		  <view class="menu-item-left">
		  	<image class="arrow" src="/static/image/组 71696.png"></image>
		  	<text>关于我们</text>
		  </view>
		  <uni-icons type="right" class="menu-item-right"></uni-icons>
      </view>
	  
      <view class="menu-item" >

		<view class="menu-item-left">
		<image class="arrow" src="/static/image/路径 6112.png"></image>
        <text>联系客服</text>
		</view>
		<uni-icons type="right" class="menu-item-right"></uni-icons>
      </view>
	  
      <view class="menu-item" @click="logout">
		<view class="menu-item-left">
		<image class="arrow" src="/static/image/路径 6111.png"></image>
        <text>退出登录</text>
		</view>
		<uni-icons type="right" class="menu-item-right"></uni-icons>
      </view>
    </view>

 <mosowe-confirm-popup
    v-model="popupNoCancelShow"
  	title="用户协议"
  	confirmText
  	cancelText
  	>
    <text v-html="aboutUs"></text>
  	<template v-slot:footer>
  	<view class="mini_container">
  		<button class="mini-btn" type="primary" size="mini" @click="closeModal">取消</button>
  		<button class="mini-btn" type="primary" size="mini" @click="getConfirm">确认</button>
  	</view>
  	</template>
  </mosowe-confirm-popup>
  </view>
</template>

<script>
	import {logout,isToken} from  '@/api.uts'
export default {
	data() {
	  return {
		  avatar:'',
		  nickName:'',
		  aboutUs:'',
		  popupNoCancelShow:false,
	  }
	},
	mounted() {
		isToken();
		this.avatar = getApp().usrInfo.avatar;
		this.nickName = getApp().usrInfo.nickName;
		this.aboutUs = getApp().aboutUs;
	},
  methods: {
	  showModal() {
	  this.popupNoCancelShow = true ;
	  },
	  getConfirm(){
	  	this.popupNoCancelShow = false;
	  }, 
	  closeModal() {
      this.popupNoCancelShow = false ;
    },
  logout() {
	  uni.showModal({
	    title: '提示',
	    content: '确定要退出登录吗？',
	    success: (res) => {
	      if (res.confirm) {
			  logout().then((res)=>{
			  		 if(res.success){
			  			 uni.showToast({
			  			   title: '退出登录成功',
			  			   icon: 'success',
			  			   success: () => {
			  			     // 这里可以添加退出登录的逻辑，例如清除用户登录状态
			  			 	uni.clearStorageSync();
			  			     setTimeout(() => {
			  			       uni.navigateTo({ url: '/pages/index/login' });
			  			     }, 1500);
			  			   }
			  			 });
			  		 }
			  })
	       
	      }
	    }
	  });
  }
    }
};
</script>

<style>
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f5f5f5;
}

.user-info {
  padding: 1rem;
  height: 30%;
  background-color: #044f7a;
  color: #fff;
  display: flex;
  flex-direction: column;
  /* justify-content: space-between; */
   align-items: center;
}
.user-info-content{
	width: 40%;
	height: 70%;
	display: flex;
	align-items: center;
	margin-top: auto;
}
.user-info-content image{
	width: 70%;
	height: 70%;
	border-radius: 10%;
}
.user-info text{
		position: absolute;
		font-size: 1rem;
		bottom: 5%;
}


.menu {
  flex: 1;
  padding: 20px;
  background-color: #fff;
}

.menu-item {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid #eee;
}
.menu-item-left {
	display: flex;
	flex-direction: row;
	margin-right: auto;
}
.menu-item text {
  margin-left: 1rem;
  
  font-size: 16px;
}

.arrow {
  width: 20px;
  height: 20px;
}

.footer {
  display: flex;
  justify-content: space-around;
  padding: 10px;
  background-color: #fff;
  border-top: 1px solid #ccc;
}

.nav-item {
  text-align: center;
}

.nav-item text {
  font-size: 14px;
}

.mini_container{
	display: flex;
	flex-direction: row;
	align-items: center;
}

/* 按钮 */
.mini-btn{
	width: 30%;
	margin-left: 15%;
}
</style>