login.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="login">
  3. <Headers></Headers>
  4. <image class="bg" src="/static/images/bg.png"></image>
  5. <view class="ddflex" style="flex-direction: column;">
  6. <view class="register ddflex">
  7. <view class="re-con-pic">
  8. <view class="re-con-pic-title">在线考试系统</view>
  9. <image src="/static/images/loginBg.png"></image>
  10. </view>
  11. <view class="re-con">
  12. <view class="re-tit">考生登录</view>
  13. <view class="re-li dflex">
  14. <!-- <image src="../../static/images/sjico.png" class="sjico"></image> -->
  15. <input v-model="testNumber" type="number" placeholder="准考证号" maxlength="11" placeholder-class="placeholder" class="re-ipt flex" />
  16. </view>
  17. <uni-data-select
  18. v-model="password"
  19. :localdata="range"
  20. @change="changeTestPro"
  21. placeholder="考试项目"
  22. ></uni-data-select>
  23. <!-- <view class="re-li re-li-yzm dflex">
  24. <input v-model="code" maxlength="4" placeholder="请输入验证码" placeholder-class="placeholder" class="re-ipt" />
  25. <view class="yzm-box" @click="refresh()"><canvas :style="{ width: width + 'px', height: height + 'px' }" canvas-id="imgcanvas"></canvas></view>
  26. </view> -->
  27. <view class="re-btn" @click="okLogin()">登录</view>
  28. <view class="re-btn-text">考生成绩查询</view>
  29. </view>
  30. </view>
  31. <view class="bottom-content ddflex">
  32. <!-- 考试公告 -->
  33. <view class="note-box">
  34. <view class="note-title ddflex">
  35. <image class="note-title-icon" src="/static/images/ksgg.png"></image>
  36. <view>考试公告</view>
  37. </view>
  38. <view>
  39. <view class="note-item ddflex">
  40. <view class="note-item-content">2022年“技能+学历”双证教育班培训简章2022年“技能+学历”双证教育班培训简章2022年“技能+学历”双证教育班培训简章</view>
  41. <view class="note-item-date">2022-08-25</view>
  42. </view>
  43. <view class="note-item ddflex">
  44. <view class="note-item-content">2022年“技能+学历”双证教育班培训简章</view>
  45. <view class="note-item-date">2022-08-25</view>
  46. </view>
  47. <view class="note-item ddflex">
  48. <view class="note-item-content">2022年“技能+学历”双证教育班培训简章</view>
  49. <view class="note-item-date">2022-08-25</view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 注意事项 -->
  54. <view class="note-box">
  55. <view class="note-title ddflex">
  56. <image class="note-title-icon" src="/static/images/zysx.png"></image>
  57. <view>注意事项</view>
  58. </view>
  59. <view>
  60. <view class="note-item ddflex">
  61. <view class="note-item-content">2022年“技能+学历”双证教育班培训简章2022年“技能+学历”双证教育班培训简章2022年“技能+学历”双证教育班培训简章</view>
  62. <view class="note-item-date">2022-08-25</view>
  63. </view>
  64. <view class="note-item ddflex">
  65. <view class="note-item-content">2022年“技能+学历”双证教育班培训简章</view>
  66. <view class="note-item-date">2022-08-25</view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <Foot :havaBackground='false'></Foot>
  73. </view>
  74. </template>
  75. <script>
  76. const app = getApp();
  77. const req = require('../../utils/request.js');
  78. const utils = require('../../utils/util.js');
  79. export default {
  80. data() {
  81. return {
  82. title: 'Hello',
  83. width: 115,
  84. height: 36,
  85. testNumber: '',
  86. password: '',
  87. code: '',
  88. isCheckArg: true,
  89. range:[
  90. { value: 0, text: "考试项目1" },
  91. { value: 1, text: "考试项目2" },
  92. { value: 2, text: "考试项目3" }
  93. ]
  94. };
  95. },
  96. onLoad() {
  97. var tha = this;
  98. setTimeout(function() {
  99. tha.initCode();
  100. }, 200);
  101. },
  102. methods: {
  103. changeEnv() {
  104. // this.isCheckArg = !this.isCheckArg;
  105. },
  106. // 考试下拉框
  107. changeTestPro(e){
  108. console.log("e:", e);
  109. },
  110. okLogin() {
  111. uni.reLaunch({
  112. url: '/pages/test/test'
  113. });
  114. return false
  115. if (!this.testNumber) {
  116. return req.msg('请输入准考证号');
  117. }
  118. if (!this.password) {
  119. return req.msg('请输入密码');
  120. }
  121. if (!this.code) {
  122. return req.msg('请输入验证码');
  123. }
  124. var imgCode = uni.getStorageSync('imgcode');
  125. if (this.code.toUpperCase() != imgCode.toUpperCase()) {
  126. req.msg('请输入正确的验证码');
  127. this.initCode();
  128. return;
  129. }
  130. var formP = {
  131. account: this.mobile,
  132. password: this.password
  133. };
  134. req.postRequest('/api/v3/hy/account/pwdLogin', formP, data => {
  135. this.getUserInfo();
  136. });
  137. },
  138. getUserInfo() {
  139. req.getRequest(
  140. '/api/v3/hy/account/userInfo',
  141. {},
  142. data => {
  143. req.setStorage('userInfo', data);
  144. if(data.type==1||data.isStaff){
  145. uni.reLaunch({
  146. url: '/pages/learn/learn'
  147. });
  148. }else{
  149. uni.reLaunch({
  150. url: '/pages/index/index'
  151. });
  152. }
  153. },
  154. true
  155. );
  156. },
  157. initCode() {
  158. console.log('start');
  159. var context = uni.createCanvasContext('imgcanvas', this),
  160. w = this.width,
  161. h = this.height;
  162. context.setFillStyle('white');
  163. context.setLineWidth(5);
  164. context.fillRect(0, 0, w, h);
  165. var pool = [
  166. 'A',
  167. 'B',
  168. 'C',
  169. 'D',
  170. 'E',
  171. 'F',
  172. 'G',
  173. 'H',
  174. 'I',
  175. 'J',
  176. 'K',
  177. 'L',
  178. 'I',
  179. 'M',
  180. 'N',
  181. 'O',
  182. 'P',
  183. 'Q',
  184. 'R',
  185. 'S',
  186. 'T',
  187. 'U',
  188. 'V',
  189. 'W',
  190. 'S',
  191. 'Y',
  192. 'Z',
  193. '1',
  194. '2',
  195. '3',
  196. '4',
  197. '5',
  198. '6',
  199. '7',
  200. '8',
  201. '9',
  202. '0'
  203. ],
  204. str = '';
  205. for (var i = 0; i < 4; i++) {
  206. var c = pool[this.rn(0, pool.length - 1)]; //随机的字
  207. var deg = this.rn(-30, 30); //字体的旋转角度
  208. context.setFontSize(18);
  209. context.setTextBaseline('top');
  210. context.setFillStyle(this.rc(80, 150));
  211. context.save();
  212. context.translate(30 * i + 15, parseInt(h / 1.5));
  213. context.rotate((deg * Math.PI) / 180);
  214. context.fillText(c, -15 + 5, -15);
  215. context.restore();
  216. str += c;
  217. }
  218. uni.setStorage({
  219. key: 'imgcode',
  220. data: str
  221. });
  222. for (var i = 0; i < 40; i++) {
  223. context.beginPath();
  224. context.arc(this.rn(0, w), this.rn(0, h), 1, 0, 2 * Math.PI);
  225. context.closePath();
  226. context.setFillStyle(this.rc(150, 200));
  227. context.fill();
  228. }
  229. context.draw();
  230. console.log('end');
  231. },
  232. rc(min, max) {
  233. var r = this.rn(min, max);
  234. var g = this.rn(min, max);
  235. var b = this.rn(min, max);
  236. return 'rgb(' + r + ',' + g + ',' + b + ')';
  237. },
  238. rn(max, min) {
  239. return parseInt(Math.random() * (max - min)) + min;
  240. },
  241. refresh() {
  242. this.initCode();
  243. }
  244. }
  245. };
  246. </script>
  247. <style>
  248. @import url('../login/login.css');
  249. </style>