upload.js 5.1 KB

12345678910
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/common/upload"],{"1f80":function(e,t,n){"use strict";n.r(t);var i=n("2e16"),a=n.n(i);for(var r in i)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(r);t["default"]=a.a},"2e16":function(e,t,n){"use strict";(function(e){var i=n("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=i(n("7eb4")),r=i(n("7ca3")),o=i(n("ee10")),s=i(n("ed46"));n("17ce");function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){(0,r.default)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var c={name:"preview",props:{list:{type:Array,default:function(){return[]}},type:{type:String,default:"preview"},accept:{type:String,default:"image"}},data:function(){return{fileList:[]}},created:function(){var e=this;this.fileList=this.list.map((function(t){if(t.type)t["isImage"]=e.image(t.type.toLowerCase());else{var n=t.name.split(".");t["isImage"]=e.image(n[n.length-1].toLowerCase())}return t}))},methods:{image:function(e){return"jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg".indexOf(e)>-1},deletePic:function(t){var n=this;e.showModal({title:"有极提示",content:"是否删除该附件",success:function(e){e.confirm&&n.fileList.splice(t.index,1)}})},afterRead:function(e){var t=this;return(0,o.default)(a.default.mark((function n(){var i,r,o,s,u;return a.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:i=[].concat(e.file),r=t.fileList.length,i.map((function(e){t.fileList.push(l(l({},e),{},{status:"uploading",message:"上传中"}))})),o=0;case 4:if(!(o<i.length)){n.next=14;break}return n.next=7,t.uploadFilePromise(i[o].url);case 7:s=n.sent,u=t.fileList[r],t.fileList.splice(r,1,Object.assign(u,{status:"success",message:"",url:s.node.url,id:s.id,name:s.name})),r++;case 11:o++,n.next=4;break;case 14:case"end":return n.stop()}}),n)})))()},uploadFilePromise:function(t){return new Promise((function(n,i){e.uploadFile({url:s.default.baseUrl+"/file/filenode/-1",filePath:t,name:"uploadFile",success:function(e){setTimeout((function(){n(JSON.parse(e.data).data)}),1e3)}})}))},getFile:function(){return this.fileList.map((function(e){return{id:e.id,name:e.name,url:e.url,type:e.type}}))},clickFile:function(t,n,i){var a=this,r=this;return t.isImage?e.previewImage({urls:n,current:i,showmenu:!0,fail:function(){r.toast("预览图片失败")}}):t.isVideo?this.$refs.update.previewVideo(t):void e.showActionSheet({itemList:["预览","下载"],success:function(e){0===e.tapIndex?a.openFile(t):1===e.tapIndex&&a.download(t)}})},download:function(t){var n=this;e.showLoading({title:"正在下载"}),e.downloadFile({url:s.default.baseUrl+"/file/filenode/"+t.id+"/type/"+t.name,success:function(i){e.hideLoading();var a=e.getStorageSync("downliadFile")?JSON.parse(e.getStorageSync("downliadFile")):[];a.unshift({wxUrl:i.tempFilePath,userId:n.$store.getters.user.userId,type:t.type,size:i.dataLength,projectId:n.$store.getters.project.id||0,organizationId:n.$store.getters.project.id||0,fileName:t.name,date:n.$dayjs().format("YYYY-MM-DD HH:mm:ss")}),e.setStorageSync("downliadFile",JSON.stringify(a)),n.$toast("下载成功")},fail:function(t){e.hideLoading(),n.$toast("下载失败")}})},openFile:function(t){var n=this;e.showLoading({title:"正在打开"}),e.downloadFile({url:s.default.baseUrl+"/file/filenode/"+t.id+"/type/"+t.name,success:function(i){e.hideLoading(),e.openDocument({filePath:i.tempFilePath,fileType:t.type,success:function(e){},fail:function(e){n.$toast("打开失败")}})},fail:function(t){e.hideLoading(),n.$toast("打开失败")}})}}};t.default=c}).call(this,n("df3c")["default"])},"91cc":function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return r})),n.d(t,"a",(function(){return i}));var i={uvUpload:function(){return Promise.all([n.e("common/vendor"),n.e("uni_modules/uv-upload/components/uv-upload/uv-upload")]).then(n.bind(null,"9d0f"))}},a=function(){var e=this.$createElement,t=(this._self._c,"insert"!==this.type?this.list.length:null);this.$mp.data=Object.assign({},{$root:{g0:t}})},r=[]},a455:function(e,t,n){"use strict";n.r(t);var i=n("91cc"),a=n("1f80");for(var r in a)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(r);var o=n("828b"),s=Object(o["a"])(a["default"],i["b"],i["c"],!1,null,null,null,!1,i["a"],void 0);t["default"]=s.exports}}]);
  2. ;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
  3. 'components/common/upload-create-component',
  4. {
  5. 'components/common/upload-create-component':(function(module, exports, __webpack_require__){
  6. __webpack_require__('df3c')['createComponent'](__webpack_require__("a455"))
  7. })
  8. },
  9. [['components/common/upload-create-component']]
  10. ]);