PC-mj/pages/publish/index.vue

590 lines
19 KiB
Vue
Raw Normal View History

2023-12-18 11:12:07 +08:00
<template>
2024-01-03 17:08:29 +08:00
<Head>
<Title>寄托天下 - 面经发布</Title>
<Meta name="keyword" content="留学资讯,留学交流论坛,留学面经,面试经验,寄托天下" />
</Head>
2024-01-09 15:11:03 +08:00
<div class="content-box">
2024-01-03 11:42:49 +08:00
<div class="flexacenter save-box save-left" @click="submit(0)">
<img class="save-icon" src="@/assets/img/arrow-gray.png" />
保存并退出
</div>
<div class="flexacenter save-box save-right" @click="abandonSaving">
放弃保存
<img class="save-icon" src="@/assets/img/cross-icon.png" />
</div>
2024-01-10 18:13:39 +08:00
<div class="contentcontent flex1">
2024-01-09 15:11:03 +08:00
<div class="header flexacenter">发布面经</div>
<div class="box flex1 flexflex">
<div class="box-left">
<div class="area-box">
<div class="item">
<div class="titletitle flexacenter">
申请信息
<div class="asterisk">*</div>
2023-12-18 11:12:07 +08:00
</div>
2024-01-09 15:11:03 +08:00
<div class="info-box">
<div class="info-item flexacenter">
<div class="info-name">院校</div>
<div class="flex1">
2025-04-27 18:19:25 +08:00
<el-autocomplete v-model="info.school" :fetch-suggestions="querySchoolSearch" clearable class="inline-input w-50" placeholder="输入关键词,选择院校" @select="handleSchoolSelect" :trigger-on-focus="false"></el-autocomplete>
2024-01-09 15:11:03 +08:00
</div>
</div>
<div class="info-item flexacenter">
<div class="info-name">专业</div>
<div class="flex1">
2025-04-27 18:19:25 +08:00
<el-autocomplete v-model="info.profession" :fetch-suggestions="queryMajorSearch" clearable class="inline-input w-50" placeholder="输入关键词,选择专业" @select="handleMajorSelect" :trigger-on-focus="false"></el-autocomplete>
2024-01-09 15:11:03 +08:00
</div>
</div>
<div class="info-item flexacenter">
<div class="info-name">项目</div>
2025-04-27 18:19:25 +08:00
<div class="flex1">
<el-autocomplete v-model="info.project" :fetch-suggestions="queryProjectSearch" clearable class="inline-input w-50" placeholder="输入关键词,选择项目" :trigger-on-focus="false"></el-autocomplete>
</div>
<!-- <el-input class="flex1 input" placeholder="请输入" v-model="info.project"></el-input> -->
2023-12-18 11:12:07 +08:00
</div>
</div>
</div>
2024-01-09 15:11:03 +08:00
<div class="item">
<div class="titletitle flexacenter">
面试时间
<div class="asterisk">*</div>
</div>
2023-12-18 11:12:07 +08:00
2024-01-09 15:11:03 +08:00
<div class="time-box item-input-box flexacenter">
<el-config-provider :locale="zhCn">
<el-date-picker v-model="info.interviewtime" type="date" placeholder="请选择" size="large" class="flex1 flexacenter" :clear-icon="{}" value-format="YYYY-MM-DD" :disabled-date="setDisabled" />
</el-config-provider>
2025-03-11 15:40:40 +08:00
<img class="calendar-icon" src="@/assets/img/calendar-icon.png" />
2024-01-09 15:11:03 +08:00
</div>
2023-12-18 11:12:07 +08:00
</div>
2024-01-09 15:11:03 +08:00
<div class="item">
<div class="titletitle flexacenter">
面经帖标题
<div class="asterisk">*</div>
</div>
2023-12-18 11:12:07 +08:00
2024-01-11 13:33:57 +08:00
<div class="title-box item-input-box flexacenter"><el-input v-model="info.subject" placeholder="给你的面经帖起一个吸引的标题吧" show-word-limit maxlength="80"></el-input></div>
2024-01-09 15:11:03 +08:00
</div>
</div>
<div class="visible-box flexacenter" @click="cutVisible()">
<img class="visible-icon" v-if="info.isvisiblereply == 0" src="@/assets/img/frame-no.svg" />
<img class="visible-icon" v-else src="@/assets/img/frame-pitch.svg" />
回复/点赞可见
2023-12-18 11:12:07 +08:00
</div>
</div>
2024-01-09 15:11:03 +08:00
<div class="box-right">
<div class="area-box">
<div class="item">
<div class="titletitle flexacenter">
面试构成及过程
<div class="asterisk">*</div>
</div>
<div class="course-box">
2024-01-11 13:33:57 +08:00
<el-input v-model="info.message" type="textarea" autosize show-word-limit maxlength="2000" placeholder="例如项目介绍、面试时长、面试官、问题QA、需要注意的地方"></el-input>
2024-01-09 15:11:03 +08:00
</div>
2023-12-18 11:12:07 +08:00
</div>
</div>
</div>
</div>
2024-01-09 15:11:03 +08:00
<div class="hint-box flexcenter">请确保以上内容已正确填写发布后将不能修改</div>
</div>
2023-12-18 11:12:07 +08:00
</div>
<div class="floor-box">
<div class="box flexacenter">
2023-12-29 18:37:38 +08:00
<div class="anonymous-box flexacenter" @click="cutAnonymous()">
<img class="anonymous-icon" v-if="info.anonymous == 0" src="@/assets/img/frame-no.svg" />
<img class="anonymous-icon" v-else src="@/assets/img/frame-pitch.svg" />
2023-12-18 11:12:07 +08:00
匿名发表
<div class="text">发布后可修改</div>
</div>
2024-01-11 13:33:57 +08:00
<div class="issue-btn flexcenter" @click="submit()">发布{{ loading ? "中..." : "" }}</div>
2023-12-18 11:12:07 +08:00
</div>
</div>
</template>
<script setup>
2025-04-27 18:19:25 +08:00
import { ElMessage } from "element-plus";
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
const router = useRouter();
useHead({ script: [{ src: "https://app.gter.net/bottom?tpl=footer,popupnotification", body: true }] });
2023-12-18 11:12:07 +08:00
2025-04-27 18:19:25 +08:00
const setDisabled = (time) => {
return time.getTime() > Date.now(); // 可选历史天、可选当前天、不可选未来天
};
2023-12-18 11:12:07 +08:00
onMounted(() => {
2025-04-27 18:19:25 +08:00
getInit();
});
2024-01-03 18:31:15 +08:00
onBeforeMount(() => {
2025-04-27 18:19:25 +08:00
clearBottom();
2024-01-04 14:11:30 +08:00
// clearTop()
2025-04-27 18:19:25 +08:00
});
2024-01-03 18:31:15 +08:00
2024-01-09 15:11:03 +08:00
// let isSchoolSpin = ref(false) // 院校左边箭头旋转
// let isMajorSpin = ref(false) // 专业左边箭头旋转
// const SchoolSearchBlur = () => (isSchoolSpin.value = false)
// const MajorSearchBlur = () => (isMajorSpin.value = false)
2024-01-03 18:31:15 +08:00
// 清除底部的次数
2025-04-27 18:19:25 +08:00
let clearBottomCount = 0;
2024-01-03 18:31:15 +08:00
// 清除 底部
const clearBottom = () => {
2025-04-27 18:19:25 +08:00
const indexFooter = document.querySelector("section.index-footer");
2024-01-03 18:31:15 +08:00
if (!indexFooter) {
2025-04-27 18:19:25 +08:00
clearBottomCount++;
setTimeout(() => clearBottom(), 50);
return;
2024-01-03 18:31:15 +08:00
}
2025-04-27 18:19:25 +08:00
if (clearBottomCount == 15) return;
indexFooter.style.display = "none";
};
2024-01-03 18:31:15 +08:00
// 清除顶部的次数
2025-04-27 18:19:25 +08:00
let clearTopCount = 0;
2024-01-03 18:31:15 +08:00
// 清除 底部
const clearTop = () => {
2025-04-27 18:19:25 +08:00
const indexHeader = document.querySelector("header.page-header");
2024-01-03 18:31:15 +08:00
if (!indexHeader) {
2025-04-27 18:19:25 +08:00
clearTopCount++;
setTimeout(() => clearTop(), 50);
return;
2024-01-03 18:31:15 +08:00
}
2025-04-27 18:19:25 +08:00
if (clearTopCount == 5) return;
2024-01-03 18:31:15 +08:00
2025-04-27 18:19:25 +08:00
indexHeader.style.display = "none";
};
2024-01-03 17:08:29 +08:00
2025-04-27 18:19:25 +08:00
let typetype = ref("");
let token = "";
2023-12-18 11:12:07 +08:00
const getInit = () => {
2025-04-27 18:19:25 +08:00
publishInitHttp().then((res) => {
2023-12-29 18:37:38 +08:00
if (res.code != 200) {
2025-04-27 18:19:25 +08:00
ElMessage.error(res.message);
return;
2023-12-29 18:37:38 +08:00
}
2025-04-27 18:19:25 +08:00
const data = res.data;
token = data["token"];
let interviewtime = data["info"]["interviewtime"] || 0;
if (interviewtime) data["info"]["interviewtime"] = handleDate(interviewtime);
2023-12-29 18:37:38 +08:00
2025-04-27 18:19:25 +08:00
info.value = { ...data["info"] };
});
};
2023-12-18 11:12:07 +08:00
2023-12-29 18:37:38 +08:00
// 处理初始化 面试时间的 时间戳格式
2025-04-27 18:19:25 +08:00
const handleDate = (timestamp) => {
2023-12-29 18:37:38 +08:00
// 使用Date对象将时间戳转换为日期对象
2025-04-27 18:19:25 +08:00
var date = new Date(timestamp * 1000);
2023-12-29 18:37:38 +08:00
// 获取年份、月份和日期
2025-04-27 18:19:25 +08:00
var year = date.getFullYear();
var month = ("0" + (date.getMonth() + 1)).slice(-2); // 月份从0开始需要加1并补0
var day = ("0" + date.getDate()).slice(-2); // 获取日期并补0
2023-12-29 18:37:38 +08:00
// 拼接为yyyy-mm-dd格式的日期字符串
2025-04-27 18:19:25 +08:00
var formattedDate = year + "-" + month + "-" + day;
2023-12-29 18:37:38 +08:00
2025-04-27 18:19:25 +08:00
return formattedDate;
};
2023-12-29 18:37:38 +08:00
let info = ref({
school: "", // 学校
profession: "", // 专业
project: "", // 项目时间
interviewtime: "", // 面试时间
subject: "", //标题
isvisiblereply: 0, // 回复点赞可见
message: "", // 过程
anonymous: 0, // 匿名状态
2025-04-27 18:19:25 +08:00
});
2023-12-29 18:37:38 +08:00
// 关键字搜索学校
const querySchoolSearch = (queryString, cb) => {
2025-04-27 18:19:25 +08:00
publishSchoolSearchHttp({ keyword: queryString }).then((res) => {
if (res.code != 200) return;
let data = res.data || [];
2023-12-29 18:37:38 +08:00
2025-04-27 18:19:25 +08:00
let isRepetition = false;
2023-12-29 18:37:38 +08:00
2025-04-27 18:19:25 +08:00
data.forEach((element) => {
element["value"] = element["checkname"];
if (element["checkname"] == queryString) isRepetition = true;
});
if (!isRepetition) data.push({ value: queryString });
2024-01-09 15:11:03 +08:00
// isSchoolSpin.value = true
2025-04-27 18:19:25 +08:00
cb(data);
});
};
2023-12-25 18:39:49 +08:00
2023-12-29 18:37:38 +08:00
// 选择院校
2025-04-27 18:19:25 +08:00
const handleSchoolSelect = (item) => {
info.value["schoolid"] = item["id"] || 0;
2024-01-09 15:11:03 +08:00
// isSchoolSpin.value = false
2025-04-27 18:19:25 +08:00
};
2023-12-25 18:39:49 +08:00
2023-12-29 18:37:38 +08:00
// 关键字搜索专业
const queryMajorSearch = (queryString, cb) => {
2025-04-27 18:19:25 +08:00
publishProfessionSearchHttp({ keyword: queryString }).then((res) => {
if (res.code != 200) return;
let data = res.data || [];
2023-12-29 18:37:38 +08:00
2025-04-27 18:19:25 +08:00
let isRepetition = false;
2023-12-29 18:37:38 +08:00
2025-04-27 18:19:25 +08:00
data.forEach((element) => {
element["value"] = element["name"];
if (element["name"] == queryString) isRepetition = true;
});
if (!isRepetition) data.push({ value: queryString });
2024-01-04 14:11:30 +08:00
2024-01-09 15:11:03 +08:00
// isMajorSpin.value = true
2025-04-27 18:19:25 +08:00
cb(data);
});
};
2023-12-18 11:12:07 +08:00
2023-12-29 18:37:38 +08:00
// 选择专业
2025-04-27 18:19:25 +08:00
const handleMajorSelect = (item) => {
info.value["profession_id"] = item["id"] || 0;
2024-01-09 15:11:03 +08:00
// isMajorSpin.value = false
2025-04-27 18:19:25 +08:00
};
// 关键字搜索项目
const queryProjectSearch = (queryString, cb) => {
console.log("queryString", queryString);
publishProjectSearchHttp({ keyword: queryString, sid: info.value["schoolid"] }).then((res) => {
if (res.code != 200) return;
let data = res.data.data || [];
let isRepetition = false;
data.forEach((element) => {
element["value"] = element["name"];
if (element["name"] == queryString) isRepetition = true;
});
if (!isRepetition) data.push({ value: queryString });
// isMajorSpin.value = true
cb(data);
});
};
2023-12-29 18:37:38 +08:00
// 切换匿名状态
const cutAnonymous = () => {
2025-04-27 18:19:25 +08:00
info.value["anonymous"] = info.value["anonymous"] == 0 ? 1 : 0;
};
2023-12-29 18:37:38 +08:00
// 切换回复可见状态
const cutVisible = () => {
2025-04-27 18:19:25 +08:00
info.value["isvisiblereply"] = info.value["isvisiblereply"] == 0 ? 1 : 0;
};
2023-12-29 18:37:38 +08:00
2025-04-27 18:19:25 +08:00
let loading = ref(false);
2023-12-29 18:37:38 +08:00
// 提交发布
const submit = (status = 1) => {
2024-01-11 13:33:57 +08:00
if (loading.value) {
2025-04-27 18:19:25 +08:00
ElMessage.error("提交中,稍等");
return;
2024-01-11 13:33:57 +08:00
}
2023-12-29 18:37:38 +08:00
2025-04-27 18:19:25 +08:00
loading.value = true;
2024-01-11 13:33:57 +08:00
publishSubmitHttp({ info: info.value, token, status })
2025-04-27 18:19:25 +08:00
.then((res) => {
2024-01-11 13:33:57 +08:00
if (res.code != 200) {
2025-04-27 18:19:25 +08:00
ElMessage.error(res.message);
return;
2024-01-11 13:33:57 +08:00
}
2023-12-29 18:37:38 +08:00
2025-04-27 18:19:25 +08:00
const data = res.data;
ElMessage.success(res.message);
2024-01-11 13:33:57 +08:00
// router.push(`/details/${data["uniqid"]}`)
2025-04-27 18:19:25 +08:00
if (status == 0) goToURL(`/index.html`, false);
else goToURL(`/details/${data["uniqid"]}`, false);
2024-01-11 13:33:57 +08:00
})
2025-04-27 18:19:25 +08:00
.finally(() => (loading.value = false));
};
2023-12-18 11:12:07 +08:00
2023-12-29 18:37:38 +08:00
// 放弃保存 跳跃上一页或者首页
const abandonSaving = () => {
2025-04-27 18:19:25 +08:00
if (router.currentRoute.value.meta.previousPage) router.go(-1);
else goToURL("./index.html", false); // 跳转到首页
2024-01-03 15:28:16 +08:00
// else router.push("./index.html") // 跳转到首页
2025-04-27 18:19:25 +08:00
};
2023-12-18 11:12:07 +08:00
</script>
<style scoped lang="less">
2024-01-09 15:11:03 +08:00
.content-box {
2024-01-10 18:13:39 +08:00
// padding: 0 10px;
padding: 0 122px;
display: flex;
justify-content: center;
}
@media (max-width: 920px) {
.content-box {
display: block;
padding: 0 10px;
// padding: 0 122px;
}
2024-01-09 15:11:03 +08:00
}
2024-01-03 18:31:15 +08:00
.contentcontent {
2024-01-09 15:11:03 +08:00
// width: 1200px;
max-width: 1200px;
min-width: 900px;
2023-12-18 11:12:07 +08:00
// height: 882px;
// min-height: 718px;
min-height: calc(100vh - 120px);
background: #fff;
margin: 30px auto 90px;
border-radius: 16px;
display: flex;
flex-direction: column;
2024-01-03 11:42:49 +08:00
position: relative;
2024-01-09 15:11:03 +08:00
// margin: 0 10px;
2023-12-18 11:12:07 +08:00
.header {
font-weight: 650;
font-size: 20px;
color: #000000;
border-bottom: 1px solid #ebebeb;
height: 88px;
padding-left: 30px;
}
.box {
2024-01-03 17:08:29 +08:00
.titletitle {
2023-12-18 11:12:07 +08:00
color: #666666;
font-size: 14px;
margin-bottom: 10px;
}
.box-left {
2024-01-09 15:11:03 +08:00
width: 44.333%;
2023-12-18 11:12:07 +08:00
border-right: 16px solid #f6f6f6;
.area-box {
padding: 30px;
padding-right: 50px;
border-bottom: 1px solid #ebebeb;
.item {
&:not(:last-of-type) {
margin-bottom: 30px;
}
}
.info-box {
2024-01-09 15:11:03 +08:00
// width: 452px;
2023-12-18 11:12:07 +08:00
height: 158px;
background-color: rgba(255, 255, 255, 0);
border: 1px solid rgba(215, 215, 215, 1);
border-radius: 5px;
display: flex;
flex-direction: column;
justify-content: center;
overflow: hidden;
2023-12-18 11:12:07 +08:00
.info-item {
height: 50px;
&:not(:last-of-type) {
border-bottom: 1px solid #d7d7d7;
}
.info-name {
font-size: 14px;
color: #666666;
padding: 0 14px;
}
.input {
height: 100%;
// background: #000000;
// padding: 1px 11px;
border: none;
outline: none;
box-shadow: none;
/deep/ .el-input__wrapper {
box-shadow: none;
}
}
/deep/ .el-autocomplete {
2024-01-09 18:49:37 +08:00
width: 99%;
2023-12-18 11:12:07 +08:00
.el-input__wrapper {
box-shadow: none;
}
}
}
}
.item-input-box {
2024-01-09 15:11:03 +08:00
// width: 452px;
2023-12-18 11:12:07 +08:00
height: 46px;
border: 1px solid rgba(215, 215, 215, 1);
border-radius: 5px;
cursor: pointer;
/deep/ .el-input {
height: 100%;
.el-input__wrapper {
height: 100%;
box-shadow: none;
}
}
}
.time-box {
.calendar-icon {
width: 15px;
height: 16px;
margin: 0 12px;
}
/deep/ .el-input {
.el-input__prefix {
display: none;
}
}
}
}
.visible-box {
margin: 30px;
font-size: 14px;
color: #555555;
cursor: pointer;
2023-12-29 18:37:38 +08:00
user-select: none;
2023-12-18 11:12:07 +08:00
.visible-icon {
width: 18px;
height: 18px;
margin-right: 5px;
}
}
}
.box-right {
2024-01-09 15:11:03 +08:00
width: 54.333%;
2023-12-18 11:12:07 +08:00
.area-box {
padding: 30px;
padding-left: 50px;
.course-box {
2024-01-09 15:11:03 +08:00
// width: 572px;
2023-12-18 11:12:07 +08:00
min-height: 480px;
background-color: rgba(255, 255, 255, 0);
border: 1px solid rgba(215, 215, 215, 1);
border-radius: 5px;
/deep/ .el-textarea__inner {
min-height: 480px !important;
box-shadow: none;
padding: 13px;
}
}
}
}
}
.hint-box {
height: 58px;
background-color: rgba(246, 246, 246, 1);
color: #555555;
font-size: 13px;
}
}
.asterisk {
color: #fa9183;
margin-left: 5px;
}
.floor-box {
width: 100vw;
min-width: 1200px;
height: 90px;
background-color: rgba(255, 255, 255, 1);
-moz-box-shadow: 0px -1px 2px rgba(0, 0, 0, 0.192156862745098);
-webkit-box-shadow: 0px -1px 2px rgba(0, 0, 0, 0.192156862745098);
box-shadow: 0px -1px 2px rgba(0, 0, 0, 0.192156862745098);
position: fixed;
bottom: 0;
.box {
width: 1200px;
height: 100%;
margin: 0 auto;
justify-content: space-between;
padding: 0 30px;
.anonymous-box {
cursor: pointer;
color: #333333;
font-size: 14px;
2023-12-29 18:37:38 +08:00
user-select: none;
2023-12-18 11:12:07 +08:00
.text {
color: rgb(170, 170, 170);
font-size: 13px;
}
.anonymous-icon {
width: 18px;
height: 18px;
}
}
.issue-btn {
width: 200px;
height: 46px;
background-color: rgba(253, 223, 109, 1);
border-radius: 190px;
font-size: 16px;
color: #000000;
cursor: pointer;
}
}
}
.save-box {
font-size: 14px;
color: #666666;
2024-01-03 11:42:49 +08:00
position: absolute;
2024-01-09 15:11:03 +08:00
// position: fixed;
top: 30px;
2023-12-18 11:12:07 +08:00
cursor: pointer;
2024-01-09 15:11:03 +08:00
transition: all 0.3s;
z-index: 1;
2023-12-18 11:12:07 +08:00
&.save-left {
2024-01-10 18:13:39 +08:00
left: 0px;
2024-01-09 15:11:03 +08:00
// left: calc((1200px - 100vw) / 2 + 25px);
2023-12-18 11:12:07 +08:00
}
&.save-right {
2024-01-10 18:13:39 +08:00
right: 0px;
2024-01-09 15:11:03 +08:00
// right: calc((1200px - 100vw) / 2 + 25px);
2024-01-03 11:42:49 +08:00
2023-12-18 11:12:07 +08:00
.save-icon {
width: 16px;
height: 16px;
margin-left: 10px;
}
}
.save-icon {
width: 22px;
height: 22px;
margin-right: 10px;
transform: rotate(180deg);
}
}
2024-01-09 15:11:03 +08:00
// .arrows-icon {
// transition: all 0.3s;
// &.spin {
// transform: rotate(180deg);
// }
// }
2023-12-18 11:12:07 +08:00
</style>