index-legacy.6d649013.js 7.6 KB

1234567891011121314151617181920
  1. ;(function(){function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}var __vite_style__=document.createElement('style');__vite_style__.innerHTML="._colUpload_or6a6_1{line-height:0}._uploadSection_or6a6_4{width:150px;height:85px;background:#f8faf9;border-radius:10px;border:1px solid rgba(45,199,170,.26);font-size:14px;color:#2dc7aa;line-height:20px}._uploadFile_or6a6_14{width:100%;min-width:300px;height:50px;border:1px solid rgba(142,142,142,.26);border-radius:10px;display:flex;align-items:center;padding:0 15px;color:var(--el-text-color-regular)}._uploadFile_or6a6_14 .el-icon{margin-right:5px}._fileUpload_or6a6_28 .el-upload--text{width:100%}._fileUpload_or6a6_28 .el-loading-spinner{display:flex;align-items:center;height:42px!important;justify-content:center;margin-top:-20px!important}._fileUpload_or6a6_28 .el-loading-spinner svg{width:20px;height:20px;margin-right:5px}._uploadClass_or6a6_43{height:85px;width:100%}._uploadClass_or6a6_43 .el-loading-spinner{margin-top:-33px;height:85px}._uploadClass_or6a6_43 .el-loading-mask{height:50px;border-radius:10px}\n";document.head.appendChild(__vite_style__);System.register(['./vendor-legacy.9ba3db9d.js','./index-legacy.da88ae94.js','./index-legacy.0dcd49ba.js'],function(exports){'use strict';var defineComponent,ElMessage,ElLoading,createVNode,ElUpload,ElImage,ElIcon,document_default,createTextVNode,iconUpload,request;return{setters:[function(module){defineComponent=module.d;ElMessage=module.E;ElLoading=module.ah;createVNode=module.c;ElUpload=module.ag;ElImage=module.x;ElIcon=module.l;document_default=module.ai;createTextVNode=module.a;},function(module){iconUpload=module.i;},function(module){request=module.r;}],execute:function execute(){var colUpload="_colUpload_or6a6_1";var uploadSection="_uploadSection_or6a6_4";var uploadFile="_uploadFile_or6a6_14";var fileUpload="_fileUpload_or6a6_28";var uploadClass="_uploadClass_or6a6_43";var styles={colUpload:colUpload,uploadSection:uploadSection,uploadFile:uploadFile,fileUpload:fileUpload,uploadClass:uploadClass};var ColUpload=exports('C',defineComponent({name:'col-upload',props:{modelValue:{type:String,default:''},uploadType:{type:String,default:'image'},disabled:{type:Boolean,default:false},bucket:{type:String,default:'daya'},size:{type:Number,default:5// 默认5M
  2. },accept:{type:String,default:'.png,.jpg,.jpeg'},tips:{type:String,default:'请上传图片'},extraTips:{type:String,default:'图片最大不能超过5MB'},onChange:{type:Function,default:function _default(){}}},data:function data(){return{// ossUploadUrl: 'https://ks3-cn-beijing.ksyuncs.com/' + this.bucket,
  3. ossUploadUrl:"https://".concat(this.bucket,".ks3-cn-beijing.ksyuncs.com/"),dataObj:{policy:'',signature:'',key:'',KSSAccessKeyId:'',acl:'public-read',name:''},fileList:[],loading:null};},methods:{handleSuccess:function handleSuccess(){var _this$loading;(_this$loading=this.loading)===null||_this$loading===void 0?void 0:_this$loading.close();var url=this.ossUploadUrl+this.dataObj.key;console.log(url);this.$emit('update:modelValue',url);this.onChange(url);},handleRemove:function handleRemove(){console.log('remove');},handleChange:function handleChange(){console.log('handleChange');},handleProgress:function handleProgress(){console.log('handleProgress');},handleError:function handleError(){var _this$loading2;(_this$loading2=this.loading)===null||_this$loading2===void 0?void 0:_this$loading2.close();},beforeUpload:function beforeUpload(file){var _this=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee(){var isLt2M,fileName,key,obj,_yield$request$post,data;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:// beforeUpload
  4. console.log(file);// let fileType = true
  5. // if (props.rules.type && props.rules.type.length > 0) {
  6. // const fileExtension = file.name.split('.').pop().toUpperCase()
  7. // console.log(
  8. // props.rules.type,
  9. // fileExtension,
  10. // props.rules.type.indexOf(fileExtension) != -1
  11. // )
  12. // if (props.rules.type.indexOf(fileExtension) != -1) {
  13. // fileType = true
  14. // } else {
  15. // fileType = false
  16. // ElMessage.error('请上传正确的文件!')
  17. // return false
  18. // }
  19. // }
  20. isLt2M=true;if(!_this.size){_context.next=7;break;}isLt2M=file.size/1024/1024<_this.size;if(isLt2M){_context.next=7;break;}ElMessage.error("\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7".concat(_this.size,"M!"));return _context.abrupt("return",false);case 7:_this.loading=ElLoading.service({target:_this.$refs.uploadDom,lock:true,fullscreen:false,text:'上传中...',background:'rgba(0, 0, 0, 0.7)'});console.log(_this.loading);_context.prev=9;fileName=file.name.replaceAll(' ','_');key=new Date().getTime()+fileName;obj={filename:fileName,bucketName:_this.bucket,postData:{filename:fileName,acl:'public-read',key:key,unknowValueField:[]}};_context.next=15;return request.post('/api-website/getUploadSign',{data:obj});case 15:_yield$request$post=_context.sent;data=_yield$request$post.data;_this.dataObj={policy:data.policy,signature:data.signature,key:key,KSSAccessKeyId:data.kssAccessKeyId,acl:'public-read',name:fileName};_context.next=23;break;case 20:_context.prev=20;_context.t0=_context["catch"](9);_this.loading.close();case 23:case"end":return _context.stop();}}},_callee,null,[[9,20]]);}))();},fileName:function fileName(){var name=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return name.split('/').pop();},handleExceed:function handleExceed(){}},render:function render(){var _this2=this;return createVNode("div",{"class":[styles.colUpload,'w-full']},[createVNode(ElUpload,{"disabled":this.disabled,"action":this.ossUploadUrl,"data":this.dataObj,"onSuccess":this.handleSuccess,"onRemove":this.handleRemove,"onChange":this.handleChange,"onProgress":this.handleProgress,"onError":this.handleError,"fileList":this.fileList,"showFileList":false,"accept":this.accept,"beforeUpload":this.beforeUpload,"onExceed":this.handleExceed,"ref":"uploadRef","class":this.uploadType==='file'?styles.fileUpload:'',"style":{lineHeight:'0'}},{default:function _default(){return[createVNode("div",{"ref":"uploadDom","class":[styles.uploadClass,'w-full'],"style":{height:_this2.uploadType==='image'?'85px':'48px'}},[_this2.modelValue?_this2.uploadType==='image'?createVNode(ElImage,{"src":_this2.modelValue,"fit":"cover","class":styles.uploadSection},null):createVNode("div",{"class":styles.uploadFile},[createVNode(ElIcon,null,{default:function _default(){return[createVNode(document_default,null,null)];}}),createVNode("span",{"class":"whitespace-nowrap overflow-hidden text-ellipsis","style":{lineHeight:'1.2'}},[_this2.fileName(_this2.modelValue)])]):_this2.uploadType==='image'?createVNode("div",{"class":[styles.uploadSection,'flex items-center flex-col justify-center']},[createVNode("img",{"src":iconUpload,"class":"w-8 h-7 mb-3"},null),createVNode("p",null,[_this2.tips])]):createVNode("div",{"class":styles.uploadFile},[createVNode(ElIcon,null,{default:function _default(){return[createVNode(document_default,null,null)];}}),createTextVNode("\u4E0A\u4F20\u6587\u4EF6")])])];}}),createVNode("p",{"class":"text-3 text-[#999999] leading-6 pt-1"},[this.extraTips])]);}}));}};});})();