exam-history.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. console.log("----" + JSON.stringify(res));
  101. if (res.data.GENERAL_EXAM) {
  102. this.generalExamPoints = res.data.GENERAL_EXAM;
  103. }
  104. if (res.data.SPECIAL_EXAM) {
  105. this.specialExamPoints = res.data.SPECIAL_EXAM;
  106. }
  107. this.userExamPonits = this.generalExamPoints + this.specialExamPoints;
  108. })
  109. .catch(() => {
  110. this.$store.commit("toggleLoading", false);
  111. });
  112. },
  113. // 格式化已获得的积分/总积分的数
  114. formatePercentageFun(getPoints, totaPonits) {
  115. if (
  116. (!getPoints && getPoints !== 0) ||
  117. (!totaPonits && totaPonits !== 0)
  118. ) {
  119. return 0;
  120. }
  121. if (isNaN(getPoints) || isNaN(totaPonits)) {
  122. return 0;
  123. }
  124. return Math.round((getPoints / totaPonits) * 100);
  125. },
  126. // 操作:返回
  127. onClickLeft() {
  128. this.$router.back();
  129. },
  130. // 查询:考试记录
  131. getExamHistory() {
  132. this.$store.commit("toggleLoading", true);
  133. let params = {
  134. user: this.user.userInfo.userName
  135. };
  136. this.$_http
  137. .get(this.$_API.JTXT_GET_USER_EXAMS_HISTORY, { params })
  138. .then(res => {
  139. res.data.forEach((item, index) => {
  140. this.getExamDetailFun(item, index, index + 1 === res.data.length);
  141. });
  142. this.finished = true;
  143. })
  144. .catch(() => {
  145. this.$store.commit("toggleLoading", false);
  146. });
  147. },
  148. // 查询:某个考试的详情
  149. getExamDetailFun(item, index, isLast) {
  150. this.$_http
  151. .get(
  152. this.$pathParams(this.$_API.GET_JTXT_GET_EXAMS_ONE_DETAIL, {
  153. examId: item.examId
  154. })
  155. )
  156. .then(res => {
  157. console.log(item, res);
  158. this.examHistoryList.push({ ...item, examName: res.data.name });
  159. if (isLast) {
  160. this.$store.commit("toggleLoading", false);
  161. }
  162. })
  163. .catch(() => {
  164. this.$store.commit("toggleLoading", false);
  165. });
  166. },
  167. clickExamRule() {
  168. this.$router.push({ name: "examPointRule" });
  169. }
  170. }
  171. };
  172. </script>
  173. <style lang="scss" scoped>
  174. .exam-history-box {
  175. width: 100%;
  176. height: 100vh;
  177. font-size: 0.6rem;
  178. background-color: #fff;
  179. .exam-history-div {
  180. width: 100%;
  181. overflow-y: auto;
  182. padding: 0 1rem;
  183. .exam-history-grades-div {
  184. display: flex;
  185. flex-direction: column;
  186. justify-content: center;
  187. align-items: center;
  188. padding-top: 1rem;
  189. .exam-history-grades {
  190. font-size: 1rem;
  191. color: #0088e9;
  192. margin-top: 0.5rem;
  193. }
  194. .exam-history-name-description {
  195. padding: 0.15rem 0.5rem;
  196. // border: 1px solid #7cc8ff;
  197. // border-radius: 0.25rem;
  198. color: #0088e9;
  199. font-size: 0.75rem;
  200. }
  201. .exam-history-description {
  202. margin-top: 0.5rem;
  203. padding: 0.15rem 0.5rem;
  204. border: 1px solid #7cc8ff;
  205. border-radius: 0.25rem;
  206. color: #7cc8ff;
  207. }
  208. .exam-history-class-box {
  209. margin-top: 0.5rem;
  210. width: 100%;
  211. display: flex;
  212. flex-direction: row;
  213. justify-content: space-between;
  214. align-items: center;
  215. }
  216. .exam-history-class-item {
  217. color: #0088e9;
  218. font-size: 0.65rem;
  219. }
  220. }
  221. .exam-history-list {
  222. padding: 0.5rem 0;
  223. .exam-history-item {
  224. padding: 0.5rem 0;
  225. border-top: 1px solid #e5e5e5;
  226. display: flex;
  227. justify-content: space-between;
  228. align-items: center;
  229. .exam-history-item-left {
  230. margin-right: 0.25rem;
  231. .exam-history-item-left-title {
  232. font-weight: bold;
  233. word-break: break-all;
  234. word-wrap: break-word;
  235. font-size: 0.5rem;
  236. }
  237. .exam-history-item-left-percentage {
  238. display: flex;
  239. align-items: center;
  240. margin-top: 0.5rem;
  241. .exam-history-item-left-schedule {
  242. width: 100px;
  243. }
  244. .exam-history-item-left-schedule-text {
  245. color: #999;
  246. font-size: 0.55rem;
  247. margin-left: 0.5rem;
  248. }
  249. }
  250. }
  251. .exam-history-item-right {
  252. .exam-history-item-btn {
  253. border-radius: 0.1rem;
  254. color: #0088e9;
  255. background-color: #d8e9f5;
  256. padding: 0.1rem 0.25rem;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. </style>