exam-history.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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-grades">
  7. {{ this.user.userInfo.examPoints }}
  8. </div>
  9. </div>
  10. <div class="exam-history-list">
  11. <div
  12. v-for="(item, index) in examHistoryList"
  13. :key="index"
  14. class="exam-history-item"
  15. >
  16. <div class="exam-history-item-left">
  17. <div class="exam-history-item-left-title">{{ item.examName }}</div>
  18. <div class="exam-history-item-left-percentage">
  19. <div class="exam-history-item-left-schedule">
  20. <van-progress
  21. :percentage="formatePercentageFun(item.points, 10)"
  22. :show-pivot="false"
  23. />
  24. </div>
  25. <div class="exam-history-item-left-schedule-text">
  26. {{ item.earnedpoints }}分 / 满分10分
  27. </div>
  28. </div>
  29. </div>
  30. <div class="exam-history-item-right">
  31. <div class="exam-history-item-btn">{{ item.points }}</div>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import { mapState } from "vuex";
  40. export default {
  41. name: "exam-history",
  42. components: {},
  43. data() {
  44. return {
  45. loading: false,
  46. userManualType: {
  47. ONE: 1,
  48. TWO: 2,
  49. THREE: 3
  50. }, // 类型
  51. examHistoryList: [],
  52. eventList: [
  53. {
  54. name: "进入应用",
  55. rule: "2分/每次进入应用",
  56. isFinish: false,
  57. getPoints: 2,
  58. totaPonits: 6,
  59. type: 1
  60. },
  61. {
  62. name: "观看视频",
  63. rule: "2分/每有效观看一个视频",
  64. isFinish: false,
  65. getPoints: 0,
  66. totaPonits: 6,
  67. type: 1
  68. },
  69. {
  70. name: "发表观点",
  71. rule: "2分/每发表一个有效观点",
  72. isFinish: false,
  73. getPoints: 0,
  74. totaPonits: 6,
  75. type: 1
  76. },
  77. {
  78. name: "阅读文章",
  79. rule: "2分/每有效阅读一篇文章",
  80. isFinish: false,
  81. getPoints: 0,
  82. totaPonits: 6,
  83. type: 1
  84. },
  85. {
  86. name: "文章学习时长",
  87. rule: "2分/有效阅读文章累计1分钟",
  88. isFinish: false,
  89. getPoints: 0,
  90. totaPonits: 6,
  91. type: 2
  92. },
  93. {
  94. name: "基础训练",
  95. rule: "2分/每训练一次",
  96. isFinish: false,
  97. getPoints: 0,
  98. totaPonits: 6,
  99. type: 3
  100. }
  101. ],
  102. userTotalPonits: 165, // 用户的总积分
  103. todayEarnPoints: 6 // 今日已累计的积分
  104. };
  105. },
  106. mounted() {
  107. this.getExamHistory();
  108. },
  109. computed: {
  110. ...mapState({
  111. user: state => state.user
  112. })
  113. },
  114. methods: {
  115. // 格式化已获得的积分/总积分的数
  116. formatePercentageFun(getPoints, totaPonits) {
  117. return Math.round((getPoints / totaPonits) * 100);
  118. },
  119. // 操作:返回
  120. onClickLeft() {
  121. this.$router.back();
  122. },
  123. // 查询:考试记录
  124. getExamHistory() {
  125. this.$store.commit("toggleLoading", true);
  126. let params = {
  127. user: this.user.userInfo.userName
  128. };
  129. this.$_http
  130. .get(this.$_API.JTXT_GET_USER_EXAMS_HISTORY, { params })
  131. .then(res => {
  132. res.data.forEach((item, index) => {
  133. this.getExamDetailFun(item, index, index + 1 === res.data.length);
  134. });
  135. this.finished = true;
  136. })
  137. .catch(() => {
  138. this.$store.commit("toggleLoading", false);
  139. });
  140. },
  141. // 查询:某个考试的详情
  142. getExamDetailFun(item, index, isLast) {
  143. this.$_http
  144. .get(
  145. this.$pathParams(this.$_API.GET_JTXT_GET_EXAMS_ONE_DETAIL, {
  146. examId: item.examId
  147. })
  148. )
  149. .then(res => {
  150. this.examHistoryList.push({ ...item, examName: res.data.name });
  151. if (isLast) {
  152. this.$store.commit("toggleLoading", false);
  153. }
  154. })
  155. .catch(() => {
  156. this.$store.commit("toggleLoading", false);
  157. });
  158. },
  159. // 操作:点击了去看看、去学习、去训练
  160. toManualEarnFun(item) {
  161. console.log(item);
  162. switch (item.type) {
  163. case this.userManualType.ONE:
  164. // TODO..
  165. break;
  166. case this.userManualType.TWO:
  167. // TODO..
  168. break;
  169. case this.userManualType.THREE:
  170. // TODO..
  171. break;
  172. default:
  173. break;
  174. }
  175. }
  176. }
  177. };
  178. </script>
  179. <style lang="scss" scoped>
  180. .exam-history-box {
  181. width: 100%;
  182. height: 100vh;
  183. overflow-y: auto;
  184. overflow-x: hidden;
  185. font-size: 0.6rem;
  186. background-color: #fff;
  187. .exam-history-div {
  188. padding: 0 0.5rem;
  189. .exam-history-grades-div {
  190. display: flex;
  191. flex-direction: column;
  192. justify-content: center;
  193. align-items: center;
  194. .exam-history-grades {
  195. margin-top: 1rem;
  196. font-size: 1rem;
  197. color: #0088e9;
  198. }
  199. }
  200. .exam-history-list {
  201. padding: 0.5rem 0;
  202. .exam-history-item {
  203. padding: 0.5rem 0;
  204. border-top: 1px solid #e5e5e5;
  205. display: flex;
  206. justify-content: space-between;
  207. align-items: center;
  208. .exam-history-item-left {
  209. .exam-history-item-left-title {
  210. font-weight: bold;
  211. }
  212. .exam-history-item-left-percentage {
  213. display: flex;
  214. align-items: center;
  215. .exam-history-item-left-schedule {
  216. width: 100px;
  217. }
  218. .exam-history-item-left-schedule-text {
  219. color: #999;
  220. font-size: 0.55rem;
  221. margin-left: 0.5rem;
  222. }
  223. }
  224. }
  225. .exam-history-item-right {
  226. .exam-history-item-btn {
  227. border-radius: 0.1rem;
  228. color: #0088e9;
  229. background-color: #d8e9f5;
  230. padding: 0.1rem 0.25rem;
  231. }
  232. }
  233. }
  234. }
  235. }
  236. }
  237. </style>