java-mall-app/unpackage/dist/build/mp-weixin/components/jin-attachment/jin-attachment.js
2024-11-01 16:35:40 +08:00

11 lines
5.5 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/jin-attachment/jin-attachment"],{"067f":function(e,t,n){"use strict";n.r(t);var i=n("9b0c"),a=n.n(i);for(var s in i)["default"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(s);t["default"]=a.a},"480a":function(e,t,n){},"9b0c":function(e,t,n){"use strict";(function(e,i){var a=n("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=a(n("7eb4")),o=a(n("ee10")),l={props:{attachmentList:{type:Array},mode:{type:String},uploadFileUrl:{type:String,dafault:"#"},showProcess:{type:Boolean,default:!0},header:{type:Object},limit:{type:Number,default:null},fileKeyName:{type:String,default:"upfile"},canUploadFile:{type:Boolean,default:!1},styleObj:{type:Object,default:{}}},computed:{list:function(){return this.attachmentList}},data:function(){return{}},methods:{previewImg:function(t){e.previewImage({current:0,urls:[t]})},downLoad:function(t){e.showModal({title:"确定要下载此附件吗",content:" ",success:function(n){n.confirm&&(e.showLoading({title:"下载中,请稍后"}),console.log(t),e.downloadFile({url:t,success:function(t){t.tempFilePath;e.saveFile({tempFilePath:t.tempFilePath,success:function(t){var n=t.savedFilePath;e.hideLoading(),e.showToast({title:"保存成功,路径为"+n}),e.openDocument({filePath:n,success:function(e){console.log(e)}})}})},fail:function(t){console.log(t),e.hideLoading(),e.showToast({title:"下载失败",icon:"none"})}}),setTimeout((function(){e.hideLoading()}),2e4))}})},deleteItem:function(t){var n=this;e.showModal({title:"提示",content:"确定要删除此项吗?",success:function(e){e.confirm&&(100!=n.list[t].process&&"undefined"!=typeof n.list[t].uploadTask&&n.list[t].uploadTask.abort(),n.list.splice(t,1),n.$forceUpdate(),n.$emit("update:attachmentList",n.list))}})},chooseFile:function(){var t=this;return(0,o.default)(s.default.mark((function n(){var a,o,l,r,u,c,f,d,p;return s.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(null==t.limit||isNaN(t.limit)){n.next=4;break}if(!(t.list.length>=t.limit)){n.next=4;break}return e.showToast({title:"已达到最大上传数量",icon:"none"}),n.abrupt("return");case 4:return t.canUploadFile,!1,a=t,n.next=10,a.$.chooseImage({count:null==t.limit||t.limit-t.list.length>9?9:9-limit,sizeType:["original","compressed"],sourceType:["album"]});case 10:if(o=n.sent,"undefined"!=typeof o[1]){n.next=13;break}return n.abrupt("return");case 13:l=o[1].tempFilePaths,n.next=34;break;case 16:return a=t,n.next=19,e.showActionSheet({itemList:["选择图片","选择文件"]});case 19:if(r=n.sent,0!=r[1].tapIndex){n.next=29;break}return n.next=23,a.$.chooseImage({count:null==t.limit||t.limit-t.list.length>9?9:9-limit,sizeType:["original","compressed"],sourceType:["album"]});case 23:if(o=n.sent,"undefined"!=typeof o[1]){n.next=26;break}return n.abrupt("return");case 26:l=o[1].tempFilePaths,n.next=34;break;case 29:return n.next=31,new Promise((function(e,n){i.chooseMessageFile({count:null==t.limit||t.limit-t.list.length>9?9:9-limit,type:"file",success:function(t){var n=t.tempFiles;e(n)}})}));case 31:o=n.sent,l=o.map((function(e,t){return e.path})),u=o.map((function(e,t){return e.name}));case 34:c=s.default.mark((function n(i){var a,o,r;return s.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return a=l[i],"undefined"!=typeof u&&"undefined"!=typeof u[i]?d=u[i]:(d=a.split("/"),d=d[d.length-1]),o=t.list.length,t.list.push({fileName:d,url:a,type:t.isImg(a)?"image":"file",index:o,uploadTask:p,process:0}),t.$forceUpdate(),console.info(t.list),r=e.getStorageSync("ukey"),n.next=9,t.$.uploadFile({url:t.uploadFileUrl,method:"POST",filePath:a,name:t.fileKeyName,headers:t.header,formData:{perm_key:r},success:function(e){if(t.$emit("uploadSuccess",e),200==e.statusCode){var n=JSON.parse(e.data);console.info(n.data),t.$set(t.list[o],"url",n.data.url),t.$set(t.list[o],"fileName",n.data.original),t.$set(t.list[o],"type",t.isImg(n.data.url)?"image":"file"),t.$set(t.list[o],"process",100),t.$emit("update:attachmentList",t.list),t.$forceUpdate()}}});case 9:p=n.sent,p.onProgressUpdate((function(e){e.progress<90&&t.$forceUpdate()}));case 11:case"end":return n.stop()}}),n)})),n.t0=s.default.keys(l);case 36:if((n.t1=n.t0()).done){n.next=41;break}return f=n.t1.value,n.delegateYield(c(f),"t2",39);case 39:n.next=36;break;case 41:case"end":return n.stop()}}),n)})))()},isImg:function(e){var t=e.lastIndexOf("."),n=e.substr(t+1),i=-1!==["png","jpg","jpeg","bmp","gif","webp","svg","tiff"].indexOf(n.toLowerCase());return i}}};t.default=l}).call(this,n("df3c")["default"],n("3223")["default"])},bcb3:function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return a})),n.d(t,"a",(function(){}));var i=function(){var e=this.$createElement;this._self._c},a=[]},c596:function(e,t,n){"use strict";var i=n("480a"),a=n.n(i);a.a},ff95:function(e,t,n){"use strict";n.r(t);var i=n("bcb3"),a=n("067f");for(var s in a)["default"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(s);n("c596");var o=n("828b"),l=Object(o["a"])(a["default"],i["b"],i["c"],!1,null,"fb739994",null,!1,i["a"],void 0);t["default"]=l.exports}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
'components/jin-attachment/jin-attachment-create-component',
{
'components/jin-attachment/jin-attachment-create-component':(function(module, exports, __webpack_require__){
__webpack_require__('df3c')['createComponent'](__webpack_require__("ff95"))
})
},
[['components/jin-attachment/jin-attachment-create-component']]
]);