UNPKG

12.3 kBJavaScriptView Raw
1!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.uploader=r():e.uploader=r()}(this,function(){return function(e){function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}var t={};return r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=11)}([function(e,r,t){function o(e){t(8)}var n=t(6)(t(2),t(7),o,null,null);e.exports=n.exports},function(e,r,t){"use strict";function o(e){var r=null;return(0,n.uploadImage)(e).then(function(t){return r=t.serverId,e}).then(n.getLocalImgData).then(function(e){return{image:e,serverId:r}})}Object.defineProperty(r,"__esModule",{value:!0});var n=t(3),a=t(0),i=function(e){return e&&e.__esModule?e:{default:e}}(a);r.default={name:"WechatUploader",extends:i.default,props:{useWechatPreview:{type:Boolean,default:!0}},data:function(){return{serverIds:[]}},methods:{setImages:function(e){for(var r=[],t=[],o=0,n=e.length;o<n;o++)r.push(e[o].image),t.push(e[o].serverId);this.images=r,this.serverIds=t},add:function(e,r,t){return this.images.length<this.size&&(this.images.push(e),this.serverIds.push(r),this.$emit("add",{image:e,serverId:r,res:t}),!0)},getImages:function(){for(var e=[],r=0,t=this.images.length;r<t;r++)e.push({image:this.images[r],serverId:this.serverIds[r]});return e},remove:function(e){return 0<=e&&e<this.size&&(this.images.splice(e,1),this.serverIds.splice(e,1),this.$emit("remove",e),!0)},onClickRequest:function(){this.request()},request:function(){var e=this;return(0,n.chooseImage)(e.size-e.images.length).then(function(r){var t=r.localIds;if(t.length>0)return e.$emit("choose",r),e.$emit("load"),e.uploadWechatImages(t).then(function(){e.$emit("finish")})})},uploadWechatImages:function(e){var r=this;return o(e.shift()).then(function(t){var o=t.image,n=t.serverId,a=t.res;if(r.add(o,n,a),e.length>0)return r.uploadWechatImages(e)})}},mounted:function(){this.$on("click",function(e){(0,n.previewImage)(this.images[e],this.images)})}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default={name:"ROUploader",props:{size:{type:Number,default:1},canModify:{type:Boolean,default:!0},containerClass:{type:[Object,Array],default:function(){return{}}},containerStyle:{type:Object,default:function(){return{}}},imageClass:{type:[Object,Array],default:function(){return{}}},imageStyle:{type:Object,default:function(){return{}}},imageWrapClass:{type:[Object,Array],default:function(){return{}}},imageWrapStyle:{type:Object,default:function(){return{}}},requestClass:{type:[Object,Array],default:function(){return{}}},requestStyle:{type:Object,default:function(){return{}}},removeClass:{type:[Object,Array],default:function(){return{}}},removeStyle:{type:Object,default:function(){return{}}},lazyload:{type:Boolean,default:!1}},data:function(){return{images:[]}},methods:{setImages:function(e){for(var r=[],t=0,o=e.length;t<o;t++)r.push(e[t]);this.images=r},add:function(e){return this.images.length<this.size&&(this.images.push(e),this.$emit("add",e),!0)},remove:function(e){return 0<=e&&e<this.size&&(this.images.splice(e,1),this.$emit("remove",e),!0)},removeAll:function(){for(var e=0,r=this.images.length;e<r;e++)this.remove(e);return!0},getImages:function(){return this.images.slice(0)},onClickImage:function(e){this.$emit("click",e)},onClickRemove:function(e){this.remove(e)},onClickRequest:function(){this.$emit("request")},onPress:function(e){var r=this;return function(){r.$emit("menu",e)}},getSize:function(){return this.size},getCount:function(){return this.images.length}}}},function(e,r,t){"use strict";function o(e,r){wx.previewImage({current:e,urls:r})}function n(e){return new Promise(function(r,t){wx.chooseImage({count:e,sizeType:["compressed"],success:function(e){return r(e)}})})}function a(e){return new Promise(function(r,t){wx.uploadImage({localId:e,isShowProgressTips:0,success:function(e){return r(e)}})})}function i(e){return s&&window.__wxjs_is_wkwebview?new Promise(function(r,t){wx.getLocalImgData({localId:e,success:function(e){return r(e.localData)}})}):e}Object.defineProperty(r,"__esModule",{value:!0}),r.previewImage=o,r.chooseImage=n,r.uploadImage=a,r.getLocalImgData=i;var s=/iPhone/.test(navigator.userAgent)},function(e,r,t){r=e.exports=t(5)(void 0),r.push([e.i,'.ro-uploader-wrap{display:flex;background-color:#fff;text-decoration:none}.ro-uploader-wrap .ro-uploader-image-wrap{position:relative;margin-right:5px}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-image{vertical-align:middle;width:70px;height:70px;background-repeat:no-repeat;background-size:cover;background-position:50%;background-color:#aaa}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove{position:absolute;width:18px;height:18px;font-size:18px;line-height:18px;color:#fff;background-color:#aaa;top:0;right:0}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:after,.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:before{background-color:#fff;transform:translate(-50%,-50%) rotate(45deg)}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:before{width:2px;height:18px}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:after{width:18px;height:2px}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:active{border-color:#fff}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:active:after,.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:active:before{background-color:#fff}.ro-uploader-wrap .ro-uploader-request{position:relative;width:70px;height:70px;border:1px solid #aaa;box-sizing:border-box}.ro-uploader-wrap .ro-uploader-request:after,.ro-uploader-wrap .ro-uploader-request:before{background-color:#bbb}.ro-uploader-wrap .ro-uploader-request:before{width:2px;height:35px}.ro-uploader-wrap .ro-uploader-request:after{width:35px;height:2px}.ro-uploader-wrap .ro-uploader-request:active{border-color:#888}.ro-uploader-wrap .ro-uploader-request:active:after,.ro-uploader-wrap .ro-uploader-request:active:before{background-color:#888}.ro-uploader-wrap .ro-uploader-remove:after,.ro-uploader-wrap .ro-uploader-remove:before,.ro-uploader-wrap .ro-uploader-request:after,.ro-uploader-wrap .ro-uploader-request:before{content:" ";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}',""])},function(e,r){function t(e,r){var t=e[1]||"",n=e[3];if(!n)return t;if(r&&"function"==typeof btoa){var a=o(n);return[t].concat(n.sources.map(function(e){return"/*# sourceURL="+n.sourceRoot+e+" */"})).concat([a]).join("\n")}return[t].join("\n")}function o(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var r=[];return r.toString=function(){return this.map(function(r){var o=t(r,e);return r[2]?"@media "+r[2]+"{"+o+"}":o}).join("")},r.i=function(e,t){"string"==typeof e&&(e=[[null,e,""]]);for(var o={},n=0;n<this.length;n++){var a=this[n][0];"number"==typeof a&&(o[a]=!0)}for(n=0;n<e.length;n++){var i=e[n];"number"==typeof i[0]&&o[i[0]]||(t&&!i[2]?i[2]=t:t&&(i[2]="("+i[2]+") and ("+t+")"),r.push(i))}},r}},function(e,r){e.exports=function(e,r,t,o,n){var a,i=e=e||{},s=typeof e.default;"object"!==s&&"function"!==s||(a=e,i=e.default);var u="function"==typeof i?i.options:i;r&&(u.render=r.render,u.staticRenderFns=r.staticRenderFns),o&&(u._scopeId=o);var l;if(n?(l=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(n)},u._ssrRegister=l):t&&(l=t),l){var c=u.functional,p=c?u.render:u.beforeCreate;c?u.render=function(e,r){return l.call(r),p(e,r)}:u.beforeCreate=p?[].concat(p,l):[l]}return{esModule:a,exports:i,options:u}}},function(e,r){e.exports={render:function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("div",{staticClass:"ro-uploader-wrap",class:e.containerClass,style:e.containerStyle},[e._l(e.images,function(r,o){return t("div",{staticClass:"ro-uploader-image-wrap",class:e.imageWrapClass,style:e.imageWrapStyle},[e.lazyload?t("div",{directives:[{name:"lazy",rawName:"v-lazy:background-image",value:r,expression:"image",arg:"background-image"},{name:"pressure-press",rawName:"v-pressure-press",value:e.onPress(o),expression:"onPress(index)"}],staticClass:"ro-uploader-image",class:e.imageClass,style:[e.imageStyle],on:{click:function(r){e.onClickImage(o)}}}):t("div",{directives:[{name:"pressure-press",rawName:"v-pressure-press",value:e.onPress(o),expression:"onPress(index)"}],staticClass:"ro-uploader-image",class:e.imageClass,style:[{"background-image":"url("+r+")"},e.imageStyle],on:{click:function(r){e.onClickImage(o)}}}),e._v(" "),e.canModify?t("div",{staticClass:"ro-uploader-remove",class:e.removeClass,style:e.removeStyle,on:{click:function(r){e.onClickRemove(o)}}}):e._e()])}),e._v(" "),e.images.length<e.size&&e.canModify?t("div",{staticClass:"ro-uploader-image-wrap ro-uploader-request",class:e.requestClass,style:e.requestStyle,on:{click:e.onClickRequest}}):e._e()],2)},staticRenderFns:[]}},function(e,r,t){var o=t(4);"string"==typeof o&&(o=[[e.i,o,""]]),o.locals&&(e.exports=o.locals);t(9)("4fb8864b",o,!0)},function(e,r,t){function o(e){for(var r=0;r<e.length;r++){var t=e[r],o=c[t.id];if(o){o.refs++;for(var n=0;n<o.parts.length;n++)o.parts[n](t.parts[n]);for(;n<t.parts.length;n++)o.parts.push(a(t.parts[n]));o.parts.length>t.parts.length&&(o.parts.length=t.parts.length)}else{for(var i=[],n=0;n<t.parts.length;n++)i.push(a(t.parts[n]));c[t.id]={id:t.id,refs:1,parts:i}}}}function n(){var e=document.createElement("style");return e.type="text/css",p.appendChild(e),e}function a(e){var r,t,o=document.querySelector('style[data-vue-ssr-id~="'+e.id+'"]');if(o){if(m)return g;o.parentNode.removeChild(o)}if(h){var a=f++;o=d||(d=n()),r=i.bind(null,o,a,!1),t=i.bind(null,o,a,!0)}else o=n(),r=s.bind(null,o),t=function(){o.parentNode.removeChild(o)};return r(e),function(o){if(o){if(o.css===e.css&&o.media===e.media&&o.sourceMap===e.sourceMap)return;r(e=o)}else t()}}function i(e,r,t,o){var n=t?"":o.css;if(e.styleSheet)e.styleSheet.cssText=v(r,n);else{var a=document.createTextNode(n),i=e.childNodes;i[r]&&e.removeChild(i[r]),i.length?e.insertBefore(a,i[r]):e.appendChild(a)}}function s(e,r){var t=r.css,o=r.media,n=r.sourceMap;if(o&&e.setAttribute("media",o),n&&(t+="\n/*# sourceURL="+n.sources[0]+" */",t+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */"),e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}var u="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!u)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var l=t(10),c={},p=u&&(document.head||document.getElementsByTagName("head")[0]),d=null,f=0,m=!1,g=function(){},h="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());e.exports=function(e,r,t){m=t;var n=l(e,r);return o(n),function(r){for(var t=[],a=0;a<n.length;a++){var i=n[a],s=c[i.id];s.refs--,t.push(s)}r?(n=l(e,r),o(n)):n=[];for(var a=0;a<t.length;a++){var s=t[a];if(0===s.refs){for(var u=0;u<s.parts.length;u++)s.parts[u]();delete c[s.id]}}}};var v=function(){var e=[];return function(r,t){return e[r]=t,e.filter(Boolean).join("\n")}}()},function(e,r){e.exports=function(e,r){for(var t=[],o={},n=0;n<r.length;n++){var a=r[n],i=a[0],s=a[1],u=a[2],l=a[3],c={id:e+":"+n,css:s,media:u,sourceMap:l};o[i]?o[i].parts.push(c):t.push(o[i]={id:i,parts:[c]})}return t}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t(0),n=t.n(o),a=t(1),i=t.n(a);t.d(r,"Uploader",function(){return n.a}),t.d(r,"WechatUploader",function(){return i.a})}])});
\No newline at end of file