1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228 |
- import React, { Component } from 'react';
- import Cropper from 'react-cropper';
- import 'cropperjs/dist/cropper.css';
- import './index.less';
- import { Checkbox, Icon } from 'antd';
- import FileUpload from '@src/components/FileUpload';
- import Assets from '@src/components/Assets';
- import scale from '@src/services/Scale';
- import { asyncSMessage } from '@src/services/AsyncTools';
- import { SelectInput, VerificationInput, Input } from '../Login';
- import { MobileArea, TextbookFeedbackTarget, TextbookSubject } from '../../../Constant';
- import Invite from '../Invite';
- import Modal from '../Modal';
- import { Common } from '../../stores/common';
- import { User } from '../../stores/user';
- import { My } from '../../stores/my';
- import Select from '../Select';
- import { formatDate, getMap } from '../../../../src/services/Tools';
- const TextbookFeedbackTargetMap = getMap(TextbookFeedbackTarget, 'value', 'tip');
- export class BindPhone extends Component {
- constructor(props) {
- super(props);
- this.props.data = this.props.data || {};
- this.state = Object.assign({ step: 0, data: {} }, this.initState(this.props));
- this.stepProp = {
- 0: {
- title: '绑定手机',
- onConfirm: props.onConfirm,
- },
- 1: {
- title: '绑定手机',
- onConfirm: () => {
- this.submit();
- },
- onCancel: props.onCancel,
- confirmText: '提交',
- },
- };
- }
- initState(props) {
- if (!props.show || this.props.show) return {};
- const data = Object.assign({}, props.data);
- if (!data.area) data.area = MobileArea[0].value;
- return { step: props.data.mobile ? 0 : 1, data };
- }
- componentWillReceiveProps(nextProps) {
- this.setState(this.initState(nextProps));
- }
- onNext() {
- this.setState({ step: 1 });
- }
- changeData(field, value) {
- let { data } = this.state;
- data = data || {};
- data[field] = value;
- this.setState({ data, error: null });
- }
- validMobile() {
- const { data } = this.state;
- const { area, mobile } = data;
- if (!area || !mobile) return;
- this.validNumber += 1;
- const number = this.validNumber;
- User.validMobile(area, mobile)
- .then(result => {
- if (number !== this.validNumber) return Promise.resolve();
- return result ? Promise.resolve() : Promise.reject(new Error('该手机已绑定其他账号,请更换手机号码'));
- })
- .catch(err => {
- this.setState({ mobileError: err.message });
- });
- }
- sendValid() {
- const { data, error } = this.state;
- const { area, mobile } = data;
- if (!area || !mobile || error) return Promise.reject();
- return Common.sendSms(area, mobile)
- .then(result => {
- if (result) {
- asyncSMessage('发送成功');
- this.setState({ error: '', validError: '' });
- } else {
- throw new Error('发送失败');
- }
- })
- .catch(err => {
- this.setState({ error: err.message });
- throw err;
- });
- }
- submit() {
- const { data, error } = this.state;
- if (!data.mobile || !data.area || error) return;
- const { area, mobile } = data;
- My.bindMobile(area, mobile)
- .then(() => {
- asyncSMessage('操作成功');
- this.setState({ step: 0 });
- User.infoHandle(Object.assign(this.props.data, { area, mobile }));
- this.props.onConfirm();
- })
- .catch(e => {
- this.setState({ error: e.message });
- });
- }
- render() {
- const { show } = this.props;
- const { step = 0 } = this.state;
- return (
- <Modal className="bind-phone-modal" show={show} width={630} {...this.stepProp[step]}>
- <div className="bind-phone-modal-wrapper">{this[`renderStep${step}`]()}</div>
- </Modal>
- );
- }
- renderStep0() {
- const { data } = this.state;
- return (
- <div className="step-0-layout">
- 已绑定手机 {data.mobile}
- <a onClick={() => this.onNext()}>修改</a>
- </div>
- );
- }
- renderStep1() {
- return (
- <div className="step-1-layout">
- <div className="label">手机号</div>
- <div className="input-layout">
- <SelectInput
- placeholder="请输入手机号"
- selectValue={this.state.data.area}
- select={MobileArea}
- value={this.state.data.mobile}
- error={this.state.error}
- onSelect={value => {
- this.changeData('area', value);
- this.validMobile();
- }}
- onChange={e => {
- this.changeData('mobile', e.target.value);
- this.validMobile();
- }}
- />
- <VerificationInput
- placeholder="请输入验证码"
- value={this.state.data.mobileVerifyCode}
- error={this.state.validError}
- onSend={() => {
- return this.sendValid();
- }}
- onChange={e => {
- this.changeData('mobileVerifyCode', e.target.value);
- }}
- />
- </div>
- </div>
- );
- }
- }
- export class BindEmail extends Component {
- constructor(props) {
- super(props);
- this.props.data = this.props.data || {};
- this.state = Object.assign({ step: 0, data: {} }, this.initState(this.props));
- this.stepProp = {
- 0: {
- title: '绑定邮箱',
- onConfirm: props.onConfirm,
- },
- 1: {
- title: '绑定邮箱',
- onConfirm: () => {
- this.submit();
- },
- onCancel: props.onCancel,
- confirmText: '提交',
- },
- };
- }
- initState(props) {
- if (!props.show || this.props.show) return {};
- return { step: props.data.email ? 0 : 1, data: Object.assign({}, props.data) };
- }
- componentWillReceiveProps(nextProps) {
- this.setState(this.initState(nextProps));
- }
- onNext() {
- this.setState({ step: 1 });
- }
- changeData(field, value) {
- let { data } = this.state;
- data = data || {};
- data[field] = value;
- this.setState({ data, error: null });
- }
- submit() {
- const { data, error } = this.state;
- if (!data.email || error) return;
- const { email } = data;
- My.bindEmail(email)
- .then(() => {
- asyncSMessage('操作成功');
- this.setState({ step: 0 });
- User.infoHandle(Object.assign(this.props.data, { email }));
- this.props.onConfirm();
- })
- .catch(e => {
- this.setState({ error: e.message });
- });
- }
- render() {
- const { show } = this.props;
- const { step = 0 } = this.state;
- return (
- <Modal className="bind-email-modal" show={show} width={630} {...this.stepProp[step]}>
- <div className="bind-email-modal-wrapper">{this[`renderStep${step}`]()}</div>
- </Modal>
- );
- }
- renderStep0() {
- const { data } = this.state;
- return (
- <div className="step-0-layout">
- 已绑定邮箱 {data.email}
- <a onClick={() => this.onNext()}>修改</a>
- </div>
- );
- }
- renderStep1() {
- return (
- <div className="step-1-layout">
- <div className="label">邮箱地址</div>
- <div className="input-layout">
- <Input
- placeholder="请输入邮箱"
- value={this.state.data.email}
- error={this.state.error}
- onChange={e => {
- this.changeData('email', e.target.value);
- }}
- />
- </div>
- </div>
- );
- }
- }
- export class EditInfo extends Component {
- constructor(props) {
- super(props);
- this.props.data = this.props.data || {};
- this.state = Object.assign({ data: {} }, this.initState(this.props));
- }
- initState(props) {
- if (props.image && this.waitImage) {
- const { state } = this;
- Common.upload(props.image)
- .then(result => {
- const { data } = this.state;
- data.avatar = result.url;
- this.setState({ data, uploading: false });
- })
- .catch(e => {
- this.setState({ imageError: e.message });
- });
- state.uploading = true;
- this.waitImage = false;
- return state;
- }
- if (!props.show || this.props.show) return {};
- return { data: Object.assign({}, props.data) };
- }
- componentWillReceiveProps(nextProps) {
- this.setState(this.initState(nextProps));
- }
- changeData(field, value) {
- let { data } = this.state;
- data = data || {};
- data[field] = value;
- this.setState({ data, error: null });
- }
- submit() {
- const { data, error } = this.state;
- if (!data.nickname || error) return;
- const { nickname, avatar } = data;
- My.editInfo({ nickname, avatar })
- .then(() => {
- asyncSMessage('操作成功');
- User.infoHandle(Object.assign(this.props.data, { nickname, avatar }));
- this.props.onConfirm();
- })
- .catch(e => {
- this.setState({ error: e.message });
- });
- }
- render() {
- const { show, onCancel, onSelectImage } = this.props;
- return (
- <Modal
- className="edit-info-modal"
- show={show}
- width={630}
- title="修改资料"
- confirmText="保存"
- onCancel={onCancel}
- onConfirm={() => {
- this.submit();
- }}
- >
- <div className="edit-info-modal-wrapper">
- <div className="edit-info-modal-block">
- <div className="label">昵称</div>
- <div className="input-layout">
- <Input
- placeholder="2-20位,不可使用特殊字符。"
- value={this.state.data.nickname || ''}
- error={this.state.error}
- onChange={e => {
- this.changeData('nickname', e.target.value);
- }}
- />
- </div>
- </div>
- <div className="edit-info-modal-block">
- <div className="label">头像</div>
- <div className="input-layout">
- <FileUpload
- uploading={this.state.uploading}
- value={this.state.data.avatar}
- onUpload={({ file }) => {
- this.waitImage = true;
- onSelectImage(file);
- return Promise.reject();
- }}
- />
- {this.state.imageError || ''}
- </div>
- </div>
- </div>
- </Modal>
- );
- }
- }
- export class RealAuth extends Component {
- constructor(props) {
- super(props);
- this.state = { data: {} };
- }
- render() {
- const { show, onConfirm } = this.props;
- return (
- <Modal
- className="real-auth-modal"
- show={show}
- width={630}
- title="实名认证"
- confirmText="好的,知道了"
- btnAlign="center"
- onConfirm={onConfirm}
- >
- <div className="real-auth-modal-wrapper">
- <div className="real-auth-text">
- <div className="t1">完成实名认证即可领取:</div>
- <div className="t2">6个月VIP权限 和 5折机经优惠劵。</div>
- <div className="t3">扫码关注公众号,点击“我的-实名认证”</div>
- </div>
- <div className="real-auth-qrcode">
- <Assets name="qrcode" />
- </div>
- </div>
- </Modal>
- );
- }
- }
- export class EditAvatar extends Component {
- constructor(props) {
- super(props);
- this.state = Object.assign({ data: {} }, this.initState(this.props));
- }
- initState(props) {
- if (props.image) this.loadImage(props.image);
- if (!props.show || this.props.show) return {};
- return { data: {} };
- }
- componentWillReceiveProps(nextProps) {
- this.setState(this.initState(nextProps));
- }
- loadImage(file) {
- this.defaultZoomValue = 1;
- if (window.FileReader) {
- const reader = new FileReader();
- reader.readAsDataURL(file);
- // 渲染文件
- reader.onload = arg => {
- this.setState({ image: arg.target.result, fileName: file.name, zoomValue: 1 });
- };
- } else {
- const img = new Image();
- img.onload = function () {
- const canvas = document.createElement('canvas');
- canvas.height = img.height;
- canvas.width = img.width;
- const ctx = canvas.getContext('2d');
- ctx.drawImage(img, 0, 0);
- this.setState({ image: canvas.toDataURL() });
- };
- img.src = '1.gif';
- }
- }
- computerZoom() {
- const data = this.cropRef.getImageData();
- this.defaultZoomValue = 200 / parseFloat(Math.max(data.naturalWidth, data.naturalHeight));
- }
- crop() {
- // image in dataUrl
- // console.log(this.cropRef.getCroppedCanvas().toDataURL())
- // const canvas = this.cropRef.getCroppedCanvas();
- // const avatar = scale(this.props.crop, canvas, 'png-src');
- // let scaleCanvas = this.cropRef.getCroppedCanvas(this.props.crop)
- // this.setState({ avatar });
- }
- select() {
- const { fileName } = this.state;
- const { onConfirm } = this.props;
- const canvas = this.cropRef.getCroppedCanvas();
- const scaleCanvas = scale(this.props.crop, canvas);
- // let scaleCanvas = this.cropRef.getCroppedCanvas(this.props.crop)
- scaleCanvas.toBlob(blob => {
- const file = new File([blob], fileName);
- onConfirm(file);
- });
- }
- render() {
- const { show, onCancel } = this.props;
- const { image } = this.state;
- return (
- <Modal
- className="edit-avatar-modal"
- show={show}
- width={630}
- title="调整头像"
- confirmText="保存头像"
- onConfirm={() => {
- this.select();
- }}
- onCancel={onCancel}
- >
- <div className="edit-avatar-modal-wrapper">
- <div className="edit-avatar-o">
- <Cropper
- ref={ref => {
- this.cropRef = ref;
- }}
- src={image}
- ready={() => {
- this.computerZoom();
- }}
- style={{ height: 360, width: 360 }}
- // Cropper.js options
- aspectRatio={1}
- viewMode={0}
- // autoCropArea={0.8}
- preview=".img-preview"
- // dragMode='move'
- guides={false}
- movable={false}
- rotatable={false}
- scalable={false}
- // zoom={(value) => {
- // console.log('zoom', value);
- // const zoomValue = value * this.defaultZoomValue / 50;
- // this.cropRef.zoomTo(zoomValue);
- // }}
- cropmove={() => {
- this.crop();
- }}
- toggleDragModeOnDblclick={false}
- cropBoxResizable
- />
- </div>
- <div className="edit-avatar-r">
- <div className="text">头像预览</div>
- <div className="img-preview" style={{ width: 100, height: 100, overflow: 'hidden' }} />
- </div>
- </div>
- </Modal>
- );
- }
- }
- export class InviteModal extends Component {
- constructor(props) {
- super(props);
- this.state = { data: {} };
- }
- render() {
- const { show, onClose, data } = this.props;
- return (
- <Modal className="invite-modal" show={show} width={630} title="邀请好友" onClose={onClose}>
- <div className="invite-modal-wrapper">
- <div className="tip">每邀请一位小伙伴加入“千行GMAT”, 您的VIP权限会延长7天,可累加 无上限!赶紧行动吧~</div>
- <Invite data={data} />
- </div>
- </Modal>
- );
- }
- }
- // 模考选择下载
- export class DownloadModal extends Component {
- constructor(props) {
- super(props);
- this.state = { checkMap: {} };
- }
- onConfirm() {
- const { onConfirm, data } = this.props;
- if (onConfirm) onConfirm();
- const { checkMap } = this.state;
- Object.keys(checkMap).forEach(key => {
- if (!checkMap[key]) return;
- const link = data[`${key}`];
- if (link) {
- openLink(link);
- }
- });
- this.setState({ checkList: [] });
- }
- render() {
- const { show, data = {}, onCancel } = this.props;
- const { checkMap = {} } = this.state;
- const quantVersion = data.quantVersion || 0;
- const irVersion = data.irVersion || 0;
- const rcVersion = data.rcVersion || 0;
- return (
- <Modal
- className="download-modal"
- show={show}
- width={570}
- title="下载"
- confirmText="下载"
- onConfirm={() => this.onConfirm()}
- onCancel={onCancel}
- >
- <div className="download-modal-wrapper">
- <div className="t-2 t-s-18 m-b-1">请选择下载科目</div>
- <div className="m-b-1">
- {quantVersion > 0 && (
- <div className="t-2 t-s-16">
- <Checkbox
- checked={checkMap.quant}
- onChange={() => {
- checkMap.quant = !checkMap.quant;
- this.setState({ checkMap });
- }}
- />
- <span className="m-l-5">数学</span>
- <span className="t-8">
- (版本{quantVersion} 最后更新:{formatDate(data.quantTime, 'YYYY-MM-DD HH:mm:ss')})
- </span>
- </div>
- )}
- {irVersion > 0 && (
- <div className="t-2 t-s-16">
- <Checkbox
- checked={checkMap.ir}
- onChange={() => {
- checkMap.ir = !checkMap.ir;
- this.setState({ checkMap });
- }}
- />
- <span className="m-l-5">逻辑</span>
- <span className="t-8">
- (版本{irVersion} 最后更新:{formatDate(data.irTime, 'YYYY-MM-DD HH:mm:ss')})
- </span>
- </div>
- )}
- {rcVersion > 0 && (
- <div className="t-2 t-s-16">
- <Checkbox
- checked={checkMap.rc}
- onChange={() => {
- checkMap.rc = !checkMap.rc;
- this.setState({ checkMap });
- }}
- />
- <span className="m-l-5">阅读</span>
- <span className="t-8">
- (版本{rcVersion} 最后更新:{formatDate(data.rcTime, 'YYYY-MM-DD HH:mm:ss')})
- </span>
- </div>
- )}
- </div>
- </div>
- </Modal>
- );
- }
- }
- // 模考开通确认
- export class OpenConfirmModal extends Component {
- render() {
- const { show, onConfirm, onCancel, data = {} } = this.props;
- return (
- <Modal
- className="open-confirm-modal"
- show={show}
- width={570}
- title="开通确认"
- confirmText="开通"
- cancelText="暂不开通"
- onConfirm={onConfirm}
- onCancel={onCancel}
- >
- <div className="open-confirm-modal-wrapper m-b-2">
- <div className="t-2 t-s-18">您正在开通「{data.title}」。</div>
- <div className="t-2 t-s-18">模考有效期至:{data.endTime && formatDate(data.endTime, 'YYYY-MM-DD')}</div>
- </div>
- </Modal>
- );
- }
- }
- // 模考重置确认
- export class RestartConfirmModal extends Component {
- render() {
- const { show, onConfirm, onCancel } = this.props;
- return (
- <Modal
- className="restart-confirm-modal"
- show={show}
- width={570}
- title="重置确认"
- confirmText="立即重置"
- cancelText="暂不重置"
- onConfirm={onConfirm}
- onCancel={onCancel}
- >
- <div className="restart-confirm-modal-wrapper m-b-2">
- <div className="t-2 t-s-18">重置后,可进行新一轮的模考。 </div>
- <div className="t-2 t-s-18 m-b-2">本轮模考的成绩和报告可在本页面或「我的报告」查看。 </div>
- <div className="t-2 t-s-18 m-b-1">只有 1 次重置机会。</div>
- </div>
- </Modal>
- );
- }
- }
- export class FeedbackErrorDataModal extends Component {
- constructor(props) {
- super(props);
- this.state = { data: { position: ['', '', ''], content: '', originContent: '' } };
- }
- componentWillReceiveProps(nextProps) {
- if (nextProps.show && nextProps.defaultData) {
- this.setState({ data: Object.assign({}, nextProps.defaultData, this.state.data) });
- }
- }
- onConfirm() {
- const { onConfirm } = this.props;
- const { data } = this.state;
- if (!data.content || !data.originContent) return;
- My.addFeedbackErrorData(data.dataId, data.title, data.position.join(','), data.originContent, data.content).then(
- () => {
- this.setState({ data: { position: ['', '', ''], content: '', originContent: '' } });
- if (onConfirm) onConfirm();
- },
- );
- }
- onCancel() {
- const { onCancel } = this.props;
- this.setState({ data: { position: ['', '', ''], content: '', originContent: '' } });
- if (onCancel) onCancel();
- }
- render() {
- const { show } = this.props;
- const { data } = this.state;
- return (
- <Modal
- show={show}
- title="纠错"
- btnType="link"
- width={630}
- onConfirm={() => this.onConfirm()}
- onCancel={() => this.onCancel()}
- >
- <div className="t-2 m-b-1 t-s-16">
- 定位:
- <input
- value={data.position[0]}
- className="t-c b-c-1 m-r-5"
- style={{ width: 56 }}
- onChange={e => {
- data.position[0] = e.target.value;
- this.setState({ data });
- }}
- />
- <span className="require">页</span>
- <input
- value={data.position[1]}
- className="t-c b-c-1 m-r-5"
- style={{ width: 56 }}
- onChange={e => {
- data.position[1] = e.target.value;
- this.setState({ data });
- }}
- />
- <span className="require">行</span> , 题号
- <input
- value={data.position[2]}
- className="t-c b-c-1"
- style={{ width: 56 }}
- onChange={e => {
- data.position[2] = e.target.value;
- this.setState({ data });
- }}
- />
- </div>
- <div className="t-2 t-s-16">错误内容是:</div>
- <textarea
- value={data.originContent}
- className="b-c-1 w-10 p-10"
- rows={10}
- placeholder={'可简单描述您发现的问题'}
- onChange={e => {
- data.originContent = e.target.value;
- this.setState({ data });
- }}
- />
- <div className="t-2 t-s-16">应该更改为:</div>
- <textarea
- value={data.content}
- className="b-c-1 w-10 p-10"
- rows={10}
- placeholder={'提供您认为正确的内容即可'}
- onChange={e => {
- data.content = e.target.value;
- this.setState({ data });
- }}
- />
- <div className="b-b m-t-2" />
- </Modal>
- );
- }
- }
- export class AskCourseModal extends Component {
- constructor(props) {
- super(props);
- this.state = { data: { position: [], content: '', originContent: '' } };
- }
- componentWillReceiveProps(nextProps) {
- if (nextProps.show && nextProps.defaultData) {
- this.setState({ data: Object.assign({}, nextProps.defaultData, this.state.data) });
- }
- }
- onConfirm() {
- const { course, courseNo, onConfirm } = this.props;
- const { data } = this.state;
- if (!data.position || !data.originContent || !data.content) return;
- My.addCourseAsk(course.id, courseNo.id, data.position.join(','), data.originContent, data.content).then(() => {
- this.setState({ data: { position: [], content: '', originContent: '' } });
- if (onConfirm) onConfirm();
- });
- }
- onCancel() {
- const { onCancel } = this.props;
- this.setState({ data: { position: [], content: '', originContent: '' } });
- if (onCancel) onCancel();
- }
- render() {
- const { show, selectList, courseNo, getContainer } = this.props;
- const { data } = this.state;
- return (
- <Modal
- show={show}
- title="提问"
- btnType="link"
- width={630}
- getContainer={getContainer}
- confirmText="提交"
- onConfirm={() => this.onConfirm()}
- onCancel={() => this.onCancel()}
- >
- <div className="t-2 m-b-1 t-s-16">
- 针对<span className="t-4">课时{courseNo.no}</span>的{' '}
- <Select
- value={data.position}
- theme="white"
- list={selectList}
- onChange={item => {
- data.position = item.key;
- this.setState({ data });
- }}
- />
- 进行提问.
- </div>
- <div className="t-2 t-s-16">老师讲解的内容是:</div>
- <textarea
- value={data.originContent}
- className="b-c-1 w-10 p-10"
- rows={4}
- placeholder={'请简单描述,以便老师准确定位。'}
- onChange={e => {
- data.originContent = e.target.value;
- this.setState({ data });
- }}
- />
- <div className="t-2 t-s-16">您的问题是:</div>
- <textarea
- value={data.content}
- className="b-c-1 w-10 p-10"
- rows={4}
- placeholder={'老师会在n小时内回答你的问题。'}
- onChange={e => {
- data.content = e.target.value;
- this.setState({ data });
- }}
- />
- <div className="b-b m-t-2" />
- </Modal>
- );
- }
- }
- export class CourseNoteModal extends Component {
- constructor(props) {
- super(props);
- this.state = { data: { content: '' } };
- }
- componentWillReceiveProps(nextProps) {
- if (nextProps.show && nextProps.defaultData) {
- this.setState({ data: Object.assign({}, nextProps.defaultData, this.state.data) });
- }
- }
- onConfirm() {
- const { course, onConfirm } = this.props;
- const { data } = this.state;
- if (!data.content) return;
- My.updateCourseNote(course.id, data.courseNoId, data.content).then(() => {
- this.setState({ data: { content: '' } });
- if (onConfirm) onConfirm();
- });
- }
- onCancel() {
- const { onCancel } = this.props;
- this.setState({ data: { content: '' } });
- if (onCancel) onCancel();
- }
- render() {
- const { show, course = {}, courseNos = [], noteMap = {}, getContainer } = this.props;
- const { data } = this.state;
- return (
- <Modal
- show={show}
- title="笔记"
- width={630}
- getContainer={getContainer}
- confirmText="提交"
- onConfirm={() => this.onConfirm()}
- onCancel={() => this.onCancel()}
- >
- <div className="t-2 m-b-1 t-s-16">
- {course.title}
- <Select
- theme="white"
- value={data.courseNoId}
- list={courseNos.map(row => {
- return {
- title: `课时${row.no}`,
- key: row.id,
- };
- })}
- onChange={item => {
- if (data.courseNoId !== item.key) {
- data.courseNoId = item.key;
- data.content = noteMap[item.key] ? noteMap[item.key].content : '';
- }
- this.setState({ data });
- }}
- />
- </div>
- <textarea
- value={data.content}
- className="b-c-1 w-10 p-10"
- rows={10}
- placeholder={'写下笔记,方便以后复习。'}
- onChange={e => {
- data.content = e.target.value;
- this.setState({ data });
- }}
- />
- <div className="b-b m-t-2" />
- </Modal>
- );
- }
- }
- export class TextbookFeedbackModal extends Component {
- constructor(props) {
- super(props);
- this.state = {
- data: { content: '' },
- targetList: TextbookFeedbackTarget.map(row => {
- return {
- title: row.label,
- key: row.value,
- };
- }),
- textbookSubject: TextbookSubject.map(row => {
- return {
- title: row.label,
- key: row.value,
- };
- }),
- };
- }
- componentWillReceiveProps(nextProps) {
- if (nextProps.show && nextProps.defaultData) {
- this.setState({ data: Object.assign({}, nextProps.defaultData, this.state.data) });
- }
- }
- onConfirm() {
- const { onConfirm } = this.props;
- const { data } = this.state;
- if (!data.content) return;
- if (data.target !== 'new' && !data.no) return;
- My.addTextbookFeedback(data.textbookSubject, data.target, data.no, data.content)
- .then(() => {
- this.setState({ data: { content: '' } });
- if (onConfirm) onConfirm();
- })
- .catch((e) => {
- asyncSMessage(e.message, 'error');
- });
- }
- onCancel() {
- const { onCancel } = this.props;
- this.setState({ data: { content: '' } });
- if (onCancel) onCancel();
- }
- render() {
- const { show } = this.props;
- const { data, targetList, textbookSubject } = this.state;
- return (
- <Modal show={show} title="反馈" width={630} onConfirm={() => this.onConfirm()} onCancel={() => this.onCancel()}>
- <div className="t-2 t-s-16 m-b-1">
- 机经类别:{' '}
- <Select
- value={data.textbookSubject}
- theme="white"
- list={textbookSubject}
- onChange={value => {
- data.textbookSubject = value;
- this.setState({ data });
- }}
- />
- 反馈类型:{' '}
- <Select
- value={data.target}
- theme="white"
- list={targetList}
- onChange={({ key }) => {
- data.target = key;
- this.setState({ data });
- }}
- />
- <span hidden={data.target === 'new'}>
- {' '}
- 题号是{' '}
- <input
- value={data.no}
- style={{ width: 80 }}
- className="m-l-1 b-c-1 t-c"
- onChange={e => {
- data.no = e.target.value;
- this.setState({ data });
- }}
- />
- </span>
- </div>
- <div className="t-2 t-s-16">{TextbookFeedbackTargetMap[data.target]}:</div>
- <textarea
- value={data.content}
- className="b-c-1 w-10 p-10"
- rows={10}
- placeholder={TextbookFeedbackTargetMap[data.target]}
- onChange={e => {
- data.content = e.target.value;
- this.setState({ data });
- }}
- />
- <div className="b-b m-t-2" />
- </Modal>
- );
- }
- }
- export class FaqModal extends Component {
- constructor(props) {
- super(props);
- this.state = { data: { content: '' } };
- }
- componentWillReceiveProps(nextProps) {
- if (nextProps.defaultData && nextProps.show) {
- this.setState({ data: Object.assign({}, nextProps.defaultData, this.state.data) });
- }
- }
- onConfirm() {
- const { onConfirm } = this.props;
- const { data } = this.state;
- if (!data.content) return;
- My.addFaq(data.channel, data.position, data.content).then(() => {
- this.setState({ data: { content: '' } });
- if (onConfirm) onConfirm();
- });
- }
- onCancel() {
- const { onCancel } = this.props;
- this.setState({ data: { content: '' } });
- if (onCancel) onCancel();
- }
- render() {
- const { show } = this.props;
- const { data } = this.state;
- return (
- <Modal show={show} title="咨询" onConfirm={() => this.onConfirm()} onCancel={() => this.onCancel()}>
- <textarea
- className="b-c-1 w-10 p-10"
- value={data.content}
- rows={6}
- placeholder="请输入您的问题!"
- onChange={e => {
- data.content = e.target.value;
- this.setState({ data });
- }}
- />
- <div className="b-b m-t-2" />
- </Modal>
- );
- }
- }
- export class CommentModal extends Component {
- constructor(props) {
- super(props);
- this.state = { data: { content: '' } };
- }
- componentWillReceiveProps(nextProps) {
- if (nextProps.show && nextProps.defaultData) {
- this.setState({ data: Object.assign({}, nextProps.defaultData, this.state.data) });
- }
- }
- onConfirm() {
- const { onConfirm } = this.props;
- const { data } = this.state;
- if (!data.content) return;
- My.addComment(data.channel, data.position, data.content).then(() => {
- this.setState({ data: { content: '' } });
- if (onConfirm) onConfirm();
- });
- }
- onCancel() {
- const { onCancel } = this.props;
- this.setState({ data: { content: '' } });
- if (onCancel) onCancel();
- }
- render() {
- const { show } = this.props;
- const { data } = this.state;
- return (
- <Modal show={show} title="评价" onConfirm={() => this.onConfirm()} onCancel={() => this.onCancel()}>
- <textarea
- value={data.content}
- className="b-c-1 w-10 p-10"
- rows={6}
- placeholder="您的看法对我们来说很重要!"
- onChange={e => {
- data.content = e.target.value;
- this.setState({ data });
- }}
- />
- <div className="b-b m-t-2" />
- </Modal>
- );
- }
- }
- export class FinishModal extends Component {
- render() {
- const { show, onConfirm } = this.props;
- return (
- <Modal show={show} title="提交成功" confirmText="好的,知道了" btnAlign="center" onConfirm={() => onConfirm()}>
- <div className="t-2 t-s-18">
- <Icon type="check" className="t-5 m-r-5" />
- 您的每一次反馈都是千行进步的动力。
- </div>
- </Modal>
- );
- }
- }
- export class SuppleModal extends Component {
- constructor(props) {
- super(props);
- this.state = { data: { content: '' } };
- }
- componentWillReceiveProps(nextProps) {
- if (nextProps.show && nextProps.defaultData) {
- this.setState({ data: Object.assign({}, nextProps.defaultData, this.state.data) });
- }
- }
- onConfirm() {
- const { onConfirm } = this.props;
- const { data } = this.state;
- if (!data.content) return;
- My.addRoomFeedback(data.roomId, data.content).then(() => {
- this.setState({ data: { content: '' } });
- if (onConfirm) onConfirm();
- });
- }
- onCancel() {
- const { onCancel } = this.props;
- this.setState({ data: { content: '' } });
- if (onCancel) onCancel();
- }
- render() {
- const { show, info = {} } = this.props;
- const { data } = this.state;
- return (
- <Modal show={show} title="考场信息" onConfirm={() => this.onConfirm()} onCancel={() => this.onCancel()}>
- <div className="t-2 t-s-16">考场位置: {info.isOverseas ? '海外' : '中国'}{info.area ? ` ${info.area}` : ''} {info.title}</div>
- <div className="t-2 t-s-16">补充内容:</div>
- <textarea
- value={data.content}
- className="b-c-1 w-10 p-10"
- rows={6}
- onChange={e => {
- data.content = e.target.value;
- this.setState({ data });
- }}
- />
- <div className="b-b m-t-2" />
- </Modal>
- );
- }
- }
- export class SuppleFinishModal extends Component {
- render() {
- const { show, onConfirm } = this.props;
- return (
- <Modal show={show} title="提交成功" confirmText="好的,知道了" btnAlign="center" onConfirm={() => onConfirm()}>
- <div className="t-2 t-s-18">
- <Icon type="check" className="t-5 m-r-5" />
- 内容将在审核通过后发布,感谢您的参与。
- </div>
- </Modal>
- );
- }
- }
|