Commit 6ba731e7 by zhangleyuan

feat:处理封面图相关的展示

parent 89929c93
...@@ -27,6 +27,7 @@ const defaultCover = 'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png'; ...@@ -27,6 +27,7 @@ const defaultCover = 'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png';
const defaultBasicInfo = { const defaultBasicInfo = {
courseName: null, // 课程名称 courseName: null, // 课程名称
coverUrl: defaultCover, coverUrl: defaultCover,
coverId:null,
categoryId:null, categoryId:null,
categoryName:null, categoryName:null,
}; };
...@@ -69,6 +70,7 @@ class AddLive extends React.Component { ...@@ -69,6 +70,7 @@ class AddLive extends React.Component {
addLiveBasicInfo: { addLiveBasicInfo: {
courseName: null, // 课程名称 courseName: null, // 课程名称
coverUrl: defaultCover, coverUrl: defaultCover,
coverId:null,
categoryId:null, categoryId:null,
categoryName:null, categoryName:null,
}, },
...@@ -127,13 +129,15 @@ class AddLive extends React.Component { ...@@ -127,13 +129,15 @@ class AddLive extends React.Component {
categoryName, categoryName,
admins admins
} = res.result; } = res.result;
let coverId;
let coverUrl; let coverUrl;
let liveCourseMediaRequests = []; let liveCourseMediaRequests = [];
let liveCourseWarmMedia; let liveCourseWarmMedia;
courseMediaVOS.map((item) => { courseMediaVOS.map((item) => {
switch (item.contentType){ switch (item.contentType){
case "COVER": case "COVER":
coverUrl = item.mediaContent; coverId = item.mediaContent;
coverUrl = item.mediaUrl;
break; break;
case "WARMUP": case "WARMUP":
liveCourseWarmMedia = item; liveCourseWarmMedia = item;
...@@ -147,10 +151,11 @@ class AddLive extends React.Component { ...@@ -147,10 +151,11 @@ class AddLive extends React.Component {
return item; return item;
}) })
const addLiveBasicInfo = { const addLiveBasicInfo = {
courseName, courseName,
coverUrl: coverUrl || defaultCover, coverUrl: coverUrl || defaultCover,
coverId,
categoryId, categoryId,
categoryName categoryName
}; };
...@@ -196,14 +201,16 @@ class AddLive extends React.Component { ...@@ -196,14 +201,16 @@ class AddLive extends React.Component {
} }
// 修改基本信息 // 修改基本信息
handleChangeBasicInfo = (field, value) => { // 修改基本信息
this.setState({ handleChangeBasicInfo = (field, value) => {
addLiveBasicInfo: { const { coverUrl } = this.state.addLiveBasicInfo;
...this.state.addLiveBasicInfo, this.setState({
[field]: value, addLiveBasicInfo: {
} ...this.state.addLiveBasicInfo,
},()=>{console.log(this.state.addLiveBasicInfo)}) [field]: value,
} }
})
}
// 修改上课信息 // 修改上课信息
handleChangeClassInfo = (field, value) => { handleChangeClassInfo = (field, value) => {
...@@ -262,7 +269,7 @@ class AddLive extends React.Component { ...@@ -262,7 +269,7 @@ class AddLive extends React.Component {
this.handleValidate(addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit).then((res) => { this.handleValidate(addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit).then((res) => {
if (!res) return; if (!res) return;
const { type } = this.state; const { type } = this.state;
const { courseName, coverUrl,categoryId} = addLiveBasicInfo; const { courseName,coverUrl,coverId,categoryId} = addLiveBasicInfo;
const { const {
liveDate, liveDate,
teacherId, teacherId,
...@@ -285,10 +292,18 @@ class AddLive extends React.Component { ...@@ -285,10 +292,18 @@ class AddLive extends React.Component {
startTime = moment(_liveDate + ' ' + _timeHorizonStart).format('x'); startTime = moment(_liveDate + ' ' + _timeHorizonStart).format('x');
endTime = moment(_liveDate + ' ' + _timeHorizonEnd).format('x'); endTime = moment(_liveDate + ' ' + _timeHorizonEnd).format('x');
} }
const coverObj ={
let coverObj ={
contentType:'COVER', contentType:'COVER',
mediaContent:coverUrl, mediaContent:coverId,
mediaType:'PICTURE' mediaType:'PICTURE',
mediaUrl: coverUrl,
}
let scheduleMediaRequests;
if(coverId){
scheduleMediaRequests = [coverObj,liveCourseWarmMedia,...liveCourseMediaRequests]
}else{
scheduleMediaRequests = [liveCourseWarmMedia,...liveCourseMediaRequests]
} }
const commonParams = { const commonParams = {
adminIds:assistant, adminIds:assistant,
...@@ -301,7 +316,7 @@ class AddLive extends React.Component { ...@@ -301,7 +316,7 @@ class AddLive extends React.Component {
storeId:User.getStoreId(), storeId:User.getStoreId(),
teacherId:teacherId, teacherId:teacherId,
whetherVisitorsJoin, whetherVisitorsJoin,
scheduleMediaRequests:[coverObj,liveCourseWarmMedia,...liveCourseMediaRequests] scheduleMediaRequests
} }
if (type === 'add') { if (type === 'add') {
......
...@@ -61,6 +61,9 @@ class AddLiveBasic extends React.Component { ...@@ -61,6 +61,9 @@ class AddLiveBasic extends React.Component {
if (isDefaultCover) return; if (isDefaultCover) return;
message.success('已替换为默认图'); message.success('已替换为默认图');
this.props.onChange('coverUrl',defaultCover); this.props.onChange('coverUrl',defaultCover);
setTimeout(()=>{
this.props.onChange('coverId', null);
},1000)
} }
catalogChange= (value) => { catalogChange= (value) => {
...@@ -108,7 +111,7 @@ class AddLiveBasic extends React.Component { ...@@ -108,7 +111,7 @@ class AddLiveBasic extends React.Component {
const viewImgDom = document.querySelector('#preview-url-box'); const viewImgDom = document.querySelector('#preview-url-box');
const options = { const options = {
size: [500, 73], size: [297, 169],
rotateFree: false, rotateFree: false,
ok: okBtnDom, ok: okBtnDom,
view: viewImgDom, view: viewImgDom,
...@@ -126,6 +129,7 @@ class AddLiveBasic extends React.Component { ...@@ -126,6 +129,7 @@ class AddLiveBasic extends React.Component {
fail: (failInfo) => { fail: (failInfo) => {
}, },
loadComplete:(img)=>{ loadComplete:(img)=>{
this.refs.headPicModal.click();
this.setState({ this.setState({
previewUrl: img.src previewUrl: img.src
}) })
...@@ -147,12 +151,14 @@ class AddLiveBasic extends React.Component { ...@@ -147,12 +151,14 @@ class AddLiveBasic extends React.Component {
); );
}; };
//获取resourceId //获取resourceId
getSignature = (blob, fileName) => { getSignature = (blob, fileName) => {
const { choosedBannerId } = this.state; const { choosedBannerId } = this.state;
Upload.uploadBlobToOSS(blob, 'avatar' + (new Date()).valueOf()).then((coverClicpPath) => { Upload.uploadBlobToOSS(blob, 'cover' + (new Date()).valueOf(),null,'signInfo').then((signInfo) => {
this.setState({ this.setState({
coverClicpPath coverClicpPath:signInfo.fileUrl,
coverId:signInfo.resourceId
}) })
}); });
}; };
// base64转换成blob // base64转换成blob
...@@ -166,7 +172,7 @@ class AddLiveBasic extends React.Component { ...@@ -166,7 +172,7 @@ class AddLiveBasic extends React.Component {
return new Blob([ab], { type: "image/png" }); return new Blob([ab], { type: "image/png" });
}; };
updateCover = () =>{ updateCover = () =>{
const {coverClicpPath} = this.state const {coverClicpPath,coverId} = this.state
this.setState({ this.setState({
showSelectFileModal: false showSelectFileModal: false
}) })
...@@ -177,6 +183,10 @@ class AddLiveBasic extends React.Component { ...@@ -177,6 +183,10 @@ class AddLiveBasic extends React.Component {
// } // }
// console.log("coverObj",coverObj); // console.log("coverObj",coverObj);
this.props.onChange('coverUrl', coverClicpPath); this.props.onChange('coverUrl', coverClicpPath);
setTimeout(()=>{
this.props.onChange('coverId', coverId);
},1000)
} }
render() { render() {
const { showCutModal, imageFile,courseCatalogList,showSelectFileModal,visible } = this.state; const { showCutModal, imageFile,courseCatalogList,showSelectFileModal,visible } = this.state;
...@@ -307,6 +317,7 @@ class AddLiveBasic extends React.Component { ...@@ -307,6 +317,7 @@ class AddLiveBasic extends React.Component {
<div className="clip-box"> <div className="clip-box">
<div <div
id="headPicModal" id="headPicModal"
ref="headPicModal"
style={{ style={{
width: "500px", width: "500px",
height: "430px", height: "430px",
......
...@@ -146,6 +146,7 @@ class LiveCourseList extends React.Component { ...@@ -146,6 +146,7 @@ class LiveCourseList extends React.Component {
</div> </div>
</div> </div>
); );
const columns = [ const columns = [
{ {
title: "直播课", title: "直播课",
...@@ -153,9 +154,20 @@ class LiveCourseList extends React.Component { ...@@ -153,9 +154,20 @@ class LiveCourseList extends React.Component {
key: "course", key: "course",
dataIndex: "courseName", dataIndex: "courseName",
render: (val, record) => { render: (val, record) => {
let hasCover = false;
return ( return (
<div className="record__item"> <div className="record__item">
<img className="course-cover" src={'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png'} /> {
record.courseMediaVOS.map((item,index)=>{
if( item.contentType === "COVER"){
hasCover = true;
return <img className="course-cover" src={item.mediaUrl} />
}
})
}
{ !hasCover &&
<img className="course-cover" src={'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png'} />
}
<div> <div>
<div className="course-name">{record.courseName}</div> <div className="course-name">{record.courseName}</div>
<div> <div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment