杨树林 6 years ago
commit 31d6f89448

@ -110,13 +110,15 @@ class Cropper extends Component {
render() { render() {
const { width, height, previewId, imageSrc } = this.props; const { width, height, previewId, imageSrc } = this.props;
return ( return (
<div> <div>
{/* This rule is very important, please do not ignore this! */} {/* This rule is very important, please do not ignore this! */}
<style>{` <style>{`
.wrapper { .wrapper {
width: ${ (width+'px') || '500px'}; width: ${ width ? (width+'px') : '500px'};
height: ${ (height+'px') || '500px'}; height: ${ height ? (height+'px') : '500px'};
border: 1px solid #eee;
} }
img { img {
max-width: 100%; max-width: 100%;
@ -129,8 +131,11 @@ class Cropper extends Component {
} }
`}</style> `}</style>
<div className="wrapper"> <div className="wrapper">
{/* http://localhost:3007/images/footNavLogo.png 图片转了后不对 */} {/* http://localhost:3007/images/footNavLogo.png 图片转了后不对
<img id={this.props.imageId || "__image"} src={`${imageSrc || "/images/testPicture.jpg"}`}></img> || "/images/testPicture.jpg"
|| "/images/shixun0.jpg"
*/}
<img id={this.props.imageId || "__image"} src={`${imageSrc }`}></img>
</div> </div>
{/* background: 'aquamarine', {/* background: 'aquamarine',
'border-radius': '128px' 'border-radius': '128px'

@ -659,7 +659,7 @@ class ShixunStudentWork extends Component {
{data&&data? {data&&data?
<div> <div>
<ul className="clearfix" style={{padding: '20px 40px 10px 40px'}}> <ul className="clearfix" style={{padding: '20px 16px 10px'}}>
<li className="clearfix "> <li className="clearfix ">
<span className="fl mr10 color-grey-8 ">查重时间{data&&data.last_review_time}</span> <span className="fl mr10 color-grey-8 ">查重时间{data&&data.last_review_time}</span>
@ -715,7 +715,7 @@ class ShixunStudentWork extends Component {
</ul> </ul>
<div id="graduation_work_list" style={{padding: '0px 40px 10px 40px'}}> <div id="graduation_work_list" style={{padding: '0px 16px 10px'}}>
<div className="clearfix"> <div className="clearfix">
<span className="fl color-grey-6 font-12"> <span className="fl color-grey-6 font-12">
@ -755,11 +755,12 @@ class ShixunStudentWork extends Component {
{datalist === undefined ? "" : <Table {datalist === undefined ? "" : <Table
dataSource={datalist} dataSource={datalist}
columns={columns} columns={columns}
pagination={{ //分页 pagination={ datalist.length<11?false:{ //分页
total: datalist.length===0?0:data&&data.all_reviews_count, //数据总数量 total: datalist.length===0?0:data&&data.all_reviews_count, //数据总数量
pageSize: 10, //显示几条一页 pageSize: 10, //显示几条一页
current:page, current:page,
}} }}
onChange={this.TablePagination} onChange={this.TablePagination}
/>} />}
</div> </div>

@ -358,7 +358,7 @@ class ShixunhomeWorkItem extends Component{
` `
} }
</style> </style>
{this.props.isAdmin?<div className={this.props.isClassManagement?"homepagePostSetting homepagePostSettingname":"homepagePostSetting homepagePostSettingbox"} style={{"right":"-2px","top":"44px","display":"block"}}> {this.props.isAdmin?<div className={this.props.isAdminOrTeacher()?"homepagePostSetting homepagePostSettingname":"homepagePostSetting homepagePostSettingbox"} style={{"right":"-2px","top":"44px","display":"block"}}>
<a className="btn colorblue font-16" href={"/shixuns/"+discussMessage.shixun_identifier+"/challenges"} target={"_blank"}>实训详情</a> <a className="btn colorblue font-16" href={"/shixuns/"+discussMessage.shixun_identifier+"/challenges"} target={"_blank"}>实训详情</a>
{this.props.isAdminOrTeacher()?<a onClick={()=>this.editname(discussMessage.name,discussMessage.homework_id)} className={"btn colorblue ml20 font-16"}>重命名</a>:""} {this.props.isAdminOrTeacher()?<a onClick={()=>this.editname(discussMessage.name,discussMessage.homework_id)} className={"btn colorblue ml20 font-16"}>重命名</a>:""}
<WordsBtn className="btn colorblue ml20 font-16" to={`/courses/${this.props.match.params.coursesId}/${this.state.shixuntypes}/${discussMessage.homework_id}/settings`} > 设置</WordsBtn> <WordsBtn className="btn colorblue ml20 font-16" to={`/courses/${this.props.match.params.coursesId}/${this.state.shixuntypes}/${discussMessage.homework_id}/settings`} > 设置</WordsBtn>

@ -31,7 +31,9 @@ class ShixunWorkModal extends Component{
response.data.group_list.map((item,key)=>{ response.data.group_list.map((item,key)=>{
newgroup_list.push(item) newgroup_list.push(item)
}) })
if( response.data.ungroup_list!== undefined || response.data.ungroup_list !== null){ if(response.data.ungroup_list===undefined){
}else{
newgroup_list.push(response.data.ungroup_list) newgroup_list.push(response.data.ungroup_list)
} }
this.setState({ this.setState({
@ -255,31 +257,10 @@ class ShixunWorkModal extends Component{
<Checkbox.Group style={{ width: '100%' }} onChange={this.shixunhomeworkedit} value={group_ids}> <Checkbox.Group style={{ width: '100%' }} onChange={this.shixunhomeworkedit} value={group_ids}>
{ {
group_list===undefined?course_groups.ungroup_list.work_count===0?"": group_list===undefined?"":
group_list&&group_list.length===0?"":group_list.map((item,key)=>{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE">
<li className="fl task-hide" style={{width: '240px'}}>
<Checkbox
className="fl task-hide edu-txt-left"
name="shixun_homework[]"
value={course_groups.ungroup_list.id}
>
<label style={{"textAlign": "left", "color": "#05101A"}}
className="task-hide color-grey-name" title="frerere">{course_groups.ungroup_list.name}</label>
</Checkbox>
</li>
<li className="fl" style={{width: '100px'}}>
{course_groups.ungroup_list.work_count}
</li>
<li className="fl" style={{width: '160px'}}>
{course_groups.ungroup_list.last_review_time}
</li>
</div>
:
group_list&&group_list.length===0?"":group_list[0]===undefined?"":group_list.map((item,key)=>{
return( return(
item.work_count===0?"":<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" key={key}> <div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" key={key}>
<li className="fl task-hide" style={{width: '240px'}}> <li className="fl task-hide" style={{width: '240px'}}>
<Checkbox <Checkbox
className="fl task-hide edu-txt-left" className="fl task-hide edu-txt-left"
@ -319,3 +300,27 @@ class ShixunWorkModal extends Component{
} }
} }
export default ShixunWorkModal; export default ShixunWorkModal;
// course_groups.ungroup_list.work_count===0?"":
//
// <div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE">
// <li className="fl task-hide" style={{width: '240px'}}>
// <Checkbox
// className="fl task-hide edu-txt-left"
// name="shixun_homework[]"
// value={course_groups.ungroup_list.id}
// >
// <label style={{"textAlign": "left", "color": "#05101A"}}
// className="task-hide color-grey-name" title="frerere">{course_groups.ungroup_list.name}</label>
// </Checkbox>
// </li>
// <li className="fl" style={{width: '100px'}}>
// {course_groups.ungroup_list.work_count}
// </li>
// <li className="fl" style={{width: '160px'}}>
// {course_groups.ungroup_list.last_review_time}
// </li>
// </div>
//
// :

@ -75,9 +75,11 @@ export function TPMIndexHOC(WrappedComponent) {
// header里面需要有user // header里面需要有user
initCommonState(user) { initCommonState(user) {
// 更新头像后,需要改变参数,不然会被图片缓存影响到
const newUser = Object.assign({}, {...user}, { image_url: `${user.image_url}?t=${new Date().getTime()}`});
this.setState({ this.setState({
user, user: newUser,
current_user: user current_user: newUser
}) })
} }
showShixun = () => { showShixun = () => {
@ -230,7 +232,7 @@ export function TPMIndexHOC(WrappedComponent) {
/** /**
课堂权限相关方法暂时写这里了 ----------------------------------------END 课堂权限相关方法暂时写这里了 ----------------------------------------END
*/ */
fetchUser() { fetchUser = () => {
let url = `/users/get_user_info.json` let url = `/users/get_user_info.json`
let courseId; let courseId;
let query = this.props.location.pathname; let query = this.props.location.pathname;
@ -289,7 +291,8 @@ export function TPMIndexHOC(WrappedComponent) {
isStudent: this.isStudent, isStudent: this.isStudent,
isAdminOrStudent: this.isAdminOrStudent, isAdminOrStudent: this.isAdminOrStudent,
isNotMember: this.isNotMember, isNotMember: this.isNotMember,
isUserid:this.state.coursedata&&this.state.coursedata.userid isUserid:this.state.coursedata&&this.state.coursedata.userid,
fetchUser: this.fetchUser
} }
return ( return (
<div> <div>

@ -51,11 +51,11 @@ class AccountPage extends Component {
} }
getBasicInfo=(login)=>{ getBasicInfo=(login)=>{
let url=`/users/accounts/${login}.json`; let url=`/users/accounts/${login || this.props.current_user.login}.json`;
axios.get(url).then((result)=>{ axios.get(url).then((result)=>{
if(result.data){ if(result.data){
this.setState({ this.setState({
basicInfo:result.data basicInfo: Object.assign({}, {...result.data}, { avatar_url: `${result.data.avatar_url}?t=${new Date().getTime()}`})
}) })
if(result.data && result.data.base_info_completed == false){ if(result.data && result.data.base_info_completed == false){
this.props.history.push(`/account/basic/edit`); this.props.history.push(`/account/basic/edit`);

@ -2,14 +2,16 @@ import React, { Component } from 'react';
import { SnackbarHOC, getImageUrl } from 'educoder'; import { SnackbarHOC, getImageUrl } from 'educoder';
import ChangeHeaderPicModal from './ChangeHeaderPicModal' import ChangeHeaderPicModal from './ChangeHeaderPicModal'
class AccountNav extends Component { class AccountImg extends Component {
editImg = () => { editImg = () => {
this.refs['picModal'].setVisible(true) this.refs['picModal'].setVisible(true)
} }
render() { render() {
const picUrl = getImageUrl("images/"+this.props.src)
return ( return (
<div className="headphoto mt14"> <div className="headphoto mt14">
<ChangeHeaderPicModal {...this.props} ref="picModal"></ChangeHeaderPicModal> <ChangeHeaderPicModal
{...this.props} ref="picModal" imageSrc={picUrl} userLogin={this.props.current_user ? this.props.current_user.login : '' }></ChangeHeaderPicModal>
<style>{` <style>{`
/* /*
.headphoto { .headphoto {
@ -47,11 +49,11 @@ class AccountNav extends Component {
display: block; display: block;
} }
`}</style> `}</style>
<img alt="头像" id="user_avatar_show" nhname="avatar_image" src={`${getImageUrl("images/"+this.props.src)}`}></img> <img alt="头像" id="user_avatar_show" nhname="avatar_image" src={`${picUrl}`}></img>
<p className="headphoto-black" onClick={this.editImg} >修改头像</p> <p className="headphoto-black" onClick={this.editImg} >修改头像</p>
</div> </div>
); );
} }
} }
export default AccountNav; export default AccountImg;

@ -22,7 +22,7 @@ class AccountNav extends Component {
return ( return (
<div className="accountNav fl"> <div className="accountNav fl">
<div className="accountInfo"> <div className="accountInfo">
<AccountImg src={basicInfo && basicInfo.avatar_url}></AccountImg> <AccountImg src={basicInfo && basicInfo.avatar_url} {...this.props}></AccountImg>
<span className="name">{basicInfo && basicInfo.name}</span> <span className="name">{basicInfo && basicInfo.name}</span>
<span className="role">{basicInfo && basicInfo.technical_title}</span> <span className="role">{basicInfo && basicInfo.technical_title}</span>
</div> </div>

@ -28,6 +28,10 @@ class ChangeHeaderPicModal extends Component{
file = files[0]; file = files[0];
if (/^image\/\w+/.test(file.type)) { if (/^image\/\w+/.test(file.type)) {
if (file.size > 2 * 1024 * 1024) {
this.props.showNotification && this.props.showNotification("仅支持文件大小小于2M的文件")
return;
}
uploadedImageType = file.type; uploadedImageType = file.type;
uploadedImageName = file.name; uploadedImageName = file.name;
@ -41,7 +45,6 @@ class ChangeHeaderPicModal extends Component{
// cropper = new Cropper(image, options); // cropper = new Cropper(image, options);
inputImage.value = null; inputImage.value = null;
} else { } else {
this.props.showNotification && this.props.showNotification("请选择一个图片格式的文件") this.props.showNotification && this.props.showNotification("请选择一个图片格式的文件")
// window.alert('Please choose an image file.'); // window.alert('Please choose an image file.');
} }
@ -72,14 +75,16 @@ class ChangeHeaderPicModal extends Component{
var dataUrl = canvas.toDataURL("image/jpeg"); var dataUrl = canvas.toDataURL("image/jpeg");
console.log(dataUrl) console.log(dataUrl)
const url = `/users/accounts/${this.props.userLogin || 'kosasa'}/avatar.json` const url = `/users/accounts/${this.props.userLogin}/avatar.json`
axios.put(url, { axios.put(url, {
image: dataUrl image: dataUrl
}) })
.then((response) => { .then((response) => {
// {"status":0,"message":"success","avatar_url":"avatars/User/15739"} // {"status":0,"message":"success","avatar_url":"avatars/User/15739"}
if (response.data.status == 0) { if (response.data.status == 0) {
// this.props.getBasicInfo()
this.props.fetchUser()
// 头像更新后会触发AccountPage的DidUpdate然后会调用getBasicInfo
this.props.showNotification && this.props.showNotification("修改头像成功") this.props.showNotification && this.props.showNotification("修改头像成功")
this.setVisible(false) this.setVisible(false)
} }
@ -111,6 +116,7 @@ class ChangeHeaderPicModal extends Component{
text-align: center; text-align: center;
width: 120px; width: 120px;
height: 120px; height: 120px;
border: 1px solid #eee;
} }
.previewWrap { .previewWrap {
flex-direction: column; flex-direction: column;
@ -121,10 +127,14 @@ class ChangeHeaderPicModal extends Component{
} }
.changeHeaderModal .tip { .changeHeaderModal .tip {
color: #9B9B9B; color: #9B9B9B;
margin-top: 4px;
}
.changeHeaderModal .cropperWrap .tip {
display: inline-block;
} }
.previewWrap .tip { .previewWrap .tip {
text-align: center; text-align: center;
margin-top: 2px; margin-top: 4px;
} }
#uploadBtn { #uploadBtn {
color: #4CACFF; color: #4CACFF;
@ -134,8 +144,9 @@ class ChangeHeaderPicModal extends Component{
} }
`}</style> `}</style>
<div className="df"> <div className="df">
<div> <div className="cropperWrap">
<Cropper <Cropper
imageSrc={''}
ref="cropper" ref="cropper"
imageId={imageId} imageId={imageId}
previewId="changeHeader_imagePreview" previewId="changeHeader_imagePreview"

Loading…
Cancel
Save