select_people.html 6.8 KB

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