exam_list.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. }
  24. else if (windowWidth > 750) {
  25. windowWidth = 750;
  26. } else if (windowWidth < 375) {
  27. windowWidth = 375;
  28. }
  29. //2. 标准屏幕的宽度
  30. var StandardWidth = 375;
  31. // 标准屏幕的html的字体大小
  32. var StandardHtmlFontSize = 10;
  33. //3. 当前屏幕需要设置的根元素的字体大小
  34. var htmlFontSize = windowWidth / StandardWidth * StandardHtmlFontSize;
  35. //4. 把当前计算的html 字体大小设置到页面的html元素上就可以
  36. document.querySelector('html').style.fontSize = htmlFontSize + 'px';
  37. }
  38. </script>
  39. <style>
  40. html,body{
  41. font-size: 1.6rem;
  42. }
  43. html,body {
  44. padding: 0;
  45. margin: 0;
  46. width: 100%;
  47. height: 100%;
  48. background: #fff;
  49. }
  50. #app {
  51. position: relative;
  52. height: 100%;
  53. }
  54. #app .van-cell{
  55. font-size: 1.6rem;
  56. }
  57. .header{
  58. width: 100%;
  59. height: 4.6rem;
  60. position: fixed;
  61. z-index: 1000;
  62. }
  63. .clear-header{
  64. width: 100%;
  65. height: 6rem;
  66. }
  67. .zheng-box{
  68. font-size: 1.3rem;
  69. color: #fff;
  70. }
  71. .bukao{
  72. background: #0f74a8;
  73. background: #0f74a8;
  74. padding: 0.5rem;
  75. font-size: 1.3rem;
  76. color: #fff;
  77. }
  78. .fenye{
  79. margin-top: 3rem;
  80. }
  81. [v-cloak] {
  82. display: none;
  83. }
  84. </style>
  85. </head>
  86. <body>
  87. <div id="app" v-cloak>
  88. <div class="header" v-if="user != 1">
  89. <van-nav-bar left-text="返回" left-arrow @click-left="onClickLeft">
  90. <div slot="title">
  91. <span v-if="num == 1">正式考试</span>
  92. <span v-if="num == 2">模拟考试</span>
  93. </div>
  94. <div v-if="num == 1" slot="right" @click.stop="goHistoryFn()">
  95. 考试记录
  96. </div>
  97. </van-nav-bar>
  98. </div>
  99. <div class="clear-header" v-if="user != 1">
  100. </div>
  101. <van-cell-group>
  102. <van-cell v-for="(item,index) in myList" :key="index" >
  103. <div slot="title" @click.stop="goPageFn(item,num)">
  104. {{index+1}}.
  105. {{item.paperName}}
  106. </div>
  107. <div class="zheng-box" v-if="num == 1 && item.ifPass != ''" slot="default">
  108. <!--<span class="bukao" @click.stop="goExamFn(item,num)" v-if="item.ifPass == 0">去补考</span>-->
  109. <span style="color: green" v-if="item.totalMark >= item.passScore">{{item.totalMark}}分</span>
  110. <span style="color: red" v-if="item.totalMark < item.passScore">{{item.totalMark}}分</span>
  111. </div>
  112. <span class="bukao" v-if="num == 2" slot="default" @click.stop="goHistoryFn(item)">记录</span>
  113. </van-cell>
  114. </van-cell-group>
  115. <div class="fenye">
  116. <van-pagination
  117. v-model="currentPage"
  118. :total-items="count"
  119. :items-per-page="limit"
  120. mode="simple"
  121. >
  122. </van-pagination>
  123. </div>
  124. </div>
  125. <script type="text/javascript" src="../../../assets/libs/layui/layui.js"></script>
  126. <script src="../../../assets/module/vue.js"></script>
  127. <script src="../../../assets/libs/jquery/jquery-3.2.1.min.js"></script>
  128. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.2/lib/index.css">
  129. <script src="https://cdn.jsdelivr.net/npm/vant@2.2/lib/vant.min.js"></script>
  130. <script type="text/javascript" src="../../../assets/js/common.js?v=312"></script>
  131. <script>
  132. function getUrlParam(name) {
  133. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  134. //如果地址栏中出现中文则进行编码
  135. var r = encodeURI(window.location.search).substr(1).match(reg);
  136. if (r != null) {
  137. //将中文编码的字符重新变成中文
  138. return decodeURI(unescape(r[2]));
  139. }
  140. return null;
  141. }
  142. new Vue({
  143. el: "#app",
  144. data: {
  145. num:1,
  146. user:'',
  147. currentPage: 1,
  148. limit:5,
  149. count:1,
  150. myList:[],
  151. },
  152. mounted(){
  153. Array.prototype.indexOf = function(val) {
  154. for (var i = 0; i < this.length; i++) {
  155. if (this[i] == val) return i;
  156. }
  157. return -1;
  158. };
  159. //在 Array 原型中植入 remove 方法 remove 中调用 indexOf 判断 str 是否存在 arr 中,有则拿到 index
  160. Array.prototype.remove = function(val) {
  161. var index = this.indexOf(val);
  162. if (index > -1) {
  163. this.splice(index, 1);
  164. }
  165. };
  166. function getQueryVariable(variable)
  167. {
  168. var query = window.location.search.substring(1);
  169. var vars = query.split("&");
  170. for (var i=0;i<vars.length;i++) {
  171. var pair = vars[i].split("=");
  172. if(pair[0] == variable){return pair[1];}
  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. {
  251. var query = window.location.search.substring(1);
  252. var vars = query.split("&");
  253. for (var i=0;i<vars.length;i++) {
  254. var pair = vars[i].split("=");
  255. if(pair[0] == variable){return pair[1];}
  256. }
  257. return(false);
  258. }
  259. }
  260. })
  261. </script>
  262. </body>
  263. </html>