123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- <!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%;
- max-width: 50rem;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .btn-box {
- margin-top: 1rem;
- margin-bottom: 2rem;
- }
- .btn-box div {
- width: 40%;
- margin: 0 auto;
- margin-bottom: 2rem;
- }
- .btn-box .van-button {
- width: 100%;
- }
- [v-cloak] {
- display: none;
- }
- </style>
- </head>
- <body>
- <div id="app" v-cloak>
- <div style="width: 60%" v-if="user != 1">
- <div>
- <van-button type="info" size="large" @click="tanFn(1)">正式考试</van-button>
- </div>
- <div style="margin-top: 5rem">
- <van-button size="large" type="info" @click="tanFn(2)">模拟考试</van-button>
- </div>
- </div>
- <van-dialog
- v-model="show"
- title="选择人员类型"
- confirm-button-text="取消"
- @confirm="confirm"
- >
- <div class="btn-box" style="display: flex;flex-flow: column;max-height:30rem;overflow-y: scroll;">
- <div v-for="item in myList">
- <van-button type="info" @click="goPagesFn(item)">{{item.typeName}}</van-button>
- </div>
- </div>
- </van-dialog>
- </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;
- }
- var postId = getUrlParam("postId");
- new Vue({
- el: "#app",
- data: {
- show: false,
- num: 1,
- myList: [],
- user: '',
- atoken: '',
- },
- mounted() {
- this.user = this.getUrlParam('user');
- if (this.user == 2) {
- this.atoken = this.getUrlParam('atoken');
- localStorage.setItem('atoken', this.atoken);
- }
- //获取考试身份列表
- this.myListFn();
- if (this.user == 1) {
- this.show = true;
- }
- },
- methods: {
- tanFn(num) {
- this.num = num;
- if (num == 1) {
- this.show = true;
- }
- if (num == 2) {
- location.href = 'exam_list.html?num=' + 2;
- }
- },
- goPagesFn(item) {
- if (this.num == 1) {
- location.href = './exam_list.html?num=1&paperTypeId=' + item.paperTypeId + '&user=' + this.user;
- }
- },
- //获取考试身份列表
- myListFn() {
- // Authorization
- let _this = this;
- layui.use(['uParas', 'admin'], () => {
- let admin = layui.admin;
- let uParas = layui.uParas;
- let url = uParas.baseUrl + '/ol/paperType/query';
- $.ajax({
- type: 'get',
- url: url,
- data: {},
- headers: {
- 'accept': 'application/json, text/javascript, */*; q=0.01',
- 'Authorization': localStorage.getItem('atoken')
- },
- success: function (res) {
- console.log(res);
- _this.myList = res.data;
- },
- });
- })
- },
- confirm() {
- if (this.user == 1) {
- window.parent.location.reload();
- }
- },
- 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;
- },
- }
- })
- </script>
- </body>
- </html>
|