<template>
  <div class="item" :class="'label__' + item.labelPosition">
    <span v-if="!item.hideLabel" class="label">{{ item.label }}</span>
    <span class="showdata">
      <img :width="item.width" :height="item.height" :src="item.url || urlDefault" />
    </span>
  </div>
</template>
<script>
import { ft } from '../../../lib/utils.js';

const LABELS = {
  dynamicValue: ft('i18n_common_dynamic_value', '动态数值'),
  label: ft('i18n_common_label', '标签')
};

// 属性信息展示卡 - 单条模式
export default {
  name: 'item-img',
  props: {
    item: {
      type: Object,
      default: function () {
        return {
          labelPosition: 'left',
          label: LABELS.label,
          hideLabel: true,
          url: null,
          props: 'myprops',
          valueDefault: LABELS.dynamicValue
        };
      }
    }
  },
  data() {
    return {
      urlDefault:
        'https://s3.amazonaws.com/creativetim_bucket/products/51/thumb/opt_mdp_thumbnail.jpg?1521134752'
    };
  }
};
</script>

<style lang="scss" scoped>
.label__top {
  span.label {
    display: block;
  }
  span.showdata {
    display: block;
    margin-left: 10px;
  }
}
.label__left {
  span.label {
    display: inline-block;
    width: 120px;
  }
  span.showdata {
    display: inline-block;
    margin-left: 10px;
  }
}
</style>
