<template>
  <view class="card">
    <view class="flex card-header">
      <view>
        <view class="title">我的档案</view>
        <button class="flex btn btn-question">
          <image class="btn-icon" src="@/static/image/icon-question.png" mode="widthFix"></image>
          <view>如何完善我的档案？</view>
        </button>
      </view>
      <view class="flex">
        <button class="btn btn-switch" @click="onSwitch">切换</button>
        <!-- <button class="btn btn-add" @click="onAdd">新增记录</button> -->
      </view>
    </view>
    <view class="card-content">
      <view class="flex info">
        <view class="avatar">
          <image class="img" :src="info.headImage" mode="scaleToFill"></image>
          <view :class="['tag', `tag-${info.role}`]">{{ info.roleDesc || '' }}</view>
        </view>
        <view class="flex summary">
          <view class="flex flex-column summary-item name">
            <view class="summary-item-content">{{ info.nickName || '' }}</view>
            <view class="summary-item-label">{{ `ID：${info.id}` }}</view>
          </view>
          <view class="flex flex-column summary-item" @click="jumpToAchievement">
            <view class="summary-item-content">{{ medalCount }}</view>
            <view class="summary-item-label nowrap">成就</view>
          </view>
          <view class="flex flex-column summary-item">
            <view class="summary-item-content">{{ experienceCount }}</view>
            <view class="summary-item-label nowrap">足迹</view>
          </view>
        </view>
      </view>
      <view class="flex medal" @click="jumpToAchievement">
        <image class="medal-item" v-for="item in medalList" :key="item.id" :src="item.medal.icon1" mode="widthFix"></image>
      </view>
    </view>
  </view>
</template>

<script>
	import { mapState } from 'vuex'

  export default {
    props: {
      medalList: {
        type: Array,
        default() {
          return []
        }
      },
      medalCount: {
        type: Number,
        default: 0
      },
      experienceCount: {
        type: Number,
        default: 0
      },
    },
    data() {
      return {
      }
    },
    onLoad() {

    },
    computed: {
      ...mapState(['userInfo', 'memberInfo']),
      info() {
        return this.memberInfo || this.userInfo
      },
    },
    methods: {
      onAdd() {
        this.$emit('addRecord')
      },
      onSwitch() {
        this.$emit('switchMember')
      },
      jumpToAchievement() {
        uni.navigateTo({
          url: '/pages_order/growing/achievement/index'
        })
      },
    },
  }
</script>

<style scoped lang="scss">

  @import '../member/styles/tag.scss';

  .card {
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 1.4;
    background: linear-gradient(to right, #DDF4FF, #9FE1FF);
    border-radius: 48rpx;

    &-header {
      justify-content: space-between;
      padding: 24rpx 40rpx 20rpx 40rpx;

      .title {
        font-size: 32rpx;
        font-weight: 600;
        color: #000000;
      }

      .btn-question {
        margin-top: 4rpx;
        column-gap: 8rpx;
        font-size: 26rpx;
        color: #21607D;

        .btn-icon {
          width: 32rpx;
          height: auto;
        }
      }

      .btn-switch {
        padding: 6rpx 22rpx;
        font-size: 28rpx;
        font-weight: 400;
        line-height: 1.4;
        color: #252545;
        border: 2rpx solid #252545;
        border-radius: 28rpx;
      }

      .btn-add {
        padding: 8rpx 24rpx;
        font-size: 28rpx;
        font-weight: 500;
        line-height: 1.4;
        color: #FFFFFF;
        background: linear-gradient(to right, #21FEEC, #019AF9);
        border-radius: 28rpx;
      }

      .btn + .btn {
        margin-left: 26rpx;
      }
    }

    &-content {
      padding: 38rpx 38rpx 14rpx 38rpx;
      background: linear-gradient(to right, #FBFEFF, #DAF3FF);
      border: 2rpx solid #FFFFFF;
      border-radius: 48rpx;
      box-shadow: 0 2px 12px 0 #009AE717;

      .info {
        column-gap: 24rpx;

        .avatar {
          flex: none;
          position: relative;
          width: 128rpx;
          height: 128rpx;
          border-radius: 24rpx;
          overflow: hidden;

          .img {
            width: 100%;
            height: 100%;
          }

        }

        .summary {
          flex: 1;
          column-gap: 26rpx;

          &-item {
            flex: 1;
            row-gap: 8rpx;

            &.name {
              flex: none;
            }

            &-content {
              font-size: 32rpx;
              font-weight: 600;
              color: #000000;
            }

            &-label {
              font-size: 24rpx;
              color: #939393;
            }
          }
        }
      }

      .medal {
        margin-top: 16rpx;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 16rpx;

        &-item {
          width: 50rpx;
          height: auto;
        }
      }
    }
  }

  .nowrap {
    white-space: nowrap;
  }

</style>