From eee433837dffd433c6470acf4bb17f3c4efc2a56 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Sun, 25 Oct 2020 12:24:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.ts | 6 ++++ src/views/mine/ReleaseWebcast.vue | 58 +++++++++++++++++++------------ 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index 1c71da0..3ccbab5 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -917,4 +917,10 @@ export async function liveinfo(id: number): Promise{ livenumber: liveinfo.livenumber, desc: liveinfo.desc } +} + +export async function setlive(data: any){ + const info = await put("live/" + data.id, data) + console.log(info.data) + } \ No newline at end of file diff --git a/src/views/mine/ReleaseWebcast.vue b/src/views/mine/ReleaseWebcast.vue index 1f136f2..e6c067c 100644 --- a/src/views/mine/ReleaseWebcast.vue +++ b/src/views/mine/ReleaseWebcast.vue @@ -161,8 +161,9 @@ import RankList from "./RankList.vue"; import { previewCover } from "@/utils/common"; import { FromSend, ImgInfo } from "@/types/index"; import { uploadflie } from "@/utils/vod"; -import { liveadd, liveinfo } from "@/api"; +import { liveadd, liveinfo, setlive } from "@/api"; import { useRoute } from 'vue-router'; +import dayjs from 'dayjs'; export default defineComponent({ name: "ReleaseWebcast", @@ -256,17 +257,20 @@ export default defineComponent({ * 表单提交 */ - const subdata = ref({ - title: "", - img: "", - fileid: "", - fileurl: "", - fileduration: "", - dateline: "", - livetime: "", - livenumber: "", - desc: "", - }); + // const subdata = ref({ + // title: "", + // img: "", + // fileid: "", + // fileurl: "", + // fileduration: "", + // dateline: "", + // livetime: "", + // livenumber: "", + // desc: "", + // }); + /** + * todo 需要后台返回年份 + */ const id = useRoute().query.id if(id != null && typeof id == 'string'){ liveinfo(parseInt(id)).then((res)=>{ @@ -278,10 +282,19 @@ export default defineComponent({ validate() .then(() => { // console.log(toRaw(form),111); - const subdata = toRaw(form); + const subdata: any = toRaw(form.value); // subdata.fileid=picinfo. - console.log(subdata); - liveadd(subdata); + if(id != undefined && id){ + /** + * todo 提交会报错 + */ + subdata.id = id; + setlive(subdata) + }else{ + console.log(subdata); + liveadd(subdata); + } + }) .catch((err: unknown) => { console.log("error", err); @@ -300,14 +313,13 @@ export default defineComponent({ */ function startchange(e: string): void { - const month = new Date(e).getMonth()+1 - console.log(new Date(e).getFullYear()+"-"+month+'-'+new Date(e).getDate()) - form.value.dateline = - new Date(e).getFullYear() + - "-" + - month + - "-" + - new Date(e).getDate(); + // const month = new Date(e).getMonth()+1 + // console.log(new Date(e).getFullYear()+"-"+month+'-'+new Date(e).getDate()) + // console.log(e.toString()) + const time = dayjs(new Date(e)) + const timestr = time.year() + "-" + (time.month() + 1) + "-" + time.date() + " " + time.hour() + ":" + time.minute() + ":" + time.second() + console.log(timestr) + form.value.dateline = timestr; } /** * 上传文件