Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

video_transcode
杨树林 5 years ago
commit ed00a8c377

@ -0,0 +1,46 @@
function Mediator(obj) {
const channels = {}
const mediator = {
subscribe: function (channel, cb) {
if (!channels[channel]) {
channels[channel] = []
}
channels[channel].push(cb)
return this.unsubscribe.bind(null, channel, cb)
},
unsubscribe: function (channel, cb) {
let rs = channels[channel]
let index = -1
if (rs) {
for (let i = 0; i < rs.length; i++) {
if (rs[i].name === cb.name) {
index = i
break
}
}
if (index >= 0) {
channels[channel].splice(index, 1)
return true
}
}
return false
},
publish: function (channel) {
if (!channels[channel]) {
return false
}
const args = Array.prototype.slice.call(arguments, 1)
channels[channel].forEach(subscription => {
subscription.apply(null, args)
})
return this
},
}
return obj ? Object.assign(obj, mediator) : mediator
}
const mediator = new Mediator()
export default mediator

@ -1,118 +1,117 @@
import React, { Component } from 'react'; import React, { Component, Fragment } from 'react';
import {getImageUrl} from 'educoder'; import { getImageUrl } from 'educoder';
import CoursesHomeCard from "./CoursesHomeCard.js" import CoursesHomeCard from "./CoursesHomeCard.js"
import axios from 'axios'; import axios from 'axios';
import {Input,Tooltip} from 'antd'; import { Pagination } from 'antd';
import LoadingSpin from '../../../common/LoadingSpin'; import LoadingSpin from '../../../common/LoadingSpin';
import UpgradeModals from '../../modals/UpgradeModals'; import UpgradeModals from '../../modals/UpgradeModals';
import './css/CoursesHome.css'; import './css/CoursesHome.css';
import Pagination from '@icedesign/base/lib/pagination'; import '../../tpm/shixuns/shixun-keyword-list.scss';
import '@icedesign/base/lib/pagination/style.js'; import btnNew from './btn-new.png'
import btnJoin from './btn-join.png'
class CoursesHome extends Component {
const Search = Input.Search;
class CoursesHome extends Component{
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
limit:16, limit: 16,
page:1, page: 1,
order:"created_at", order: "created_at",
coursesHomelist:undefined, coursesHomelist: undefined,
search:"", search: "",
} }
} }
//切换列表状态 //切换列表状态
changeStatus=(value)=>{ changeStatus = (value) => {
this.setState({ this.setState({
order:value, order: value,
page:1, page: 1,
coursesHomelist:undefined coursesHomelist: undefined
}) })
this.searchcourses(16,1,value,"") this.searchcourses(16, 1, value, "")
} }
//搜索输入 //搜索输入
inputSearchValue=(e)=>{ inputSearchValue = (e) => {
this.setState({ this.setState({
search:e.target.value, search: e.target.value,
page:1 page: 1
}) })
} }
//搜索 //搜索
searchValue=(e)=>{ searchValue = (e) => {
let { search ,order}=this.state; let { search, order } = this.state;
this.setState({ this.setState({
order:order, order: order,
page:1 page: 1
}) })
this.searchcourses(16,1,order,search) this.searchcourses(16, 1, order, search)
} }
componentDidMount(){ componentDidMount() {
document.title="教学课堂"; document.title = "教学课堂";
const upsystem=`/users/system_update.json`; const upsystem = `/users/system_update.json`;
axios.get(upsystem).then((response)=>{ axios.get(upsystem).then((response) => {
let updata=response.data; let updata = response.data;
this.setState({ this.setState({
updata:updata updata: updata
}) })
}).catch((error)=>{ }).catch((error) => {
console.log(error); console.log(error);
}) })
this.searchcourses(16,1,"all","") this.searchcourses(16, 1, "all", "")
} }
onChange=(pageNumber)=> { onChange = (pageNumber) => {
this.setState({ this.setState({
page:pageNumber page: pageNumber
}) })
let {limit,order,search}=this.state; let { limit, order, search } = this.state;
this.searchcourses(limit,pageNumber,order,search) this.searchcourses(limit, pageNumber, order, search)
} }
searchcourses=(limit,page,order,search)=>{ searchcourses = (limit, page, order, search) => {
let url="/courses.json"; let url = "/courses.json";
axios.get(url,{ axios.get(url, {
params: { params: {
limit:limit, limit: limit,
page:page, page: page,
order:order, order: order,
search:search search: search
} }
}).then((result)=>{ }).then((result) => {
if(result.data.status===401){ if (result.data.status === 401) {
}else{ } else {
this.setState({ this.setState({
coursesHomelist:result.data coursesHomelist: result.data
}) })
} }
}).catch((error)=>{ }).catch((error) => {
console.log(error); console.log(error);
}) })
} }
getUser=(url,type)=>{ getUser = (url, type) => {
if(this.props.checkIfLogin()===false){ if (this.props.checkIfLogin() === false) {
this.props.showLoginDialog() this.props.showLoginDialog()
return return
} }
if(this.props.checkIfProfileCompleted()===false){ if (this.props.checkIfProfileCompleted() === false) {
this.props.showProfileCompleteDialog() this.props.showProfileCompleteDialog()
return return
} }
if(url !== undefined || url!==""){ if (url !== undefined || url !== "") {
this.props.history.push(url); this.props.history.push(url);
} }
@ -120,11 +119,12 @@ class CoursesHome extends Component{
} }
render() { render() {
let { order,search,page,coursesHomelist }=this.state; const { order, page, coursesHomelist } = this.state;
//console.log(this.props) const { user, tojoinclass } = this.props
console.log(tojoinclass, '--------------s')
return ( return (
<div> <div>
{this.state.updata===undefined?"":<UpgradeModals {this.state.updata === undefined ? "" : <UpgradeModals
{...this.state} {...this.state}
/>} />}
<div className="newMain clearfix"> <div className="newMain clearfix">
@ -136,7 +136,7 @@ class CoursesHome extends Component{
.courses-head{ .courses-head{
width: 100%; width: 100%;
height: 300px; height: 300px;
background-image: url(${getImageUrl(this.props.mygetHelmetapi && this.props.mygetHelmetapi.course_banner_url === null ?`images/educoder/courses/courses.jpg`:this.props.mygetHelmetapi&&this.props.mygetHelmetapi.course_banner_url)}); background-image: url(${getImageUrl(this.props.mygetHelmetapi && this.props.mygetHelmetapi.course_banner_url === null ? `images/educoder/courses/courses.jpg` : this.props.mygetHelmetapi && this.props.mygetHelmetapi.course_banner_url)});
background-color: #081C4B; background-color: #081C4B;
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
@ -152,43 +152,34 @@ class CoursesHome extends Component{
</div> </div>
</div> </div>
<div className="mt20 educontent mb20 clearfix"> <div className="wrapper">
{/*<a className={ order == "all" ? "fl mr20 font-16 bestChoose active" : "fl mr20 font-16 bestChoose"}*/} <div className="educontent search-keyword-container" style={{ padding: '20px 0 0 0' }}>
{/*onClick={ () => this.changeStatus("all")}>全部</a>*/} <div className="btn-groups">
{/*<a className={ order == "mine" ? "fl mr20 font-16 bestChoose active" : "fl mr20 font-16 bestChoose"}*/} <a id='new' className={order === 'created_at' ? 'active' : ''} onClick={() => this.changeStatus("created_at")} title='最新'>最新</a>
{/*onClick={ () => this.changeStatus("mine")}>我的</a>*/} <a id='hot' className={order === 'visits' ? 'active' : ''} onClick={() => this.changeStatus("visits")} title='最热'>最热</a>
<a className={ order == "created_at" ? "fl mr20 font-16 bestChoose active" : "fl mr20 font-16 bestChoose"} </div>
onClick={ () => this.changeStatus("created_at")}>最新</a> </div>
<a className={ order == "visits" ? "fl mr20 font-16 bestChoose active" : "fl mr20 font-16 bestChoose"} {user && user.user_identity !== '学生' ?
onClick={ () => this.changeStatus("visits")}>最热</a> <Fragment>
{this.props.user&&this.props.user.user_identity==="学生"?"":<span className={ "fr font-16 bestChoose color-blue" } onClick={(url)=>this.getUser("/courses/new")}>+新建教学课堂</span>} <a className="btn-new" style={{ top: '67px' }} onClick={() => { this.getUser("/courses/new") }} > <img src={btnNew} width={40} alt="创建教学课堂" /> </a>
<a className="btn-join" style={{ top: '123px' }} onClick={() => { window._header_componentHandler.tojoinclass() }} > <img src={btnJoin} width={40} alt="加入教学课堂" /> </a>
{/*<div className="fr mr5 search-new">*/} </Fragment> : null
{/*/!* <Search*/} }
{/*placeholder="课堂名称/教师姓名/学校名称"*/}
{/*id="subject_search_input"*/}
{/*value={search}*/}
{/*onInput={this.inputSearchValue}*/}
{/*onSearch={this.searchValue}*/}
{/*autoComplete="off"*/}
{/*></Search> *!/*/}
{/*</div>*/}
</div> </div>
{coursesHomelist===undefined?<LoadingSpin/>:<CoursesHomeCard {...this.props} {...this.state} {coursesHomelist === undefined ? <LoadingSpin /> : <CoursesHomeCard {...this.props} {...this.state}
coursesHomelist={coursesHomelist}></CoursesHomeCard>} coursesHomelist={coursesHomelist}></CoursesHomeCard>}
{coursesHomelist===undefined?"":coursesHomelist.courses.length===0?<div className="edu-tab-con-box clearfix edu-txt-center mb50"> {coursesHomelist === undefined ? "" : coursesHomelist.courses.length === 0 ? <div className="edu-tab-con-box clearfix edu-txt-center mb50">
<img className="edu-nodata-img mb20" src={getImageUrl("images/educoder/nodata.png")}/> <img className="edu-nodata-img mb20" src={getImageUrl("images/educoder/nodata.png")} />
<p className="edu-nodata-p mb20">暂时还没有相关数据哦</p> <p className="edu-nodata-p mb20">暂时还没有相关数据哦</p>
</div>:""} </div> : ""}
{ {
coursesHomelist===undefined?"":coursesHomelist.courses_count > 16? coursesHomelist === undefined ? "" : coursesHomelist.courses_count > 16 ?
<div className="educontent mb80 edu-txt-center mt10"> <div className="educontent mb80 edu-txt-center mt10">
<Pagination current={page} total={ coursesHomelist.courses_count || 1299 } type="mini" pageSize={16} onChange={this.onChange} /> <Pagination current={page} total={coursesHomelist.courses_count || 1299} type="mini" pageSize={16} onChange={this.onChange} />
</div>:"" </div> : ""
} }
</div> </div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

File diff suppressed because it is too large Load Diff

@ -65,6 +65,14 @@
position: absolute; position: absolute;
width: 40px; width: 40px;
right: 39px; right: 39px;
top: 76px; top: 77px;
z-index: 10;
}
.btn-join {
position: absolute;
width: 40px;
right: 39px;
top: 133px;
z-index: 10; z-index: 10;
} }
Loading…
Cancel
Save