index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div>
  3. <!-- <img :src="bcg" alt="" class="pos">-->
  4. <div class="container" @keypress="keypress">
  5. <div class="bigTitle">业委会管理系统登录</div>
  6. <div class="module" v-if="step == 0" style="margin-top: 50px;width: 100%; display: flex;flex-direction:column;align-items: center ;">
  7. <div class="floor">
  8. <el-button style="width: 240px; height: 50px;border:1px solid rgb(64,158,225);color: rgb(64,158,225)" @click="changeType('1')">密码登录</el-button>
  9. </div>
  10. <div class="floor">
  11. <el-button style="width: 240px; height: 50px;border:1px solid rgb(64,158,225);color: rgb(64,158,225)" @click="changeType('2')">验证码登录</el-button>
  12. </div>
  13. </div>
  14. <div v-if="step == 1" class="module">
  15. <div class="floor">
  16. <div class="title">手机号</div>
  17. <el-input class="input" type="text" v-model="loginForm.mobile"/>
  18. </div>
  19. <div class="floor" v-if="loginForm.type == 1">
  20. <div class="title">密码</div>
  21. <el-input class="input" show-password type="text" v-model="loginForm.securityCode"/>
  22. </div>
  23. <div class="floor" v-if="loginForm.type == 2">
  24. <div class="title">验证码</div>
  25. <el-input class="codeInput" type="text" v-model="loginForm.securityCode"/>
  26. <el-button type="success" @click="getSecurityCode" style="width: 100px;display: flex;justify-content: center;">获取验证码</el-button>
  27. </div>
  28. <div class="floor">
  29. <el-button style="width: 100%" @click="handleLogin" type="success">登录</el-button>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import {Loading} from 'element-ui';
  37. export default {
  38. name: "index",
  39. data: () => {
  40. return {
  41. step:0,
  42. loginForm: {
  43. securityCode: "",
  44. mobile: '',
  45. type:""
  46. },
  47. codeSrc: ""
  48. }
  49. },
  50. created() {
  51. this.captchaImage();
  52. },
  53. methods: {
  54. changeType(type){
  55. this.loginForm.type = type;
  56. this.step = 1;
  57. },
  58. getSecurityCode(){
  59. let mobile = this.loginForm.mobile;
  60. if(mobile == ""){
  61. this.$message.warning("请先输入手机号码")
  62. return false;
  63. }
  64. this.$api.verificationCode({
  65. mobile
  66. }).then(res => {
  67. console.log(res)
  68. this.loginForm.securityCode = res.content.verificationCode;
  69. })
  70. },
  71. keypress(e){
  72. if(e.keyCode == 13){
  73. this.handleLogin();
  74. }
  75. },
  76. handleLogin() {
  77. this.$api.login(this.loginForm).then(res => {
  78. // console.log(res)
  79. this.$router.push("home")
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style scoped>
  86. .code {
  87. height: 50px;
  88. width: 100px;
  89. cursor: pointer;
  90. padding-left: 10px;
  91. box-sizing: border-box;
  92. }
  93. .floor {
  94. display: flex;
  95. margin-top: 20px;
  96. align-items: center;
  97. }
  98. .floor .title {
  99. flex-grow: 1;
  100. }
  101. .input {
  102. width: 240px;
  103. }
  104. .codeInput {
  105. width: 140px;
  106. }
  107. .container {
  108. position: fixed;
  109. left: 50%;
  110. top: 50%;
  111. transform: translate(-50%, -50%); /* 50%为自身尺寸的一半 */
  112. z-index: 4;
  113. background-color: #fff;
  114. width: 360px;
  115. height: 300px;
  116. padding: 30px;
  117. border-radius: 20px;
  118. }
  119. .pos {
  120. position: fixed;
  121. height: 100vh;
  122. width: 100vw;
  123. z-index: 3;
  124. }
  125. .bigTitle {
  126. font-weight: bold;
  127. font-size: 24px;
  128. text-align: center;
  129. }
  130. </style>