1057 lines
33 KiB
JavaScript
1057 lines
33 KiB
JavaScript
// pages/projectDetails/projectDetails.js
|
|
var miucms = require('../../utils/miucms.js');
|
|
let app = getApp()
|
|
const util = require('../../utils/util')
|
|
const common = require('../../utils/commonMethod')
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
informationState: false, // 授权后可能需要弹出完成信息框 个人背景那些
|
|
islogin: false,
|
|
isloginBtnState: false,
|
|
|
|
isFirstPattern: true,
|
|
screen_data: {},
|
|
totalTopHeight: 82,
|
|
|
|
admissionCurrent: 0, // 招生官 轮播图的下标
|
|
admissionState: false, // 招生官 弹窗的状态
|
|
|
|
stateState: false, // 底部状态显示状态
|
|
|
|
headHeight: 0, // 头部 高度
|
|
rpx150: 150,
|
|
index: 0,
|
|
current: {},
|
|
|
|
headerObj: {
|
|
ranking: "专业排名",
|
|
brief: "简介",
|
|
},
|
|
|
|
info: {},
|
|
|
|
keyboardHeight: 0, // 键盘高度
|
|
|
|
isadmission: 0, // 是否是招生官项目
|
|
urls: [], // 招生官项目
|
|
|
|
uniqid: "",
|
|
info: {},
|
|
|
|
side: {
|
|
// pivotal: "关键信息",
|
|
basic: "基本信息",
|
|
apply: "申请信息",
|
|
attend: "就读信息",
|
|
graduate: "毕业&就业",
|
|
answers: "招生官问答",
|
|
consult: "录取参考",
|
|
issue: "常见问题",
|
|
links: "相关链接",
|
|
recommend: "推荐项目",
|
|
},
|
|
|
|
|
|
sideKey: "basic", // 侧边栏选中 key
|
|
|
|
course: {}, // 课程
|
|
|
|
scrollTop: 0,
|
|
|
|
contras: {}, //
|
|
|
|
stateObj: {
|
|
0: "待定",
|
|
1: "主申",
|
|
2: "冲刺",
|
|
3: "保底",
|
|
},
|
|
|
|
rankingsObj: {}, // 排名对象
|
|
|
|
studyMode: 'ft', // 学习模式显示状态 ft 全日制 pt 兼读制
|
|
|
|
moldObj: {
|
|
1: "直播",
|
|
2: "回放",
|
|
3: "答疑"
|
|
},
|
|
|
|
isInitFinish: false,
|
|
|
|
sideFixed: false,
|
|
rpx30: 30,
|
|
user: {},
|
|
offerList: [],
|
|
offerShowList: [],
|
|
offerPage: 1,
|
|
sideNum: {},
|
|
answerType: 0, // 招生管显示类型 0不显示 1长期答疑 2即将开始
|
|
countDown: {
|
|
days: 0,
|
|
hours: 0,
|
|
minutes: 0,
|
|
seconds: 0,
|
|
},
|
|
admissionofficerin: [],
|
|
answerquestions: [],
|
|
|
|
quickAnswerState: false,
|
|
rankingKey: common.rankingKey,
|
|
detailsInfo: {},
|
|
accreditation: {},
|
|
isAccreditation: false,
|
|
|
|
admissions: [],
|
|
admissionsObj: {},
|
|
admissionsIndex: 0,
|
|
|
|
demandState: 0, // 要求展示状态 0 显示全部 1 显示箭头和部分 2 显示箭头和全部
|
|
|
|
recommendPage: 1, // 推荐页数
|
|
recommendList: [],
|
|
|
|
scholarships: [], // 奖学金
|
|
documents: [], // 文件
|
|
|
|
discipline: {}, // 学科领域
|
|
|
|
admission_requirements: [], // 语言能力要求
|
|
admission_requirementsObj: {},
|
|
isNoRequire: false, // 需求是否为空
|
|
|
|
applyListState: false, // 申请信息选择列表状态
|
|
|
|
newest: "",
|
|
duckProphet: 0, // 鸭先知
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
options: {},
|
|
onLoad(options) {
|
|
this.options = options
|
|
miucms.pageStart(app).then(() => {
|
|
const screen_data = app.globalData.screen_data || {}
|
|
this.setData({
|
|
screen_data,
|
|
totalTopHeight: screen_data.totalTopHeight,
|
|
islogin: app.globalData.user.uid > 0 ? true : false,
|
|
uniqid: options.uniqid,
|
|
rpx150: util.rpxTopx(150),
|
|
rpx30: util.rpxTopx(30),
|
|
user: app.globalData.user,
|
|
})
|
|
|
|
this.windowHeight = screen_data.windowHeight || 812
|
|
|
|
common.xgBasicData(this, app).then(data => {
|
|
this.setData({
|
|
rankingsObj: data.rankings,
|
|
})
|
|
|
|
this.getData()
|
|
})
|
|
})
|
|
},
|
|
|
|
getData() {
|
|
wx.showLoading({
|
|
title: '加载中...',
|
|
})
|
|
util.wxpost("https://api.gter.net/v1/program/details", {
|
|
uniqid: this.data.uniqid,
|
|
query: {
|
|
...this.options
|
|
},
|
|
}).then(res => {
|
|
const data = res.data
|
|
const encodefields = data.encodefields || []
|
|
const decodePromises = encodefields.map(element => {
|
|
return common.decodeKey(data[element]).then(res => {
|
|
data[element] = res;
|
|
});
|
|
});
|
|
|
|
Promise.all(decodePromises).then(() => {
|
|
let admissionofficerin = data.admissionofficerin || []
|
|
if (admissionofficerin.length > 0) {
|
|
admissionofficerin.forEach(element => {
|
|
const date = new Date(element.date);
|
|
if (!isNaN(date.getTime())) {
|
|
if (Date.now() < date.getTime()) {
|
|
this.startCountdown(date.getTime() - Date.now() || 0)
|
|
this.setData({
|
|
answerType: 2,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
let answerquestions = data.answerquestions || []
|
|
if (data.info) {
|
|
const info = data.info || {}
|
|
|
|
let contras = Array.isArray(data.contras) ? {} : data.contras;
|
|
|
|
let side = this.data.side
|
|
|
|
const isadmission = info.admissionsproject || 0
|
|
if (isadmission == 1) this.getAdmissionList()
|
|
|
|
// const date = new Date()
|
|
// const month = date.getMonth() + 1
|
|
// const year = date.getFullYear()
|
|
// const semester = info.semester || {}
|
|
// if ((year < semester.year) || (year === semester.year && month < semester.month)) info['semesterState'] = true
|
|
|
|
this.setData({
|
|
info,
|
|
contras,
|
|
side,
|
|
isadmission,
|
|
sideKey: "basic", // basic
|
|
isInitFinish: true,
|
|
admissionofficerin,
|
|
answerintroduction: data.answerintroduction,
|
|
}, () => {
|
|
setTimeout(() => {
|
|
this.getHeadHeight()
|
|
this.getIndexHeight()
|
|
}, 500)
|
|
})
|
|
|
|
}
|
|
|
|
if (data.detailsInfo) {
|
|
const res = data.detailsInfo || {}
|
|
const direction = ['career_fields', 'typical_employers', 'career_positions'];
|
|
direction.forEach(field => {
|
|
let text = ""
|
|
if (res[field]) {
|
|
res[field].forEach(element => {
|
|
text += element + '\n'
|
|
})
|
|
res[field] = text
|
|
}
|
|
});
|
|
|
|
res.language_of_instruction && (res.language_of_instruction_text = res.language_of_instruction.join(","));
|
|
|
|
let course = {
|
|
required: [],
|
|
requiredCount: 0,
|
|
elective: [],
|
|
electiveCount: 0,
|
|
}
|
|
const curriculum = res.curriculum || []
|
|
curriculum.forEach(element => {
|
|
if (element.course_credits == 'N/A') element.course_credits = 0
|
|
element.type === 'Compulsory' ? (course.required.push(element), course.requiredCount += element.course_credits) : (course.elective.push(element), course.electiveCount += element.course_credits);
|
|
})
|
|
let side = this.data.side
|
|
|
|
// 判断是否常见问题 ,没有则删除左侧
|
|
if (!res.faq || res.faq.length == 0) delete side.issue
|
|
|
|
if (answerquestions.length == 0) delete side.answers
|
|
|
|
this.setData({
|
|
course,
|
|
answerquestions,
|
|
detailsInfo: res,
|
|
side,
|
|
})
|
|
}
|
|
|
|
this.handleAccreditationData(data.accreditations || [])
|
|
this.handleDocumentsData(data.documents || [])
|
|
|
|
const admissions = data.admissions
|
|
this.setData({
|
|
admissions,
|
|
scholarships: data.scholarships || [],
|
|
discipline: data.discipline,
|
|
admission_requirements: data.admission_requirements || [],
|
|
newest: data.newest || '',
|
|
})
|
|
|
|
const admissionsId = admissions?.[0]?.id
|
|
this.handleAmissionsData(admissionsId)
|
|
this.handleRequirementData(admissionsId)
|
|
this.getRecommendData()
|
|
|
|
this.getOfferData()
|
|
this.getDuckProphet()
|
|
})
|
|
}).finally(() => wx.hideLoading())
|
|
},
|
|
|
|
// 获取 鸭先知 数据
|
|
getDuckProphet() {
|
|
util.wxget("https://api.gter.net/v1/program/duckProphet", {
|
|
uniqid: this.data.uniqid,
|
|
}).then(res => {
|
|
if (res.code != 200) {
|
|
common.toast(res.message)
|
|
return
|
|
}
|
|
|
|
let data = res.data
|
|
// data = {
|
|
// earliestdate: "2025-06-09",
|
|
// latestdate: "2023-04-06",
|
|
// offercount: 0,
|
|
// rejectcount: 10,
|
|
// studentcount: 0,
|
|
// }
|
|
const hasValidCount = data.studentcount || data.offercount || data.rejectcount;
|
|
const shouldResetSide = !hasValidCount && this.data.offerShowList.length === 0 && this.data.offerPage !== 1;
|
|
this.setData({
|
|
duckProphet: hasValidCount ? data : null,
|
|
side: shouldResetSide ? (() => {
|
|
const side = {
|
|
...this.data.side
|
|
};
|
|
delete side.consult;
|
|
return side;
|
|
})() : this.data.side
|
|
});
|
|
|
|
setTimeout(() => this.getHeadHeight(), 500)
|
|
})
|
|
},
|
|
|
|
// 处理 能力要求信息
|
|
handleRequirementData(id) {
|
|
const admission_requirements = this.data.admission_requirements || []
|
|
|
|
this.setData({
|
|
admission_requirements,
|
|
})
|
|
|
|
this.getRequirementsObj(id)
|
|
},
|
|
|
|
// 拿到 能力要求 选中信息
|
|
getRequirementsObj(id) {
|
|
const target = this.data.admission_requirements.find(item => item.admission_id === id) || {};
|
|
|
|
const obj = {
|
|
"ENGLISH": "英语能力要求",
|
|
"CHINESE": "汉语能力要求",
|
|
"test": "能力测试",
|
|
"native": "母语",
|
|
"education": "教育",
|
|
"qualification": "专业资格",
|
|
"recommended": "推荐",
|
|
"required": "必须",
|
|
"optional": "可选",
|
|
};
|
|
|
|
let language = target.language_requirements || []
|
|
|
|
language.forEach(element => {
|
|
element['name'] = obj[element['language']];
|
|
element.proof_methods.forEach((ele) => {
|
|
ele["name"] = obj[ele["type"]];
|
|
(ele.tests || []).forEach((e) => {
|
|
let text = "";
|
|
if (["GMAT", "GMAT Focus Edition"].includes(e.test_name)) text = `Verbal Reasoning ${e.min_score} 分以上`;
|
|
else if (e.grade && e.grade == "Pass") text = `等级 ${e.grade}`;
|
|
else if (e.grade) text = `等级 ${e.grade} 以上`;
|
|
else if (e.sub_scores.length > 0) {
|
|
let allEqual = true;
|
|
e.sub_scores.forEach((ee) => {
|
|
if (ee.score != e.sub_scores[0].score) allEqual = false;
|
|
});
|
|
|
|
const fields = {
|
|
Total: "总分",
|
|
Reading: "阅读",
|
|
Speaking: "口语",
|
|
Writing: "写作",
|
|
Listening: "听力",
|
|
};
|
|
|
|
if (allEqual) text = `总分 ${e.min_score} 分以上,各项分数不低于 ${e.sub_scores[0].score} 分`;
|
|
else {
|
|
e.sub_scores.forEach((ee) => {
|
|
if (fields[ee.subject] && ee.score) text += `${fields[ee.subject]} ${ee.score} 分以上、`;
|
|
});
|
|
if (text.endsWith("、")) text = text.slice(0, -1);
|
|
}
|
|
} else if (e.min_score) text = `总分 ${e.min_score} 分以上`;
|
|
|
|
e["text"] = text;
|
|
});
|
|
});
|
|
|
|
let mergedData = {};
|
|
|
|
element.proof_methods.forEach((item) => {
|
|
if (!mergedData[item.type]) mergedData[item.type] = {
|
|
...item
|
|
};
|
|
else mergedData[item.type].description_zh += "\n" + item.description_zh;
|
|
});
|
|
|
|
element.proof_methods = Object.values(mergedData);
|
|
})
|
|
|
|
const standardized = target.standardized_tests_requirements || []
|
|
const arr = standardized.map((element) => ({
|
|
...element,
|
|
level: obj[element.requirement_level],
|
|
}));
|
|
|
|
if (arr.length != 0) {
|
|
language.push({
|
|
name: "其他标化考试要求",
|
|
iselse: true,
|
|
proof_methods: arr,
|
|
})
|
|
}
|
|
|
|
target.language_requirements = language
|
|
this.setData({
|
|
admission_requirementsObj: target,
|
|
isNoRequire: JSON.stringify(target) == "{}" ? true : false
|
|
}, () => {
|
|
const rpx800 = util.rpxTopx(800)
|
|
const query = wx.createSelectorQuery();
|
|
query.select('.side-item .demand.block').boundingClientRect(rect => {
|
|
if (!rect) return
|
|
this.setData({
|
|
demandState: rect.height >= rpx800 ? 1 : 0
|
|
})
|
|
}).exec()
|
|
})
|
|
},
|
|
|
|
// 处理 申请信息 季
|
|
handleAmissionsData(id) {
|
|
let admissions = this.data.admissions || []
|
|
const fields = ['tuition_fee', 'tuition_fee_per_credit', 'application_fee', 'admission_deposit'];
|
|
admissions.forEach(element => {
|
|
fields.forEach(field => {
|
|
const textKey = `${field}_text`;
|
|
element[textKey] = common.formatNumberWithSpaces(element[field] || '');
|
|
});
|
|
|
|
element['season'] = this.getIntakeSeason(element.intake_month, element.intake_year)
|
|
element['interviewRounds'] = this.calculateInterviewRound(element.application_end || {})
|
|
// console.log("element", element);
|
|
|
|
})
|
|
this.setData({
|
|
admissions,
|
|
})
|
|
this.getAdmissionsObj(id)
|
|
},
|
|
|
|
// 拿到 招生 选中信息
|
|
getAdmissionsObj(id) {
|
|
const admissionsObj = this.data.admissions.find(item => item.id === id) || {}
|
|
if (admissionsObj.leaflet_url) {
|
|
const leaflet_url = decodeURIComponent(admissionsObj.leaflet_url)
|
|
const urlWithoutParams = leaflet_url.split('?')[0];
|
|
const urlParts = urlWithoutParams.split('/');
|
|
const fileName = urlParts[urlParts.length - 1];
|
|
admissionsObj['leaflet_name'] = fileName
|
|
}
|
|
this.setData({
|
|
admissionsObj,
|
|
})
|
|
},
|
|
|
|
// 处理 文件数据
|
|
handleDocumentsData(documents) {
|
|
const mergedData = [];
|
|
const map = new Map();
|
|
|
|
documents.forEach((item) => {
|
|
const key = `${item.document_id}-${item.is_required}`;
|
|
if (map.has(key)) {
|
|
const existingItem = map.get(key);
|
|
existingItem.details += `\n${item.details}`;
|
|
} else {
|
|
const newItem = {
|
|
...item
|
|
};
|
|
map.set(key, newItem);
|
|
mergedData.push(newItem);
|
|
}
|
|
});
|
|
|
|
const documentsArr = [];
|
|
for (let i = 0; i < mergedData.length; i += 4) {
|
|
documentsArr.push(mergedData.slice(i, i + 4));
|
|
}
|
|
this.setData({
|
|
documents: documentsArr,
|
|
})
|
|
},
|
|
|
|
// 处理认证数据
|
|
handleAccreditationData(accreditation) {
|
|
let accArr = {
|
|
AC: {
|
|
title: "认证机构",
|
|
list: []
|
|
},
|
|
RE: {
|
|
title: "验证机构",
|
|
list: []
|
|
},
|
|
VA: {
|
|
title: "认可机构",
|
|
list: []
|
|
},
|
|
}
|
|
|
|
accreditation.forEach(element => {
|
|
if (element.accreditation_type == "ACCREDITATION") accArr.AC.list.push(element)
|
|
if (element.accreditation_type == "RECOGNITION") accArr.RE.list.push(element)
|
|
if (element.accreditation_type == "VALIDATION") accArr.VA.list.push(element)
|
|
})
|
|
|
|
this.setData({
|
|
accreditation: accArr,
|
|
isAccreditation: accreditation.length != 0 ? true : false,
|
|
})
|
|
},
|
|
|
|
countdownInterval: null,
|
|
startCountdown(duration) {
|
|
clearTimeout(this.countdownInterval);
|
|
let timer = duration;
|
|
const days = Math.floor(timer / (24 * 60 * 60 * 1000));
|
|
const hours = Math.floor((timer % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000));
|
|
const minutes = Math.floor((timer % (60 * 60 * 1000)) / (60 * 1000));
|
|
const seconds = Math.floor(timer % (60 * 1000) / 1000);
|
|
this.setData({
|
|
countDown: {
|
|
days,
|
|
hours: hours.toString().padStart(2, '0'),
|
|
minutes: minutes.toString().padStart(2, '0'),
|
|
seconds: seconds.toString().padStart(2, '0'),
|
|
},
|
|
countDownState: true,
|
|
});
|
|
timer = timer - 1000
|
|
if (timer > 0) this.countdownInterval = setTimeout(() => this.startCountdown(timer), 1000)
|
|
},
|
|
|
|
// 计算出面试轮的数组
|
|
calculateInterviewRound(obj) {
|
|
let rounds = [];
|
|
const chineseNumbers = ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十"];
|
|
|
|
const formatTime = (time, index) => {
|
|
return {
|
|
text: `第${chineseNumbers[index]}轮`,
|
|
time,
|
|
};
|
|
};
|
|
|
|
Object.keys(obj).forEach((key, index) => {
|
|
rounds.push(formatTime(obj[key], index));
|
|
});
|
|
|
|
if (rounds.length == 0) rounds = [{}]
|
|
return rounds || [{}]
|
|
},
|
|
|
|
// 切换招生官 轮播图状态
|
|
cutAdmission() {
|
|
this.setData({
|
|
admissionState: !this.data.admissionState
|
|
})
|
|
},
|
|
|
|
// 招生官 轮播图 修改状态
|
|
admissionChange(e) {
|
|
this.setData({
|
|
admissionCurrent: e.detail.current
|
|
})
|
|
},
|
|
|
|
// 获取index的高度
|
|
getIndexHeight() {
|
|
const query = wx.createSelectorQuery();
|
|
query.select('.head-box').boundingClientRect(rect => {
|
|
if (!rect) return
|
|
this.setData({
|
|
headHeight: rect.height,
|
|
})
|
|
if (!this.indexSidebar) this.indexSidebar = this.selectComponent('#index-sidebar')
|
|
}).exec();
|
|
},
|
|
|
|
// 获取头部 高度
|
|
sideHeight: {},
|
|
getHeadHeight() {
|
|
const query = wx.createSelectorQuery();
|
|
query.selectAll('.head-box').boundingClientRect()
|
|
query.selectAll('.details-box .side-item').boundingClientRect()
|
|
query.exec(rect => {
|
|
if (!rect) return
|
|
const headBox = rect[0][0] || {}
|
|
const side = rect[1]
|
|
let sideHeight = {}
|
|
let height = headBox.height - this.data.rpx30
|
|
side.forEach(element => {
|
|
const type = element.dataset.type
|
|
sideHeight[type] = height
|
|
height += element.height || 0
|
|
})
|
|
this.sideHeight = sideHeight
|
|
})
|
|
},
|
|
|
|
onPageScroll(e) {
|
|
const scrollTop = e.scrollTop
|
|
|
|
const sideHeight = this.sideHeight
|
|
const sideHeightList = Object.keys(sideHeight) || []
|
|
if (sideHeightList.length == 0) return
|
|
|
|
// 获取对象的所有键
|
|
const keys = Object.keys(sideHeight);
|
|
// 对键数组进行倒序排列
|
|
let closestValue = keys.reduce((acc, key) => {
|
|
const diff = sideHeight[key] - scrollTop;
|
|
if (diff <= this.data.totalTopHeight + 5) return key
|
|
return acc;
|
|
}, null);
|
|
|
|
const sideKey = closestValue || 'basic'
|
|
if (sideKey != this.data.sideKey) {
|
|
this.setData({
|
|
sideKey,
|
|
})
|
|
}
|
|
|
|
const headHeight = this.data.headHeight
|
|
const totalTopHeight = this.data.totalTopHeight
|
|
let sideFixed = false
|
|
if (scrollTop > headHeight - totalTopHeight - 15) sideFixed = true
|
|
if (sideFixed != this.data.sideFixed) {
|
|
this.setData({
|
|
sideFixed,
|
|
})
|
|
}
|
|
|
|
let sidebarState = this.indexSidebar.data.sidebarState
|
|
if (scrollTop > this.windowHeight * 3 && sidebarState !== 3) sidebarState = 3
|
|
|
|
if (scrollTop < this.windowHeight * 3 && sidebarState == 3) sidebarState = 2
|
|
|
|
// 同一搜集 修改的 sidebarState
|
|
if (sidebarState !== this.indexSidebar.data.sidebarState) {
|
|
this.indexSidebar.setData({
|
|
sidebarState
|
|
})
|
|
}
|
|
|
|
this.indexSidebar.openSidebarTwoHide()
|
|
},
|
|
|
|
// 点击复制
|
|
copy(e) {
|
|
const text = e.currentTarget.dataset.text
|
|
util.copy(text, '复制成功,浏览器打开')
|
|
},
|
|
|
|
// 打开文件
|
|
openFile(e) {
|
|
const url = e.currentTarget.dataset.url
|
|
common.goPage("/pages/webview/webview?url=" + encodeURIComponent(url))
|
|
},
|
|
|
|
// 打开 授权按钮
|
|
openLoginBtnState() {
|
|
this.setData({
|
|
isloginBtnState: true,
|
|
})
|
|
},
|
|
|
|
// 关闭授权登录事件
|
|
popClose() {
|
|
this.setData({
|
|
isloginBtnState: !this.data.isloginBtnState
|
|
})
|
|
},
|
|
|
|
userClickLogin(e) {
|
|
let data = e.detail.data
|
|
this.setData({
|
|
islogin: true,
|
|
isloginBtnState: false,
|
|
informationState: data.regdatastep == 'success' ? false : true,
|
|
})
|
|
this.onLoad(this.options)
|
|
},
|
|
|
|
// 子组件传值 修改 完善信息组件的状态
|
|
revampInformationState() {
|
|
this.setData({
|
|
informationState: false
|
|
})
|
|
},
|
|
|
|
// 点击 跳转 公共方法
|
|
goPage(e) {
|
|
const url = e.currentTarget.dataset.url
|
|
common.goPage(url)
|
|
},
|
|
|
|
goMyProject() {
|
|
if (!this.data.islogin) {
|
|
this.openLoginBtnState()
|
|
return
|
|
}
|
|
common.goPage("/pages/projectMy/projectMy?classify=manage")
|
|
},
|
|
|
|
handSide(e) {
|
|
const sideKey = e.currentTarget.dataset.key
|
|
const sideHeight = this.sideHeight
|
|
let value = sideHeight[sideKey] - this.data.totalTopHeight || 0
|
|
wx.pageScrollTo({
|
|
scrollTop: value,
|
|
})
|
|
},
|
|
|
|
indexSidebar: null,
|
|
windowHeight: 812, // 屏幕高度
|
|
|
|
// 点击加入对比单
|
|
addComparison() {
|
|
if (!this.data.islogin) {
|
|
this.openLoginBtnState()
|
|
return
|
|
}
|
|
|
|
const contras = this.data.contras
|
|
const info = this.data.info
|
|
|
|
util.wxpost("https://api.gter.net/v1/program/addContrast", {
|
|
projectid: info.id,
|
|
}).then(res => {
|
|
if (res.code != 200) return
|
|
const data = res.data
|
|
common.toast(res.message)
|
|
contras['status'] = 1
|
|
contras['ismanage'] = 1
|
|
contras['typeid'] = 0 // 默认是待定
|
|
contras['token'] = data.token
|
|
this.setData({
|
|
contras,
|
|
})
|
|
app.globalData.basicData['contrastcount'] = data.count
|
|
}).catch(err => {
|
|
if (err.code == 401) this.openLoginBtnState()
|
|
})
|
|
},
|
|
|
|
cutStudyMode(e) {
|
|
const type = e.currentTarget.dataset.type
|
|
this.setData({
|
|
studyMode: type,
|
|
})
|
|
},
|
|
|
|
// 获取招生官
|
|
getAdmissionList() {
|
|
util.wxget('/miniprogramApi/offer/home').then(res => {
|
|
if (res.code != 200) return
|
|
const data = res.data
|
|
let admissionsOfficer = data.admissionsOfficer || []
|
|
let urls = []
|
|
admissionsOfficer.forEach(element => {
|
|
let mold = null
|
|
if (element.date == null || element.date.indexOf("答疑") >= 0) mold = 3
|
|
else mold = this.isToday(element.date) ? 1 : 2
|
|
|
|
element.urls.forEach(ele => {
|
|
urls.push({
|
|
...ele,
|
|
mold,
|
|
logo: element['logo'],
|
|
})
|
|
})
|
|
})
|
|
|
|
const urlsOne = urls[0] || {}
|
|
|
|
const chunkedArray = [];
|
|
for (let i = 0; i < urls.length; i += 4) {
|
|
chunkedArray.push(urls.slice(i, i + 4));
|
|
}
|
|
|
|
this.setData({
|
|
urls: chunkedArray,
|
|
urlsOne,
|
|
})
|
|
})
|
|
},
|
|
|
|
isToday(dateString) {
|
|
const now = new Date().getTime()
|
|
const date = new Date(dateString).getTime()
|
|
return now <= date
|
|
},
|
|
|
|
offerLoading: false, // 加载中
|
|
offerAllList: [],
|
|
getOfferData() {
|
|
if (this.data.offerPage == 0 || this.offerLoading) return
|
|
this.offerLoading = true
|
|
const limit = 5
|
|
this.requestOfferData(limit).then(data => {
|
|
let list = data.list || []
|
|
let side = this.data.side
|
|
// if (list.length == 0) delete side.consult
|
|
|
|
let sideNum = this.data.sideNum
|
|
sideNum['consult'] = data.count
|
|
const page = data.count > data.limit * data.page ? this.data.offerPage + 1 : 0
|
|
this.setData({
|
|
offerShowList: list,
|
|
side,
|
|
sideNum,
|
|
offerPage: page,
|
|
}, () => setTimeout(() => this.getHeadHeight(), 500))
|
|
|
|
if (list.length == 0 && this.data.duckProphet == null) {
|
|
console.log("1111111", this.data.duckProphet);
|
|
|
|
let side = this.data.side
|
|
delete side.consult
|
|
this.setData({
|
|
side,
|
|
})
|
|
}
|
|
}).finally(() => this.offerLoading = false)
|
|
},
|
|
|
|
// 第二页
|
|
moreOfferData() {
|
|
const render = () => {
|
|
let offerPage = this.data.offerPage
|
|
let allList = this.offerAllList
|
|
let offerShowList = this.data.offerShowList || []
|
|
if (offerPage == 0) return
|
|
const offset = 10
|
|
const startIndex = offerShowList.length;
|
|
const endIndex = startIndex + offset;
|
|
|
|
let list = allList.slice(startIndex, endIndex);
|
|
|
|
this.setData({
|
|
offerShowList: offerShowList.concat(list),
|
|
offerPage: endIndex >= allList.length ? 0 : offerPage + 1,
|
|
}, () => {
|
|
setTimeout(() => this.getHeadHeight(), 500)
|
|
})
|
|
}
|
|
const request = () => {
|
|
if (this.offerLoading) return
|
|
this.offerLoading = true
|
|
this.requestOfferData(3000).then(data => {
|
|
this.offerAllList = data.list
|
|
render()
|
|
}).finally(() => this.offerLoading = false)
|
|
}
|
|
|
|
if (this.offerAllList.length == 0) request()
|
|
else render()
|
|
},
|
|
|
|
// 请求 offer 数据
|
|
requestOfferData(limit) {
|
|
return new Promise(resolve => {
|
|
util.wxget(`https://api.gter.net/v1/program/offerList?limit=${ limit }&projectid=${ this.data.info.id }`).then(res => {
|
|
if (res.code != 200) {
|
|
common.toast(res.message)
|
|
reject()
|
|
return
|
|
}
|
|
const data = res.data;
|
|
(data.list || []).forEach(element => {
|
|
element["timestamp"] = util.strtimeago(element["timestamp"], 3)
|
|
})
|
|
resolve(data)
|
|
}).finally(() => this.offerLoading = false)
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
wx.stopPullDownRefresh()
|
|
this.getData()
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
// if (this.data.offerPage != 0) this.getOfferData()
|
|
},
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
wx.stopPullDownRefresh()
|
|
this.getData()
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
return {
|
|
title: `【${ this.data.info.schoolalias || this.data.info.schoolname || '' }】 - ${this.data.info.name_zh}`,
|
|
path: `/pages/projectDetails/projectDetails?uniqid=${this.data.info.uniqid}`,
|
|
}
|
|
},
|
|
onShareTimeline() {
|
|
return {
|
|
title: `【${ this.data.info.schoolalias || this.data.info.schoolname || '' }】 - ${this.data.info.name_zh}`,
|
|
path: `/pages/projectDetails/projectDetails?uniqid=${this.data.info.uniqid}`,
|
|
}
|
|
},
|
|
|
|
cutQuickAnswer() {
|
|
this.setData({
|
|
quickAnswerState: !this.data.quickAnswerState
|
|
})
|
|
},
|
|
|
|
// 跳转专业排名
|
|
goProjectList(e) {
|
|
const rankings = this.data.info.rankings || []
|
|
const index = e.currentTarget.dataset.index
|
|
let item = rankings[index]
|
|
item['system'] = encodeURIComponent(item['system'])
|
|
item['subject'] = encodeURIComponent(item['subject'])
|
|
wx.navigateTo({
|
|
url: `/pages/projectList/projectList?type=subject&year=${ item.year }&system=${item.system}&subject=${item.subject}`,
|
|
})
|
|
},
|
|
|
|
// 切换要求展示
|
|
cutDemandState() {
|
|
this.setData({
|
|
demandState: this.data.demandState == 1 ? 2 : 1
|
|
}, () => setTimeout(() => this.getHeadHeight(), 500))
|
|
},
|
|
|
|
// 获取 格式 2025Fall
|
|
getIntakeSeason(intake_month, intake_year) {
|
|
let season = "Fall";
|
|
if (intake_month >= 8 && intake_month <= 12) season = "Fall";
|
|
else if (intake_month >= 1 && intake_month <= 5) season = "Spring";
|
|
else if (intake_month >= 6 && intake_month <= 7) season = "Summer";
|
|
const shortYear = String(intake_year).slice(-2);
|
|
return `${shortYear}${season}`;
|
|
},
|
|
|
|
cutApplyIndex(e) {
|
|
const id = e.currentTarget.dataset.id
|
|
this.handleAmissionsData(id)
|
|
this.handleAmissionsData(id)
|
|
this.cutApplyState()
|
|
},
|
|
|
|
cutApplyState() {
|
|
this.setData({
|
|
applyListState: !this.data.applyListState,
|
|
})
|
|
},
|
|
|
|
recommendLoading: false, // 加载中
|
|
// 获取推荐数据
|
|
getRecommendData() {
|
|
if (this.data.recommendPage == 0 || this.recommendLoading) return
|
|
this.recommendLoading = true
|
|
util.wxpost("https://api.gter.net/v1/program/recommendProgram", {
|
|
uniqid: this.data.uniqid,
|
|
page: this.data.recommendPage,
|
|
limit: 10,
|
|
}).then(res => {
|
|
const data = res.data
|
|
|
|
const date = new Date()
|
|
const month = date.getMonth() + 1
|
|
const year = date.getFullYear()
|
|
|
|
let list = data.data || []
|
|
list = (list).map(element => ({
|
|
...element,
|
|
semesterState: (year < element.semester.year) || (year === element.semester.year && month < element.semester.month),
|
|
tuition_fee_text: common.formatNumberWithSpaces(element.tuition_fee || '')
|
|
}));
|
|
|
|
let side = this.data.side
|
|
if (list.length == 0) delete side.recommend
|
|
|
|
this.setData({
|
|
recommendList: this.data.recommendList.concat(list),
|
|
side,
|
|
recommendPage: this.data.recommendPage + 1
|
|
})
|
|
}).finally(() => this.recommendLoading = false)
|
|
},
|
|
|
|
// 点击 推荐项目 的详情
|
|
goDetails(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
const list = this.data.recommendList
|
|
const target = list[index]
|
|
common.goPage(`/pages/projectDetails/projectDetails?uniqid=${ target.uniqid }`)
|
|
},
|
|
|
|
goVs(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
const info = this.data.info
|
|
const list = this.data.recommendList
|
|
const target = list[index]
|
|
common.goPage(`/pages/projectComparison/projectComparison?ids=${[info.id, target.id]}`)
|
|
},
|
|
goDepartment() {
|
|
const info = this.data.info
|
|
common.goPage(`/pages/projectSchoolHomepage/projectSchoolHomepage?id=${info.sid}&department=${info.department}`)
|
|
},
|
|
}) |