Pārlūkot izejas kodu

增加查看下级的模拟成绩

zhangyujun 3 gadi atpakaļ
vecāks
revīzija
46f3336418

+ 1 - 0
src/api/modules/branch.ts

@@ -33,6 +33,7 @@ export declare namespace BranchTypeTest {
 		achievement: number;
 		achievementSettled: number;
 		extensionCount: number;
+		id:number;
 	};
 
 	interface IntegralRes extends Common.Res {

+ 14 - 0
src/api/modules/testScores.ts

@@ -24,6 +24,20 @@ export const getTestScoresInfo = async () => {
   return res.data;
 };
 
+/**
+ * 根据用户ID获取考试成绩的列表
+ * @returns
+ */
+export const getScoreInfoByUserId = async (params: {
+  userId: number
+}) => {
+  let res = await request({
+    url: "/student/score/info/getScoreInfoByUserId",
+  });
+
+  return res.data;
+};
+
 interface TestScores {
   kskm: string;
   score: number;

+ 1 - 0
src/api/request.ts

@@ -7,6 +7,7 @@ const request = axios.create({
 });
 
 request.interceptors.request.use((config) => {
+	console.log(config)
 	// 是否需要设置 token
 	if (config.headers.isToken !== false) {
 		config.headers["Authorization"] = "Bearer " + store.getters.getToken; // 让每个请求携带自定义token 请根据实际情况自行修改

+ 7 - 1
src/store/index.ts

@@ -5,11 +5,17 @@ const store = createStore({
   plugins: [createPersistedState()],
   state: () => ({
     token: "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjllNTU3NDk1LWQyOGQtNDMyNy1hYTBjLTdjOTk2OTk5NTk1YiJ9.GvGgys5erlFYJMLEhk2S1e7W_9CKDJohfXfW8fZpitkpZ8RWni5u9VvTGjl8dhD1916s-4MTM_7TsNaTNwsuPg",
-    userData: {},
+    userData: {
+      schoolName:""
+    },
     carType: "0",
     suject: "0",
   }),
   getters: {
+    getSchoolName(state){
+      return state.userData.schoolName
+
+    },
     getCarType(state) {
       return state.carType;
     },

+ 113 - 92
src/views/myIntegral/index.vue

@@ -14,19 +14,21 @@
 					<th>头像</th>
 					<th>昵称</th>
 					<th>推广人数</th>
-					<th>未结算</th>
-					<th>已结算</th>
-					<th>按钮</th>
+					<th v-if="saleType == 2 || saleType == 3">未结算</th>
+					<th v-else>推广积分</th>
+
+					<th v-if="saleType == 2 || saleType == 3">已结算</th>
+					<th v-if="saleType == 2 || saleType == 3">按钮</th>
 				</tr>
-				<tr v-for="(userInfo, index) in integralList.filter((userInfo) => userInfo.nickName.includes(searchValue))" :key="index">
+				<tr @click="goStudentScore(userInfo)" v-for="(userInfo, index) in integralList.filter((userInfo) => userInfo.nickName.includes(searchValue))" :key="index">
 					<td>
 						<van-image round width="50px" height="50px" :src="userInfo.headImage" />
 					</td>
 					<td>{{ userInfo.nickName }}</td>
 					<td>{{ userInfo.extensionCount }}</td>
 					<td>{{ userInfo.achievement }}</td>
-					<td>{{ userInfo.achievementSettled }}</td>
-					<td><van-button type="primary" @click="showSettlement(userInfo)">结算</van-button></td>
+					<td v-if="saleType == 2 || saleType == 3">{{ userInfo.achievementSettled }}</td>
+					<td v-if="saleType == 2 || saleType == 3"><van-button type="primary" @click="showSettlement(userInfo)">结算</van-button></td>
 				</tr>
 			</table>
 			<div v-else style="text-align: center">暂无数据</div>
@@ -35,112 +37,131 @@
 </template>
 
 <script lang="ts">
-	import { BranchModel } from "@/model/myBranchList";
-	import { ref, onBeforeMount } from "vue";
+import { BranchModel } from "@/model/myBranchList";
+import { ref, onBeforeMount } from "vue";
 
-	export type UserInfo = {
-		openid: string;
-		nickName: string;
-		headImage: string;
-		achievement: number;
-		achievementSettled: number;
-		extensionCount: number;
-	};
+import store from "@/store";
+// const saleType = store.getters.getUserData?.saleType
 
-	const branchModel = new BranchModel();
+export type UserInfo = {
+	openid: string;
+	nickName: string;
+	headImage: string;
+	achievement: number;
+	achievementSettled: number;
+	extensionCount: number;
+	id: number;
+};
+const branchModel = new BranchModel();
 
-	const useMyIntegral = () => {
-		const integralList = ref<Array<UserInfo>>([]);
+const useMyIntegral = () => {
+	const integralList = ref<Array<UserInfo>>([]);
 
-		onBeforeMount(async () => {
-			const data = await branchModel.getIntegralList();
-			integralList.value = data;
-		});
+	onBeforeMount(async () => {
+		const data = await branchModel.getIntegralList();
+		integralList.value = data;
+	});
 
-		const integralSettlement = branchModel.integralSettlement;
+	const integralSettlement = branchModel.integralSettlement;
 
-		return {
-			integralList,
-		};
+	return {
+		integralList,
+		store,
 	};
+};
 </script>
 
 <script lang="ts" setup>
-	import { showSettlement } from "./components/settlement";
-	const { integralList } = useMyIntegral();
-	const searchValue = ref("");
+const saleType = ref(store.getters.getUserData?.saleType as number);
+import { showSettlement } from "./components/settlement";
+import { useRouter } from "vue-router";
+const router = useRouter()
+const { integralList } = useMyIntegral();
+const searchValue = ref("");
+const goStudentScore = (item: UserInfo) => {
+
+		router.push({
+			name: "studentScore",
+			query: {
+				id: item.id,
+				headImage:item.headImage,
+				nickName:window.encodeURIComponent(item.nickName)
+			},
+		});
+	
+};
 </script>
 
 <style scoped lang="scss">
-	.integral-box {
-		margin-top: -90px;
-		padding: 10px;
-	}
-	.header-back {
-		width: 375px;
-		padding-bottom: 82px;
-		background: linear-gradient(180deg, #498ef5 0%, #4da8e6 100%);
-		border-radius: 0px 0px 82px 82px;
-		.user-data {
-			display: flex;
-			flex-direction: column;
-			justify-content: space-between;
-			align-items: center;
-			padding: 19px 17px 24px;
-			font-size: 23px;
-			color: #ffffff;
-		}
+.integral-box {
+	margin-top: -90px;
+	padding: 10px;
+}
+.header-back {
+	width: 375px;
+	padding-bottom: 82px;
+	background: linear-gradient(180deg, #498ef5 0%, #4da8e6 100%);
+	border-radius: 0px 0px 82px 82px;
+	.user-data {
+		display: flex;
+		flex-direction: column;
+		justify-content: space-between;
+		align-items: center;
+		padding: 19px 17px 24px;
+		font-size: 23px;
+		color: #ffffff;
 	}
-	.content-box {
-		width: 345px;
-		background: #ffffff;
-		box-shadow: 0px 0px 8px rgba(124, 129, 136, 0.2);
+}
+.content-box {
+	width: 345px;
+	background: #ffffff;
+	box-shadow: 0px 0px 8px rgba(124, 129, 136, 0.2);
+	border-radius: 10px;
+	position: relative;
+	left: 50%;
+	transform: translateX(-50%);
+	margin-top: 10px;
+}
+.summary {
+	display: flex;
+	justify-content: space-around;
+	box-sizing: border-box;
+	overflow: hidden;
+	.search {
+		width: 100%;
 		border-radius: 10px;
-		position: relative;
-		left: 50%;
-		transform: translateX(-50%);
-		margin-top: 10px;
-	}
-	.summary {
-		display: flex;
-		justify-content: space-around;
-		box-sizing: border-box;
 		overflow: hidden;
-		.search {
-			width: 100%;
-			border-radius: 10px;
-			overflow: hidden;
-		}
 	}
-	.test-scores {
+}
+.test-scores {
+	font-size: 13px;
+	font-family: PingFang SC;
+	font-weight: 400;
+	line-height: 19px;
+	color: #0a1a33;
+	padding: 15px;
+	box-sizing: border-box;
+	.table {
+		width: 100%;
+		border-collapse: collapse;
 		font-size: 13px;
-		font-family: PingFang SC;
-		font-weight: 400;
-		line-height: 19px;
-		color: #0a1a33;
-		padding: 15px;
-		box-sizing: border-box;
-		.table {
-			width: 100%;
-			border-collapse: collapse;
-			font-size: 13px;
-			th {
-				padding: 5px;
-				color: #0a1a33;
-			}
-			td {
-				text-align: center;
-				padding: 5px;
-				color: #8a9099;
+		th {
+			padding: 5px;
+			color: #0a1a33;
+		}
+		td {
+			text-align: center;
+			padding: 5px;
+			color: #8a9099;
+		}
+		tr {
+			&:nth-of-type(n) {
+				background: #ffffff;
 			}
-			tr {
-				&:nth-of-type(n) {
-					background: #ffffff;
-				}
-				&:nth-of-type(2n) {
-					background: rgba(73, 142, 245, 0.15);
-				}
+			&:nth-of-type(2n) {
+				background: rgba(73, 142, 245, 0.15);
 			}
 		}
 	}
+}
 </style>

+ 256 - 0
src/views/studentScore/index.vue

@@ -0,0 +1,256 @@
+<template>
+	<div class="header-back">
+		<m-nav-bar :transparent="true" title="模拟考试成绩" style="color: #ffffff" />
+		<div class="user-data">
+			<div class="left">
+				<img class="user-avatar" :src="headImage" />
+				<div class="name">
+						<span class="user-name">{{ nickName }}</span>
+					<span
+						>最高成绩<span class="grade">{{ maxScore }}</span
+						>分</span
+					>
+				</div>
+			</div>
+			<!-- <m-button
+        @click="goMockTest"
+        class="continue"
+        width="90px"
+        height="30px"
+        text="继续考试"
+      /> -->
+		</div>
+	</div>
+	<!-- <div class="summary content-box">
+    <div class="item">
+      <div>
+        <span class="number">{{ testScoresList.length }}</span
+        >次
+      </div>
+      <div>考试次数</div>
+    </div>
+    <div class="item">
+      <div>
+        <span class="number">{{ testScoresInfo.avgScore }}</span
+        >分
+      </div>
+      <div>平均成绩</div>
+    </div>
+    <div class="item">
+      <div>
+        <span class="number">{{ testScoresInfo.forecastScore }}</span
+        >分
+      </div>
+      <div>成绩预测</div>
+    </div>
+  </div> -->
+	<div class="test-scores content-box">
+		<table class="table">
+			<tr>
+				<th>车型</th>
+				<th>科目</th>
+				<th>分数</th>
+				<th>时间</th>
+			</tr>
+			<tr v-for="(item, index) in testScoresList" :key="index">
+				<td>{{ item.type }}</td>
+				<td>{{ item.kskm }}</td>
+				<td>{{ item.score }}</td>
+				<td>{{ item.createTime }}</td>
+			</tr>
+		</table>
+	</div>
+</template>
+
+<script lang="ts">
+import { getTestScoresList, getTestScoresInfo, getScoreInfoByUserId } from "@/api";
+import { ref, onBeforeMount } from "vue";
+import { RouterBus } from "@/hooks";
+import { useRoute } from "vue-router";
+/**
+ * 考试成绩数据结构
+ */
+interface TestScores {
+	createTime: string; //考试时间
+	kskm: string; //科目
+	score: number; //分数
+	type: string; //车型
+}
+/**
+ * 模拟考成绩列表
+ */
+
+// 获取url上的参数
+
+function GetQueryString(name: string) {
+	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+	var r = window.location.search.substr(1).match(reg);
+	if (r != null) return unescape(r[2]);
+	return null;
+}
+
+const useTestScoresList = () => {
+	const testScoresList = ref<TestScores[]>([]);
+  let maxScore =ref(0)
+	onBeforeMount(async () => {
+		let res = await getScoreInfoByUserId({
+			userId: Number(GetQueryString("id")),
+   
+      
+		});
+		testScoresList.value = res.data;
+    
+     res.data.forEach((item: { score: any; })=>{
+       if(Number(item.score)>maxScore.value){
+         maxScore.value=Number(item.score)
+       }
+      
+    })
+	});
+	return {
+		testScoresList,
+    maxScore
+	};
+};
+/**
+ * 成绩信息数据结构
+ */
+interface TestScoresInfo {
+	avgScore: number; //平均成绩
+	forecastScore: number; //预测成绩
+	maxScore: number; //最大成绩
+}
+/**
+ * 最大成绩,平均成绩,预测成绩
+ */
+const useTestScoresInfo = () => {
+	const testScoresInfo = ref<TestScoresInfo>({
+		avgScore: 0,
+		forecastScore: 0,
+		maxScore: 0,
+	});
+	onBeforeMount(async () => {
+		let res = await getTestScoresInfo();
+		testScoresInfo.value = res.data;
+	});
+	return {
+		testScoresInfo,
+	};
+};
+</script>
+
+<script lang="ts" setup>
+const { testScoresList,maxScore } = useTestScoresList();
+const { testScoresInfo } = useTestScoresInfo();
+const { goMockTest } = new RouterBus();
+const nickName = ref(window.decodeURIComponent(GetQueryString("nickName")))
+const headImage = ref(GetQueryString("headImage"))
+</script>
+
+<style scoped lang="scss">
+.user-avatar {
+  width: 54px;
+  height: 54px;
+  border-radius: 50%;
+}
+.header-back {
+	width: 375px;
+	padding-bottom: 82px;
+	background: linear-gradient(180deg, #498ef5 0%, #4da8e6 100%);
+	border-radius: 0px 0px 82px 82px;
+	.user-data {
+		display: flex;
+		justify-content: space-between;
+		align-items: center;
+		padding: 19px 17px 24px;
+		.left {
+			display: flex;
+			justify-content: space-between;
+			align-items: center;
+			.name {
+				display: flex;
+				flex-direction: column;
+				font-size: 13px;
+				color: #ffffff;
+				justify-content: space-between;
+				margin-left: 6px;
+				.grade {
+					font-size: 24px;
+					padding: 4px;
+				}
+			}
+		}
+		.continue {
+			font-size: 13px;
+			font-family: PingFang SC;
+			font-weight: 400;
+			line-height: 19px;
+			color: #ffffff;
+			background: #01c18d;
+		}
+	}
+}
+.content-box {
+	width: 345px;
+	background: #ffffff;
+	box-shadow: 0px 0px 8px rgba(124, 129, 136, 0.2);
+	border-radius: 10px;
+	position: relative;
+	left: 50%;
+	transform: translateX(-50%);
+	top: -82px;
+	margin-top: 10px;
+}
+.summary {
+	display: flex;
+	justify-content: space-around;
+	padding: 25px 30px;
+	box-sizing: border-box;
+	.item {
+		font-size: 13px;
+		font-family: PingFang SC;
+		font-weight: 400;
+		line-height: 19px;
+		color: #8a9099;
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		.number {
+			font-size: 24px;
+			color: #0a1a33;
+			padding: 4px;
+		}
+	}
+}
+.test-scores {
+	font-size: 13px;
+	font-family: PingFang SC;
+	font-weight: 400;
+	line-height: 19px;
+	color: #0a1a33;
+	padding: 15px;
+	box-sizing: border-box;
+	.table {
+		width: 100%;
+		border-collapse: collapse;
+		font-size: 13px;
+		th {
+			padding: 5px;
+			color: #0a1a33;
+		}
+		td {
+			text-align: center;
+			padding: 5px;
+			color: #8a9099;
+		}
+		tr {
+			&:nth-of-type(n) {
+				background: #ffffff;
+			}
+			&:nth-of-type(2n) {
+				background: rgba(73, 142, 245, 0.15);
+			}
+		}
+	}
+}
+</style>