diff --git a/src/api/indexExternalChain.js b/src/api/indexExternalChain.js new file mode 100644 index 00000000..9de46f42 --- /dev/null +++ b/src/api/indexExternalChain.js @@ -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 }) \ No newline at end of file diff --git a/src/components/drawers/AddLive.vue b/src/components/drawers/AddLive.vue index 36f64096..65cdc135 100644 --- a/src/components/drawers/AddLive.vue +++ b/src/components/drawers/AddLive.vue @@ -65,7 +65,6 @@ @@ -110,7 +109,7 @@
直播封面:
-
+
- +
@@ -289,6 +288,13 @@ import { reactive, toRefs, ref } from "vue"; import { message } from "ant-design-vue"; 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([ { value: "value1", @@ -465,6 +471,8 @@ export default { inputV8: "", //结束前多少分钟开始签退 textV1: "", radioV1: "", //标准设置的单选 + imageUrl: "", //上传图片地址 + loading: false, switchC1: "", checkedC1: "", checkedC2: true, @@ -474,6 +482,18 @@ export default { ctx.emit("update:addliveVisible", false); state.radioV1 = ""; 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) => { console.log("state", bool); @@ -487,23 +507,66 @@ export default { 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 = () => { - if (!state.inputV1) return message.info("请输入直播名称"); - if (!state.time) return message.info("请输入直播时间"); - if (!state.inputV2) return message.info("请输入直播时长"); + if (!state.inputV1) return message.warning("请输入直播名称"); + if (!state.time) return message.warning("请输入直播时间"); + if (!state.inputV2) return message.warning("请输入直播时长"); const regular = /^[+]{0,1}(\d+)$/; if (!regular.test(state.inputV2)) { - return message.info("直播时长需大于0"); + return message.warning("直播时长需大于0"); } // if (!state.inputV3) return message.info("请输入授课老师"); let check = state.checkedC2 * 1; - let startTime = state.time[0].$d; - let endTime = state.time[1].$d; - console.log(startTime); //时间需要处理 - console.log(endTime); + // let startTime = state.time[0].$d; + // let endTime = state.time[1].$d; + // console.log(startTime); //时间需要处理 + // 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 = { afterSignIn: state.inputV6, beforeSignIn: state.inputV7, @@ -511,8 +574,8 @@ export default { createUser: 0, // liveCover: state.fileList,//直播封面 liveDuration: state.inputV2, - // liveEndTime: endTime, - // liveStartTime: startTime, + liveEndTime: endTime, + liveStartTime: startTime, liveExplain: state.textV1, liveFlag: "", liveId: 0, @@ -532,6 +595,11 @@ export default { .createLiveBroadcast(obj) .then((res) => { console.log(res.data.data, 1111); + console.log(state, 2222); + message.success("提交成功"); + closeDrawer(); + + // state = {} }) .catch((err) => { console.log(err, 2222); @@ -548,6 +616,8 @@ export default { rowSelection, cloradio1, createLiveBroadcast, + handleChange, + beforeUpload, }; }, }; diff --git a/src/components/drawers/AddRef.vue b/src/components/drawers/AddRef.vue index b4d56075..3ff9cecb 100644 --- a/src/components/drawers/AddRef.vue +++ b/src/components/drawers/AddRef.vue @@ -1,268 +1,300 @@ +
+ + +
+ + + + api + .createExternalChain(obj) + .then((res) => { + console.log(res.data.data); + message.success("提交成功"); + closeDrawer(); + }) + .catch((err) => { + console.log(err); + }); + }; + return { + ...toRefs(state), + afterVisibleChange, + closeDrawer, + rowSelection, + createExternalChain, + }; + }, +}; + +} + \ No newline at end of file diff --git a/src/views/projectcenter/ProjectAdd.vue b/src/views/projectcenter/ProjectAdd.vue index 57078111..5fcfc04b 100644 --- a/src/views/projectcenter/ProjectAdd.vue +++ b/src/views/projectcenter/ProjectAdd.vue @@ -1,754 +1,888 @@