<template>
  <view class="container">
    <!-- 顶部装饰条 -->
    <view class="top-decoration"></view>

    <CustomHeader title="个人中心" @back="handleBack" />

    <view class="user-info-card">
      <view class="user-avatar">
        <text class="avatar-icon">👤</text>
      </view>
      <text class="user-name">{{ userName }}</text>
      <text class="wechat-status">
        <text class="status-icon">{{ isWechatBound ? '✓' : '!' }}</text>
        {{ isWechatBound ? '微信已绑定' : '微信未绑定' }}
      </text>
    </view>

    <view class="menu-list">
      <view class="menu-item" @click="handleVisitRecords">
        <text class="menu-icon">📋</text>
        <text class="menu-text">访问记录</text>
        <text class="menu-arrow">→</text>
      </view>

      <view class="menu-item" @click="handleAccessCredential">
        <text class="menu-icon">🎫</text>
        <text class="menu-text">访问凭证</text>
        <text class="menu-arrow">→</text>
      </view>

      <view class="menu-item" @click="handleWechatBind">
        <text class="menu-icon">🔗</text>
        <text class="menu-text">微信绑定</text>
        <text class="menu-arrow">→</text>
      </view>
    </view>

    <!-- 底部装饰 -->
    <view class="bottom-decoration"></view>
  </view>
</template>

<script>
import CustomHeader from '../components/CustomHeader.vue';

export default {
  components: { CustomHeader },
  data() {
    return {
      openid: '',
      userName: '访客用户',
      isWechatBound: true
    };
  },
  onLoad(options) {
    this.openid = options.openid || '';
  },
  mounted() {
    // 模拟获取用户信息
    setTimeout(() => {
      this.userName = '访客_' + this.openid.slice(-4);
    }, 500);
  },
  methods: {
    handleBack() {
      uni.navigateBack();
    },
    handleVisitRecords() {
      uni.navigateTo({
        url: `/pages/supply_chain/visitor_records/index?openid=${this.openid}`
      });
    },
    handleAccessCredential() {
      uni.navigateTo({
        url: `/pages/supply_chain/visitor_credential/index?openid=${this.openid}`
      });
    },
    handleWechatBind() {
      if (this.isWechatBound) {
        uni.showToast({ title: '微信已绑定', icon: 'success' });
      } else {
        uni.showToast({ title: '微信绑定功能开发中', icon: 'none' });
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.container {
  min-height: 100vh;
  background: linear-gradient(135deg, #3a5da6 0%, #4a72c2 100%);
  padding: 20rpx;
  position: relative;
  overflow: hidden;
}

.top-decoration {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10rpx;
  background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
}

.user-info-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 24rpx;
  padding: 50rpx;
  box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10rpx);
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 40rpx;
  margin-top: 12rpx;
}

.user-avatar {
  width: 160rpx;
  height: 160rpx;
  background: linear-gradient(135deg, #3a5da6 0%, #4a72c2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 30rpx;
  box-shadow: 0 12rpx 30rpx rgba(58, 93, 166, 0.4);
}

.avatar-icon {
  font-size: 80rpx;
}

.user-name {
  font-size: 44rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 16rpx;
}

.wechat-status {
  font-size: 32rpx;
  color: #666;
  display: flex;
  align-items: center;
  gap: 10rpx;
}

.status-icon {
  font-size: 32rpx;
  color: #4caf50;
  font-weight: bold;
}

.menu-list {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 24rpx;
  padding: 20rpx;
  box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10rpx);
  position: relative;
  z-index: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 40rpx 30rpx;
  border-bottom: 1rpx solid rgba(58, 93, 166, 0.1);
  transition: all 0.3s ease;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:active {
  background: rgba(58, 93, 166, 0.05);
  border-radius: 16rpx;
}

.menu-icon {
  font-size: 44rpx;
  margin-right: 30rpx;
}

.menu-text {
  flex: 1;
  font-size: 36rpx;
  color: #333;
}

.menu-arrow {
  font-size: 32rpx;
  color: #999;
}

.bottom-decoration {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200rpx;
  background: linear-gradient(180deg, transparent, rgba(42, 82, 152, 0.2));
  opacity: 0.6;
}
</style>
