1
0

index.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. import React, { Component } from 'react';
  2. import Cropper from 'react-cropper';
  3. import 'cropperjs/dist/cropper.css';
  4. import './index.less';
  5. import { Checkbox } from 'antd';
  6. import FileUpload from '@src/components/FileUpload';
  7. import Assets from '@src/components/Assets';
  8. import scale from '@src/services/Scale';
  9. import { asyncSMessage } from '@src/services/AsyncTools';
  10. import { SelectInput, VerificationInput, Input } from '../Login';
  11. import { MobileArea } from '../../../Constant';
  12. import Invite from '../Invite';
  13. import Modal from '../Modal';
  14. import { Common } from '../../stores/common';
  15. import { User } from '../../stores/user';
  16. import { My } from '../../stores/my';
  17. import Select from '../Select';
  18. export class BindPhone extends Component {
  19. constructor(props) {
  20. super(props);
  21. this.props.data = this.props.data || {};
  22. this.state = Object.assign({ step: 0, data: {} }, this.initState(this.props));
  23. this.stepProp = {
  24. 0: {
  25. title: '绑定手机',
  26. onConfirm: props.onConfirm,
  27. },
  28. 1: {
  29. title: '绑定手机',
  30. onConfirm: () => {
  31. this.submit();
  32. },
  33. onCancel: props.onCancel,
  34. confirmText: '提交',
  35. },
  36. };
  37. }
  38. initState(props) {
  39. if (!props.show || this.props.show) return {};
  40. const data = Object.assign({}, props.data);
  41. if (!data.area) data.area = MobileArea[0].value;
  42. return { step: props.data.mobile ? 0 : 1, data };
  43. }
  44. componentWillReceiveProps(nextProps) {
  45. this.setState(this.initState(nextProps));
  46. }
  47. onNext() {
  48. this.setState({ step: 1 });
  49. }
  50. changeData(field, value) {
  51. let { data } = this.state;
  52. data = data || {};
  53. data[field] = value;
  54. this.setState({ data, error: null });
  55. }
  56. validMobile() {
  57. const { data } = this.state;
  58. const { area, mobile } = data;
  59. if (!area || !mobile) return;
  60. this.validNumber += 1;
  61. const number = this.validNumber;
  62. User.validMobile(area, mobile)
  63. .then(result => {
  64. if (number !== this.validNumber) return Promise.resolve();
  65. return result ? Promise.resolve() : Promise.reject(new Error('该手机已绑定其他账号,请更换手机号码'));
  66. })
  67. .catch(err => {
  68. this.setState({ mobileError: err.message });
  69. });
  70. }
  71. sendValid() {
  72. const { data, error } = this.state;
  73. const { area, mobile } = data;
  74. if (!area || !mobile || error) return Promise.reject();
  75. return Common.sendSms(area, mobile)
  76. .then(result => {
  77. if (result) {
  78. asyncSMessage('发送成功');
  79. this.setState({ error: '', validError: '' });
  80. } else {
  81. throw new Error('发送失败');
  82. }
  83. })
  84. .catch(err => {
  85. this.setState({ error: err.message });
  86. throw err;
  87. });
  88. }
  89. submit() {
  90. const { data, error } = this.state;
  91. if (!data.mobile || !data.area || error) return;
  92. const { area, mobile } = data;
  93. My.bindMobile(area, mobile)
  94. .then(() => {
  95. asyncSMessage('操作成功');
  96. this.setState({ step: 0 });
  97. User.infoHandle(Object.assign(this.props.data, { area, mobile }));
  98. this.props.onConfirm();
  99. })
  100. .catch(e => {
  101. this.setState({ error: e.message });
  102. });
  103. }
  104. render() {
  105. const { show } = this.props;
  106. const { step = 0 } = this.state;
  107. return (
  108. <Modal className="bind-phone-modal" show={show} width={630} {...this.stepProp[step]}>
  109. <div className="bind-phone-modal-wrapper">{this[`renderStep${step}`]()}</div>
  110. </Modal>
  111. );
  112. }
  113. renderStep0() {
  114. const { data } = this.state;
  115. return (
  116. <div className="step-0-layout">
  117. 已绑定手机 {data.mobile}
  118. <a onClick={() => this.onNext()}>修改</a>
  119. </div>
  120. );
  121. }
  122. renderStep1() {
  123. return (
  124. <div className="step-1-layout">
  125. <div className="label">手机号</div>
  126. <div className="input-layout">
  127. <SelectInput
  128. placeholder="请输入手机号"
  129. selectValue={this.state.data.area}
  130. select={MobileArea}
  131. value={this.state.data.mobile}
  132. error={this.state.error}
  133. onSelect={value => {
  134. this.changeData('area', value);
  135. this.validMobile();
  136. }}
  137. onChange={e => {
  138. this.changeData('mobile', e.target.value);
  139. this.validMobile();
  140. }}
  141. />
  142. <VerificationInput
  143. placeholder="请输入验证码"
  144. value={this.state.data.mobileVerifyCode}
  145. error={this.state.validError}
  146. onSend={() => {
  147. return this.sendValid();
  148. }}
  149. onChange={e => {
  150. this.changeData('mobileVerifyCode', e.target.value);
  151. }}
  152. />
  153. </div>
  154. </div>
  155. );
  156. }
  157. }
  158. export class BindEmail extends Component {
  159. constructor(props) {
  160. super(props);
  161. this.props.data = this.props.data || {};
  162. this.state = Object.assign({ step: 0, data: {} }, this.initState(this.props));
  163. this.stepProp = {
  164. 0: {
  165. title: '绑定邮箱',
  166. onConfirm: props.onConfirm,
  167. },
  168. 1: {
  169. title: '绑定邮箱',
  170. onConfirm: () => {
  171. this.submit();
  172. },
  173. onCancel: props.onCancel,
  174. confirmText: '提交',
  175. },
  176. };
  177. }
  178. initState(props) {
  179. if (!props.show || this.props.show) return {};
  180. return { step: props.data.email ? 0 : 1, data: Object.assign({}, props.data) };
  181. }
  182. componentWillReceiveProps(nextProps) {
  183. this.setState(this.initState(nextProps));
  184. }
  185. onNext() {
  186. this.setState({ step: 1 });
  187. }
  188. changeData(field, value) {
  189. let { data } = this.state;
  190. data = data || {};
  191. data[field] = value;
  192. this.setState({ data, error: null });
  193. }
  194. submit() {
  195. const { data, error } = this.state;
  196. if (!data.email || error) return;
  197. const { email } = data;
  198. My.bindEmail(email)
  199. .then(() => {
  200. asyncSMessage('操作成功');
  201. this.setState({ step: 0 });
  202. User.infoHandle(Object.assign(this.props.data, { email }));
  203. this.props.onConfirm();
  204. })
  205. .catch(e => {
  206. this.setState({ error: e.message });
  207. });
  208. }
  209. render() {
  210. const { show } = this.props;
  211. const { step = 0 } = this.state;
  212. return (
  213. <Modal className="bind-email-modal" show={show} width={630} {...this.stepProp[step]}>
  214. <div className="bind-email-modal-wrapper">{this[`renderStep${step}`]()}</div>
  215. </Modal>
  216. );
  217. }
  218. renderStep0() {
  219. const { data } = this.state;
  220. return (
  221. <div className="step-0-layout">
  222. 已绑定邮箱 {data.email}
  223. <a onClick={() => this.onNext()}>修改</a>
  224. </div>
  225. );
  226. }
  227. renderStep1() {
  228. return (
  229. <div className="step-1-layout">
  230. <div className="label">邮箱地址</div>
  231. <div className="input-layout">
  232. <Input
  233. placeholder="请输入邮箱"
  234. value={this.state.data.email}
  235. error={this.state.error}
  236. onChange={e => {
  237. this.changeData('email', e.target.value);
  238. }}
  239. />
  240. </div>
  241. </div>
  242. );
  243. }
  244. }
  245. export class EditInfo extends Component {
  246. constructor(props) {
  247. super(props);
  248. this.props.data = this.props.data || {};
  249. this.state = Object.assign({ data: {} }, this.initState(this.props));
  250. }
  251. initState(props) {
  252. if (props.image && this.waitImage) {
  253. const { state } = this;
  254. Common.upload(props.image)
  255. .then(result => {
  256. const { data } = this.state;
  257. data.avatar = result.url;
  258. this.setState({ data, uploading: false });
  259. })
  260. .catch(e => {
  261. this.setState({ imageError: e.message });
  262. });
  263. state.uploading = true;
  264. this.waitImage = false;
  265. return state;
  266. }
  267. if (!props.show || this.props.show) return {};
  268. return { data: Object.assign({}, props.data) };
  269. }
  270. componentWillReceiveProps(nextProps) {
  271. this.setState(this.initState(nextProps));
  272. }
  273. changeData(field, value) {
  274. let { data } = this.state;
  275. data = data || {};
  276. data[field] = value;
  277. this.setState({ data, error: null });
  278. }
  279. submit() {
  280. const { data, error } = this.state;
  281. if (!data.nickname || error) return;
  282. const { nickname, avatar } = data;
  283. My.editInfo({ nickname, avatar })
  284. .then(() => {
  285. asyncSMessage('操作成功');
  286. User.infoHandle(Object.assign(this.props.data, { nickname, avatar }));
  287. this.props.onConfirm();
  288. })
  289. .catch(e => {
  290. this.setState({ error: e.message });
  291. });
  292. }
  293. render() {
  294. const { show, onCancel, onSelectImage } = this.props;
  295. return (
  296. <Modal
  297. className="edit-info-modal"
  298. show={show}
  299. width={630}
  300. title="修改资料"
  301. confirmText="保存"
  302. onCancel={onCancel}
  303. onConfirm={() => {
  304. this.submit();
  305. }}
  306. >
  307. <div className="edit-info-modal-wrapper">
  308. <div className="edit-info-modal-block">
  309. <div className="label">昵称</div>
  310. <div className="input-layout">
  311. <Input
  312. placeholder="2-20位,不可使用特殊字符。"
  313. value={this.state.data.nickname || ''}
  314. error={this.state.error}
  315. onChange={e => {
  316. this.changeData('nickname', e.target.value);
  317. }}
  318. />
  319. </div>
  320. </div>
  321. <div className="edit-info-modal-block">
  322. <div className="label">头像</div>
  323. <div className="input-layout">
  324. <FileUpload
  325. uploading={this.state.uploading}
  326. value={this.state.data.avatar}
  327. onUpload={({ file }) => {
  328. this.waitImage = true;
  329. onSelectImage(file);
  330. return Promise.reject();
  331. }}
  332. />
  333. {this.state.imageError || ''}
  334. </div>
  335. </div>
  336. </div>
  337. </Modal>
  338. );
  339. }
  340. }
  341. export class RealAuth extends Component {
  342. constructor(props) {
  343. super(props);
  344. this.state = { data: {} };
  345. }
  346. render() {
  347. const { show, onConfirm } = this.props;
  348. return (
  349. <Modal
  350. className="real-auth-modal"
  351. show={show}
  352. width={630}
  353. title="实名认证"
  354. confirmText="好的,知道了"
  355. btnAlign="center"
  356. onConfirm={onConfirm}
  357. >
  358. <div className="real-auth-modal-wrapper">
  359. <div className="real-auth-text">
  360. <div className="t1">完成实名认证即可领取:</div>
  361. <div className="t2">6个月VIP权限 和 5折机经优惠劵。</div>
  362. <div className="t3">扫码关注公众号,点击“我的-实名认证”</div>
  363. </div>
  364. <div className="real-auth-qrcode">
  365. <Assets name="qrcode" />
  366. </div>
  367. </div>
  368. </Modal>
  369. );
  370. }
  371. }
  372. export class EditAvatar extends Component {
  373. constructor(props) {
  374. super(props);
  375. this.state = Object.assign({ data: {} }, this.initState(this.props));
  376. }
  377. initState(props) {
  378. if (props.image) this.loadImage(props.image);
  379. if (!props.show || this.props.show) return {};
  380. return { data: {} };
  381. }
  382. componentWillReceiveProps(nextProps) {
  383. this.setState(this.initState(nextProps));
  384. }
  385. loadImage(file) {
  386. this.defaultZoomValue = 1;
  387. if (window.FileReader) {
  388. const reader = new FileReader();
  389. reader.readAsDataURL(file);
  390. // 渲染文件
  391. reader.onload = arg => {
  392. this.setState({ image: arg.target.result, fileName: file.name, zoomValue: 1 });
  393. };
  394. } else {
  395. const img = new Image();
  396. img.onload = function() {
  397. const canvas = document.createElement('canvas');
  398. canvas.height = img.height;
  399. canvas.width = img.width;
  400. const ctx = canvas.getContext('2d');
  401. ctx.drawImage(img, 0, 0);
  402. this.setState({ image: canvas.toDataURL() });
  403. };
  404. img.src = '1.gif';
  405. }
  406. }
  407. computerZoom() {
  408. const data = this.cropRef.getImageData();
  409. this.defaultZoomValue = 200 / parseFloat(Math.max(data.naturalWidth, data.naturalHeight));
  410. }
  411. crop() {
  412. // image in dataUrl
  413. // console.log(this.cropRef.getCroppedCanvas().toDataURL())
  414. // const canvas = this.cropRef.getCroppedCanvas();
  415. // const avatar = scale(this.props.crop, canvas, 'png-src');
  416. // let scaleCanvas = this.cropRef.getCroppedCanvas(this.props.crop)
  417. // this.setState({ avatar });
  418. }
  419. select() {
  420. const { fileName } = this.state;
  421. const { onConfirm } = this.props;
  422. const canvas = this.cropRef.getCroppedCanvas();
  423. const scaleCanvas = scale(this.props.crop, canvas);
  424. // let scaleCanvas = this.cropRef.getCroppedCanvas(this.props.crop)
  425. scaleCanvas.toBlob(blob => {
  426. const file = new File([blob], fileName);
  427. onConfirm(file);
  428. });
  429. }
  430. render() {
  431. const { show, onCancel } = this.props;
  432. const { image } = this.state;
  433. return (
  434. <Modal
  435. className="edit-avatar-modal"
  436. show={show}
  437. width={630}
  438. title="调整头像"
  439. confirmText="保存头像"
  440. onConfirm={() => {
  441. this.select();
  442. }}
  443. onCancel={onCancel}
  444. >
  445. <div className="edit-avatar-modal-wrapper">
  446. <div className="edit-avatar-o">
  447. <Cropper
  448. ref={ref => {
  449. this.cropRef = ref;
  450. }}
  451. src={image}
  452. ready={() => {
  453. this.computerZoom();
  454. }}
  455. style={{ height: 360, width: 360 }}
  456. // Cropper.js options
  457. aspectRatio={1}
  458. viewMode={0}
  459. // autoCropArea={0.8}
  460. preview=".img-preview"
  461. // dragMode='move'
  462. guides={false}
  463. movable={false}
  464. rotatable={false}
  465. scalable={false}
  466. // zoom={(value) => {
  467. // console.log('zoom', value);
  468. // const zoomValue = value * this.defaultZoomValue / 50;
  469. // this.cropRef.zoomTo(zoomValue);
  470. // }}
  471. cropmove={() => {
  472. this.crop();
  473. }}
  474. toggleDragModeOnDblclick={false}
  475. cropBoxResizable
  476. />
  477. </div>
  478. <div className="edit-avatar-r">
  479. <div className="text">头像预览</div>
  480. <div className="img-preview" style={{ width: 100, height: 100, overflow: 'hidden' }} />
  481. </div>
  482. </div>
  483. </Modal>
  484. );
  485. }
  486. }
  487. export class InviteModal extends Component {
  488. constructor(props) {
  489. super(props);
  490. this.state = { data: {} };
  491. }
  492. render() {
  493. const { show, onClose, data } = this.props;
  494. return (
  495. <Modal className="invite-modal" show={show} width={630} title="邀请好友" onClose={onClose}>
  496. <div className="invite-modal-wrapper">
  497. <div className="tip">每邀请一位小伙伴加入“千行GMAT”, 您的VIP权限会延长7天,可累加 无上限!赶紧行动吧~</div>
  498. <Invite data={data} />
  499. </div>
  500. </Modal>
  501. );
  502. }
  503. }
  504. // 模考选择下载
  505. export class DownloadModal extends Component {
  506. render() {
  507. const { show, onConfirm, onCancel } = this.props;
  508. return (
  509. <Modal
  510. className="download-modal"
  511. show={show}
  512. width={570}
  513. title="下载"
  514. confirmText="下载"
  515. onConfirm={onConfirm}
  516. onCancel={onCancel}
  517. >
  518. <div className="download-modal-wrapper">
  519. <div className="t-2 t-s-18 m-b-1">请选择下载科目</div>
  520. <div className="m-b-1">
  521. <div className="t-2 t-s-16">
  522. <Checkbox />
  523. <span className="m-l-5">数学</span>
  524. <span className="t-8">(版本7 最后更新:2019-07-16 11:41:13)</span>
  525. </div>
  526. <div className="t-2 t-s-16">
  527. <Checkbox />
  528. <span className="m-l-5">数学</span>
  529. <span className="t-8">(版本7 最后更新:2019-07-16 11:41:13)</span>
  530. </div>
  531. <div className="t-2 t-s-16">
  532. <Checkbox />
  533. <span className="m-l-5">数学</span>
  534. <span className="t-8">(版本7 最后更新:2019-07-16 11:41:13)</span>
  535. </div>
  536. </div>
  537. </div>
  538. </Modal>
  539. );
  540. }
  541. }
  542. // 模考开通确认
  543. export class OpenConfirmModal extends Component {
  544. render() {
  545. const { show, onConfirm, onCancel } = this.props;
  546. return (
  547. <Modal
  548. className="open-confirm-modal"
  549. show={show}
  550. width={570}
  551. title="开通确认"
  552. confirmText="开通"
  553. cancelText="暂不开通"
  554. onConfirm={onConfirm}
  555. onCancel={onCancel}
  556. >
  557. <div className="open-confirm-modal-wrapper m-b-2">
  558. <div className="t-2 t-s-18">您正在开通「千行CAT模考」。</div>
  559. <div className="t-2 t-s-18">模考有效期至:2019-11-17</div>
  560. </div>
  561. </Modal>
  562. );
  563. }
  564. }
  565. // 模考重置确认
  566. export class RestartConfirmModal extends Component {
  567. render() {
  568. const { show, onConfirm, onCancel } = this.props;
  569. return (
  570. <Modal
  571. className="restart-confirm-modal"
  572. show={show}
  573. width={570}
  574. title="重置确认"
  575. confirmText="立即重置"
  576. cancelText="暂不重置"
  577. onConfirm={onConfirm}
  578. onCancel={onCancel}
  579. >
  580. <div className="restart-confirm-modal-wrapper m-b-2">
  581. <div className="t-2 t-s-18">重置后,可进行新一轮的模考。 </div>
  582. <div className="t-2 t-s-18 m-b-2">本轮模考的成绩和报告可在本页面或「我的报告」查看。 </div>
  583. <div className="t-2 t-s-18 m-b-1">只有 1 次重置机会。</div>
  584. </div>
  585. </Modal>
  586. );
  587. }
  588. }
  589. export class CheckErrorModal extends Component {
  590. constructor(props) {
  591. super(props);
  592. this.state = { data: { position: [] } };
  593. }
  594. onConfirm() {
  595. const { onConfirm } = this.props;
  596. if (onConfirm) onConfirm(this.state.data);
  597. this.setState({ data: { position: [] } });
  598. }
  599. onCancel() {
  600. const { onCancel } = this.props;
  601. if (onCancel) onCancel();
  602. this.setState({ data: { position: [] } });
  603. }
  604. render() {
  605. const { show } = this.props;
  606. const { data } = this.state;
  607. return (
  608. <Modal
  609. show={show}
  610. title="纠错"
  611. btnType="link"
  612. width={630}
  613. onConfirm={() => this.onConfirm()}
  614. onCancel={() => this.onCancel()}
  615. >
  616. <div className="t-2 m-b-1 t-s-16">
  617. 定位:
  618. <input
  619. value={data.position[0]}
  620. className="t-c b-c-1 m-r-5"
  621. style={{ width: 56 }}
  622. onChange={e => {
  623. data.position[0] = e.target.value;
  624. this.setState({ data });
  625. }}
  626. />
  627. <span className="require">页</span>
  628. <input
  629. value={data.position[1]}
  630. className="t-c b-c-1 m-r-5"
  631. style={{ width: 56 }}
  632. onChange={e => {
  633. data.position[1] = e.target.value;
  634. this.setState({ data });
  635. }}
  636. />
  637. <span className="require">行</span> , 题号
  638. <input
  639. value={data.position[2]}
  640. className="t-c b-c-1"
  641. style={{ width: 56 }}
  642. onChange={e => {
  643. data.position[2] = e.target.value;
  644. this.setState({ data });
  645. }}
  646. />
  647. </div>
  648. <div className="t-2 t-s-16">错误内容是:</div>
  649. <textarea
  650. value={data.originContent}
  651. className="b-c-1 w-10 p-10"
  652. rows={10}
  653. placeholder={'可简单描述您发现的问题'}
  654. onChange={e => {
  655. data.originContent = e.target.value;
  656. this.setState({ data });
  657. }}
  658. />
  659. <div className="t-2 t-s-16">应该更改为:</div>
  660. <textarea
  661. value={data.content}
  662. className="b-c-1 w-10 p-10"
  663. rows={10}
  664. placeholder={'提供您认为正确的内容即可'}
  665. onChange={e => {
  666. data.content = e.target.value;
  667. this.setState({ data });
  668. }}
  669. />
  670. <div className="b-b m-t-2" />
  671. </Modal>
  672. );
  673. }
  674. }
  675. export class QuestionModal extends Component {
  676. constructor(props) {
  677. super(props);
  678. this.state = { data: {} };
  679. }
  680. onConfirm() {
  681. const { onConfirm } = this.props;
  682. if (onConfirm) onConfirm(this.state.data);
  683. this.setState({ data: {} });
  684. }
  685. onCancel() {
  686. const { onCancel } = this.props;
  687. if (onCancel) onCancel();
  688. this.setState({ data: {} });
  689. }
  690. render() {
  691. const { show, selectList } = this.props;
  692. const { data } = this.state;
  693. return (
  694. <Modal
  695. show={show}
  696. title="提问"
  697. btnType="link"
  698. width={630}
  699. confirmText="提交"
  700. onConfirm={() => this.onConfirm()}
  701. onCancel={() => this.onCancel()}
  702. >
  703. <div className="t-2 m-b-1 t-s-16">
  704. 针对<span className="t-4">课时1</span>的 <Select theme="white" list={selectList} />
  705. 进行提问.
  706. </div>
  707. <div className="t-2 t-s-16">老师讲解的内容是:</div>
  708. <textarea
  709. value={data.originContent}
  710. className="b-c-1 w-10 p-10"
  711. rows={4}
  712. placeholder={'请简单描述,以便老师准确定位。'}
  713. onChange={e => {
  714. data.originContent = e.target.value;
  715. this.setState({ data });
  716. }}
  717. />
  718. <div className="t-2 t-s-16">您的问题是:</div>
  719. <textarea
  720. value={data.content}
  721. className="b-c-1 w-10 p-10"
  722. rows={4}
  723. placeholder={'老师会在n小时内回答你的问题。'}
  724. onChange={e => {
  725. data.content = e.target.value;
  726. this.setState({ data });
  727. }}
  728. />
  729. <div className="b-b m-t-2" />
  730. </Modal>
  731. );
  732. }
  733. }
  734. export class NoteModal extends Component {
  735. constructor(props) {
  736. super(props);
  737. this.state = { data: {} };
  738. }
  739. onConfirm() {
  740. const { onConfirm } = this.props;
  741. if (onConfirm) onConfirm(this.state.data);
  742. this.setState({ data: {} });
  743. }
  744. onCancel() {
  745. const { onCancel } = this.props;
  746. if (onCancel) onCancel();
  747. this.setState({ data: {} });
  748. }
  749. render() {
  750. const { show, selectList } = this.props;
  751. const { data } = this.state;
  752. return (
  753. <Modal
  754. show={show}
  755. title="笔记"
  756. width={630}
  757. confirmText="提交"
  758. onConfirm={() => this.onConfirm()}
  759. onCancel={() => this.onCancel()}
  760. >
  761. <div className="t-2 m-b-1 t-s-16">
  762. OG20 刷题 语文 SC
  763. <Select theme="white" list={selectList} />
  764. </div>
  765. <textarea
  766. value={data.originContent}
  767. className="b-c-1 w-10 p-10"
  768. rows={10}
  769. placeholder={'写下笔记,方便以后复习。'}
  770. onChange={e => {
  771. data.originContent = e.target.value;
  772. this.setState({ data });
  773. }}
  774. />
  775. <div className="b-b m-t-2" />
  776. </Modal>
  777. );
  778. }
  779. }