From d898941c093dab71a72914b955440bc4763c6515 Mon Sep 17 00:00:00 2001 From: "DESKTOP-RQ919RC\\Pc" <1300399510@qq.com> Date: Mon, 7 Apr 2025 18:49:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=B8=AD=E5=85=88=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/survey-box/survey-box.js | 15 ++++++++- pages/projectDetails/projectDetails.js | 41 ++++++++++++++++++------ pages/projectDetails/projectDetails.wxml | 8 +++-- utils/util.js | 4 ++- 4 files changed, 53 insertions(+), 15 deletions(-) diff --git a/component/survey-box/survey-box.js b/component/survey-box/survey-box.js index 8307c20..a3f97ad 100644 --- a/component/survey-box/survey-box.js +++ b/component/survey-box/survey-box.js @@ -1,11 +1,24 @@ // pagesSquare/components/survey-box/survey-box.js +const util = require('../../utils/util') + Component({ /** * 组件的属性列表 */ properties: { - duckProphet: Object, + duckProphet: { + type: Object, + observer(res) { + if (JSON.stringify(res) == "{}") return + res['latestdate'] = util.timeformat(res['latestdate'], 6) + res['earliestdate'] = util.timeformat(res['earliestdate'], 6) + console.log("res", res); + this.setData({ + duckProphet: res || {} + }) + } + }, newest: { type: String, observer(res) { diff --git a/pages/projectDetails/projectDetails.js b/pages/projectDetails/projectDetails.js index f622f5f..bae5e16 100644 --- a/pages/projectDetails/projectDetails.js +++ b/pages/projectDetails/projectDetails.js @@ -88,6 +88,7 @@ Page({ rpx30: 30, user: {}, offerList: [], + offerShowList: [], offerPage: 1, sideNum: {}, answerType: 0, // 招生管显示类型 0不显示 1长期答疑 2即将开始 @@ -127,7 +128,7 @@ Page({ applyListState: false, // 申请信息选择列表状态 newest: "", - duckProphet: {}, // 鸭先知 + duckProphet: 0, // 鸭先知 }, /** @@ -227,7 +228,6 @@ Page({ }, 500) }) - this.getOfferData() } if (data.detailsInfo) { @@ -288,6 +288,7 @@ Page({ this.handleRequirementData(admissionsId) this.getRecommendData() + this.getOfferData() this.getDuckProphet() }) }).finally(() => wx.hideLoading()) @@ -295,7 +296,7 @@ Page({ // 获取 鸭先知 数据 getDuckProphet() { - util.wxpost("https://api.gter.net/v1/program/duckProphet", { + util.wxget("https://api.gter.net/v1/program/duckProphet", { uniqid: this.data.uniqid, }).then(res => { if (res.code != 200) { @@ -304,9 +305,20 @@ Page({ } const data = res.data + const hasValidCount = data.studentcount || data.offercount || data.rejectcount; + const shouldResetSide = !hasValidCount && this.data.offerShowList.length === 0 && this.data.offerPage !== 1; this.setData({ - duckProphet: data, - }) + duckProphet: hasValidCount ? data : null, + side: shouldResetSide ? (() => { + const side = { + ...this.data.side + }; + delete side.consult; + return side; + })() : this.data.side + }); + + setTimeout(() => this.getHeadHeight(), 500) }) }, @@ -799,20 +811,29 @@ Page({ this.offerLoading = true const limit = 5 this.requestOfferData(limit).then(data => { - const list = data.list || [] + 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: data.count > data.limit * data.page ? this.data.offerPage + 1 : 0, - }, () => { - setTimeout(() => this.getHeadHeight(), 500) - }) + 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) }, diff --git a/pages/projectDetails/projectDetails.wxml b/pages/projectDetails/projectDetails.wxml index 49650b6..3998d06 100644 --- a/pages/projectDetails/projectDetails.wxml +++ b/pages/projectDetails/projectDetails.wxml @@ -496,10 +496,12 @@ - + 录取参考 - - + + + + diff --git a/utils/util.js b/utils/util.js index c20017b..606985f 100644 --- a/utils/util.js +++ b/utils/util.js @@ -384,7 +384,9 @@ function timeformat(time, type = 1) { result = `${Nmonth}月${Ndate}日 ${Nhour}:${Nmin}`; if (new Date().getFullYear() != Nyear) result = `${Nyear}年` + result; } else if (type == 4) result = `${Nyear}-${Nmonth}-${Ndate} ${Nhour}:${Nmin}`; - + else if (type == 5) result = `${Nyear}-${Nmonth}-${Ndate}`; + else if (type == 6) result = `${Nyear}年${Nmonth}月${Ndate}日`; + return result; }