// components/comImg/index.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    src:String,
    width:String,
    height:String,
    mode:String
  },

  /**
   * 组件的初始数据
   */
  data: {
    type:'video',
    videoDefault:'',
    videoSrc:'',
    show:false,

  },
attached(){

  let index = this.data.src.lastIndexOf('.')
  let type = this.data.src.substr(index+1,this.data.src.length)
  let imageType =['png','jpg','jpeg']
  if(imageType.indexOf(type)!=-1){
    this.setData({
      type:'img',
    })
  }else{
    this.setData({
      type:'video',
    })


  
  }

},
  /**
   * 组件的方法列表
   */
  methods: {
    showData(){
      console.log(this.data.type)
      if(this.data.type=='img'){
        wx.previewImage({
          urls: [this.data.src],
        })
      }else{
       console.log('1')
       wx.previewMedia({
         sources: [
           {url:this.data.src,type:'video'}],
       })

      }
    
    },

  }
})