Преглед изворни кода

fix:培训周期(对比年份替换)

xiexaing пре 1 година
родитељ
комит
a210ed994c
1 измењених фајлова са 14 додато и 1 уклоњено
  1. 14 1
      pages/learn/index.vue

+ 14 - 1
pages/learn/index.vue

@@ -302,7 +302,7 @@
 							</div>
 							<div v-if="isMajorEducation(item)">
 								<span v-if="item.sevenPushReason === '培训周期时间未到' && item.officialStatus != 1">
-									温馨提示:您{{item.orderYear}}年{{ item.majorName }}专业培训周期还没到,请在{{ item.sevenPushDate }}后再进行继教。
+									温馨提示:您{{item.orderYear}}年{{ item.majorName }}专业培训周期还没到,请在{{ trainDate(item.sevenPushDate) }}后再进行继教。
 								</span>
 								<span v-if="item.sevenPushReason === '无相关专业专书'">
 									温馨提示:您当前的课程{{item.orderYear}}年{{ item.majorName }}专业,未能匹配到可继教证书,可前往住建证书官网查询。
@@ -689,6 +689,19 @@
 					);
 				}
 			},
+			// 培训周期时间小于当前年份,进行年份替换
+			trainDate() {
+				return function(val) {
+					const oldDate = val ? val.split("/") : []
+					if (oldDate.length != 3) return
+					const [oldYear, month, day] = oldDate
+					let currentYear = new Date().getFullYear()
+					if (oldYear < currentYear) {
+						return `${currentYear}/${month}/${day}`
+					}
+					return val
+				}
+			}
 		},
 		async onLoad(options) {
 			uni.hideTabBar();