<template>
  <custom-dialog :visible.sync="dialogVisible" title="角色信息" @close="onClose">
    <view class="character-content">
      <view class="character-info">
        <view class="avatar-section">
          <image class="avatar" src="/static/avatar/default.png" mode="aspectFit"></image>
          <text class="level">Lv.{{level}}</text>
        </view>
        <view class="info-section">
          <view class="info-item">
            <text class="label">名称：</text>
            <text class="value">{{name}}</text>
          </view>
          <view class="info-item">
            <text class="label">经验：</text>
            <text class="value">{{exp}}/{{nextLevelExp}}</text>
          </view>
          <view class="progress-bar">
            <view class="progress" :style="{width: expProgress + '%'}"></view>
          </view>
        </view>
      </view>
      <view class="stats-section">
        <view class="stat-item" v-for="(stat, index) in stats" :key="index">
          <text class="stat-label">{{stat.label}}</text>
          <text class="stat-value">{{stat.value}}</text>
        </view>
      </view>
    </view>
  </custom-dialog>
</template>

<script>
import CustomDialog from '../CustomDialog/CustomDialog.vue'

export default {
  name: 'CharacterDialog',
  components: {
    CustomDialog
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      dialogVisible: false,
      name: '玩家名称',
      level: 1,
      exp: 100,
      nextLevelExp: 200,
      stats: [
        { label: '力量', value: 10 },
        { label: '敏捷', value: 8 },
        { label: '智力', value: 12 },
        { label: '体力', value: 15 }
      ]
    }
  },
  computed: {
    expProgress() {
      return (this.exp / this.nextLevelExp) * 100
    }
  },
  watch: {
    visible(val) {
      this.dialogVisible = val
    },
    dialogVisible(val) {
      this.$emit('update:visible', val)
    }
  },
  methods: {
    onClose() {
      this.dialogVisible = false
    }
  }
}
</script>

<style lang="scss" scoped>
.character-content {
  .character-info {
    display: flex;
    padding: 20rpx;
    gap: 30rpx;

    .avatar-section {
      position: relative;
      
      .avatar {
        width: 160rpx;
        height: 160rpx;
        border-radius: 80rpx;
        border: 4rpx solid #eee;
      }

      .level {
        position: absolute;
        bottom: -10rpx;
        left: 50%;
        transform: translateX(-50%);
        background: #007AFF;
        color: white;
        padding: 4rpx 16rpx;
        border-radius: 20rpx;
        font-size: 24rpx;
      }
    }

    .info-section {
      flex: 1;

      .info-item {
        margin-bottom: 16rpx;
        
        .label {
          color: #666;
          font-size: 28rpx;
        }
        
        .value {
          color: #333;
          font-size: 28rpx;
        }
      }

      .progress-bar {
        height: 16rpx;
        background: #eee;
        border-radius: 8rpx;
        overflow: hidden;
        margin-top: 10rpx;

        .progress {
          height: 100%;
          background: #007AFF;
          transition: width 0.3s ease;
        }
      }
    }
  }

  .stats-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20rpx;
    padding: 20rpx;
    background: #f8f8f8;
    border-radius: 12rpx;
    margin: 20rpx;

    .stat-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10rpx 20rpx;

      .stat-label {
        color: #666;
        font-size: 28rpx;
      }

      .stat-value {
        color: #333;
        font-size: 28rpx;
        font-weight: 500;
      }
    }
  }
}
</style> 