Explorar o código

添加预约考试条件限制

Tang %!s(int64=3) %!d(string=hai) anos
pai
achega
151cb7fc49
Modificáronse 1 ficheiros con 41 adicións e 7 borrados
  1. 41 7
      pages2/exam/exam_appointment.vue

+ 41 - 7
pages2/exam/exam_appointment.vue

@@ -112,7 +112,7 @@
 				<u-line color="#EEEEEE" />
 				<view class="foot" v-if="activeList.subscribeStatus === 1">
 					<view class="btn" @click="hideModel">知道了</view>
-					<view class="btn cancel" v-if="isShowFun(activeList.applyEndTime)" @click="cancelBtn">取消预约</view>
+					<view class="btn cancel" v-if="isShowFun(activeList)" @click="cancelBtn">取消预约</view>
 				</view>
 				<view class="foot" v-else><view class="abtns" @click="hideModel">知道了</view></view>
 			</view>
@@ -185,12 +185,38 @@ export default {
 		};
 	},
 	methods: {
-		isShowFun(times){
-			var timestamp=parseInt(new Date().getTime() / 1000)
-			if(times < timestamp){
-				return false
-			}else{
-				return true
+		isShowFun(times) {
+			var timestamp = parseInt(new Date().getTime() / 1000);
+			var newDataAge = parseInt(new Date(new Date().toLocaleDateString()).getTime() / 1000);
+			if (times.applyEndTime < timestamp) {
+				return false;
+			} else {
+				if (times.beforeStatus === 1) {
+					return false;
+				} else if (times.examStatus !== 0) {
+					return false;
+				} else if (times.applySiteExamTime < times.newDataAge) {
+					return false;
+				} else if (times.applySiteExamTime > times.newDataAge) {
+					return true;
+				} else if (times.applySiteExamTime == times.newDataAge) {
+					var hours = new Date().getHours();
+					var mins = new Date().getMinutes();
+					var arrays = times.applySiteStartTime.split('-').map(Number);
+					if (arrays[0] > hours) {
+						return true;
+					} else if (arrays[0] < hours) {
+						return false;
+					} else {
+						if (arrays[1] <= mins) {
+							return false;
+						} else {
+							return true;
+						}
+					}
+				} else {
+					return true;
+				}
 			}
 		},
 		showDetails(item) {
@@ -204,6 +230,14 @@ export default {
 			this.details_show = false;
 		},
 		submit() {
+			var bols = this.isShowFun(this.activeList)
+			if(!bols){
+				uni.showToast({
+					icon:"none",
+					title:"当前已无法取消预约"
+				})
+				return
+			}
 			this.$api
 				.editApply({
 					subscribeId: this.activeList.subscribeId,