import TyComponent from '../common/component'

TyComponent({
  /**
   * 组件的属性列表
   */
  properties: {

    name: {
      type: [String, Number]
    },
    accept: {
      type: String,
      value: 'image'
    },
    sizeType: {
      type: Array,
      value: ['original', 'compressed']
    },
    previewSize: {
      type: [String, Number],
      value: '80px'
    },
    previewImage: {
      type: Boolean,
      value: true
    },
    previewFullImage: {
      type: Boolean,
      value: true
    },
    multiple: {
      type: Boolean,
      value: false
    },
    disabled: {
      type: Boolean,
      value: false
    },
    deletable: {
      type: Boolean,
      value: true
    },
    capture: {
      type: [String, Array],
      value: ['album', 'camera']
    },
    fileList: {
      type: Array,
      value: []
    },
    maxSize: {
      type: Number,
      value: Number.MAX_VALUE
    },
    maxCount: {
      type: Number,
      value: 100
    },
    uploadText: {
      type: String
    },
    imageFit: {
      type: String,
      value: 'scaleToFill'
    },
    useBeforeRead: {
      type: Boolean
    },
    camera: {
      type: String
    },
    compressed: {
      type: Boolean
    },
    maxDuration: {
      type: Number
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleBeforeRead({detail}) {
      this.triggerEvent('before-read', detail)
    },
    handleAfterRead({detail}) {
      this.triggerEvent('after-read', detail)
    },
    handleOversize({detail}) {
      this.triggerEvent('oversize', detail)
    },
    handleClickPreview({detail}) {
      this.triggerEvent('click-preview', detail)
    },
    handleDelete({detail}) {
      this.triggerEvent('delete', detail)
    },
  }
})
