浏览代码

考试相关

wangxy 3 月之前
父节点
当前提交
3b36abc3cd
共有 7 个文件被更改,包括 273 次插入186 次删除
  1. 130 118
      api/exam.js
  2. 6 0
      components/custom-scroll-list/custom-scroll-list.vue
  3. 66 30
      components/kaoshixuzhi/kaoshixuzhi.vue
  4. 69 27
      pages/exam/index.vue
  5. 1 1
      utils/auth.js
  6. 0 10
      utils/cacheManager.js
  7. 1 0
      utils/userCache.js

+ 130 - 118
api/exam.js

@@ -1,156 +1,168 @@
 import request from '@/utils/request'
 export function getExamList(data = {}) {
-  return request({
-    'url': '/app/kaoshi/list',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		'url': '/app/kaoshi/list',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 export function getFileUpload(data = {}) {
-  return request({
-    url: '/app/file/upload',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/file/upload',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 
 export function getClientQiepingCheat(data = {}) {
-  return request({
-    url: '/app/qieping/cheat',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/qieping/cheat',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 
 export function getClientQiepingTimes(data = {}) {
-  return request({
-    url: '/app/qieping/times',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/qieping/times',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 
 export function getClientKaoshiBiaoji(data = {}) {
-  return request({
-    url: '/app/kaoshi/biaoji',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/kaoshi/biaoji',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 
 export function getClientKsChengjiList(data = {}) {
-  return request({
-    url: '/app/chengji/list',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/chengji/list',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 
 export function getClientKsChengjiView(data = {}) {
-  return request({
-    url: '/app/chengji/view',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/chengji/view',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 
 export function getClientKsSave(data = {}) {
-  return request({
-    url: '/app/kaoshi/save',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/kaoshi/save',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 
 export function getClientKsStart(data = {}) {
-  return request({
-    url: '/app/kaoshi/start',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/kaoshi/start',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 
 export function getClientKsSubmit(data = {}) {
-  return request({
-    url: '/app/kaoshi/submit',
-    headers: {
-      isToken: true
-    },
-	isLoading:true,
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/kaoshi/submit',
+		headers: {
+			isToken: true
+		},
+		isLoading: true,
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 // 不存在
 export function getClientUserInfo(data = {}) {
-  return request({
-    url: '/app/kaoshi/user/info',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/kaoshi/user/info',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 
 export function getClientZhuaPaiUpdate(data = {}) {
-  return request({
-    url: '/app/kaoshi/zhuapai',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/kaoshi/zhuapai',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
 }
 
 export function getClientKaoshiInfo(data = {}) {
-  return request({
-    url: '/app/kaoshi/info',
-    headers: {
-      isToken: true
-    },
-    method: 'post',
-    data,
-    timeout: 20000
-  })
+	return request({
+		url: '/app/kaoshi/info',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
+}
+
+export function kaoShiApply(data = {}) {
+	return request({
+		url: '/app/kaoshi/apply',
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	});
 }

+ 6 - 0
components/custom-scroll-list/custom-scroll-list.vue

@@ -79,6 +79,7 @@
 
 	})
 
+
 	const page = ref(1);
 	const list = ref([]); // 项目列表
 	const triggered = ref(false); // 是否触发下拉刷新
@@ -194,6 +195,11 @@
 		page.value++;
 		getData('reach-buttom')
 	}
+
+	
+	defineExpose({
+		onRefresh
+	})
 </script>
 
 <style lang="scss">

+ 66 - 30
components/kaoshixuzhi/kaoshixuzhi.vue

@@ -1,61 +1,93 @@
 <template>
 	<view>
-		<uni-popup ref="popupRef" type="dialog" :animation="false" :is-mask-click="false"
-		mask-background-color="rgba(0, 0, 0, 0.4);">
-			<uni-popup-dialog mode="input"
-			class="phone-ksxz-dialog"
-				title="考试须知"
-				:duration="2000" 
-				:before-close="true"
-				@close="handleClose"
-				@confirm="handleConfirm">
-				<view class="ksxz-content-box">
-					<view v-if="data.ksName">考试名称:{{data.ksName}}</view>
-					<view v-if="data.zyName">职业:{{data.zyName}}</view>
-					<view v-if="data.zyLevelName">等级:{{data.zyLevelName}}</view>
-					<view v-if="data.ksScore">总分:{{data.ksScore}}</view>
-					<view v-if="data.okScore">及格分:{{data.okScore}}</view>
-					<view>
-						<view v-if="data.intro" class="ksms-row">考试描述:</view>
-						<rich-text v-if="data.intro" :nodes="data.intro" class="ksms-intro"></rich-text>
-					</view>
+		<uni-popup ref="popupRef" :animation="false" :is-mask-click="false" mask-background-color="rgba(0, 0, 0, 0.4);">
+			<view class="ksxz-content-box" style="background-color: #fff;padding: 20rpx;">
+				<view>
+					<text>考试须知</text>
+					<!-- 倒计时 -->
+					<examCountDownVue v-if="data.startSecond>0" :count="data.startSecond" ref="countDownRef"
+						class="cur-exam-count-down" @time-end="onTimeEnd"></examCountDownVue>
 				</view>
-			</uni-popup-dialog>
+				<view v-if="data.name">考试名称:{{data.name}}</view>
+				<view v-if="data.ksScore">用户名:{{data.ksScore}}</view>
+				<view v-if="data.credit">学分:{{data.credit}}</view>
+				<view v-if="data.okScore">及格分:{{data.okScore}}</view>
+				<view v-if="data.ksScore">总分:{{data.ksScore}}</view>
+				<view v-if="data.startTime">开始:{{data.startTime}}</view>
+				<view v-if="data.endTime">结束:{{data.endTime}}</view>
+				<view>
+					<view v-if="data.textareaHtml" class="ksms-row">考试描述:</view>
+					<rich-text v-if="data.textareaHtml" :nodes="data.textareaHtml" class="ksms-intro"></rich-text>
+				</view>
+
+				<view>
+					<button class="cancel" @click="handleClose">取消</button>
+					<button class="confirm" v-if="isCanJoinExam" @click="handleConfirm">确定</button>
+				</view>
+			</view>
 		</uni-popup>
 	</view>
 </template>
 
 <script setup>
+	import examCountDownVue from "./examCountDown.vue";
 	import {
-		ref,reactive
+		ref,
+		reactive,
+		nextTick
 	} from "vue";
 	const popupRef = ref(null)
+	const countDownRef = ref(null)
 	const data = reactive({
 		intro: '',
-		ksName: '',
+		name: '',
 		ksScore: '',
 		okScore: '',
-		zyLevelName: '',
-		zyName: '',
+		textareaHtml: '',
+		credit: '',
+		startTime: '',
+		endTime: '',
+		ksId: '',
+		startSecond: 0
 	})
-	
+	const isCanJoinExam = ref(false)
+
 	const emits = defineEmits(['confirm', 'cancel'])
 
 	function showDialog(options) {
 		data.intro = options.intro;
-		data.ksName = options.ksName;
+		data.ksName = options.name;
 		data.ksScore = options.ksScore;
 		data.okScore = options.okScore;
-		data.zyName = options.zyName;
-		data.zyLevelName = options.zyLevelName;
+		data.credit = options.credit;
+		data.startTime = options.startTime;
+		data.endTime = options.endTime;
+		data.startSecond = options.startSecond;
 		data.ksId = options.ksId;
-		
-		popupRef.value.open()
+
+
+		if (typeof options.intro == 'undefined' || options.intro == null || options.intro == '') {
+			data.textareaHtml = '暂无描述信息';
+		} else {
+			data.textareaHtml = options.intro;
+		}
+
+
+		if (options.startSecond < 0) {
+			isCanJoinExam.value = true;
+		}
+
+		popupRef.value.open('center')
+		setTimeout(() => {
+			countDownRef.value.init()
+		}, 0)
 	}
 
 	function handleClose() {
 		emits('cancel');
 		popupRef.value.close()
+		isCanJoinExam.value = false;
+		countDownRef.value.termination()
 	}
 
 	function handleConfirm() {
@@ -63,6 +95,10 @@
 		popupRef.value.close()
 	}
 
+	function onTimeEnd() {
+		isCanJoinExam.value = true;
+	}
+
 	defineExpose({
 		showDialog
 	})

+ 69 - 27
pages/exam/index.vue

@@ -1,24 +1,35 @@
 <template>
-	<custom-scroll-list :refreshFn="getExamList" :tabList="tabData" :defaultTab="1">
+	<custom-scroll-list :refreshFn="getExamList" :tabList="tabData" :defaultTab="1" ref="scrollRef">
 		<template #default="{list}">
-			<scroll-list-card  v-for="(item,index) in list" :key="item.ksId" :data="item" @btnClick="handleClick"></scroll-list-card>
+			<scroll-list-card v-for="(item,index) in list" :key="item.ksId" :data="item"
+				@btnClick="handleClick"></scroll-list-card>
 		</template>
 	</custom-scroll-list>
+	<!-- 考试须知 -->
+	<kaoshixuzhi ref="ksxzRef" @confirm="handleConfirm"></kaoshixuzhi>
 </template>
 
 <script setup>
 	import {
-		getExamList
+		getExamList,
+		kaoShiApply,
+		getClientKaoshiInfo
 	} from "@/api/exam.js";
 	import {
-		// onLoad,
 		onReady,
-		
 	} from "@dcloudio/uni-app"
 	import {
 		reactive,
 		ref
 	} from "vue";
+	import kaoshixuzhi from "@/components/kaoshixuzhi/kaoshixuzhi.vue"
+
+	const activeKs = ref(null);
+	const scrollRef = ref(null);
+	const examNoticeInfo = ref(null);
+	const textareaHtml = ref(null);
+	const examNoticeShowFlag = ref(false);
+	const ksxzRef = ref(null);
 
 	const tabData = [{
 			label: "可以考试",
@@ -29,47 +40,78 @@
 			value: 4,
 		}
 	]
+
+	function goKaoshiPage(data) {
+		uni.redirectTo({
+			url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
+		})
+	}
 	
+	function handleConfirm() {
+		goKaoshiPage(activeKs.value)
+	}
+
+	function showKaoshiXuzhi() {
+		const option = {
+			ksId: activeKs.value.ksId
+		}
+		getClientKaoshiInfo(option).then(res => {
+			examNoticeInfo.value = res.data;
+			// 校验抓拍
+			doCheckZhuapai()
+		})
+
+	}
+
+	function doCheckZhuapai() {
+		if (examNoticeInfo.value.zhuapai) {
+			// 存在抓拍
+		} else {
+			// 不存在抓拍
+			ksxzRef.value.showDialog(examNoticeInfo.value)
+		}
+	}
+
 	function handleClick(data) {
-		console.log('data', data)
+		activeKs.value = data;
 		if (data.status == 0) {
 			// 未开始
-			uni.redirectTo({
-				url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
-			})
+			// goKaoshiPage(data);
+			showKaoshiXuzhi()
 		}
 		if (data.status == 1) {
 			// 可以考试
-			uni.redirectTo({
-				url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
-			})
+			// goKaoshiPage(data);
+			showKaoshiXuzhi()
 		}
 		if (data.status == 2) {
 			// 再次考试
-			uni.redirectTo({
-				url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
-			})
+			// goKaoshiPage(data);
+			showKaoshiXuzhi()
 		}
 		if (data.status == 3) {
 			// 考试中
-			uni.redirectTo({
-				url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
-			})
+			// goKaoshiPage(data);
+			showKaoshiXuzhi()
 		}
 		if (data.status == 4) {
 			// 已结束
+			uni.showToast({
+				title: '考试已结束',
+				icon: 'none'
+			})
 		}
 		if (data.status == 5) {
 			// 未报名
-		}
-		if (data.status == 6) {
-			// 报名审核中
-		}
-		if (data.status == 7) {
-			// 审核未通过
-		}
-		if (data.status == 8) {
-			// 等待人工评分
+			kaoShiApply({
+				ksId: data.ksId
+			}).then(res => {
+				uni.showToast({
+					title: '报名成功',
+					icon: 'none'
+				})
+				scrollRef.value.onRefresh()
+			})
 		}
 
 	}

+ 1 - 1
utils/auth.js

@@ -1,4 +1,4 @@
-const TokenKey = 'Mta-Auth'
+const TokenKey = 'Mta-UserCache'
 
 export function getAuth() {
   return uni.getStorageSync(TokenKey)

+ 0 - 10
utils/cacheManager.js

@@ -131,13 +131,3 @@ const cacheManager = (function() {
 
 export default cacheManager;
 
-// 单元测试 引导大鹅提示 缓存Key
-export const SHOW_UNIT_TEST_TISHI = 'SHOW_UNIT_TEST_TISHI';
-
-// 单元测试大鹅提示缓存
-export function useUnitTestTishi() {
-	return {
-		updateTishi: () => cacheManager.set(SHOW_UNIT_TEST_TISHI, 'has'),
-		getTishi: () => cacheManager.get(SHOW_UNIT_TEST_TISHI)
-	}
-}

+ 1 - 0
utils/userCache.js

@@ -2,6 +2,7 @@ import cacheManager from "@/utils/cacheManager.js"
 
 const TokenKey = 'Mta-UserCache'
 
+// 分用户记录缓存
 export function useUserCache() {
 	function saveCache() {
 		let pageId, key, value;