|
|
@ -1,5 +1,5 @@
|
|
|
|
import React,{ Component } from "react";
|
|
|
|
import React,{ Component } from "react";
|
|
|
|
import { Modal , Form , Input } from 'antd';
|
|
|
|
import { Modal , Form , Input , Spin } from 'antd';
|
|
|
|
|
|
|
|
|
|
|
|
import './video.css';
|
|
|
|
import './video.css';
|
|
|
|
import axios from 'axios';
|
|
|
|
import axios from 'axios';
|
|
|
@ -7,25 +7,83 @@ const { TextArea } = Input;
|
|
|
|
|
|
|
|
|
|
|
|
class LiveNew extends Component{
|
|
|
|
class LiveNew extends Component{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state={
|
|
|
|
|
|
|
|
isSpining:true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate=(prevState)=>{
|
|
|
|
|
|
|
|
if(prevState && prevState.liveId !== this.props.liveId){
|
|
|
|
|
|
|
|
this.checkType();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkType=()=>{
|
|
|
|
|
|
|
|
const { liveId } = this.props;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(liveId){
|
|
|
|
|
|
|
|
const url =`/live_links/${liveId}/edit.json`;
|
|
|
|
|
|
|
|
axios.get(url).then(result=>{
|
|
|
|
|
|
|
|
if(result){
|
|
|
|
|
|
|
|
this.props.form.setFieldsValue({
|
|
|
|
|
|
|
|
url:result.data.url,
|
|
|
|
|
|
|
|
description:result.data.description,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
isSpining:false
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleSubmit=()=>{
|
|
|
|
handleSubmit=()=>{
|
|
|
|
this.props.form.validateFields((err, values) => {
|
|
|
|
this.props.form.validateFields((err, values) => {
|
|
|
|
if(!err){
|
|
|
|
if(!err){
|
|
|
|
const CourseId=this.props.match.params.coursesId;
|
|
|
|
const { liveId } = this.props;
|
|
|
|
const url = `/courses/${CourseId}/live_links.json`;
|
|
|
|
if(liveId){
|
|
|
|
axios.post(url,{
|
|
|
|
// 修改
|
|
|
|
...values
|
|
|
|
this.updateFunc(liveId,values);
|
|
|
|
}).then(result=>{
|
|
|
|
}else{
|
|
|
|
if(result){
|
|
|
|
this.creatFunc(values);
|
|
|
|
this.props.showNotification("添加成功!");
|
|
|
|
}
|
|
|
|
const { setliveVisibel } = this.props;
|
|
|
|
|
|
|
|
setliveVisibel && setliveVisibel(false,true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch(error=>{
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 修改
|
|
|
|
|
|
|
|
updateFunc=(id,values)=>{
|
|
|
|
|
|
|
|
const url = `/live_links/${id}.json`;
|
|
|
|
|
|
|
|
axios.put(url,{
|
|
|
|
|
|
|
|
...values
|
|
|
|
|
|
|
|
}).then(result=>{
|
|
|
|
|
|
|
|
if(result){
|
|
|
|
|
|
|
|
this.props.showNotification("修改成功!");
|
|
|
|
|
|
|
|
const { setliveVisibel } = this.props;
|
|
|
|
|
|
|
|
setliveVisibel && setliveVisibel(false,true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch(error=>{
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 新增
|
|
|
|
|
|
|
|
creatFunc=(values)=>{
|
|
|
|
|
|
|
|
const CourseId=this.props.match.params.coursesId;
|
|
|
|
|
|
|
|
const url = `/courses/${CourseId}/live_links.json`;
|
|
|
|
|
|
|
|
axios.post(url,{
|
|
|
|
|
|
|
|
...values
|
|
|
|
|
|
|
|
}).then(result=>{
|
|
|
|
|
|
|
|
if(result){
|
|
|
|
|
|
|
|
this.props.showNotification("添加成功!");
|
|
|
|
|
|
|
|
const { setliveVisibel } = this.props;
|
|
|
|
|
|
|
|
setliveVisibel && setliveVisibel(false,true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch(error=>{
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
validateDesc= (rule, value, callback) => {
|
|
|
|
validateDesc= (rule, value, callback) => {
|
|
|
|
if (value.length > 100) {
|
|
|
|
if (value.length > 100) {
|
|
|
@ -44,8 +102,10 @@ class LiveNew extends Component{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
render(){
|
|
|
|
|
|
|
|
const { isSpining } = this.state;
|
|
|
|
const {getFieldDecorator} = this.props.form;
|
|
|
|
const {getFieldDecorator} = this.props.form;
|
|
|
|
const { visible } = this.props;
|
|
|
|
const { visible } = this.props;
|
|
|
|
|
|
|
|
|
|
|
|
return(
|
|
|
|
return(
|
|
|
|
<Modal
|
|
|
|
<Modal
|
|
|
|
visible={visible}
|
|
|
|
visible={visible}
|
|
|
@ -55,34 +115,36 @@ class LiveNew extends Component{
|
|
|
|
closable={false}
|
|
|
|
closable={false}
|
|
|
|
className="liveModal"
|
|
|
|
className="liveModal"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<div className="task-popup-content">
|
|
|
|
<Spin spinning={isSpining}>
|
|
|
|
<Form onSubmit={this.handleSubmit}>
|
|
|
|
<div className="task-popup-content">
|
|
|
|
<Form.Item label={`直播链接`}>
|
|
|
|
<Form onSubmit={this.handleSubmit}>
|
|
|
|
{getFieldDecorator('url', {
|
|
|
|
<Form.Item label={`直播链接`}>
|
|
|
|
rules: [{required: true, message: "请输入第三方直播链接"}],
|
|
|
|
{getFieldDecorator('url', {
|
|
|
|
})(
|
|
|
|
rules: [{required: true, message: "请输入第三方直播链接"}],
|
|
|
|
<Input placeholder="请输入第三方直播链接,如:腾讯课堂播放链接等。" />
|
|
|
|
})(
|
|
|
|
)}
|
|
|
|
<Input placeholder="请输入第三方直播链接,如:腾讯课堂播放链接等。" />
|
|
|
|
</Form.Item>
|
|
|
|
)}
|
|
|
|
<Form.Item label={`直播说明`}>
|
|
|
|
</Form.Item>
|
|
|
|
{getFieldDecorator('description', {
|
|
|
|
<Form.Item label={`直播说明`}>
|
|
|
|
rules: [{
|
|
|
|
{getFieldDecorator('description', {
|
|
|
|
validator: this.validateDesc,
|
|
|
|
rules: [{
|
|
|
|
}],
|
|
|
|
validator: this.validateDesc,
|
|
|
|
})(
|
|
|
|
}],
|
|
|
|
<TextArea rows={4} placeholder="可在此介绍开播具体事项,如开播时间安排等。" />
|
|
|
|
})(
|
|
|
|
)}
|
|
|
|
<TextArea rows={4} placeholder="可在此介绍开播具体事项,如开播时间安排等。" />
|
|
|
|
</Form.Item>
|
|
|
|
)}
|
|
|
|
<p className="flex-middle" style={{justifyContent:"space-between"}}>
|
|
|
|
</Form.Item>
|
|
|
|
<span>EduCoder推荐您使用<a href="https://ke.qq.com/" target="_blank" className="color-blue">腾讯课堂</a>进行直播</span>
|
|
|
|
<p className="flex-middle" style={{justifyContent:"space-between"}}>
|
|
|
|
<a href="https://pub.idqqimg.com/pc/misc/files/20200204/2e4cb765bef54f0c919c0ab8ab79d969.pdf" target="_blank" className="color-blue">操作指引</a>
|
|
|
|
<span>EduCoder推荐您使用<a href="https://ke.qq.com/" target="_blank" className="color-blue">腾讯课堂</a>进行直播</span>
|
|
|
|
</p>
|
|
|
|
<a href="https://pub.idqqimg.com/pc/misc/files/20200204/2e4cb765bef54f0c919c0ab8ab79d969.pdf" target="_blank" className="color-blue">操作指引</a>
|
|
|
|
</Form>
|
|
|
|
</p>
|
|
|
|
<div className="clearfix mt30 edu-txt-center">
|
|
|
|
</Form>
|
|
|
|
<a onClick={this.cancelNew} className="task-btn mr30">取消</a>
|
|
|
|
<div className="clearfix mt30 edu-txt-center">
|
|
|
|
<a type="submit" onClick={this.handleSubmit} className="task-btn task-btn-orange">确定</a>
|
|
|
|
<a onClick={this.cancelNew} className="task-btn mr30">取消</a>
|
|
|
|
|
|
|
|
<a type="submit" onClick={this.handleSubmit} className="task-btn task-btn-orange">确定</a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Spin>
|
|
|
|
</Modal>
|
|
|
|
</Modal>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|