<template>
  <view class="card">
    <view class="flex header">
      <view class="flex left">
        <view class="avatar">
          <image class="avatar-img" :src="data.user.headImage" mode="scaleToFill"></image>
        </view>
        <view class="info">
          <view class="name">{{ data.user.nickName }}</view>
          <view>{{ $dayjs(data.createTime).format('YYYY-MM-DD') }}</view>
        </view>
      </view>
    </view>
    <view class="section content">{{ data.content }}</view>
    <view class="flex section imgs">
      <image class="img" 
        v-for="(url, iIdx) in images" 
        :key="iIdx" :src="url" 
        mode="scaleToFill"
      ></image>
    </view>
  </view>
</template>

<script>
  import formRate from '@/pages_order/components/formRate.vue'

  export default {
    components: {
      formRate,
    },
    props: {
      data: {
        type: Object,
        default() {
          return {}
        }
      },
      mode: {
        type: String,
        default: 'read' // read | edit
      }
    },
    computed: {
      images() {
        const { image } = this.data || {}

        return image?.split?.(',')?.filter(val => val)
      },
      disabled() {
        return this.mode !== 'edit'
      },
    },
    methods: {
    },
  }
</script>

<style scoped lang="scss">
  .card {
    width: 100%;
    padding: 32rpx;
    box-sizing: border-box;
    background: #FAFAFF;
    border: 2rpx solid #FFFFFF;
    border-radius: 32rpx;
  }

  .header {

    .left {
      flex: 1;
      justify-content: flex-start;
      column-gap: 24rpx;
    }

    .avatar {
      width: 100rpx;
      height: 100rpx;
      border: 4rpx solid #FFFFFF;
      border-radius: 50%;
      overflow: hidden;

      &-img {
        width: 100%;
        height: 100%;
      }
    }

    .info {
      font-family: PingFang SC;
      font-weight: 400;
      font-size: 24rpx;
      line-height: 1.5;
      color: #8B8B8B;

      .name {
        font-weight: 600;
        font-size: 36rpx;
        line-height: 1.2;
        color: #252545;
        margin-bottom: 8rpx;
      }
    }

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

  .section {
    margin-top: 24rpx;
  }

  .content {
    white-space: pre-wrap;
    font-family: PingFang SC;
    font-weight: 400;
    font-size: 32rpx;
    line-height: 1.4;
    color: #181818;
  }

  .imgs {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 24rpx;

    .img {
      width: 190rpx;
      height: 190rpx;
    }
  }

  .score {
    &-item {
      padding: 12rpx 0;
      justify-content: space-between;

      & + & {
        margin-top: 4rpx;
      }
      
      &-label {
        font-family: PingFang SC;
        font-weight: 400;
        font-size: 26rpx;
        line-height: 1.4;
        color: #181818;
      }
      
    }
  }

  .operate {
    justify-content: flex-start;
    column-gap: 24rpx;
    
    .btn {
      column-gap: 8rpx;
      font-size: 24rpx;
      color: #999999;

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

  .comment {
    &-user {
      column-gap: 16rpx;

      .avatar {
        width: 48rpx;
        height: 48rpx;
        border-radius: 50%;

        &-img {
          width: 100%;
          height: 100%;
        }
      }

      .name {
        font-size: 26rpx;
        font-weight: 600;
        color: #000000;
      }

      .time {
        flex: 1;
        text-align: right;
        font-size: 24rpx;
        color: #999999;
      }
    }

    &-content {
      margin-top: 28rpx;
      font-size: 26rpx;
      color: #666666;
    }
  }
</style>