select_people.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. max-width: 50rem;
  53. display: flex;
  54. justify-content: center;
  55. align-items: center;
  56. }
  57. .btn-box {
  58. margin-top: 1rem;
  59. margin-bottom: 2rem;
  60. }
  61. .btn-box div {
  62. width: 40%;
  63. margin: 0 auto;
  64. margin-bottom: 2rem;
  65. }
  66. .btn-box .van-button {
  67. width: 100%;
  68. }
  69. [v-cloak] {
  70. display: none;
  71. }
  72. </style>
  73. </head>
  74. <body>
  75. <div id="app" v-cloak>
  76. <div style="width: 60%" v-if="user != 1">
  77. <div>
  78. <van-button type="info" size="large" @click="tanFn(1)">正式考试</van-button>
  79. </div>
  80. <div style="margin-top: 5rem">
  81. <van-button size="large" type="info" @click="tanFn(2)">模拟考试</van-button>
  82. </div>
  83. </div>
  84. <van-dialog
  85. v-model="show"
  86. title="选择人员类型"
  87. confirm-button-text="取消"
  88. @confirm="confirm"
  89. >
  90. <div class="btn-box" style="display: flex;flex-flow: column;max-height:30rem;overflow-y: scroll;">
  91. <div v-for="item in myList">
  92. <van-button type="info" @click="goPagesFn(item)">{{item.typeName}}</van-button>
  93. </div>
  94. </div>
  95. </van-dialog>
  96. </div>
  97. <script type="text/javascript" src="../../../assets/libs/layui/layui.js"></script>
  98. <script src="../../../assets/module/vue.js"></script>
  99. <script src="../../../assets/libs/jquery/jquery-3.2.1.min.js"></script>
  100. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.2/lib/index.css">
  101. <script src="https://cdn.jsdelivr.net/npm/vant@2.2/lib/vant.min.js"></script>
  102. <script type="text/javascript" src="../../../assets/js/common.js?v=312"></script>
  103. <script>
  104. function getUrlParam(name) {
  105. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  106. //如果地址栏中出现中文则进行编码
  107. var r = encodeURI(window.location.search).substr(1).match(reg);
  108. if (r != null) {
  109. //将中文编码的字符重新变成中文
  110. return decodeURI(unescape(r[2]));
  111. }
  112. return null;
  113. }
  114. var postId = getUrlParam("postId");
  115. new Vue({
  116. el: "#app",
  117. data: {
  118. show: false,
  119. num: 1,
  120. myList: [],
  121. user: '',
  122. atoken: '',
  123. },
  124. mounted() {
  125. this.user = this.getUrlParam('user');
  126. if (this.user == 2) {
  127. this.atoken = this.getUrlParam('atoken');
  128. localStorage.setItem('atoken', this.atoken);
  129. }
  130. //获取考试身份列表
  131. this.myListFn();
  132. if (this.user == 1) {
  133. this.show = true;
  134. }
  135. },
  136. methods: {
  137. tanFn(num) {
  138. this.num = num;
  139. if (num == 1) {
  140. this.show = true;
  141. }
  142. if (num == 2) {
  143. location.href = 'exam_list.html?num=' + 2;
  144. }
  145. },
  146. goPagesFn(item) {
  147. if (this.num == 1) {
  148. location.href = './exam_list.html?num=1&paperTypeId=' + item.paperTypeId + '&user=' + this.user;
  149. }
  150. },
  151. //获取考试身份列表
  152. myListFn() {
  153. // Authorization
  154. let _this = this;
  155. layui.use(['uParas', 'admin'], () => {
  156. let admin = layui.admin;
  157. let uParas = layui.uParas;
  158. let url = uParas.baseUrl + '/ol/paperType/query';
  159. $.ajax({
  160. type: 'get',
  161. url: url,
  162. data: {},
  163. headers: {
  164. 'accept': 'application/json, text/javascript, */*; q=0.01',
  165. 'Authorization': localStorage.getItem('atoken')
  166. },
  167. success: function (res) {
  168. console.log(res);
  169. _this.myList = res.data;
  170. },
  171. });
  172. })
  173. },
  174. confirm() {
  175. if (this.user == 1) {
  176. window.parent.location.reload();
  177. }
  178. },
  179. getUrlParam(name) {
  180. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  181. //如果地址栏中出现中文则进行编码
  182. var r = encodeURI(window.location.search).substr(1).match(reg);
  183. if (r != null) {
  184. //将中文编码的字符重新变成中文
  185. return decodeURI(unescape(r[2]));
  186. }
  187. return null;
  188. },
  189. }
  190. })
  191. </script>
  192. </body>
  193. </html>