123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>试卷列表</title>
- <link rel="apple-touch-icon" href="apple-touch-icon.png">
- <meta name="viewport" content="initial-scale=1.0, maximum-scale=1, user-scalable=no">
- <link rel="icon" href="favicon.ico" type="image/x-icon"/>
- <script>
- window.addEventListener('resize', setHtmlFontSize)
- setHtmlFontSize();
- function setHtmlFontSize() {
- // 根据屏幕的宽度来改变根元素的字体大小的值
- // 当前屏幕 / 标准的375屏幕 求得你当前屏幕是标准屏幕的多少倍 * 标准屏幕根元素的字体大小
- // 当前屏幕的宽度 / 375 * 100
- // 假如当前750/375 = 2 * 100 == 200px
- // 1. 当前屏幕的宽度
- var windowWidth = document.documentElement.offsetWidth;
- // 限制最大屏幕 和最小屏幕
- if (windowWidth > 1200) {
- document.querySelector('html').style.fontSize = 10 + 'px';
- return;
- } else if (windowWidth > 750) {
- windowWidth = 750;
- } else if (windowWidth < 375) {
- windowWidth = 375;
- }
- //2. 标准屏幕的宽度
- var StandardWidth = 375;
- // 标准屏幕的html的字体大小
- var StandardHtmlFontSize = 10;
- //3. 当前屏幕需要设置的根元素的字体大小
- var htmlFontSize = windowWidth / StandardWidth * StandardHtmlFontSize;
- //4. 把当前计算的html 字体大小设置到页面的html元素上就可以
- document.querySelector('html').style.fontSize = htmlFontSize + 'px';
- }
- </script>
- <style>
- html, body {
- font-size: 1.6rem;
- }
- html, body {
- padding: 0;
- margin: 0;
- width: 100%;
- height: 100%;
- background: #fff;
- }
- #app {
- position: relative;
- height: 100%;
- }
- #app .van-cell {
- font-size: 1.6rem;
- }
- .header {
- width: 100%;
- height: 4.6rem;
- position: fixed;
- z-index: 1000;
- }
- .clear-header {
- width: 100%;
- height: 6rem;
- }
- .zheng-box {
- font-size: 1.3rem;
- color: #fff;
- }
- .bukao {
- background: #0f74a8;
- background: #0f74a8;
- padding: 0.5rem;
- font-size: 1.3rem;
- color: #fff;
- }
- .fenye {
- margin-top: 3rem;
- }
- [v-cloak] {
- display: none;
- }
- </style>
- </head>
- <body>
- <div id="app" v-cloak>
- <div class="header" v-if="user != 1">
- <van-nav-bar left-text="返回" left-arrow @click-left="onClickLeft">
- <div slot="title">
- <span v-if="num == 1">正式考试</span>
- <span v-if="num == 2">模拟考试</span>
- </div>
- <div v-if="num == 1" slot="right" @click.stop="goHistoryFn()">
- 考试记录
- </div>
- </van-nav-bar>
- </div>
- <div class="clear-header" v-if="user != 1">
- </div>
- <van-cell-group>
- <van-cell v-for="(item,index) in myList" :key="index">
- <div slot="title" @click.stop="goPageFn(item,num)">
- {{index+1}}.
- {{item.paperName}}
- </div>
- <div class="zheng-box" v-if="num == 1 && item.ifPass != ''" slot="default">
- <!--<span class="bukao" @click.stop="goExamFn(item,num)" v-if="item.ifPass == 0">去补考</span>-->
- <span style="color: green" v-if="item.totalMark >= item.passScore">{{item.totalMark}}分</span>
- <span style="color: red" v-if="item.totalMark < item.passScore">{{item.totalMark}}分</span>
- </div>
- <span class="bukao" v-if="num == 2" slot="default" @click.stop="goHistoryFn(item)">记录</span>
- </van-cell>
- </van-cell-group>
- <div class="fenye">
- <van-pagination
- v-model="currentPage"
- :total-items="count"
- :items-per-page="limit"
- mode="simple"
- >
- </van-pagination>
- </div>
- </div>
- <script type="text/javascript" src="../../../assets/libs/layui/layui.js"></script>
- <script src="../../../assets/module/vue.js"></script>
- <script src="../../../assets/libs/jquery/jquery-3.2.1.min.js"></script>
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.2/lib/index.css">
- <script src="https://cdn.jsdelivr.net/npm/vant@2.2/lib/vant.min.js"></script>
- <script type="text/javascript" src="../../../assets/js/common.js?v=312"></script>
- <script>
- function getUrlParam(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- //如果地址栏中出现中文则进行编码
- var r = encodeURI(window.location.search).substr(1).match(reg);
- if (r != null) {
- //将中文编码的字符重新变成中文
- return decodeURI(unescape(r[2]));
- }
- return null;
- }
- new Vue({
- el: "#app",
- data: {
- num: 1,
- user: '',
- currentPage: 1,
- limit: 5,
- count: 1,
- myList: [],
- },
- mounted() {
- Array.prototype.indexOf = function (val) {
- for (var i = 0; i < this.length; i++) {
- if (this[i] == val) return i;
- }
- return -1;
- };
- //在 Array 原型中植入 remove 方法 remove 中调用 indexOf 判断 str 是否存在 arr 中,有则拿到 index
- Array.prototype.remove = function (val) {
- var index = this.indexOf(val);
- if (index > -1) {
- this.splice(index, 1);
- }
- };
- function getQueryVariable(variable) {
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i = 0; i < vars.length; i++) {
- var pair = vars[i].split("=");
- if (pair[0] == variable) {
- return pair[1];
- }
- }
- return (false);
- }
- this.num = getQueryVariable('num');
- this.user = getQueryVariable('user');
- //获取试卷列表
- this.myListFn();
- },
- methods: {
- //获取试卷列表
- myListFn() {
- // Authorization
- let _this = this;
- layui.use(['uParas', 'admin'], () => {
- let admin = layui.admin;
- let uParas = layui.uParas;
- let url = uParas.baseUrl + '/ol/userTestPaper/myList';
- // admin.req(url, {
- // limit:1000,
- // page:1
- // }, function (res) {
- // console.log(res);
- // });
- $.ajax({
- type: 'get',
- url: url,
- data: {
- page: 1,
- limit: this.limit
- },
- headers: {
- 'accept': 'application/json, text/javascript, */*; q=0.01',
- 'Authorization': localStorage.getItem('atoken')
- },
- success: function (res) {
- console.log(res);
- _this.myList = res.data;
- _this.count = res.count;
- },
- });
- })
- },
- goPageFn(item, num) {
- if ((item.status == 0 && this.num == 1) || this.num == 2) {
- let paperTypeId = '';
- if (this.num == 1) {
- paperTypeId = this.getQueryVariable('paperTypeId');
- }
- if (this.user == 1) {
- let zindex = $(window.parent.document).find('.layui-layer-iframe').css('z-index');
- $(window.parent.document).find('.layui-layer-iframe').css({
- zIndex: zindex,
- width: '90%',
- height: '90%',
- position: 'absolute',
- top: '40px',
- left: '50px',
- })
- }
- location.href = './index.html?paperId=' + item.paperId + '&num=' + num + '&paperTypeId=' + paperTypeId;
- }
- },
- goExamFn(item, num) {
- location.href = './index.html?paperId=' + item.paperId + '&num=' + num;
- },
- //跳转考试记录
- goHistoryFn(item = {}) {
- let paperId = '';
- if (item.paperId) {
- paperId = item.paperId;
- }
- location.href = './exam_history.html?num=' + this.num + '&paperId=' + paperId;
- },
- onClickLeft() {
- window.history.back(-1);
- },
- getQueryVariable(variable) {
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i = 0; i < vars.length; i++) {
- var pair = vars[i].split("=");
- if (pair[0] == variable) {
- return pair[1];
- }
- }
- return (false);
- }
- }
- })
- </script>
- </body>
- </html>
|