<template>
  <view class="mine-container" :style="{height: `${windowHeight}px`}">
    <!--顶部个人信息栏-->
    <view class="header-section">
      <view class="flex padding justify-between">
        <!-- 修改为横向排列 -->
        <view class="flex align-center"> 
          <view v-if="!avatar" class="cu-avatar xl round bg-white">
            <view class="iconfont icon-people text-gray icon"></view>
          </view>
          <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
          </image>
          <!-- 电话号码和个人信息部分 -->
          <view v-if="name || !name" class="user-info flex flex-column ml-2"> 
            <view v-if="!name" @click="handleToLogin" class="login-tip">
              点击登录
            </view>
            <view v-if="name" class="u_title">
              {{ 19030623072  }}
            </view>
            <view v-if="name" @click="handleToInfo" class="flex align-center mt-1"> 
              <text>个人信息</text>
              <view class="iconfont icon-right"></view>
            </view>
          </view>
        </view>
      </view>
    </view>

    <view class="content-section">
      <view class="mine-actions grid col-4 text-center">
        <view class="action-item" @click="handleBuilding">
          <view class="iconfont1 icon-rili text-green icon"></view>
          <text class="text">日历</text>
        </view>
        <view class="action-item" @click="handleBuilding">
          <view class="iconfont1 icon-wodexiazai text-blue icon"></view>
          <text class="text">我的下载</text>
        </view>
        <view class="action-item" @click="handleBuilding">
          <view class="iconfont1 icon-cuotiben text-blue icon"></view>
          <text class="text">错题本</text>
        </view>
        <view class="action-item" @click="handleBuilding">
          <view class="iconfont1 icon-chaojihuiyuan text-green icon"></view>
          <text class="text">超级会员</text>
        </view>
		<view class="action-item" @click="handleBuilding">
		  <view class="iconfont1 icon-dianpu text-blue icon"></view>
		  <text class="text">订阅店铺</text>
		</view>
      </view>

      <view class="menu-list">
        <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
          <view class="menu-item-box">
            <view class="iconfont1 icon-dianpuhoutai menu-icon"></view>
            <view>商家店铺后台</view>
          </view>
        </view>
        <view class="list-cell list-cell-arrow" @click="handleHelp">
          <view class="menu-item-box">
            <view class="iconfont1 icon-huishouzhan menu-icon"></view>
            <view>回收站</view>
          </view>
        </view>
        <view class="list-cell list-cell-arrow" @click="handleAbout">
          <view class="menu-item-box">
            <view class="iconfont1 icon-tongzhishezhi menu-icon"></view>
            <view>通知设置</view>
          </view>
        </view>
        <view class="list-cell list-cell-arrow" @click="handleToSetting">
          <view class="menu-item-box">
            <view class="iconfont1 icon-yijianfankui menu-icon"></view>
            <view>意见反馈</view>
          </view>
        </view>
		<view class="list-cell list-cell-arrow" @click="handleToSetting">
		  <view class="menu-item-box">
		    <view class="iconfont1 icon-zaixiankefu menu-icon"></view>
		    <view>在线客服</view>
		  </view>
		</view>
		<view class="list-cell list-cell-arrow" @click="handleToXiao">
		  <view class="menu-item-box">
		    <view class="iconfont1 icon-lejiexiaoetong menu-icon"></view>
		    <view>了解小鹅通</view>
		  </view>
		</view>
		<view class="list-cell list-cell-arrow" @click="handleToSetting">
		  <view class="menu-item-box">
		    <view class="iconfont1 icon-shezhi menu-icon"></view>
		    <view>设置</view>
		  </view>
		</view>
      </view>

    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        name: this.$store.state.user.name
      }
    },
    computed: {
      avatar() {
        return this.$store.state.user.avatar
      },
      windowHeight() {
        return uni.getSystemInfoSync().windowHeight - 50
      }
    },
    methods: {
      handleToInfo() {
        this.$tab.navigateTo('/pages/mine/info/index')
      },
      handleToEditInfo() {
        this.$tab.navigateTo('/pages/mine/info/edit')
      },
      handleToSetting() {
        this.$tab.navigateTo('/pages/mine/setting/index')
      },
      handleToLogin() {
        this.$tab.reLaunch('/pages/login')
      },
      handleToAvatar() {
        this.$tab.navigateTo('/pages/mine/avatar/index')
      },
      handleHelp() {
        this.$tab.navigateTo('/pages/mine/help/index')
      },
      handleAbout() {
        this.$tab.navigateTo('/pages/mine/about/index')
      },
      handleToXiao() {
        this.$tab.navigateTo('/pages/mine/xiao/index')
      },
      handleBuilding() {
        this.$modal.showToast('模块建设中~')
      }
    }
  }
</script>

<style lang="scss" scoped>

  @import '@/static/fontico/iconfont.css';
  page {
    background-color: #f5f6f7;
  }

  .mine-container {
    width: 100%;
    height: 100%;


    .header-section {
      padding: 15px 15px 45px 15px;
      background-color: #3c96f3;
      color: white;

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

      .cu-avatar {
        border: 2px solid #eaeaea;

        .icon {
          font-size: 40px;
        }
      }

      .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>

<style lang="scss" scoped>
  .user-info {
    display: flex;
    flex-direction: column; // 确保垂直排列
    justify-content: center; // 垂直居中
  }

  .u_title {
    // 可以根据需要调整字体样式
    font-size: 18px;
    line-height: 1.2; 
  }

  // 个人信息部分的样式
  .flex align-center.mt-1 {
    // 可以根据需要调整间距
    margin-top: 4px; 
  }
</style>
