exam_list.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>试卷列表</title>
  6. <link rel="apple-touch-icon" href="apple-touch-icon.png">
  7. <meta name="viewport" content="initial-scale=1.0, maximum-scale=1, user-scalable=no">
  8. <link rel="icon" href="favicon.ico" type="image/x-icon"/>
  9. <script>
  10. window.addEventListener('resize', setHtmlFontSize)
  11. setHtmlFontSize();
  12. function setHtmlFontSize() {
  13. // 根据屏幕的宽度来改变根元素的字体大小的值
  14. // 当前屏幕 / 标准的375屏幕 求得你当前屏幕是标准屏幕的多少倍 * 标准屏幕根元素的字体大小
  15. // 当前屏幕的宽度 / 375 * 100
  16. // 假如当前750/375 = 2 * 100 == 200px
  17. // 1. 当前屏幕的宽度
  18. var windowWidth = document.documentElement.offsetWidth;
  19. // 限制最大屏幕 和最小屏幕
  20. if (windowWidth > 1200) {
  21. document.querySelector('html').style.fontSize = 10 + 'px';
  22. return;
  23. } else if (windowWidth > 750) {
  24. windowWidth = 750;
  25. } else if (windowWidth < 375) {
  26. windowWidth = 375;
  27. }
  28. //2. 标准屏幕的宽度
  29. var StandardWidth = 375;
  30. // 标准屏幕的html的字体大小
  31. var StandardHtmlFontSize = 10;
  32. //3. 当前屏幕需要设置的根元素的字体大小
  33. var htmlFontSize = windowWidth / StandardWidth * StandardHtmlFontSize;
  34. //4. 把当前计算的html 字体大小设置到页面的html元素上就可以
  35. document.querySelector('html').style.fontSize = htmlFontSize + 'px';
  36. }
  37. </script>
  38. <style>
  39. html, body {
  40. font-size: 1.6rem;
  41. }
  42. html, body {
  43. padding: 0;
  44. margin: 0;
  45. width: 100%;
  46. height: 100%;
  47. background: #fff;
  48. }
  49. #app {
  50. position: relative;
  51. height: 100%;
  52. }
  53. #app .van-cell {
  54. font-size: 1.6rem;
  55. }
  56. .header {
  57. width: 100%;
  58. height: 4.6rem;
  59. position: fixed;
  60. z-index: 1000;
  61. }
  62. .clear-header {
  63. width: 100%;
  64. height: 6rem;
  65. }
  66. .zheng-box {
  67. font-size: 1.3rem;
  68. color: #fff;
  69. }
  70. .bukao {
  71. background: #0f74a8;
  72. background: #0f74a8;
  73. padding: 0.5rem;
  74. font-size: 1.3rem;
  75. color: #fff;
  76. }
  77. .fenye {
  78. margin-top: 3rem;
  79. }
  80. [v-cloak] {
  81. display: none;
  82. }
  83. </style>
  84. </head>
  85. <body>
  86. <div id="app" v-cloak>
  87. <div class="header" v-if="user != 1">
  88. <van-nav-bar left-text="返回" left-arrow @click-left="onClickLeft">
  89. <div slot="title">
  90. <span v-if="num == 1">正式考试</span>
  91. <span v-if="num == 2">模拟考试</span>
  92. </div>
  93. <div v-if="num == 1" slot="right" @click.stop="goHistoryFn()">
  94. 考试记录
  95. </div>
  96. </van-nav-bar>
  97. </div>
  98. <div class="clear-header" v-if="user != 1">
  99. </div>
  100. <van-cell-group>
  101. <van-cell v-for="(item,index) in myList" :key="index">
  102. <div slot="title" @click.stop="goPageFn(item,num)">
  103. {{index+1}}.
  104. {{item.paperName}}
  105. </div>
  106. <div class="zheng-box" v-if="num == 1 && item.ifPass != ''" slot="default">
  107. <!--<span class="bukao" @click.stop="goExamFn(item,num)" v-if="item.ifPass == 0">去补考</span>-->
  108. <span style="color: green" v-if="item.totalMark >= item.passScore">{{item.totalMark}}分</span>
  109. <span style="color: red" v-if="item.totalMark < item.passScore">{{item.totalMark}}分</span>
  110. </div>
  111. <span class="bukao" v-if="num == 2" slot="default" @click.stop="goHistoryFn(item)">记录</span>
  112. </van-cell>
  113. </van-cell-group>
  114. <div class="fenye">
  115. <van-pagination
  116. v-model="currentPage"
  117. :total-items="count"
  118. :items-per-page="limit"
  119. mode="simple"
  120. >
  121. </van-pagination>
  122. </div>
  123. </div>
  124. <script type="text/javascript" src="../../../assets/libs/layui/layui.js"></script>
  125. <script src="../../../assets/module/vue.js"></script>
  126. <script src="../../../assets/libs/jquery/jquery-3.2.1.min.js"></script>
  127. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.2/lib/index.css">
  128. <script src="https://cdn.jsdelivr.net/npm/vant@2.2/lib/vant.min.js"></script>
  129. <script type="text/javascript" src="../../../assets/js/common.js?v=312"></script>
  130. <script>
  131. function getUrlParam(name) {
  132. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  133. //如果地址栏中出现中文则进行编码
  134. var r = encodeURI(window.location.search).substr(1).match(reg);
  135. if (r != null) {
  136. //将中文编码的字符重新变成中文
  137. return decodeURI(unescape(r[2]));
  138. }
  139. return null;
  140. }
  141. new Vue({
  142. el: "#app",
  143. data: {
  144. num: 1,
  145. user: '',
  146. currentPage: 1,
  147. limit: 5,
  148. count: 1,
  149. myList: [],
  150. },
  151. mounted() {
  152. Array.prototype.indexOf = function (val) {
  153. for (var i = 0; i < this.length; i++) {
  154. if (this[i] == val) return i;
  155. }
  156. return -1;
  157. };
  158. //在 Array 原型中植入 remove 方法 remove 中调用 indexOf 判断 str 是否存在 arr 中,有则拿到 index
  159. Array.prototype.remove = function (val) {
  160. var index = this.indexOf(val);
  161. if (index > -1) {
  162. this.splice(index, 1);
  163. }
  164. };
  165. function getQueryVariable(variable) {
  166. var query = window.location.search.substring(1);
  167. var vars = query.split("&");
  168. for (var i = 0; i < vars.length; i++) {
  169. var pair = vars[i].split("=");
  170. if (pair[0] == variable) {
  171. return pair[1];
  172. }
  173. }
  174. return (false);
  175. }
  176. this.num = getQueryVariable('num');
  177. this.user = getQueryVariable('user');
  178. //获取试卷列表
  179. this.myListFn();
  180. },
  181. methods: {
  182. //获取试卷列表
  183. myListFn() {
  184. // Authorization
  185. let _this = this;
  186. layui.use(['uParas', 'admin'], () => {
  187. let admin = layui.admin;
  188. let uParas = layui.uParas;
  189. let url = uParas.baseUrl + '/ol/userTestPaper/myList';
  190. // admin.req(url, {
  191. // limit:1000,
  192. // page:1
  193. // }, function (res) {
  194. // console.log(res);
  195. // });
  196. $.ajax({
  197. type: 'get',
  198. url: url,
  199. data: {
  200. page: 1,
  201. limit: this.limit
  202. },
  203. headers: {
  204. 'accept': 'application/json, text/javascript, */*; q=0.01',
  205. 'Authorization': localStorage.getItem('atoken')
  206. },
  207. success: function (res) {
  208. console.log(res);
  209. _this.myList = res.data;
  210. _this.count = res.count;
  211. },
  212. });
  213. })
  214. },
  215. goPageFn(item, num) {
  216. if ((item.status == 0 && this.num == 1) || this.num == 2) {
  217. let paperTypeId = '';
  218. if (this.num == 1) {
  219. paperTypeId = this.getQueryVariable('paperTypeId');
  220. }
  221. if (this.user == 1) {
  222. let zindex = $(window.parent.document).find('.layui-layer-iframe').css('z-index');
  223. $(window.parent.document).find('.layui-layer-iframe').css({
  224. zIndex: zindex,
  225. width: '90%',
  226. height: '90%',
  227. position: 'absolute',
  228. top: '40px',
  229. left: '50px',
  230. })
  231. }
  232. location.href = './index.html?paperId=' + item.paperId + '&num=' + num + '&paperTypeId=' + paperTypeId;
  233. }
  234. },
  235. goExamFn(item, num) {
  236. location.href = './index.html?paperId=' + item.paperId + '&num=' + num;
  237. },
  238. //跳转考试记录
  239. goHistoryFn(item = {}) {
  240. let paperId = '';
  241. if (item.paperId) {
  242. paperId = item.paperId;
  243. }
  244. location.href = './exam_history.html?num=' + this.num + '&paperId=' + paperId;
  245. },
  246. onClickLeft() {
  247. window.history.back(-1);
  248. },
  249. getQueryVariable(variable) {
  250. var query = window.location.search.substring(1);
  251. var vars = query.split("&");
  252. for (var i = 0; i < vars.length; i++) {
  253. var pair = vars[i].split("=");
  254. if (pair[0] == variable) {
  255. return pair[1];
  256. }
  257. }
  258. return (false);
  259. }
  260. }
  261. })
  262. </script>
  263. </body>
  264. </html>