From bb49f978c923e5d310a023e4eb821eac4badaab3 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Thu, 26 Sep 2019 15:40:47 +0800 Subject: [PATCH] loading --- .../modules/courses/common/ModalWrapper.js | 6 +++-- .../user/account/ChangeHeaderPicModal.js | 22 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/common/ModalWrapper.js b/public/react/src/modules/courses/common/ModalWrapper.js index e92a508d6..8b7e87692 100644 --- a/public/react/src/modules/courses/common/ModalWrapper.js +++ b/public/react/src/modules/courses/common/ModalWrapper.js @@ -1,5 +1,5 @@ import React,{ Component } from "react"; -import { Modal,Input, Checkbox} from "antd"; +import { Modal,Input, Checkbox, Spin} from "antd"; import '../css/members.css' class ModalWrapper extends Component{ @@ -23,7 +23,7 @@ class ModalWrapper extends Component{ } render(){ let {flag, visible}=this.state - let { onOk, cancelText, okText, title, width, className, bottomRender}=this.props; + let { onOk, cancelText, okText, title, width, className, bottomRender, loading}=this.props; return( :"" } + {this.props.children} {this.props.checkBoxValuestype===true? @@ -59,6 +60,7 @@ class ModalWrapper extends Component{ { bottomRender } + ) } diff --git a/public/react/src/modules/user/account/ChangeHeaderPicModal.js b/public/react/src/modules/user/account/ChangeHeaderPicModal.js index 197e84a5c..0a2205261 100644 --- a/public/react/src/modules/user/account/ChangeHeaderPicModal.js +++ b/public/react/src/modules/user/account/ChangeHeaderPicModal.js @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import { Modal } from "antd"; +import { Spin } from "antd"; import axios from 'axios' import ModalWrapper from "../../courses/common/ModalWrapper" import { Cropper, getUrl } from 'educoder' @@ -13,7 +13,7 @@ class ChangeHeaderPicModal extends Component{ constructor(props){ super(props); this.state={ - + uploading: false } } init = () => { @@ -85,12 +85,23 @@ class ChangeHeaderPicModal extends Component{ } - onOk = () => { + if (this.state.uploading == true) return; if (this.fileUploaded != true) { this.props.showNotification("请先上传图片") return; } + console.log(new Date().getTime()) + this.setState({ uploading: true }, () => { + window.setTimeout(() => { + console.log(new Date().getTime()) + this._onOk() + }, 10) + + }) + } + _onOk = () => { + var img_lg = document.getElementById(previewId); // https://github.com/niklasvh/html2canvas/issues/1908 // 截图小的显示框内的内容 @@ -115,9 +126,12 @@ class ChangeHeaderPicModal extends Component{ } else { this.doAfterUpdated(); } + this.setState({ uploading: false }) } }) .catch(function (error) { + this.setState({ uploading: false }) + console.log(error); }); }); @@ -142,6 +156,8 @@ class ChangeHeaderPicModal extends Component{ okText="保存" width={552} className="changeHeaderModal" + loading={this.state.uploading} + onCancel={() => this.setState({ uploading: false })} >