根据设计修改

Adjustreact
caicai8 5 years ago
parent 6b147fa5c3
commit 6d69031da9

@ -1,25 +1,12 @@
import React,{ Component } from "react";
import { Switch } from 'antd';
import { getImageUrl } from 'educoder';
import { WordsBtn } from 'educoder';
import moment from 'moment';
import axios from 'axios';
class LiveItem extends Component{
changeStatus=(flag,event,id)=>{
const url = `/live_links/${id}.json`;
axios.put(url,{
on_status:flag?1:0
}).then(result=>{
if(result){
this.props.showNotification(`直播已${flag?"开启":"关闭"}!`);
const { successFunc } = this.props;
successFunc && successFunc(1);
}
}).catch(error=>{
console.log(error);
})
}
deleteLive=(id)=>{
this.props.confirm({
content: '是否确认删除?',
@ -44,20 +31,13 @@ class LiveItem extends Component{
}
render(){
const { key, item , setLiveId } = this.props;
// let flag = false;
// flag = item.on_status;
return(
<div className="liveItem" key={key}>
<div className="lineMiddle livesMain">
<span className="lineMiddle">
<img alt={`${item.author_name}`} className="liveAuthor" src={getImageUrl(`images/${item.author_img}`)}/>
<label>{item.author_name}</label>
<span className="font-18 task-hide" style={{maxWidth:"759px"}}>{item.course_name}</span>
<span className={item.on_status?"labels living":"labels lived"}>{item.on_status?'已开播':'未开播'}</span>
</span>
{
item.op_auth ?
<Switch checkedChildren="on" key={key} className="switchStyle" unCheckedChildren="off" checked={item.on_status} onChange={(flag,event)=>this.changeStatus(flag,event,item.id)}></Switch>:""
}
</div>
<div className="lineMiddle mt15">
<div className="liveDesc">
@ -71,8 +51,13 @@ class LiveItem extends Component{
}
</div>
<p className="lineMiddle livesMain mt15 font-12">
<span className="color-grey-9">创建时间{item.created_at}</span>
<span className="lineMiddle color-grey-9">
<img alt={`${item.author_name}`} className="liveAuthor" src={getImageUrl(`images/${item.author_img}`)}/>
<label className="mr50">{item.author_name}</label>
{ item.platform && <span className="mr50">直播平台{item.platform}</span> }
{ item.live_time && <span className="mr50">开播时间{item.live_time}</span>}
{ item.duration && <span className="mr50">直播时长{item.duration}</span> }
</span>
<span>
{
item.op_auth ?
@ -80,7 +65,7 @@ class LiveItem extends Component{
}
{
item.delete_auth ?
<WordsBtn style="s" className="ml30" onClick={()=>this.deleteLive(item.id)}>删除</WordsBtn>
<WordsBtn style="grey" className="ml30" onClick={()=>this.deleteLive(item.id)}>删除</WordsBtn>
:""
}
</span>

@ -1,20 +1,50 @@
import React,{ Component } from "react";
import { Modal , Form , Input , Spin } from 'antd';
import { Modal , Form , Input , Spin , Select , DatePicker , InputNumber } from 'antd';
import locale from 'antd/lib/date-picker/locale/zh_CN';
import moment from 'moment';
import { handleDateString } from 'educoder';
import './video.css';
import axios from 'axios';
const { TextArea } = Input;
const { Option } = Select;
function range(start, end) {
const result = [];
for (let i = start; i < end; i++) {
result.push(i);
}
return result;
}
function disabledDateTime() {
return {
disabledMinutes: () => range(1, 30).concat(range(31, 60)),
};
}
function disabledDate(current) {
return current && current < moment().endOf('day').subtract(1, 'days');
}
class LiveNew extends Component{
constructor(props){
super(props);
this.state={
isSpining:false
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
@ -25,7 +55,8 @@ 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`;
axios.get(url).then(result=>{
@ -33,14 +64,15 @@ class LiveNew extends Component{
this.props.form.setFieldsValue({
url:result.data.url,
description:result.data.description,
platform:result.data.platform || "tencent",
duration:result.data.duration,
course_name:result.data.course_name
})
this.setState({
beginTime:result.data.live_time && moment(result.data.live_time,"YYYY-MM-DD HH:mm")
})
}
})
}else{
this.props.form.setFieldsValue({
url:undefined,
description:undefined
})
}
this.setState({
isSpining:false
@ -50,7 +82,13 @@ class LiveNew extends Component{
handleSubmit=()=>{
this.props.form.validateFields((err, values) => {
if(!err){
console.log("2")
const { beginTime } = this.state;
if(!beginTime){
this.setState({
beginTimeFlag:true
})
return;
}
const { liveId } = this.props;
if(liveId){
// 修改
@ -64,8 +102,10 @@ class LiveNew extends Component{
// 修改
updateFunc=(id,values)=>{
const url = `/live_links/${id}.json`;
const { beginTime } = this.state;
axios.put(url,{
...values
...values,
live_time:beginTime
}).then(result=>{
if(result){
this.props.showNotification("修改成功!");
@ -81,8 +121,10 @@ class LiveNew extends Component{
creatFunc=(values)=>{
const CourseId=this.props.match.params.coursesId;
const url = `/courses/${CourseId}/live_links.json`;
const { beginTime } = this.state;
axios.post(url,{
...values
...values,
live_time:beginTime
}).then(result=>{
if(result){
this.props.showNotification("添加成功!");
@ -107,15 +149,31 @@ class LiveNew extends Component{
cancelNew=()=>{
const { setliveVisibel } = this.props;
this.clearAll();
setliveVisibel && setliveVisibel(false);
}
clearAll=()=>{
this.props.form.setFieldsValue({
course_name:undefined,
platform:"tencent",
url:undefined,
description:undefined
description:undefined,
duration:undefined
})
this.setState({
beginTime:undefined
})
}
onChangeTime=(data,dateString)=>{
this.setState({
beginTime:handleDateString(dateString)
})
setliveVisibel && setliveVisibel(false);
}
render(){
const { isSpining } = this.state;
const { isSpining , beginTime , beginTimeFlag } = this.state;
const {getFieldDecorator} = this.props.form;
const { visible } = this.props;
@ -131,6 +189,24 @@ class LiveNew extends Component{
<Spin spinning={isSpining}>
<div className="task-popup-content">
<Form onSubmit={this.handleSubmit}>
<Form.Item label={`直播课程`}>
{getFieldDecorator('course_name', {
rules: [{required: true, message: "请输入课程名字"}],
})(
<Input placeholder="请输入课程名字" />
)}
</Form.Item>
<Form.Item label={`直播平台`}>
{getFieldDecorator('platform', {
rules: [{required: true, message: "请选择直播平台"}],
})(
<Select>
<Option value="tencent">腾讯课堂</Option>
<Option value="douyu">斗鱼</Option>
<Option value="bilibili">B站</Option>
</Select>
)}
</Form.Item>
<Form.Item label={`直播链接`}>
{getFieldDecorator('url', {
rules: [{required: true, message: "请输入第三方直播链接"}],
@ -138,6 +214,38 @@ class LiveNew extends Component{
<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>
<DatePicker
dropdownClassName="hideDisable"
className={beginTimeFlag ? "timeStyle borderRed":"timeStyle"}
placeholder="年/月/日"
style={{width:"220px"}}
showTime={{ format: 'HH:mm' }}
locale={locale}
format="YYYY-MM-DD HH:mm"
showToday={false}
disabledTime={disabledDateTime}
disabledDate={disabledDate}
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', {
rules: [],
})(
<InputNumber placeholder="请输入直播时长" style={{width:"220px"}}/>
)}
</Form.Item>
<span className="mb20 ml5">分钟</span>
</div>
<Form.Item label={`直播说明`}>
{getFieldDecorator('description', {
rules: [{
@ -147,10 +255,7 @@ class LiveNew extends Component{
<TextArea rows={4} placeholder="可在此介绍开播具体事项,如开播时间安排等。" />
)}
</Form.Item>
{/* <p className="flex-middle" style={{justifyContent:"space-between"}}>
<span>EduCoder推荐您使用<a href="https://ke.qq.com/" target="_blank" className="color-blue">腾讯课堂</a></span>
<a href="https://pub.idqqimg.com/pc/misc/files/20200204/2e4cb765bef54f0c919c0ab8ab79d969.pdf" target="_blank" className="color-blue">操作指引</a>
</p> */}
</Form>
<div className="clearfix mt30 edu-txt-center">
<a onClick={this.cancelNew} className="task-btn mr30">取消</a>

@ -28,7 +28,6 @@ class VideoIndex extends Component{
lives:undefined,
liveData:undefined,
my_liveId:undefined,
liveId:undefined,
liveVisible:false
@ -66,8 +65,6 @@ class VideoIndex extends Component{
liveData:result.data,
lives:result.data.lives,
isSpining:false,
my_liveId:result.data.my_live_id,
liveId:result.data.my_live_id
})
}
}).catch(error=>{
@ -155,9 +152,8 @@ class VideoIndex extends Component{
// }
// 直播设置
liveSetting=()=>{
const { my_liveId } = this.state;
this.setState({
liveId:my_liveId
liveId:undefined
})
this.setliveVisibel(true);
}
@ -166,6 +162,11 @@ class VideoIndex extends Component{
this.setState({
liveVisible:flag
})
if(flag === false){
this.setState({
liveId:undefined
})
}
if(changetypeFlag){
this.checkType("live",1);
}
@ -223,7 +224,7 @@ class VideoIndex extends Component{
}
</React.Fragment>
:
<WordsBtn style="blue" className="font-16 ml30" onClick={this.liveSetting}>直播设置</WordsBtn>
<WordsBtn style="blue" className="font-16 ml30" onClick={this.liveSetting}>添加直播</WordsBtn>
}
</li>
}

@ -42,6 +42,11 @@
align-items: center;
height: 25px;
}
.flex-bottom{
display: flex;
justify-content: space-between;
align-items: flex-end;
}
.square-main .buttonRow i {
vertical-align: top;
font-size: 16px;
@ -68,8 +73,8 @@
align-items: center;
}
.liveAuthor{
width: 36px;
height: 36px;
width: 20px;
height: 20px;
border-radius: 50%;
margin-right: 20px;
}
@ -117,6 +122,16 @@
line-clamp: 2;
-webkit-box-orient: vertical;
}
.timeStyle{
transition: 0.5s;
}
.borderRed{
border:1px solid #f5222d;
border-radius: 4px;
}
.setStyle{
margin-bottom: 5px!important;
}
.switchStyle.ant-switch-checked{
background-color: #25C03B;
}
@ -128,7 +143,7 @@
}
.liveModal .ant-row.ant-form-item{
position: relative;
margin-bottom: 20px;
margin-bottom: 16px;
}
.liveModal .ant-form-explain{
position: absolute;
@ -136,8 +151,8 @@
left: 0px;
}
.liveModal .ant-col.ant-form-item-label{
height: 30px;
line-height: 30px;
height: 22px;
line-height: 22px;
}
.platform{
background: #fff;

@ -399,15 +399,15 @@ class ShixunhomeWorkItem extends Component{
</WordsBtn>:"":"":"":""
}
{ this.props.isAdmin?<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">查看详情</a>:""}
{ this.props.isAdmin?<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">作品详情</a>:""}
{
this.props.isStudent? <a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr mt2">查看详情</a>:""
this.props.isStudent? <a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr mt2">作品详情</a>:""
}
{
this.props.isNotMember===true? this.props.discussMessage.private_icon===true?""
:<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">查看详情</a>:""
:<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">作品详情</a>:""
}

Loading…
Cancel
Save