webpackJsonp([31],{ /***/ 4817: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_educoder__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__AccountImg__ = __webpack_require__(4818); var _createClass=function(){function defineProperties(target,props){for(var i=0;i2*1024*1024){this.props.showNotification&&this.props.showNotification("仅支持文件大小小于2M的文件");return;}uploadedImageType=file.type;uploadedImageName=file.name;if(uploadedImageURL){URL.revokeObjectURL(uploadedImageURL);}var image=document.getElementById(imageId);// base64 var reader=new FileReader();reader.readAsBinaryString(file);reader.onload=function(){var base64_content=btoa(reader.result);console.log();image.src="data:"+file.type+";base64,"+base64_content;// uploadedImageURL = URL.createObjectURL(file); that.fileUploaded=true;that.refs['cropper'].renew(image);// cropper.destroy(); // cropper = new Cropper(image, options); inputImage.value=null;};reader.onerror=function(){console.log('there are some problems');};}else{this.props.showNotification&&this.props.showNotification("请选择一个图片格式的文件");// window.alert('Please choose an image file.'); }}};};_this.setVisible=function(visible){_this.refs['modalWrapper'].setVisible(visible);if(visible){_this.fileUploaded=false;setTimeout(function(){_this.init();},500);}};_this.onSendOk=function(){};_this.onOk=function(){if(_this.state.uploading==true)return;if(_this.fileUploaded!=true){_this.props.showNotification("请先上传图片");return;}console.log(new Date().getTime());_this.setState({uploading:true},function(){window.setTimeout(function(){console.log(new Date().getTime());_this._onOk();},10);});};_this._onOk=function(){var img_lg=document.getElementById(previewId);// https://github.com/niklasvh/html2canvas/issues/1908 // 截图小的显示框内的内容 window.html2canvas(img_lg).then(function(canvas){var dataUrl=canvas.toDataURL("image/jpeg");console.log(dataUrl);var url="/users/accounts/"+_this.props.userLogin+"/avatar.json";__WEBPACK_IMPORTED_MODULE_1_axios___default.a.put(url,{image:dataUrl}).then(function(response){// {"status":0,"message":"success","avatar_url":"avatars/User/15739"} if(response.data.status==0){// this.props.getBasicInfo() // https://www.trustie.net/issues/22461 if(_this.props.current_user.image_url.indexOf('avatars/User/b')!=-1||_this.props.current_user.image_url.indexOf('avatars/User/g')!=-1){window.setTimeout(function(){_this.doAfterUpdated();},1000);}else{_this.doAfterUpdated();}_this.setState({uploading:false});}}).catch(function(error){this.setState({uploading:false});console.log(error);});});};_this.doAfterUpdated=function(){_this.props.fetchUser();// 头像更新后会触发AccountPage的DidUpdate,然后会调用getBasicInfo _this.props.showNotification&&_this.props.showNotification("修改头像成功");_this.setVisible(false);};_this.state={uploading:false};return _this;}_createClass(ChangeHeaderPicModal,[{key:"componentDidMount",value:function componentDidMount(){}},{key:"render",value:function render(){var _this2=this;var course_lists=this.state.course_lists;var _props=this.props,moduleName=_props.moduleName,current_user=_props.current_user;var userHeaderImgUrl=current_user?Object(__WEBPACK_IMPORTED_MODULE_3_educoder__["U" /* getUrl */])()+"/images/"+current_user.image_url:'';return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_2__courses_common_ModalWrapper__["a" /* default */],Object.assign({ref:"modalWrapper",title:"\u4E0A\u4F20\u5934\u50CF"},this.props,{onOk:this.onOk,okText:"\u4FDD\u5B58",width:552,className:"changeHeaderModal",loading:this.state.uploading,onCancel:function onCancel(){return _this2.setState({uploading:false});}}),__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("style",null,"\n #changeHeader_imagePreview {\n overflow: hidden;\n background-color: #fff;\n border-radius: 50%;\n text-align: center;\n width: 120px;\n height: 120px;\n /* border: 1px solid #eee; */\n }\n .previewWrap {\n flex-direction: column;\n justify-content: space-between;\n height: 320px;\n align-items: center;\n margin-left: 36px;\n }\n .changeHeaderModal .tip {\n color: #9B9B9B;\n margin-top: 4px;\n }\n .changeHeaderModal .cropperWrap .tip {\n display: inline-block;\n }\n .previewWrap .tip {\n text-align: center;\n margin-top: 4px;\n }\n #uploadBtn {\n color: #4CACFF;\n border: 1px solid #4CACFF;\n padding: 2px 18px;\n cursor: pointer;\n }\n "),__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div",{className:"df"},__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div",{className:"cropperWrap"},__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_3_educoder__["h" /* Cropper */],{imageSrc:'',initPreviewUrl:userHeaderImgUrl,ref:"cropper",imageId:imageId,previewId:"changeHeader_imagePreview",width:320,height:320}),__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("span",{className:"tip"},"\u4EC5\u652F\u6301JPG\u3001GIF\u3001PNG\uFF0C\u4E14\u6587\u4EF6\u5C0F\u4E8E2M")),__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div",{className:"df previewWrap",style:{flexDirection:'column'}},__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div",null,__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div",{id:"changeHeader_imagePreview"},userHeaderImgUrl&&__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("img",{src:userHeaderImgUrl})),__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div",{className:"tip"},"\u5934\u50CF\u9884\u89C8")),__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("label",{id:"uploadBtn","for":"inputImage"},__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("input",{type:"file","class":"sr-only",id:"inputImage",name:"file",accept:"image/*"}),"\u70B9\u51FB\u4E0A\u4F20"))));}}]);return ChangeHeaderPicModal;}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);/* harmony default export */ __webpack_exports__["a"] = (ChangeHeaderPicModal); /***/ }), /***/ 838: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_router_dom__ = __webpack_require__(48); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__courses_common_CNotificationHOC__ = __webpack_require__(334); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Loading__ = __webpack_require__(324); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react_loadable__ = __webpack_require__(325); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_react_loadable___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_react_loadable__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__tpm_TPMIndexHOC__ = __webpack_require__(323); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_educoder__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__account_AccountNav__ = __webpack_require__(4817); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_axios__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_axios___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8_axios__); var _createClass=function(){function defineProperties(target,props){for(var i=0;i