Sanakey
2021-06-04 355a84d740a2a9dfa1d67cb2d2e11843d42809ac
components/file-uploader/index.ts
@@ -9,6 +9,7 @@
   * 组件的属性列表
   */
  options: {
    styleIsolation:"shared",
    addGlobalClass:true,
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },
@@ -17,6 +18,26 @@
      type: String,
      value: ""
    },
    fileDeleteUrl:{
      type: String,
      value: ""
    },
    description:{
      type: String,
      value: "建议尺寸:500x500像素,72分辨率"
    },
    previewSize:{
      type: String,
      value: "500rpx"
    },
    imageFit:{
      type: String,
      value: "aspectFill"
    },
    hasSlot:{
      type:Boolean,
      value: false
    },
    multiple:{
      type:Boolean,
      value: false
@@ -24,6 +45,10 @@
    imgList:{
      type:Array,
      value: []
    },
    isMustUpload:{
      type:Boolean,
      value: true
    }
  },
@@ -117,18 +142,22 @@
      this.setData({ imgList });
      console.log('多张上传后imgList。。。',imgList);
      this.getImgUnid('images');
      if (this.data.isMustUpload){
        this.checkImages("images", "请至少上传一张图片")
      }
      // this.triggerEvent('getCoverImage',{
      //   imgList
      // })
    },
    async deleteFile(event:any){
      let imgList = this.data.imgList;
      let {imgList,fileDeleteUrl} = this.data;
      let {index} = event.detail;
      console.log(index,'dd');
      let [err,result] = await wx.$utils.to(
        wx.$http.request({
          url: '/shopping/panicBuying.do?m=deleteAttachment',
          url: fileDeleteUrl,
          data:{
            unid:imgList[index].unid,
            seq:imgList[index].seq,
@@ -220,6 +249,18 @@
    },
    getImagesUnid(){
      return this.data.images;
    },
    clearImagesData(){
      this.setData({
        imgList:[],
        images:'',
        coverImage:''
      })
    },
    startUpload(){
      let fileUpload = this.selectComponent('#my-file-uploader');
      console.log('准备上传。。。');
      fileUpload.startUpload();
    }
      // async deleteFile(param:any){
      //   let [err,result] = await wx.$utils.to(