|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import React,{ Component } from "react";
|
|
|
|
|
import { Modal , Form , Input , Spin , Select , DatePicker , InputNumber } from 'antd';
|
|
|
|
|
import { Modal , Form , Input , Spin , Select , AutoComplete , DatePicker , InputNumber } from 'antd';
|
|
|
|
|
import locale from 'antd/lib/date-picker/locale/zh_CN';
|
|
|
|
|
import moment from 'moment';
|
|
|
|
|
import { handleDateString } from 'educoder';
|
|
|
|
@ -9,6 +9,7 @@ import axios from 'axios';
|
|
|
|
|
|
|
|
|
|
const { TextArea } = Input;
|
|
|
|
|
const { Option } = Select;
|
|
|
|
|
const array=['腾讯课堂','B站','斗鱼','威佰通']
|
|
|
|
|
|
|
|
|
|
function range(start, end) {
|
|
|
|
|
const result = [];
|
|
|
|
@ -34,17 +35,14 @@ class LiveNew extends Component{
|
|
|
|
|
this.state={
|
|
|
|
|
isSpining:false,
|
|
|
|
|
beginTime:undefined,
|
|
|
|
|
beginTimeFlag:false,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount=()=>{
|
|
|
|
|
console.log("1",this.props.liveId)
|
|
|
|
|
this.checkType();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidUpdate=(prevState)=>{
|
|
|
|
|
console.log("2",prevState.liveId);
|
|
|
|
|
if(prevState && prevState.liveId !== this.props.liveId){
|
|
|
|
|
this.setState({
|
|
|
|
|
isSpining:true
|
|
|
|
@ -55,7 +53,6 @@ class LiveNew extends Component{
|
|
|
|
|
|
|
|
|
|
checkType=()=>{
|
|
|
|
|
const { liveId } = this.props;
|
|
|
|
|
console.log("3",this.props.liveId);
|
|
|
|
|
this.clearAll();
|
|
|
|
|
if(liveId){
|
|
|
|
|
const url =`/live_links/${liveId}/edit.json`;
|
|
|
|
@ -64,7 +61,7 @@ class LiveNew extends Component{
|
|
|
|
|
this.props.form.setFieldsValue({
|
|
|
|
|
url:result.data.url,
|
|
|
|
|
description:result.data.description,
|
|
|
|
|
platform:result.data.platform || "tencent",
|
|
|
|
|
platform:result.data.platform || "腾讯课堂",
|
|
|
|
|
duration:result.data.duration,
|
|
|
|
|
course_name:result.data.course_name
|
|
|
|
|
})
|
|
|
|
@ -80,15 +77,12 @@ class LiveNew extends Component{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleSubmit=()=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
isSpining:true
|
|
|
|
|
})
|
|
|
|
|
this.props.form.validateFields((err, values) => {
|
|
|
|
|
if(!err){
|
|
|
|
|
const { beginTime } = this.state;
|
|
|
|
|
if(!beginTime){
|
|
|
|
|
this.setState({
|
|
|
|
|
beginTimeFlag:true
|
|
|
|
|
})
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
console.log(values);
|
|
|
|
|
const { liveId } = this.props;
|
|
|
|
|
if(liveId){
|
|
|
|
|
// 修改
|
|
|
|
@ -108,6 +102,9 @@ class LiveNew extends Component{
|
|
|
|
|
live_time:beginTime
|
|
|
|
|
}).then(result=>{
|
|
|
|
|
if(result){
|
|
|
|
|
this.setState({
|
|
|
|
|
isSpining:false
|
|
|
|
|
})
|
|
|
|
|
this.props.showNotification("修改成功!");
|
|
|
|
|
const { setliveVisibel } = this.props;
|
|
|
|
|
setliveVisibel && setliveVisibel(false,true);
|
|
|
|
@ -127,6 +124,9 @@ class LiveNew extends Component{
|
|
|
|
|
live_time:beginTime
|
|
|
|
|
}).then(result=>{
|
|
|
|
|
if(result){
|
|
|
|
|
this.setState({
|
|
|
|
|
isSpining:false
|
|
|
|
|
})
|
|
|
|
|
this.props.showNotification("添加成功!");
|
|
|
|
|
const { setliveVisibel } = this.props;
|
|
|
|
|
setliveVisibel && setliveVisibel(false,true);
|
|
|
|
@ -156,7 +156,7 @@ class LiveNew extends Component{
|
|
|
|
|
clearAll=()=>{
|
|
|
|
|
this.props.form.setFieldsValue({
|
|
|
|
|
course_name:undefined,
|
|
|
|
|
platform:"tencent",
|
|
|
|
|
platform:"腾讯课堂",
|
|
|
|
|
url:undefined,
|
|
|
|
|
description:undefined,
|
|
|
|
|
duration:undefined
|
|
|
|
@ -173,10 +173,15 @@ class LiveNew extends Component{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
const { isSpining , beginTime , beginTimeFlag } = this.state;
|
|
|
|
|
const { isSpining , beginTime } = this.state;
|
|
|
|
|
const {getFieldDecorator} = this.props.form;
|
|
|
|
|
const { visible } = this.props;
|
|
|
|
|
|
|
|
|
|
const dataSource = array.map((item,key)=>{
|
|
|
|
|
return(
|
|
|
|
|
<Option value={item}>{item}</Option>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
return(
|
|
|
|
|
<Modal
|
|
|
|
|
visible={visible}
|
|
|
|
@ -200,26 +205,26 @@ class LiveNew extends Component{
|
|
|
|
|
{getFieldDecorator('platform', {
|
|
|
|
|
rules: [{required: true, message: "请选择直播平台"}],
|
|
|
|
|
})(
|
|
|
|
|
<Select>
|
|
|
|
|
<Option value="tencent">腾讯课堂</Option>
|
|
|
|
|
<Option value="douyu">斗鱼</Option>
|
|
|
|
|
<Option value="bilibili">B站</Option>
|
|
|
|
|
</Select>
|
|
|
|
|
<AutoComplete
|
|
|
|
|
placeholder="请选择或输入直播平台名称"
|
|
|
|
|
dataSource={dataSource}
|
|
|
|
|
>
|
|
|
|
|
</AutoComplete>
|
|
|
|
|
)}
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item label={`直播链接`}>
|
|
|
|
|
{getFieldDecorator('url', {
|
|
|
|
|
rules: [{required: true, message: "请输入第三方直播链接"}],
|
|
|
|
|
rules: [],
|
|
|
|
|
})(
|
|
|
|
|
<Input placeholder="请输入第三方直播链接,如:腾讯课堂播放链接等。" />
|
|
|
|
|
)}
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<div className="flex-bottom">
|
|
|
|
|
<div className="flex1">
|
|
|
|
|
<p className="ant-col ant-form-item-label color-grey-3 font-16 setStyle"><span className="color-red">*</span>开播时间</p>
|
|
|
|
|
<p className="ant-col ant-form-item-label color-grey-3 font-16 setStyle">开播时间</p>
|
|
|
|
|
<DatePicker
|
|
|
|
|
dropdownClassName="hideDisable"
|
|
|
|
|
className={beginTimeFlag ? "timeStyle borderRed":"timeStyle"}
|
|
|
|
|
className="timeStyle mb20"
|
|
|
|
|
placeholder="年/月/日"
|
|
|
|
|
style={{width:"220px"}}
|
|
|
|
|
showTime={{ format: 'HH:mm' }}
|
|
|
|
@ -231,11 +236,6 @@ class LiveNew extends Component{
|
|
|
|
|
value={beginTime && moment(beginTime,"YYYY-MM-DD HH:mm")}
|
|
|
|
|
onChange={this.onChangeTime}
|
|
|
|
|
></DatePicker>
|
|
|
|
|
<p style={{height:"20px",lineHeight:"20px"}} className="pl10">
|
|
|
|
|
{
|
|
|
|
|
beginTimeFlag && <span className="color-red">请选择开播时间</span>
|
|
|
|
|
}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<Form.Item label={`直播时长`}>
|
|
|
|
|
{getFieldDecorator('duration', {
|
|
|
|
|