exam-history.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div class="exam-history-box">
  3. <van-nav-bar title="考试" left-arrow @click-left="onClickLeft" />
  4. <div class="exam-history-div">
  5. <div class="exam-history-grades-div">
  6. <div class="exam-history-name-description">考试积分</div>
  7. <div class="exam-history-grades">
  8. {{ userExamPonits }}
  9. </div>
  10. <div class="exam-history-description" @click="clickExamRule">
  11. 积分说明
  12. </div>
  13. <div class="exam-history-class-box">
  14. <div class="exam-history-class-item">
  15. 专项考试积分:{{ specialExamPoints }}
  16. </div>
  17. <div class="exam-history-class-item">
  18. 普通考试积分:{{ generalExamPoints }}
  19. </div>
  20. </div>
  21. </div>
  22. <div class="exam-history-list">
  23. <div
  24. v-for="(item, index) in examHistoryList"
  25. :key="index"
  26. class="exam-history-item"
  27. >
  28. <div class="exam-history-item-left">
  29. <div class="exam-history-item-left-title">{{ item.examName }}</div>
  30. <div class="exam-history-item-left-percentage">
  31. <div class="exam-history-item-left-schedule">
  32. <van-progress
  33. :percentage="
  34. formatePercentageFun(item.points, examFullPoints)
  35. "
  36. :show-pivot="false"
  37. />
  38. </div>
  39. <div class="exam-history-item-left-schedule-text">
  40. {{ item.points || 0 }} 分 / 满分 {{ examFullPoints }} 分
  41. </div>
  42. </div>
  43. </div>
  44. <div class="exam-history-item-right">
  45. <div class="exam-history-item-btn">{{ item.points }}</div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </template>
  52. <script>
  53. import { mapState } from "vuex";
  54. export default {
  55. name: "exam-history",
  56. components: {},
  57. data() {
  58. return {
  59. loading: false,
  60. userExamPonits: 0,
  61. generalExamPoints: 0,
  62. specialExamPoints: 0,
  63. examFullPoints: 100,
  64. userManualType: {
  65. ONE: 1,
  66. TWO: 2,
  67. THREE: 3
  68. }, // 类型
  69. examHistoryList: []
  70. };
  71. },
  72. mounted() {
  73. this.getExamHistory();
  74. this.getExamPoints();
  75. },
  76. created() { this.setLanXinNavigator(); },
  77. activated() {
  78. this.setLanXinNavigator();
  79. },
  80. computed: {
  81. ...mapState({
  82. user: state => state.user
  83. })
  84. },
  85. methods: {
  86. // 设置蓝信navigator
  87. setLanXinNavigator() {
  88. lx.ui.setNavigationBarTitle({
  89. title: "考试积分"
  90. });
  91. },
  92. // 查询总积分
  93. getExamPoints() {
  94. let path = {
  95. userName: this.user.userInfo.userName
  96. };
  97. this.$_http
  98. .get(this.$pathParams(this.$_API.JTXT_GET_USER_EXAM_POINTS, path))
  99. .then(res => {
  100. if (res.data.GENERAL_EXAM) {
  101. this.generalExamPoints = res.data.GENERAL_EXAM;
  102. }
  103. if (res.data.SPECIAL_EXAM) {
  104. this.specialExamPoints = res.data.SPECIAL_EXAM;
  105. }
  106. this.userExamPonits = this.generalExamPoints + this.specialExamPoints;
  107. })
  108. .catch(() => {
  109. this.$store.commit("toggleLoading", false);
  110. });
  111. },
  112. // 格式化已获得的积分/总积分的数
  113. formatePercentageFun(getPoints, totaPonits) {
  114. if (
  115. (!getPoints && getPoints !== 0) ||
  116. (!totaPonits && totaPonits !== 0)
  117. ) {
  118. return 0;
  119. }
  120. if (isNaN(getPoints) || isNaN(totaPonits)) {
  121. return 0;
  122. }
  123. return Math.round((getPoints / totaPonits) * 100);
  124. },
  125. // 操作:返回
  126. onClickLeft() {
  127. this.$router.back();
  128. },
  129. // 查询:考试记录
  130. getExamHistory() {
  131. this.$store.commit("toggleLoading", true);
  132. let params = {
  133. user: this.user.userInfo.userName
  134. };
  135. this.$_http
  136. .get(this.$_API.JTXT_GET_USER_EXAMS_HISTORY, { params })
  137. .then(res => {
  138. res.data.content.forEach((item, index) => {
  139. this.getExamDetailFun(item, index, index + 1 === res.data.length);
  140. });
  141. this.finished = true;
  142. })
  143. .catch(() => {
  144. this.$store.commit("toggleLoading", false);
  145. });
  146. },
  147. // 查询:某个考试的详情
  148. getExamDetailFun(item, index, isLast) {
  149. this.$_http
  150. .get(
  151. this.$pathParams(this.$_API.GET_JTXT_GET_EXAMS_ONE_DETAIL, {
  152. examId: item.examId
  153. })
  154. )
  155. .then(res => {
  156. console.log(item, res);
  157. this.examHistoryList.push({ ...item, examName: res.data.name });
  158. if (isLast) {
  159. this.$store.commit("toggleLoading", false);
  160. }
  161. })
  162. .catch(() => {
  163. this.$store.commit("toggleLoading", false);
  164. });
  165. },
  166. clickExamRule() {
  167. this.$router.push({ name: "examPointRule" });
  168. }
  169. }
  170. };
  171. </script>
  172. <style lang="scss" scoped>
  173. .exam-history-box {
  174. width: 100%;
  175. height: 100vh;
  176. font-size: 0.6rem;
  177. background-color: #fff;
  178. .exam-history-div {
  179. width: 100%;
  180. overflow-y: auto;
  181. padding: 0 1rem;
  182. .exam-history-grades-div {
  183. display: flex;
  184. flex-direction: column;
  185. justify-content: center;
  186. align-items: center;
  187. padding-top: 1rem;
  188. .exam-history-grades {
  189. font-size: 1rem;
  190. color: #0088e9;
  191. margin-top: 0.5rem;
  192. }
  193. .exam-history-name-description {
  194. padding: 0.15rem 0.5rem;
  195. // border: 1px solid #7cc8ff;
  196. // border-radius: 0.25rem;
  197. color: #0088e9;
  198. font-size: 0.75rem;
  199. }
  200. .exam-history-description {
  201. margin-top: 0.5rem;
  202. padding: 0.15rem 0.5rem;
  203. border: 1px solid #7cc8ff;
  204. border-radius: 0.25rem;
  205. color: #7cc8ff;
  206. }
  207. .exam-history-class-box {
  208. margin-top: 0.5rem;
  209. width: 100%;
  210. display: flex;
  211. flex-direction: row;
  212. justify-content: space-between;
  213. align-items: center;
  214. }
  215. .exam-history-class-item {
  216. color: #0088e9;
  217. font-size: 0.65rem;
  218. }
  219. }
  220. .exam-history-list {
  221. padding: 0.5rem 0;
  222. .exam-history-item {
  223. padding: 0.5rem 0;
  224. border-top: 1px solid #e5e5e5;
  225. display: flex;
  226. justify-content: space-between;
  227. align-items: center;
  228. .exam-history-item-left {
  229. margin-right: 0.25rem;
  230. .exam-history-item-left-title {
  231. font-weight: bold;
  232. word-break: break-all;
  233. word-wrap: break-word;
  234. font-size: 0.5rem;
  235. }
  236. .exam-history-item-left-percentage {
  237. display: flex;
  238. align-items: center;
  239. margin-top: 0.5rem;
  240. .exam-history-item-left-schedule {
  241. width: 100px;
  242. }
  243. .exam-history-item-left-schedule-text {
  244. color: #999;
  245. font-size: 0.55rem;
  246. margin-left: 0.5rem;
  247. }
  248. }
  249. }
  250. .exam-history-item-right {
  251. .exam-history-item-btn {
  252. border-radius: 0.1rem;
  253. color: #0088e9;
  254. background-color: #d8e9f5;
  255. padding: 0.1rem 0.25rem;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. </style>