Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

Adjustreact
杨树明 5 years ago
commit b7677866fa

@ -4,26 +4,13 @@ class LiveLink < ApplicationRecord
has_many :tidings, as: :container, dependent: :destroy
validates :url, format: { with: CustomRegexp::URL, message: "必须为网址超链接" }
# validates :url, format: { with: CustomRegexp::URL, message: "必须为网址超链接" }
validates :description, length: { maximum: 100, too_long: "不能超过100个字符" }
validates :course_name, presence: true
validates :platform, presence: true, inclusion: {in: %W(tencent douyu bilibili vbt)}
validates :platform, presence: true
# validates :live_time, presence: true
validates :duration, numericality: { only_integer: true, greater_than: 0}, allow_blank: true
def platform_name
case platform
when "tencent"
"腾讯课堂"
when "douyu"
"斗鱼直播"
when "vbt"
"威佰通"
else
platform
end
end
def op_auth?
user == User.current || User.current.admin_or_business?
end

@ -40,10 +40,14 @@ json.exam do
json.all_questions_count @items.size
json.discipline do
json.(@exam.sub_discipline&.discipline, :id, :name)
if @exam.sub_discipline&.discipline.present?
json.(@exam.sub_discipline&.discipline, :id, :name)
end
end
json.sub_discipline do
json.(@exam.sub_discipline, :id, :name)
if @exam.sub_discipline.present?
json.(@exam.sub_discipline, :id, :name)
end
end
json.tag_disciplines @exam.tag_disciplines do |tag|
json.(tag, :id, :name)

@ -1,5 +1,5 @@
json.lives @lives do |live|
json.(live, :id, :description, :on_status, :duration, :course_name)
json.(live, :id, :description, :on_status, :duration, :course_name, :platform)
json.url live.on_status ? live.url : ""
json.author_name live.user.show_real_name
json.author_login live.user.login
@ -7,7 +7,6 @@ json.lives @lives do |live|
json.op_auth live.op_auth?
json.delete_auth live.delete_auth?
json.live_time live.live_time&.strftime('%Y-%m-%d %H:%M:%S')
json.platform live.platform_name
end
json.my_live_id @my_live_id
json.total_count @total_count

@ -0,0 +1,11 @@
class MigrateUserLocation < ActiveRecord::Migration[5.2]
def change
UserExtension.where("location like '%省'").each do |ue|
ue.update_column("location", ue.location.chop)
end
UserExtension.where("location_city like '%市'").each do |ue|
ue.update_column("location_city", ue.location_city.chop)
end
end
end

@ -44,7 +44,7 @@ class LiveItem extends Component{
<p><span className="task-hide-2 break_word">{item.description}</span></p>
</div>
{
item.on_status?
(item.on_status && item.url)?
<a className="btns going" target="_blank" href={`${item.url}`}>进入</a>
:
<span className="btns ect">进入</span>

@ -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
})
@ -82,13 +79,9 @@ class LiveNew extends Component{
handleSubmit=()=>{
this.props.form.validateFields((err, values) => {
if(!err){
const { beginTime } = this.state;
if(!beginTime){
this.setState({
beginTimeFlag:true
})
return;
}
this.setState({
isSpining:true
})
const { liveId } = this.props;
if(liveId){
// 修改
@ -112,7 +105,13 @@ class LiveNew extends Component{
const { setliveVisibel } = this.props;
setliveVisibel && setliveVisibel(false,true);
}
this.setState({
isSpining:false
})
}).catch(error=>{
this.setState({
isSpining:false
})
console.log(error);
})
}
@ -131,7 +130,13 @@ class LiveNew extends Component{
const { setliveVisibel } = this.props;
setliveVisibel && setliveVisibel(false,true);
}
this.setState({
isSpining:false
})
}).catch(error=>{
this.setState({
isSpining:false
})
console.log(error);
})
}
@ -156,7 +161,7 @@ class LiveNew extends Component{
clearAll=()=>{
this.props.form.setFieldsValue({
course_name:undefined,
platform:"tencent",
platform:"腾讯课堂",
url:undefined,
description:undefined,
duration:undefined
@ -173,15 +178,20 @@ 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}
width="560px"
title={'直播设置'}
title={'添加直播'}
footer={null}
closable={false}
className="liveModal"
@ -191,36 +201,36 @@ class LiveNew extends Component{
<Form onSubmit={this.handleSubmit}>
<Form.Item label={`直播课程`}>
{getFieldDecorator('course_name', {
rules: [{required: true, message: "请输入课程名"}],
rules: [{required: true, message: "请输入课程名"}],
})(
<Input placeholder="请输入课程名" />
<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>
<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"}
placeholder="年/月/日"
className="timeStyle mb20"
placeholder="2020/02/02 12:00"
style={{width:"220px"}}
showTime={{ format: 'HH:mm' }}
locale={locale}
@ -231,11 +241,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', {

@ -196,10 +196,22 @@ class VideoIndex extends Component{
<style>{
`
body{
width: 100%!important;
width: calc(100% - 7px)!important;
overflow: hidden!important;
}
`}</style>:""
.-task-sidebar{
right:44px!important
}
`}</style>:
<style>{
`
.-task-sidebar{
right:35px
}
body{
width: 100%!important;
}
`}</style>
}
<div className="edu-back-white" style={{marginBottom:"1px"}}>

Loading…
Cancel
Save