Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div class="login-box">
  3. <div class="login-content">
  4. <h2 class="title">菊城人才市场招聘后台管理系统</h2>
  5. <div class="sub-title">欢迎使用</div>
  6. <a-form>
  7. <a-space direction="vertical">
  8. <a-row :gutter="10">
  9. <a-col :span="24">
  10. <a-form-item>
  11. <a-input size="large" placeholder="账号" v-model:value="createForm.mobile">
  12. <template #prefix>
  13. <user-outlined type="user" />
  14. </template>
  15. </a-input>
  16. </a-form-item>
  17. </a-col>
  18. </a-row>
  19. <a-row :gutter="10">
  20. <a-col :span="24">
  21. <a-form-item>
  22. <a-input size="large" type="password" placeholder="密码"
  23. v-model:value="createForm.password">
  24. <template #prefix>
  25. <LockOutlined />
  26. </template>
  27. <template #suffix>
  28. <a-tooltip title="Extra information">
  29. <EyeInvisibleOutlined style="color: rgba(0, 0, 0, 0.25)" />
  30. </a-tooltip>
  31. </template>
  32. </a-input>
  33. </a-form-item>
  34. </a-col>
  35. </a-row>
  36. <a-row :gutter="10">
  37. <a-col span="12">
  38. <a-form-item>
  39. <a-input v-model:value="captcha" placeholder="图形验证码" size="large" />
  40. </a-form-item>
  41. </a-col>
  42. <a-col span="12">
  43. <a-form-item>
  44. <image-container :imgObj="{src: codeImage,width: '100%',height: '40px', mode: 'fill'}"
  45. @click="getCaptcha"></image-container>
  46. </a-form-item>
  47. </a-col>
  48. </a-row>
  49. <a-row :gutter="10">
  50. <a-col span="16">
  51. <a-form-item>
  52. <a-input v-model:value="createForm.sms_code" placeholder="短信验证码" size="large" />
  53. </a-form-item>
  54. </a-col>
  55. <a-col span="8">
  56. <a-form-item>
  57. <a-button type="primary" block size="large" @click="sendCode"
  58. :disabled="state.disabled">
  59. {{ state.codeTxt }}</a-button>
  60. </a-form-item>
  61. </a-col>
  62. </a-row>
  63. <!-- <a-row type="flex" justify="end">
  64. <a-col :span="6">
  65. <a-form-item>
  66. <div>忘记密码?</div>
  67. </a-form-item>
  68. </a-col>
  69. </a-row> -->
  70. <a-row>
  71. <a-col :span="24">
  72. <a-button size="large" @click="toLogin" style="width: 100%;" type="primary">登录</a-button>
  73. </a-col>
  74. </a-row>
  75. </a-space>
  76. </a-form>
  77. </div>
  78. </div>
  79. </template>
  80. <script lang="ts" setup>
  81. import { ref, onMounted, onBeforeUnmount } from 'vue';
  82. import { Login, PostSmsSend, GetCaptcha } from '@/apis/models';
  83. import { useAsRouter } from '@/hooks/useAsRouter'
  84. import { UserOutlined, InfoCircleOutlined, LockOutlined, EyeInvisibleOutlined } from '@ant-design/icons-vue';
  85. import { useCommon } from '@/hooks/useCommon';
  86. let { message } = useCommon();
  87. const { routerTo } = useAsRouter();
  88. let capt_id = ref<String>('')
  89. let codeImage = ref<String>('')
  90. let captcha = ref<String>('')
  91. const createForm = ref<Object>({
  92. mobile: '',
  93. password: '',
  94. sms_code: ''
  95. })
  96. interface State {
  97. count : number;
  98. sending : boolean;
  99. disabled : boolean;
  100. }
  101. const state = ref<State>({
  102. count: 60,
  103. codeTxt: '获取验证码',
  104. disabled: false,
  105. });
  106. let timer = ref<any>(null)
  107. const sendCode = () => {
  108. if (!createForm.value.mobile) {
  109. message.warn('请输入手机号')
  110. return false;
  111. }
  112. PostSmsSend({ mobile: createForm.value.mobile, captcha: captcha.value, capt_id: capt_id.value }).then(res => {
  113. message.success('发送验证码成功,验证码有效期为一分钟');
  114. timer.value = setInterval(function () {
  115. if (state.value.count > 1) {
  116. state.value.count = state.value.count - 1;
  117. state.value.codeTxt = '剩余' + (state.value.count - 1) + '秒';
  118. state.value.disabled = true
  119. } else {
  120. clearInterval(timer.value);
  121. state.value.count = 60;
  122. state.value.codeTxt = '获取验证码';
  123. state.value.disabled = false
  124. };
  125. }, 1000)
  126. })
  127. };
  128. onBeforeUnmount(() => {
  129. clearInterval(timer.value);
  130. })
  131. const toLogin = () => {
  132. createForm.value.sms_code = Number(createForm.value.sms_code)
  133. if (!createForm.value.mobile) {
  134. message.warning('请输入登录账号');
  135. return false;
  136. }
  137. if (!createForm.value.password) {
  138. message.warning('请输入密码');
  139. return false;
  140. }
  141. Login(createForm.value).then(res => {
  142. sessionStorage.setItem('token', res.data.jwttoken.accesstoken);
  143. routerTo('/home');
  144. createForm.value = {
  145. mobile: '',
  146. password: ''
  147. }
  148. })
  149. // sessionStorage.setItem('token', '1321');
  150. // routerTo('/home');
  151. }
  152. const getCaptcha = () => {
  153. capt_id.value = ''
  154. GetCaptcha().then(res => {
  155. capt_id.value = res.data.capt_id;
  156. codeImage.value = res.data.img;
  157. })
  158. }
  159. onMounted(() => {
  160. getCaptcha()
  161. })
  162. </script>
  163. <style lang="less">
  164. @import 'login.less';
  165. </style>