login.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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/loginBg1.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="testProject"
  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" @click="jumpUrl('/pages/scoreQuery/scoreQuery')">考生成绩查询</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" v-for="item,index in otherInfo" :key="index" @click="jumpUrl('/pages/contentDetail/contentDetail?id='+item.id)">
  40. <view class="note-item-content">{{item.title}}</view>
  41. <view class="note-item-date">{{dateFormat(item.creatDate)}}</view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 注意事项 -->
  46. <view class="note-box">
  47. <view class="note-title ddflex">
  48. <image class="note-title-icon" src="/static/images/zysx.png"></image>
  49. <view>注意事项</view>
  50. </view>
  51. <view>
  52. <view class="note-item ddflex" v-for="item,index in noteInfo" :key="index+'zy'" @click="jumpUrl('/pages/contentDetail/contentDetail?id='+item.id)">
  53. <view class="note-item-content">{{item.title}}</view>
  54. <view class="note-item-date">{{dateFormat(item.creatDate)}}</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <Foot :havaBackground='false'></Foot>
  61. </view>
  62. </template>
  63. <script>
  64. const app = getApp();
  65. const req = require('../../utils/request.js');
  66. const utils = require('../../utils/util.js');
  67. export default {
  68. data() {
  69. return {
  70. title: 'Hello',
  71. width: 115,
  72. height: 36,
  73. testNumber: '',
  74. testProject:'',
  75. code: '',
  76. isCheckArg: true,
  77. range:[],
  78. otherInfo:[],//考试公告
  79. noteInfo:[],//注意事项
  80. };
  81. },
  82. onLoad() {
  83. var tha = this;
  84. this.getTestProject()
  85. this.getTextOtherInfo()
  86. this.getTextNoteInfo()
  87. setTimeout(function() {
  88. tha.initCode();
  89. }, 200);
  90. },
  91. methods: {
  92. jumpUrl(url){
  93. uni.navigateTo({
  94. url:url
  95. })
  96. },
  97. // 考试下拉框
  98. changeTestPro(e){
  99. console.log("e:", e);
  100. },
  101. // 获取考试项目
  102. getTestProject(){
  103. console.log('11')
  104. req.getRequest('https://mock.apifox.cn/m1/2171629-0-default/api/test/project',{},res=>{
  105. console.log('this.range',res)
  106. this.range = res.map(item=>{return {text:item.title,value:item.id}})
  107. console.log(this.range)
  108. })
  109. },
  110. // 考试公告
  111. getTextOtherInfo(){
  112. req.getRequest('https://mock.apifox.cn/m1/2171629-0-default/api/ksgg',{},res=>{
  113. this.otherInfo = res
  114. })
  115. },
  116. // 考试公告
  117. getTextNoteInfo(){
  118. req.getRequest('https://mock.apifox.cn/m1/2171629-0-default/api/ksgg',{type:2},res=>{
  119. this.noteInfo = res
  120. })
  121. },
  122. okLogin() {
  123. if (!this.testNumber) {
  124. return req.msg('请输入准考证号');
  125. }
  126. if (!this.testProject) {
  127. return req.msg('请选择考试项目');
  128. }
  129. var formP = {
  130. testNumber: this.testNumber,
  131. testProject: this.testProject
  132. };
  133. uni.reLaunch({
  134. url: '/pages/test/test'
  135. });
  136. return false
  137. req.postRequest('/api/v3/hy/account/pwdLogin', formP, data => {
  138. this.getUserInfo();
  139. });
  140. },
  141. // 时间格式化
  142. dateFormat(date){
  143. return req.dateFormat(date).v5
  144. },
  145. getUserInfo() {
  146. req.getRequest(
  147. '/api/v3/hy/account/userInfo',
  148. {},
  149. data => {
  150. req.setStorage('userInfo', data);
  151. if(data.type==1||data.isStaff){
  152. uni.reLaunch({
  153. url: '/pages/learn/learn'
  154. });
  155. }else{
  156. uni.reLaunch({
  157. url: '/pages/index/index'
  158. });
  159. }
  160. },
  161. true
  162. );
  163. },
  164. }
  165. };
  166. </script>
  167. <style>
  168. @import url('../login/login.css');
  169. </style>