<template>
  <view class="my-container">
    <!-- 用户信息区域 -->
    <view class="user-info">
      <view class="avatar-wrap">
        <image class="avatar" :src="userInfo.avatarUrl || '/static/default-avatar.png'" mode="aspectFill" />
      </view>
      <view class="info-content">
        <text class="nickname">{{ userInfo.nickName || '未登录' }}</text>
        <text class="phone">{{ userInfo.phone || '点击登录' }}</text>
      </view>
    </view>

    <!-- 押金卡片 -->
    <view class="balance-card" @click="navigateTo('/pages/deposit/index')">
      <view class="balance-content">
        <text class="label">押金余额</text>
        <text class="amount">¥{{ deposit }}</text>
      </view>
      <view class="withdraw-btn">
        提现
        <view class="arrow"></view>
      </view>
    </view>

    <!-- 功能模块 -->
    <view class="function-list">
      <!-- 订单 -->
      <view class="function-item" @click="navigateTo('/pages/order/index')">
        <view class="item-left">
          <view class="icon-wrap order">
            <view class="icon-placeholder"></view>
          </view>
          <text class="title">租借记录</text>
        </view>
        <view class="arrow"></view>
      </view>

      <!-- 押金 -->
      <view class="function-item" @click="navigateTo('/pages/deposit/index')">
        <view class="item-left">
          <view class="icon-wrap deposit">
            <view class="icon-placeholder"></view>
          </view>
          <text class="title">押金管理</text>
        </view>
        <view class="arrow"></view>
      </view>

      <!-- 投诉建议 -->
      <view class="function-item" @click="navigateTo('/pages/feedback/index')">
        <view class="item-left">
          <view class="icon-wrap feedback">
            <view class="icon-placeholder"></view>
          </view>
          <text class="title">投诉与建议</text>
        </view>
        <view class="arrow"></view>
      </view>

      <!-- 帮助中心 -->
      <view class="function-item" @click="navigateTo('/pages/help/index')">
        <view class="item-left">
          <view class="icon-wrap help">
            <view class="icon-placeholder"></view>
          </view>
          <text class="title">帮助中心</text>
        </view>
        <view class="arrow"></view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      userInfo: {},
      deposit: '0.00'
    }
  },
  onShow() {
    this.getUserInfo()
  },
  methods: {
    getUserInfo() {
      const userInfo = uni.getStorageSync('userInfo')
      if (userInfo) {
        this.userInfo = userInfo
      }
    },
    navigateTo(url) {
      uni.navigateTo({ url })
    }
  }
}
</script>

<style lang="scss" scoped>
.my-container {
  min-height: 100vh;
  background: #f8f8f8;
  padding-bottom: 40rpx;

  .user-info {
    background: linear-gradient(135deg, #1976D2, #64B5F6);
    padding: 40rpx 30rpx;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;

    &::after {
      content: '';
      position: absolute;
      right: -20%;
      bottom: -30%;
      width: 400rpx;
      height: 400rpx;
      background: rgba(255,255,255,0.1);
      border-radius: 50%;
    }

    .avatar-wrap {
      width: 120rpx;
      height: 120rpx;
      border-radius: 60rpx;
      overflow: hidden;
      background: #fff;
      margin-right: 30rpx;
      border: 4rpx solid rgba(255,255,255,0.3);
      
      .avatar {
        width: 100%;
        height: 100%;
      }
    }

    .info-content {
      color: #fff;
      position: relative;
      z-index: 1;

      .nickname {
        font-size: 36rpx;
        font-weight: 500;
        margin-bottom: 10rpx;
        display: block;
      }

      .phone {
        font-size: 28rpx;
        opacity: 0.9;
      }
    }
  }

  .balance-card {
    margin: 20rpx 30rpx;
    background: #fff;
    border-radius: 20rpx;
    padding: 30rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;

    &::after {
      content: '';
      position: absolute;
      right: 0;
      top: 0;
      width: 200rpx;
      height: 200rpx;
      background: linear-gradient(135deg, transparent, rgba(25,118,210,0.1));
      border-radius: 0 0 0 200rpx;
    }

    .balance-content {
      .label {
        font-size: 28rpx;
        color: #666;
        margin-bottom: 10rpx;
        display: block;
      }

      .amount {
        font-size: 48rpx;
        color: #1976D2;
        font-weight: bold;
      }
    }

    .withdraw-btn {
      padding: 16rpx 32rpx;
      background: #1976D2;
      color: #fff;
      border-radius: 30rpx;
      font-size: 28rpx;
      display: flex;
      align-items: center;
      
      .arrow {
        width: 12rpx;
        height: 12rpx;
        border-top: 3rpx solid #fff;
        border-right: 3rpx solid #fff;
        transform: rotate(45deg);
        margin-left: 8rpx;
      }
    }
  }

  .function-list {
    margin: 30rpx;
    background: #fff;
    border-radius: 20rpx;
    padding: 0 20rpx;
    box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);

    .function-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 30rpx 10rpx;
      border-bottom: 1rpx solid #f5f5f5;
      transition: all 0.3s;

      &:active {
        background: #f9f9f9;
      }

      &:last-child {
        border-bottom: none;
      }

      .item-left {
        display: flex;
        align-items: center;

        .icon-wrap {
          width: 80rpx;
          height: 80rpx;
          border-radius: 16rpx;
          margin-right: 20rpx;
          display: flex;
          align-items: center;
          justify-content: center;

          &.order {
            background: #E3F2FD;
            color: #1976D2;
          }

          &.deposit {
            background: #FFF3E0;
            color: #FF9800;
          }

          &.feedback {
            background: #E8F5E9;
            color: #4CAF50;
          }

          &.help {
            background: #F3E5F5;
            color: #9C27B0;
          }

          .icon-placeholder {
            width: 40rpx;
            height: 40rpx;
            background: currentColor;
            border-radius: 8rpx;
          }
        }

        .title {
          font-size: 30rpx;
          color: #333;
        }
      }

      .arrow {
        width: 16rpx;
        height: 16rpx;
        border-top: 4rpx solid #999;
        border-right: 4rpx solid #999;
        transform: rotate(45deg);
      }
    }
  }
}
</style> 