<template>
  <view class="mine-container">
    <!--顶部个人信息栏-->
    <view class="header-section">
      <view class="header-box">
        <view class="header-info">
          <view v-if="!userName" class="cu-avatar">
            <image :src="userAvatar" mode="widthFix"></image>
          </view>
          <image v-else :src="userAvatar" class="cu-avatar" mode="widthFix"></image>
          <view v-if="!userName" class="login-tip">
            点击登录
          </view>
          <view v-else @click="handleToInfo" class="user-info">
            <view class="u_title">
              用户名：{{ userName }}
            </view>
          </view>
        </view>
        <view @click="handleToInfo" class="header-info">
          <text>个人信息</text>
          <uv-icon name="arrow-right" color="#FFFFFF"></uv-icon>
        </view>
      </view>
    </view>


    <uv-list>
      <uv-list-item title="关于我们" border></uv-list-item>
      <uv-list-item title="退出登录" border></uv-list-item>
    </uv-list>
  </view>
</template>

<script setup>
import { computed, onMounted, ref } from 'vue'
import userAvatar from "@/static/tabbar/mine.png"


// 从store获取用户信息
const userName = ref("")


const handleLogout = () => {
  uni.showModal({
    title: '提示',
    content: '确定注销并退出系统吗？',
    success: (res) => {
      if (res.confirm) {
        store.dispatch('LogOut').then(() => {
          uni.reLaunch({ url: '/pages/index' })
        })
      }
    }
  })
}

</script>

<style scoped lang="scss">
page {
  background-color: #f5f6f7;
}


.header-section {
  padding: 30rpx 30rpx 90px 30rpx;
  background-color: #199793;
  color: white;
  
  .header-box {
    padding: 30rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .header-info {
      display: flex;
      align-items: center;
    }
  }

  .login-tip {
    font-size: 18px;
    margin-left: 10px;
  }

  .cu-avatar {
    width: 128rpx;
    height: 128rpx;
    border-radius: 50%;
    background-color: #FFFFFF;

    image {
      width: 98rpx;
      height: 98rpx;
      margin: 15rpx;
    }
  }

  .user-info {
    margin-left: 15px;

    .u_title {
      font-size: 18px;
      line-height: 30px;
    }
  }
}

.content-section {
  position: relative;
  top: -50px;

  .mine-actions {
    margin: 15px 15px;
    padding: 20px 0px;
    border-radius: 8px;
    background-color: white;

    .action-item {
      .icon {
        font-size: 28px;
      }

      .text {
        display: block;
        font-size: 13px;
        margin: 8px 0px;
      }
    }
  }
}
</style>  