mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-09 10:56:47 +08:00
1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pages-my-headimg"],{"09d3":function(t,i,e){"use strict";var a=e("4ea4");e("d3b7");a(e("b85c"));e("96cf");a(e("1da1"));var n=a(e("be8c")),s=e("5cd5");function o(t,i){return new Promise((function(e,a){uni.uploadFile({header:{"XBOE-Access-Token":(0,s.getToken)()},url:n.default.apiBaseUrl+"/xboe/sys/xuploader/file/upload",filePath:t,name:"file",formData:i,success:function(t){e(JSON.parse(t.data))}})}))}function r(t,i){return new Promise((function(e,a){uni.uploadFile({header:{"XBOE-Access-Token":(0,s.getToken)()},url:n.default.apiBaseUrl+"/xboe/sys/xuploader/file/upload",file:t,name:"file",formData:i,success:function(t){e(JSON.parse(t.data))}})}))}t.exports={uploadFile:o,uploadFileObject:r}},"260c":function(t,i,e){"use strict";e.d(i,"b",(function(){return n})),e.d(i,"c",(function(){return s})),e.d(i,"a",(function(){return a}));var a={uIcon:e("fabd").default},n=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("v-uni-view",{staticStyle:{position:"relative"}},[e("v-uni-image",{staticClass:"my-avatar",style:t.imgStyle,attrs:{src:t.imgSrc.imgSrc,mode:"aspectFill"},on:{click:function(i){arguments[0]=i=t.$handleEvent(i),t.fSelect.apply(void 0,arguments)}}}),e("v-uni-canvas",{staticClass:"my-canvas",style:{top:t.styleTop,height:t.cvsStyleHeight},attrs:{"canvas-id":"avatar-canvas",id:"avatar-canvas","disable-scroll":"false"}}),""==t.imgSrc.imgSrc?e("v-uni-view",{staticStyle:{position:"absolute",top:"50%",left:"50%","margin-left":"-29px","margin-top":"-29px"},on:{click:function(i){arguments[0]=i=t.$handleEvent(i),t.fSelect.apply(void 0,arguments)}}},[e("u-icon",{attrs:{name:"plus",color:"#ccc",size:"58"}})],1):t._e(),e("v-uni-canvas",{staticClass:"oper-canvas",style:{top:t.styleTop,height:t.cvsStyleHeight},attrs:{"canvas-id":"oper-canvas",id:"oper-canvas","disable-scroll":"false"},on:{touchstart:function(i){arguments[0]=i=t.$handleEvent(i),t.fStart.apply(void 0,arguments)},touchmove:function(i){arguments[0]=i=t.$handleEvent(i),t.fMove.apply(void 0,arguments)},touchend:function(i){arguments[0]=i=t.$handleEvent(i),t.fEnd.apply(void 0,arguments)}}}),e("v-uni-view",{staticClass:"oper-wrapper",style:{display:t.styleDisplay}},[t.showOper?e("v-uni-view",{staticClass:"btn-wrapper"},[e("v-uni-view",{attrs:{"hover-class":"hover"},on:{click:function(i){arguments[0]=i=t.$handleEvent(i),t.fClose.apply(void 0,arguments)}}},[t._v("取消")]),e("v-uni-view",{attrs:{"hover-class":"hover"},on:{click:function(i){arguments[0]=i=t.$handleEvent(i),t.fUpload.apply(void 0,arguments)}}},[t._v("选取")])],1):t._e()],1)],1)},s=[]},"35a7":function(t,i,e){"use strict";e.r(i);var a=e("7a9e"),n=e.n(a);for(var s in a)"default"!==s&&function(t){e.d(i,t,(function(){return a[t]}))}(s);i["default"]=n.a},"611f":function(t,i,e){var a=e("24fb");i=a(!1),i.push([t.i,".my-canvas[data-v-11fd36cf]{display:flex;position:fixed!important;background:#000;left:0;z-index:100;width:100%}.my-avatar[data-v-11fd36cf]{width:100vw;height:100vw}.oper-canvas[data-v-11fd36cf]{display:flex;position:fixed!important;left:0;z-index:101;width:100%}.oper-wrapper[data-v-11fd36cf]{height:71px;position:fixed!important;box-sizing:border-box;width:100%;left:0;bottom:0;z-index:200;flex-direction:row}.btn-wrapper[data-v-11fd36cf]{background-color:#000;color:#fff;display:flex;height:100%;width:100%;justify-content:space-around;align-items:center}.btn-wrapper uni-view[data-v-11fd36cf]{width:%?160?%;height:%?80?%;line-height:%?80?%;text-align:center;font-size:16px;color:#fff;z-index:300}.hover[data-v-11fd36cf]{color:#f1f1f1}",""]),t.exports=i},"6c42":function(t,i,e){"use strict";e.r(i);var a=e("260c"),n=e("e96c");for(var s in n)"default"!==s&&function(t){e.d(i,t,(function(){return n[t]}))}(s);e("986e");var o,r=e("f0c5"),h=Object(r["a"])(n["default"],a["b"],a["c"],!1,null,"11fd36cf",null,!1,a["a"],o);i["default"]=h.exports},"7a9e":function(t,i,e){"use strict";var a=e("4ea4");Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var n=a(e("6c42")),s=a(e("5f95")),o=a(e("09d3")),r=(a(e("be8c")),e("26cb")),h={components:{cropper:n.default},computed:(0,r.mapGetters)(["userInfo"]),data:function(){return{loading:!0,isNew:!1,imgurl:"",filePath:"",aid:""}},onShow:function(){var t=this;this.$store.dispatch("GetUserInfo").then((function(i){t.imgurl=i.avatar,t.aid=i.aid,t.loading=!1}))},methods:{uploadImg:function(t){var i=this;this.imgurl=t.path,o.default.uploadFileObject(t.file).then((function(t){200==t.status&&(i.imgurl=t.result.httpPath,i.filePath=t.result.filePath,i.isNew=!0)}))},submitUpdate:function(){var t=this;""!==this.filePath&&this.isNew&&s.default.updateAvatar({id:t.aid,avatar:t.filePath}).then((function(i){200==i.status?(t.$store.dispatch("InitData"),uni.showModal({icon:"success",title:"更新成功",showCancel:!1,success:function(){uni.navigateBack(-1)}})):uni.showToast({title:"更新失败"})}))}}};i.default=h},"946b":function(t,i,e){"use strict";e.d(i,"b",(function(){return n})),e.d(i,"c",(function(){return s})),e.d(i,"a",(function(){return a}));var a={pageTitle:e("151d").default},n=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("v-uni-view",[e("page-title",{attrs:{showBack:!0}},[t._v("更换头像")]),e("v-uni-view",{staticStyle:{"text-align":"center",padding:"20upx",color:"#6b6b6b"}},[t._v("点击选择修改头像图片")]),e("v-uni-view",{staticStyle:{"margin-top":"50upx","text-align":"center",width:"360upx",height:"360upx",margin:"0upx auto","background-color":"#FFFFFF",position:"relative"}},[e("cropper",{attrs:{selWidth:"660rpx",selHeight:"660rpx",avatarSrc:t.imgurl,avatarStyle:"width:50vw;height:50vw;"},on:{upload:function(i){arguments[0]=i=t.$handleEvent(i),t.uploadImg.apply(void 0,arguments)}}})],1),t.isNew?e("v-uni-view",[e("v-uni-view",{staticStyle:{"margin-top":"100upx"}},[e("v-uni-button",{staticStyle:{width:"50%"},attrs:{type:"primary"},on:{click:function(i){arguments[0]=i=t.$handleEvent(i),t.submitUpdate.apply(void 0,arguments)}}},[t._v("提交修改")])],1)],1):t._e()],1)},s=[]},"986e":function(t,i,e){"use strict";var a=e("efb8"),n=e.n(a);n.a},b85c:function(t,i,e){"use strict";e("a4d3"),e("e01a"),e("d28b"),e("d3b7"),e("3ca3"),e("ddb0"),Object.defineProperty(i,"__esModule",{value:!0}),i.default=s;var a=n(e("06c5"));function n(t){return t&&t.__esModule?t:{default:t}}function s(t,i){var e;if("undefined"===typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=(0,a.default)(t))||i&&t&&"number"===typeof t.length){e&&(t=e);var n=0,s=function(){};return{s:s,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,r=!0,h=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return r=t.done,t},e:function(t){h=!0,o=t},f:function(){try{r||null==e["return"]||e["return"]()}finally{if(h)throw o}}}}},e96c:function(t,i,e){"use strict";e.r(i);var a=e("fc21"),n=e.n(a);for(var s in a)"default"!==s&&function(t){e.d(i,t,(function(){return a[t]}))}(s);i["default"]=n.a},efb8:function(t,i,e){var a=e("611f");"string"===typeof a&&(a=[[t.i,a,""]]),a.locals&&(t.exports=a.locals);var n=e("4f06").default;n("5eb32276",a,!0,{sourceMap:!1,shadowMode:!1})},f9d2:function(t,i,e){"use strict";e.r(i);var a=e("946b"),n=e("35a7");for(var s in n)"default"!==s&&function(t){e.d(i,t,(function(){return n[t]}))}(s);var o,r=e("f0c5"),h=Object(r["a"])(n["default"],a["b"],a["c"],!1,null,"b85ad458",null,!1,a["a"],o);i["default"]=h.exports},fc21:function(t,i,e){"use strict";var a=e("4ea4");e("c975"),e("ace4"),e("d3b7"),e("e25e"),e("ac1f"),e("3ca3"),e("466d"),e("1276"),e("5cc6"),e("9a8c"),e("a975"),e("735e"),e("c1ac"),e("d139"),e("3a7b"),e("d5d6"),e("82f8"),e("e91f"),e("60bd"),e("5f96"),e("3280"),e("3fcc"),e("ca91"),e("25a1"),e("cd26"),e("2954"),e("649e"),e("219c"),e("b39a"),e("72f7"),e("ddb0"),e("2b3d"),Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0,e("96cf");var n=a(e("1da1")),s=70,o={name:"cropper",data:function(){return{cvsStyleHeight:"0px",styleDisplay:"none",styleTop:"-10000px",prvTop:"-10000px",imgStyle:{},selStyle:{},showOper:!0,imgSrc:{imgSrc:""},qlty:.9,postWidthFirst:{}}},watch:{avatarSrc:function(){this.imgSrc.imgSrc=this.avatarSrc}},props:{avatarSrc:"",avatarStyle:"",selWidth:"",selHeight:"",expWidth:"",expHeight:"",minScale:"",maxScale:"",canScale:"",noTop:"",quality:"",index:""},created:function(){var t=this;this.ctxCanvas=uni.createCanvasContext("avatar-canvas",this),this.ctxCanvasOper=uni.createCanvasContext("oper-canvas",this),this.qlty=parseInt(this.quality)||.9,this.imgSrc.imgSrc=this.avatarSrc,this.letScale="false"===this.canScale?0:1,this.indx=this.index||void 0,this.mnScale=this.minScale||.3,this.mxScale=this.maxScale||4,this.noBar=!this.noTop,this.noBar?(this.moreHeight=0,this.fWindowResize()):uni.showTabBar({complete:function(i){t.moreHeight="showTabBar:ok"===i.errMsg?50:0,t.fWindowResize()}})},methods:{fWindowResize:function(){var t=uni.getSystemInfoSync();this.platform=t.platform,this.pixelRatio=t.pixelRatio,this.windowWidth=t.windowWidth,this.drawTop=t.windowTop,this.windowHeight=t.windowHeight+t.windowBottom,this.cvsStyleHeight=this.windowHeight-s+"px",this.pxRatio=this.windowWidth/750;var i=this.avatarStyle;this.imgStyle=i,this.expWidth&&(this.exportWidth=this.expWidth.indexOf("rpx")>=0?parseInt(this.expWidth)*this.pxRatio:parseInt(this.expWidth)),this.expHeight&&(this.exportHeight=this.expHeight.indexOf("rpx")>=0?parseInt(this.expHeight)*this.pxRatio:parseInt(this.expHeight)),"flex"===this.styleDisplay&&this.fDrawInit(!0),this.fHideImg()},fSelect:function(){var t=this,i=this;this.fSelecting||(this.fSelecting=!0,setTimeout((function(){t.fSelecting=!1}),500),uni.chooseImage({count:1,sizeType:["original","compressed"],sourceType:["camera","album"],success:function(e){uni.showLoading({mask:!0});var a=t.imgPath=e.tempFilePaths[0];uni.getImageInfo({src:a,success:function(e){if(t.imgWidth=e.width,t.imgHeight=e.height,t.path=a,!t.hasSel){var n=t.selStyle||{};if(!t.selWidth||!t.selHeight)return void uni.showModal({title:"裁剪框的宽或高没有设置",showCancel:!1});var o=t.selWidth.indexOf("rpx")>=0?parseInt(t.selWidth)*t.pxRatio:parseInt(t.selWidth),r=t.selHeight.indexOf("rpx")>=0?parseInt(t.selHeight)*t.pxRatio:parseInt(t.selHeight);n.width=parseInt(o),n.height=parseInt(r),n.top=parseInt((t.windowHeight-n.height-s)/2),n.left=parseInt((t.windowWidth-n.width)/2),t.selStyle=n}i.noBar?i.fDrawInit(!0):uni.hideTabBar({complete:function(){i.fDrawInit(!0)}})},fail:function(){uni.showToast({title:"error3",duration:2e3})},complete:function(){uni.hideLoading()}})}}))},fUpload:function(){var t=this,i=this;if(!this.fUploading){this.fUploading=!0,setTimeout((function(){t.fUploading=!1}),1e3);var e=this.selStyle,a=parseInt(e.left),n=parseInt(e.top),s=parseInt(e.width),o=parseInt(e.height),r=this.exportWidth||s,h=this.exportHeight||o;this.styleDisplay="none",this.styleTop="-10000px",this.hasSel=!1,this.fHideImg(),uni.canvasToTempFilePath({x:a,y:n,width:s,height:o,destWidth:r,destHeight:h,canvasId:"avatar-canvas",fileType:"png",quality:this.qlty,success:function(e){e=e.tempFilePath;var a=i.base64toFile(e,Math.floor(1e5*Math.random()+1)+".png");t.btop(e).then((function(e){if(t.exportWidth&&t.exportHeight){var n=t.ctxCanvas;r=t.exportWidth,h=t.exportHeight,n.drawImage(e,0,0,r,h),n.draw(!1,(function(){uni.canvasToTempFilePath({x:0,y:0,width:r,height:h,destWidth:r,destHeight:h,canvasId:"avatar-canvas",fileType:"png",quality:t.qlty,success:function(e){e=e.tempFilePath;var a=i.base64toFile(e,Math.floor(1e5*Math.random()+1)+".png");t.btop(e).then((function(i){t.$emit("upload",{avatar:t.imgSrc,path:i,file:a,index:t.indx})}))},fail:function(){uni.showToast({title:"error0",duration:2e3})}})}))}else t.$emit("upload",{avatar:t.imgSrc,path:e,file:a,index:t.indx})}))},fail:function(t){uni.showToast({title:"error1",duration:2e3})},complete:function(){t.noBar||uni.showTabBar()}},this)}},fDrawInit:function(){var t=this,i=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.windowWidth,a=this.windowHeight,n=this.imgWidth,o=this.imgHeight,r=n/o,h=e,l=a-s,c=(this.pixelRatio,parseInt(this.selStyle.width)),d=parseInt(this.selStyle.height);this.fixWidth=0,this.fixHeight=0,this.fixWidth?(h=c,l=h/r):this.fixHeight?(l=d,h=l*r):r<1?(h=c,l=parseInt(h/r)):(l=d,h=parseInt(l*r)),this.scaleSize=1,this.rotateDeg=0,this.posWidth=parseInt((e-h)/2),this.posHeight=parseInt((a-l-s)/2),this.useWidth=h,this.useHeight=l;var u=this.selStyle,p=parseInt(u.left),f=parseInt(u.top),v=parseInt(u.width),g=parseInt(u.height),w=(this.canvas,this.canvasOper,this.ctxCanvas),m=this.ctxCanvasOper;m.setFillStyle("rgba(0,0,0, 0.5)"),m.fillRect(0,0,this.windowWidth,f),m.fillRect(0,f,p,g),m.fillRect(0,f+g,this.windowWidth,this.windowHeight-g-s-f),m.fillRect(p+v,f,this.windowWidth-v-p,g),m.setLineWidth(1),m.setStrokeStyle("rgba(255, 255, 255,1)"),m.strokeRect(p,f,v,g),m.draw(),m.setLineWidth(3),m.setStrokeStyle("rgba(255, 255, 255, 1)"),m.moveTo(p+20,f),m.lineTo(p,f),m.lineTo(p,f+20),m.moveTo(p+v-20,f),m.lineTo(p+v,f),m.lineTo(p+v,f+20),m.moveTo(p+20,f+g),m.lineTo(p,f+g),m.lineTo(p,f+g-20),m.moveTo(p+v-20,f+g),m.lineTo(p+v,f+g),m.lineTo(p+v,f+g-20),m.stroke(),this.postFirst={left:p,top:f,width:v,height:c,posWidth:this.posWidth,posHeight:this.posHeight},m.draw(!0,(function(){i&&(t.styleDisplay="flex",t.styleTop=t.drawTop+"px",w.setFillStyle("black"),t.fDrawImage())})),this.$emit("avtinit")},fDrawImage:function(){var t=Date.now();if(!(t-this.drawTm<20)){this.drawTm=t;var i=this.ctxCanvas;i.fillRect(0,0,this.windowWidth,this.windowHeight-s),i.translate(this.posWidth+this.useWidth/2,this.posHeight+this.useHeight/2),i.scale(this.scaleSize,this.scaleSize),i.drawImage(this.imgPath,-this.useWidth/2,-this.useHeight/2,this.useWidth,this.useHeight),i.draw(!1)}},fHideImg:function(){this.prvImg="",this.prvTop="-10000px",this.showOper=!0,this.prvImgData=null,this.target=null},fClose:function(){this.styleDisplay="none",this.styleTop="-10000px",this.hasSel=!1,this.fHideImg(),this.noBar||uni.showTabBar()},fStart:function(t){var i=t.touches,e=i[0],a=i[1];if(this.touch0=e,this.touch1=a,a){var n=a.clientX-e.clientX,s=a.clientY-e.clientY;this.fgDistance=Math.sqrt(n*n+s*s)}},fMove:function(t){var i=t.touches,e=i[0],a=i[1];if(a){var n=a.clientX-e.clientX,s=a.clientY-e.clientY,o=Math.sqrt(n*n+s*s),r=.005*(o-this.fgDistance),h=this.scaleSize+r;do{if(!this.letScale)break;if(h<this.mnScale)break;if(h>this.mxScale)break;this.scaleSize=h}while(0);this.fgDistance=o,a.x!==e.x&&this.letRotate&&(n=(this.touch1.clientY-this.touch0.clientY)/(this.touch1.clientX-this.touch0.clientX),s=(a.clientY-e.clientY)/(a.clientX-e.clientX),this.rotateDeg+=180*Math.atan((s-n)/(1+n*s))/Math.PI,this.touch0=e,this.touch1=a),this.fDrawImage()}else if(this.touch0){var l=e.clientX-this.touch0.clientX,c=e.clientY-this.touch0.clientY,d=this.posWidth+l,u=this.posHeight+c;Math.abs(l)<100&&!this.lckWidth&&(this.posWidth=d),Math.abs(c)<100&&!this.lckHeight&&(this.posHeight=u),this.touch0=e,this.fDrawImage()}},fEnd:function(t){var i=this;return(0,n.default)(regeneratorRuntime.mark((function e(){var a,n,s,o,r,h,l,c,d;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:a=i,n=t.touches,s=n&&n[0],n&&n[1],a.scaleSize<1?(o=a.selStyle,r=a.imgWidth/a.imgHeight,r<1&&a.scaleSize*a.useWidth<o.width?(a.posWidth=o.left,a.scaleSize=1,setTimeout((function(){a.fDrawImage()}),100)):a.scaleSize*a.useHeight<o.width&&(a.posHeight=o.top,a.scaleSize=1,setTimeout((function(){a.fDrawImage()}),100))):1==i.scaleSize&&(h=i.posWidth-i.postFirst.posWidth,l=i.postFirst.left-i.postFirst.posWidth,c=i.posHeight-i.postFirst.posHeight,d=i.postFirst.top-i.postFirst.posHeight,h>0&&i.posWidth>i.postFirst.left?i.posWidth=i.postFirst.left:h<0&&h<l&&(i.posWidth=-i.postFirst.left+2*i.postFirst.posWidth),c<0&&i.posHeight<i.postFirst.top?i.posHeight=-i.postFirst.top+2*i.postFirst.posHeight:c>0&&c>d&&(i.posHeight=i.postFirst.top),setTimeout((function(){a.fDrawImage()}),100)),s?i.touch0=s:(i.touch0=null,i.touch1=null);case 4:case"end":return e.stop()}}),e)})))()},btop:function(t){var i=this;return new Promise((function(e,a){var n=i.base64toBlob(t),s=(window.URL||window.webkitURL).createObjectURL(n);return e(s)}))},base64toBlob:function(t){var i=t.split(","),e=i[0].match(/:(.*?);/)[1],a=atob(i[1]),n=a.length,s=new Uint8Array(n);while(n--)s[n]=a.charCodeAt(n);return new Blob([s],{type:e})},base64toFile:function(t,i){var e=t.split(","),a=e[0].match(/:(.*?);/)[1],n=atob(e[1]),s=n.length,o=new Uint8Array(s);while(s--)o[s]=n.charCodeAt(s);return new File([o],i,{type:a})}}};i.default=o}}]); |