新增项目库组件item-project,包含学校、专业、学费等信息的展示 优化搜索页面样式,调整分类项宽度和间距 修复搜索页面滚动定位问题,完善分页和URL参数处理 添加本地开发服务器脚本serve.ps1 更新public.css和public.less样式文件
92 lines
4.5 KiB
JavaScript
92 lines
4.5 KiB
JavaScript
const { defineComponent, ref, onMounted } = Vue;
|
|
|
|
export const itemProject = defineComponent({
|
|
name: "item-project",
|
|
props: {
|
|
itemdata: {
|
|
type: Object,
|
|
default: () => ({}),
|
|
},
|
|
},
|
|
setup(props) {
|
|
const formatNumberWithSpaces = (number) => {
|
|
if (Number(number) != number) return;
|
|
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
};
|
|
|
|
const judgmentClass = (name) => {
|
|
const redtag = redtagArr.value || ["26Fall", "26Spring"];
|
|
let classname = "";
|
|
if (redtag.includes(name)) classname = "gray semester";
|
|
else {
|
|
// 判断 字符串 是以 25/26/27... + Fall/Spring/Summer
|
|
const regex = /^(2[0-9]|3\d)(Fall|Spring|Summer)$/;
|
|
classname = regex.test(name) ? "gray" : "";
|
|
}
|
|
return {
|
|
name,
|
|
class: classname,
|
|
};
|
|
};
|
|
|
|
onMounted(() => {
|
|
checkWConfig();
|
|
});
|
|
|
|
let redtagArr = ref([]);
|
|
|
|
const checkWConfig = () => {
|
|
const wConfig = JSON.parse(localStorage.getItem("wConfig")) || {};
|
|
if (wConfig.time) {
|
|
const time = new Date(wConfig.time);
|
|
const now = new Date();
|
|
if (now - time > 24 * 60 * 60 * 1000) {
|
|
getWConfig();
|
|
monitorGetRedTag();
|
|
} else {
|
|
const config = wConfig.config || {};
|
|
redtagArr.value = config.redtag || [];
|
|
}
|
|
} else {
|
|
getWConfig();
|
|
monitorGetRedTag();
|
|
}
|
|
};
|
|
|
|
const monitorGetRedTag = () => {
|
|
let timer = setInterval(() => {
|
|
const wConfig = JSON.parse(localStorage.getItem("wConfig")) || {};
|
|
if (wConfig.time) {
|
|
const config = wConfig.config || {};
|
|
redtagArr.value = config.redtag;
|
|
clearInterval(timer);
|
|
}
|
|
}, 1000);
|
|
};
|
|
|
|
const getWConfig = () => {
|
|
if (window.wConfigloading) return;
|
|
window.wConfigloading = true;
|
|
ajaxGet("/v2/api/config/website").then((res) => {
|
|
if (res.code == 200) {
|
|
let data = res["data"] || {};
|
|
const config = data.config || {};
|
|
redtagArr.value = config.redtag;
|
|
data.time = new Date().toISOString();
|
|
localStorage.setItem("wConfig", JSON.stringify(data));
|
|
}
|
|
window.wConfigloading = false;
|
|
});
|
|
};
|
|
|
|
let item = ref({ ...props.itemdata });
|
|
|
|
item.value["tuition_fee_text"] = formatNumberWithSpaces(item.value.tuition_fee || "");
|
|
|
|
item.value["url"] = "https://program.gter.net/details/" + item.value.uniqid;
|
|
|
|
return { item };
|
|
},
|
|
template: `<div class="item-box item-project"> <div class="tag flexflex"> <img class="tag-item icon" v-if="item.admissionsproject" src="https://app.gter.net/image/miniApp/offer/admissions-icon.png" /> <a class="tag-item blue" href="https://program.gter.net/" target="_blank">港校项目库</a> <div class="tag-item" :class="item.class" v-for="(tag, index) in item.tags" :key="index">{{ tag.name || tag }} </div> </div> <a class="school flexacenter" :href="item.url" target="_blank"> <img class="icon" v-if="item.schoollogo" :src="item.schoollogo" /> <span class="flex1">{{ item.schoolname }}</span> </a> <a class="name flexacenter" :href="item.url" target="_blank">{{ item.name_zh || item.program_zh }}</a> <a class="en flexacenter" :href="item.url" target="_blank">{{ item.name_en || item.program_en }}</a> <a class="introduce flexacenter" :href="item.url" target="_blank"> <span>{{ item.department }}</span> <div class="flexacenter" v-if="item.rank"> <div class="line" v-if="item.department">|</div> 专业排名 <div class="q">{{ item.rank }}</div> </div> <div class="flexacenter" v-if="item.tuition_fee"> <div class="line" v-if="item.department || item.rank">|</div> 学费HK$ <div class="q">{{ item.tuition_fee_text }}</div> </div> </a> <a class="word flexacenter one-line-display" v-if="item.distinctive" :href="item.url" target="_blank">{{ item.distinctive }}</a></div>`,
|
|
});
|