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 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 :description, length: { maximum: 100, too_long: "不能超过100个字符" }
validates :course_name, presence: true 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 :live_time, presence: true
validates :duration, numericality: { only_integer: true, greater_than: 0}, allow_blank: 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? def op_auth?
user == User.current || User.current.admin_or_business? user == User.current || User.current.admin_or_business?
end end

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

@ -1,5 +1,5 @@
json.lives @lives do |live| 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.url live.on_status ? live.url : ""
json.author_name live.user.show_real_name json.author_name live.user.show_real_name
json.author_login live.user.login json.author_login live.user.login
@ -7,7 +7,6 @@ json.lives @lives do |live|
json.op_auth live.op_auth? json.op_auth live.op_auth?
json.delete_auth live.delete_auth? json.delete_auth live.delete_auth?
json.live_time live.live_time&.strftime('%Y-%m-%d %H:%M:%S') json.live_time live.live_time&.strftime('%Y-%m-%d %H:%M:%S')
json.platform live.platform_name
end end
json.my_live_id @my_live_id json.my_live_id @my_live_id
json.total_count @total_count 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> <p><span className="task-hide-2 break_word">{item.description}</span></p>
</div> </div>
{ {
item.on_status? (item.on_status && item.url)?
<a className="btns going" target="_blank" href={`${item.url}`}>进入</a> <a className="btns going" target="_blank" href={`${item.url}`}>进入</a>
: :
<span className="btns ect">进入</span> <span className="btns ect">进入</span>

@ -1,5 +1,5 @@
import React,{ Component } from "react"; 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 locale from 'antd/lib/date-picker/locale/zh_CN';
import moment from 'moment'; import moment from 'moment';
import { handleDateString } from 'educoder'; import { handleDateString } from 'educoder';
@ -9,6 +9,7 @@ import axios from 'axios';
const { TextArea } = Input; const { TextArea } = Input;
const { Option } = Select; const { Option } = Select;
const array=['腾讯课堂','B站','斗鱼','威佰通']
function range(start, end) { function range(start, end) {
const result = []; const result = [];
@ -34,17 +35,14 @@ class LiveNew extends Component{
this.state={ this.state={
isSpining:false, isSpining:false,
beginTime:undefined, beginTime:undefined,
beginTimeFlag:false,
} }
} }
componentDidMount=()=>{ componentDidMount=()=>{
console.log("1",this.props.liveId)
this.checkType(); this.checkType();
} }
componentDidUpdate=(prevState)=>{ componentDidUpdate=(prevState)=>{
console.log("2",prevState.liveId);
if(prevState && prevState.liveId !== this.props.liveId){ if(prevState && prevState.liveId !== this.props.liveId){
this.setState({ this.setState({
isSpining:true isSpining:true
@ -55,7 +53,6 @@ class LiveNew extends Component{
checkType=()=>{ checkType=()=>{
const { liveId } = this.props; const { liveId } = this.props;
console.log("3",this.props.liveId);
this.clearAll(); this.clearAll();
if(liveId){ if(liveId){
const url =`/live_links/${liveId}/edit.json`; const url =`/live_links/${liveId}/edit.json`;
@ -64,7 +61,7 @@ class LiveNew extends Component{
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
url:result.data.url, url:result.data.url,
description:result.data.description, description:result.data.description,
platform:result.data.platform || "tencent", platform:result.data.platform || "腾讯课堂",
duration:result.data.duration, duration:result.data.duration,
course_name:result.data.course_name course_name:result.data.course_name
}) })
@ -82,13 +79,9 @@ class LiveNew extends Component{
handleSubmit=()=>{ handleSubmit=()=>{
this.props.form.validateFields((err, values) => { this.props.form.validateFields((err, values) => {
if(!err){ if(!err){
const { beginTime } = this.state;
if(!beginTime){
this.setState({ this.setState({
beginTimeFlag:true isSpining:true
}) })
return;
}
const { liveId } = this.props; const { liveId } = this.props;
if(liveId){ if(liveId){
// 修改 // 修改
@ -112,7 +105,13 @@ class LiveNew extends Component{
const { setliveVisibel } = this.props; const { setliveVisibel } = this.props;
setliveVisibel && setliveVisibel(false,true); setliveVisibel && setliveVisibel(false,true);
} }
this.setState({
isSpining:false
})
}).catch(error=>{ }).catch(error=>{
this.setState({
isSpining:false
})
console.log(error); console.log(error);
}) })
} }
@ -131,7 +130,13 @@ class LiveNew extends Component{
const { setliveVisibel } = this.props; const { setliveVisibel } = this.props;
setliveVisibel && setliveVisibel(false,true); setliveVisibel && setliveVisibel(false,true);
} }
this.setState({
isSpining:false
})
}).catch(error=>{ }).catch(error=>{
this.setState({
isSpining:false
})
console.log(error); console.log(error);
}) })
} }
@ -156,7 +161,7 @@ class LiveNew extends Component{
clearAll=()=>{ clearAll=()=>{
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
course_name:undefined, course_name:undefined,
platform:"tencent", platform:"腾讯课堂",
url:undefined, url:undefined,
description:undefined, description:undefined,
duration:undefined duration:undefined
@ -173,15 +178,20 @@ class LiveNew extends Component{
} }
render(){ render(){
const { isSpining , beginTime , beginTimeFlag } = this.state; const { isSpining , beginTime } = this.state;
const {getFieldDecorator} = this.props.form; const {getFieldDecorator} = this.props.form;
const { visible } = this.props; const { visible } = this.props;
const dataSource = array.map((item,key)=>{
return(
<Option value={item}>{item}</Option>
)
})
return( return(
<Modal <Modal
visible={visible} visible={visible}
width="560px" width="560px"
title={'直播设置'} title={'添加直播'}
footer={null} footer={null}
closable={false} closable={false}
className="liveModal" className="liveModal"
@ -191,36 +201,36 @@ class LiveNew extends Component{
<Form onSubmit={this.handleSubmit}> <Form onSubmit={this.handleSubmit}>
<Form.Item label={`直播课程`}> <Form.Item label={`直播课程`}>
{getFieldDecorator('course_name', { {getFieldDecorator('course_name', {
rules: [{required: true, message: "请输入课程名"}], rules: [{required: true, message: "请输入课程名"}],
})( })(
<Input placeholder="请输入课程名" /> <Input placeholder="请输入课程名" />
)} )}
</Form.Item> </Form.Item>
<Form.Item label={`直播平台`}> <Form.Item label={`直播平台`}>
{getFieldDecorator('platform', { {getFieldDecorator('platform', {
rules: [{required: true, message: "请选择直播平台"}], rules: [{required: true, message: "请选择直播平台"}],
})( })(
<Select> <AutoComplete
<Option value="tencent">腾讯课堂</Option> placeholder="请选择或输入直播平台名称"
<Option value="douyu">斗鱼</Option> dataSource={dataSource}
<Option value="bilibili">B站</Option> >
</Select> </AutoComplete>
)} )}
</Form.Item> </Form.Item>
<Form.Item label={`直播链接`}> <Form.Item label={`直播链接`}>
{getFieldDecorator('url', { {getFieldDecorator('url', {
rules: [{required: true, message: "请输入第三方直播链接"}], rules: [],
})( })(
<Input placeholder="请输入第三方直播链接,如:腾讯课堂播放链接等。" /> <Input placeholder="请输入第三方直播链接,如:腾讯课堂播放链接等。" />
)} )}
</Form.Item> </Form.Item>
<div className="flex-bottom"> <div className="flex-bottom">
<div className="flex1"> <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 <DatePicker
dropdownClassName="hideDisable" dropdownClassName="hideDisable"
className={beginTimeFlag ? "timeStyle borderRed":"timeStyle"} className="timeStyle mb20"
placeholder="年/月/日" placeholder="2020/02/02 12:00"
style={{width:"220px"}} style={{width:"220px"}}
showTime={{ format: 'HH:mm' }} showTime={{ format: 'HH:mm' }}
locale={locale} locale={locale}
@ -231,11 +241,6 @@ class LiveNew extends Component{
value={beginTime && moment(beginTime,"YYYY-MM-DD HH:mm")} value={beginTime && moment(beginTime,"YYYY-MM-DD HH:mm")}
onChange={this.onChangeTime} onChange={this.onChangeTime}
></DatePicker> ></DatePicker>
<p style={{height:"20px",lineHeight:"20px"}} className="pl10">
{
beginTimeFlag && <span className="color-red">请选择开播时间</span>
}
</p>
</div> </div>
<Form.Item label={`直播时长`}> <Form.Item label={`直播时长`}>
{getFieldDecorator('duration', { {getFieldDecorator('duration', {

@ -196,10 +196,22 @@ class VideoIndex extends Component{
<style>{ <style>{
` `
body{ body{
width: 100%!important; width: calc(100% - 7px)!important;
overflow: hidden!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"}}> <div className="edu-back-white" style={{marginBottom:"1px"}}>

Loading…
Cancel
Save