feat:添加外链接口对接 完善添加直播

This commit is contained in:
songwc
2022-11-01 12:21:18 +08:00
parent 2c3edeaf24
commit 06633222be
4 changed files with 1167 additions and 912 deletions

View File

@@ -0,0 +1,19 @@
import http from "./config";
//创建外链接口
export const createExternalChain = (obj) => http.post('/link/createLinks', obj)
//外链信息删除接口
export const deleteLink = (obj) => http.post('/link/deleteLink', { params: obj })
//获取外链详细信息接口
export const getLink = (obj) => http.post('/link/getOne', { params: obj })
// 更新外链数据
export const updateLinks = (obj) => http.post('/link/updateLinks', obj)
//修改为必修的接口
export const updateToCompulsory = (obj) => http.post('/link/updateToCompulsory', { params: obj })
//修改为选修的接口
export const updateToElective = (obj) => http.post('/link/updateToElective', { params: obj })

View File

@@ -65,7 +65,6 @@
<a-range-picker <a-range-picker
style="width: 424px" style="width: 424px"
v-model:value="time" v-model:value="time"
format="YYYY-MM-DD HH:MM"
:placeholder="[' 开始时间', ' 结束时间']" :placeholder="[' 开始时间', ' 结束时间']"
/> />
</div> </div>
@@ -110,7 +109,7 @@
<div class="signbox"> <div class="signbox">
<span style="margin-right: 3px">直播封面</span> <span style="margin-right: 3px">直播封面</span>
</div> </div>
<div class="textarea"> <div class="textarea" style="overflow: hidden">
<a-upload <a-upload
v-model:file-list="fileList" v-model:file-list="fileList"
name="avatar" name="avatar"
@@ -279,7 +278,7 @@
</div> </div>
</div> </div>
<div class="main_btns"> <div class="main_btns">
<button class="btn1">取消</button> <button class="btn1" @click="closeDrawer">取消</button>
<button class="btn2" @click="createLiveBroadcast">确定</button> <button class="btn2" @click="createLiveBroadcast">确定</button>
</div> </div>
</div> </div>
@@ -289,6 +288,13 @@
import { reactive, toRefs, ref } from "vue"; import { reactive, toRefs, ref } from "vue";
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
import * as api from "../../api/indexLiveBroadcast"; import * as api from "../../api/indexLiveBroadcast";
import { toDate } from "@/api/method";
function getBase64(img, callback) {
const reader = new FileReader();
reader.addEventListener("load", () => callback(reader.result));
reader.readAsDataURL(img);
}
const options1 = ref([ const options1 = ref([
{ {
value: "value1", value: "value1",
@@ -465,6 +471,8 @@ export default {
inputV8: "", //结束前多少分钟开始签退 inputV8: "", //结束前多少分钟开始签退
textV1: "", textV1: "",
radioV1: "", //标准设置的单选 radioV1: "", //标准设置的单选
imageUrl: "", //上传图片地址
loading: false,
switchC1: "", switchC1: "",
checkedC1: "", checkedC1: "",
checkedC2: true, checkedC2: true,
@@ -474,6 +482,18 @@ export default {
ctx.emit("update:addliveVisible", false); ctx.emit("update:addliveVisible", false);
state.radioV1 = ""; state.radioV1 = "";
state.playback = false; state.playback = false;
state.inputV6 = "";
state.inputV7 = "";
state.inputV2 = "";
state.inputV3 = "";
state.inputV1 = "";
state.inputV4 = "";
state.inputV5 = "";
state.inputV8 = "";
state.time = "";
state.textV1 = "";
state.switchC1 = "";
state.imageUrl = "";
}; };
const afterVisibleChange = (bool) => { const afterVisibleChange = (bool) => {
console.log("state", bool); console.log("state", bool);
@@ -487,23 +507,66 @@ export default {
state.radioV1 = ""; state.radioV1 = "";
} }
}; };
const handleChange = (info) => {
if (info.file.status === "uploading") {
state.loading = true;
return;
}
if (info.file.status === "done") {
// Get this url from response in real world.
getBase64(info.file.originFileObj, (base64Url) => {
state.imageUrl = base64Url;
state.loading = false;
});
}
if (info.file.status === "error") {
state.loading = false;
message.error("upload error");
}
};
const beforeUpload = (file) => {
const isJpgOrPng =
file.type === "image/jpeg" || file.type === "image/png";
if (!isJpgOrPng) {
message.error("You can only upload JPG file!");
}
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isLt2M) {
message.error("Image must smaller than 2MB!");
}
return isJpgOrPng && isLt2M;
};
//创建直播 //创建直播
const createLiveBroadcast = () => { const createLiveBroadcast = () => {
if (!state.inputV1) return message.info("请输入直播名称"); if (!state.inputV1) return message.warning("请输入直播名称");
if (!state.time) return message.info("请输入直播时间"); if (!state.time) return message.warning("请输入直播时间");
if (!state.inputV2) return message.info("请输入直播时长"); if (!state.inputV2) return message.warning("请输入直播时长");
const regular = /^[+]{0,1}(\d+)$/; const regular = /^[+]{0,1}(\d+)$/;
if (!regular.test(state.inputV2)) { if (!regular.test(state.inputV2)) {
return message.info("直播时长需大于0"); return message.warning("直播时长需大于0");
} }
// if (!state.inputV3) return message.info("请输入授课老师"); // if (!state.inputV3) return message.info("请输入授课老师");
let check = state.checkedC2 * 1; let check = state.checkedC2 * 1;
let startTime = state.time[0].$d; // let startTime = state.time[0].$d;
let endTime = state.time[1].$d; // let endTime = state.time[1].$d;
console.log(startTime); //时间需要处理 // console.log(startTime); //时间需要处理
console.log(endTime); // console.log(endTime);
let startTime = toDate(
new Date(state.time[0].$d).getTime() / 1000,
"Y-M-D"
);
let endTime = toDate(
new Date(state.time[1].$d).getTime() / 1000,
"Y-M-D"
);
let obj = { let obj = {
afterSignIn: state.inputV6, afterSignIn: state.inputV6,
beforeSignIn: state.inputV7, beforeSignIn: state.inputV7,
@@ -511,8 +574,8 @@ export default {
createUser: 0, createUser: 0,
// liveCover: state.fileList,//直播封面 // liveCover: state.fileList,//直播封面
liveDuration: state.inputV2, liveDuration: state.inputV2,
// liveEndTime: endTime, liveEndTime: endTime,
// liveStartTime: startTime, liveStartTime: startTime,
liveExplain: state.textV1, liveExplain: state.textV1,
liveFlag: "", liveFlag: "",
liveId: 0, liveId: 0,
@@ -532,6 +595,11 @@ export default {
.createLiveBroadcast(obj) .createLiveBroadcast(obj)
.then((res) => { .then((res) => {
console.log(res.data.data, 1111); console.log(res.data.data, 1111);
console.log(state, 2222);
message.success("提交成功");
closeDrawer();
// state = {}
}) })
.catch((err) => { .catch((err) => {
console.log(err, 2222); console.log(err, 2222);
@@ -548,6 +616,8 @@ export default {
rowSelection, rowSelection,
cloradio1, cloradio1,
createLiveBroadcast, createLiveBroadcast,
handleChange,
beforeUpload,
}; };
}, },
}; };

View File

@@ -1,268 +1,300 @@
<template> <template>
<a-drawer <a-drawer
:visible="addrefVisible" :visible="addrefVisible"
class="drawerStyle addrefDrawer" class="drawerStyle addrefDrawer"
width="80%" width="80%"
title="添加外链" title="添加外链"
placement="right" placement="right"
@after-visible-change="afterVisibleChange" @after-visible-change="afterVisibleChange"
> >
<div class="drawerMain"> <div class="drawerMain">
<div class="header"> <div class="header">
<div class="headerTitle">添加外链</div> <div class="headerTitle">添加外链</div>
<img <img
style="width: 29px; height: 29px; cursor: pointer" style="width: 29px; height: 29px; cursor: pointer"
src="../../assets/images/basicinfo/close.png" src="../../assets/images/basicinfo/close.png"
@click="closeDrawer" @click="closeDrawer"
/> />
</div> </div>
<div class="contentMain"> <div class="contentMain">
<div class="main_left"> <div class="main_left">
<div class="main_item"> <div class="main_item">
<div class="signbox"> <div class="signbox">
<div class="sign"> <div class="sign">
<img <img
src="@/assets/images/coursewareManage/asterisk.png" src="@/assets/images/coursewareManage/asterisk.png"
alt="" alt=""
/> />
</div>
<span style="margin-right: 3px">外链名称</span>
</div> </div>
<div class="btnbox"> <span style="margin-right: 3px">外链名称</span>
<a-input </div>
v-model:value="inputV1" <div class="btnbox">
style="width: 424px; height: 32px" <a-input
placeholder="请输入外链名称" v-model:value="inputV1"
style="width: 424px; height: 32px"
placeholder="请输入外链名称"
maxlength="20" maxlength="20"
/>
</div>
</div>
<div class="main_item">
<div class="signbox">
<div class="sign">
<img
src="@/assets/images/coursewareManage/asterisk.png"
alt=""
/> />
</div> </div>
<span style="margin-right: 3px">链接</span>
</div> </div>
<div class="main_item"> <div class="btnbox">
<div class="signbox"> <a-input
<div class="sign"> v-model:value="inputV2"
<img style="width: 424px; height: 32px"
src="@/assets/images/coursewareManage/asterisk.png" placeholder="请输入链接"
alt="" />
/>
</div>
<span style="margin-right: 3px">链接</span>
</div>
<div class="btnbox">
<a-input
v-model:value="inputV2"
style="width: 424px; height: 32px"
placeholder="请输入链接"
/>
</div>
</div> </div>
<div class="main_item2"> </div>
<div class="signbox"> <div class="main_item2">
<span style="margin-right: 3px">外链说明</span> <div class="signbox">
</div> <span style="margin-right: 3px">外链说明</span>
<div class="textarea"> </div>
<a-textarea <div class="textarea">
v-model:value="textV1" <a-textarea
placeholder="请输入外链说明" v-model:value="textV1"
allow-clear placeholder="请输入外链说明"
/> allow-clear
</div> />
</div> </div>
</div> </div>
</div> </div>
<div class="main_btns">
<button class="btn1">取消</button>
<button class="btn2">确定</button>
</div>
</div> </div>
</a-drawer> <div class="main_btns">
</template> <button class="btn1" @click="closeDrawer">取消</button>
<button class="btn2" @click="createExternalChain">确定</button>
</div>
</div>
</a-drawer>
</template>
<script> <script>
import { reactive, toRefs, ref } from "vue"; import { reactive, toRefs, ref } from "vue";
const rowSelection = ref({ import * as api from "../../api/indexExternalChain";
checkStrictly: false, import { message } from "ant-design-vue";
onChange: (selectedRowKeys, selectedRows) => { const rowSelection = ref({
console.log( checkStrictly: false,
`selectedRowKeys: ${selectedRowKeys}`, onChange: (selectedRowKeys, selectedRows) => {
"selectedRows: ", console.log(
selectedRows `selectedRowKeys: ${selectedRowKeys}`,
); "selectedRows: ",
selectedRows
);
},
onSelect: (record, selected, selectedRows) => {
console.log(record, selected, selectedRows);
},
onSelectAll: (selected, selectedRows, changeRows) => {
console.log(selected, selectedRows, changeRows);
},
});
export default {
name: "AddRef",
// components: {
// },
props: {
addrefVisible: {
type: Boolean,
default: false,
}, },
onSelect: (record, selected, selectedRows) => { },
console.log(record, selected, selectedRows); setup(props, ctx) {
}, const state = reactive({
onSelectAll: (selected, selectedRows, changeRows) => { inputV1: "",
console.log(selected, selectedRows, changeRows); inputV2: "",
}, textV1: "",
}); });
export default { const closeDrawer = () => {
name: "AddRef", ctx.emit("update:addrefVisible", false);
// components: { state.inputV2 = "";
// }, state.inputV1 = "";
props: { state.textV1 = "";
addrefVisible: { };
type: Boolean, const afterVisibleChange = (bool) => {
default: false, console.log("state", bool);
}, };
}, const createExternalChain = () => {
setup(props, ctx) { console.log(Object.prototype.toString.call(state.inputV1));
const state = reactive({ console.log(Object.prototype.toString.call(state.inputV2));
inputV1: "", console.log(Object.prototype.toString.call(state.textV1));
inputV2: "", let obj = {
textV1:"", createUser: 0,
}); createTime: "",
const closeDrawer = () => { linkAddress: state.inputV2,
ctx.emit("update:addrefVisible", false); linkDescription: state.textV1,
linkFlag: "",
linkId: 0,
linkName: state.inputV1,
linkTag: "",
updateTime: "",
updateUser: 0,
}; };
const afterVisibleChange = (bool) => { api
console.log("state", bool); .createExternalChain(obj)
}; .then((res) => {
return { console.log(res.data.data);
...toRefs(state), message.success("提交成功");
afterVisibleChange, closeDrawer();
closeDrawer, })
rowSelection, .catch((err) => {
}; console.log(err);
}, });
}; };
</script> return {
...toRefs(state),
afterVisibleChange,
closeDrawer,
rowSelection,
createExternalChain,
};
},
};
</script>
<style lang="scss"> <style lang="scss">
.ant-table-striped :deep(.table-striped) td { .ant-table-striped :deep(.table-striped) td {
background-color: #fafafa !important; background-color: #fafafa !important;
} }
.addrefDrawer { .addrefDrawer {
.drawerMain { .drawerMain {
.header { .header {
height: 73px; height: 73px;
border-bottom: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
.headerTitle { .headerTitle {
font-size: 18px; font-size: 18px;
font-weight: 600; font-weight: 600;
color: #333333; color: #333333;
line-height: 25px; line-height: 25px;
margin-left: 24px; margin-left: 24px;
}
} }
.contentMain { }
display: flex; .contentMain {
justify-content: space-between; display: flex;
.main_left { justify-content: space-between;
padding-right: 30px; .main_left {
flex: 1; padding-right: 30px;
border-right: 1px solid #e8e8e8; flex: 1;
.main_item { border-right: 1px solid #e8e8e8;
.main_item {
display: flex;
align-items: center;
margin-bottom: 32px;
.signbox {
width: 120px;
display: flex; display: flex;
justify-content: end;
align-items: center; align-items: center;
margin-bottom: 32px; .sign {
.signbox { margin-right: 5px;
width: 120px;
display: flex;
justify-content: end;
align-items: center;
.sign {
margin-right: 5px;
}
}
.btnbox {
display: flex;
flex: 1;
align-items: center;
.xkbtn {
cursor: pointer;
width: 130px;
height: 40px;
background: #388be1;
border-radius: 8px;
border: 0;
margin-right: 8px;
color: #fff;
}
} }
} }
.main_item2 { .btnbox {
display: flex; display: flex;
align-items: flex-start; flex: 1;
margin-bottom: 32px; align-items: center;
.signbox { .xkbtn {
width: 120px; cursor: pointer;
display: flex; width: 130px;
justify-content: end; height: 40px;
align-items: center; background: #388be1;
.sign { border-radius: 8px;
margin-right: 5px; border: 0;
} margin-right: 8px;
} color: #fff;
.kqszbox {
.qdqtbox {
margin-left: 56px;
}
.setbox {
display: flex;
flex-wrap: wrap;
margin-top: 10px;
margin-bottom: 24px;
.timerbox {
margin-top: 6px;
margin-right: 32px;
display: flex;
align-items: center;
flex-wrap: nowrap;
}
}
}
.btnbox2 {
display: flex;
flex-direction: column;
justify-content: flex-start;
.xkbtn {
cursor: pointer;
width: 130px;
height: 40px;
background: #388be1;
border-radius: 8px;
border: 0;
margin-right: 16px 8px 32px 0;
color: #fff;
margin-top: 16px;
margin-bottom: 60px;
}
} }
} }
} }
} .main_item2 {
.main_btns { display: flex;
height: 72px; align-items: flex-start;
width: 100%; margin-bottom: 32px;
bottom: 0; .signbox {
left: 0; width: 120px;
display: flex; display: flex;
align-items: center; justify-content: end;
justify-content: center; align-items: center;
box-shadow: 0px 1px 35px 0px rgba(118, 136, 166, 0.16); .sign {
.btn1 { margin-right: 5px;
width: 100px; }
height: 40px; }
border: 1px solid #4ea6ff; .kqszbox {
border-radius: 8px; .qdqtbox {
color: #4ea6ff; margin-left: 56px;
background-color: #fff; }
cursor: pointer; .setbox {
} display: flex;
.btn2 { flex-wrap: wrap;
cursor: pointer; margin-top: 10px;
width: 100px; margin-bottom: 24px;
height: 40px; .timerbox {
background: #4ea6ff; margin-top: 6px;
border-radius: 8px; margin-right: 32px;
border: 0; display: flex;
margin-left: 15px; align-items: center;
color: #fff; flex-wrap: nowrap;
}
}
}
.btnbox2 {
display: flex;
flex-direction: column;
justify-content: flex-start;
.xkbtn {
cursor: pointer;
width: 130px;
height: 40px;
background: #388be1;
border-radius: 8px;
border: 0;
margin-right: 16px 8px 32px 0;
color: #fff;
margin-top: 16px;
margin-bottom: 60px;
}
}
} }
} }
} }
.main_btns {
height: 72px;
width: 100%;
bottom: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0px 1px 35px 0px rgba(118, 136, 166, 0.16);
.btn1 {
width: 100px;
height: 40px;
border: 1px solid #4ea6ff;
border-radius: 8px;
color: #4ea6ff;
background-color: #fff;
cursor: pointer;
}
.btn2 {
cursor: pointer;
width: 100px;
height: 40px;
background: #4ea6ff;
border-radius: 8px;
border: 0;
margin-left: 15px;
color: #fff;
}
}
} }
</style> }
</style>

File diff suppressed because it is too large Load Diff