login.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="logo-content align-center justify-center flex">
  4. <image style="width: 100%;"
  5. :src="config.logoSrc" mode="widthFix">
  6. </image>
  7. <!-- <text class="title">OA移动端登录</text> -->
  8. </view>
  9. <view class="login-form-content">
  10. <view class="input-item flex align-center">
  11. <view class="iconfont icon-user icon"></view>
  12. <input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
  13. </view>
  14. <view class="input-item flex align-center">
  15. <view class="iconfont icon-password icon"></view>
  16. <input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
  17. </view>
  18. <view class="action-btn">
  19. <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script setup lang="ts">
  25. import config from '@/config.js'
  26. import { ref } from 'vue'
  27. import { useUserStore } from '@/store/user.js'
  28. import $modal from '@/plugins/modal.js'
  29. import $tab from '@/plugins/tab.js'
  30. const userStore = useUserStore()
  31. const loginForm = ref({
  32. username: '',
  33. password: ''
  34. })
  35. function handleLogin() {
  36. const username = loginForm.value.username
  37. const password = loginForm.value.password
  38. if (username === "") {
  39. $modal.msgError("请输入您的账号")
  40. } else if (password === "") {
  41. $modal.msgError("请输入您的密码")
  42. } else {
  43. $modal.loading("登录中,请耐心等待...")
  44. // TEST: 测试登录接口
  45. userStore.Login(loginForm.value).then(() => {
  46. $modal.closeLoading()
  47. loginSuccess()
  48. })
  49. }
  50. }
  51. function loginSuccess() {
  52. userStore.GetInfo()
  53. $tab.reLaunch('/pages/message/index')
  54. }
  55. </script>
  56. <style lang="scss">
  57. @import "@/static/scss/colorui.css";
  58. @import '@/static/font/iconfont.css';
  59. page {
  60. background-color: #ffffff;
  61. }
  62. .normal-login-container {
  63. width: 100%;
  64. .logo-content {
  65. width: 100%;
  66. font-size: 21px;
  67. text-align: center;
  68. padding-top: 45%;
  69. image {
  70. border-radius: 4px;
  71. }
  72. .title {
  73. margin-left: 10px;
  74. }
  75. }
  76. .login-form-content {
  77. text-align: center;
  78. margin: 20px auto;
  79. margin-top: 15%;
  80. width: 80%;
  81. .input-item {
  82. margin: 20px auto;
  83. background-color: #f5f6f7;
  84. height: 45px;
  85. border-radius: 20px;
  86. .icon {
  87. font-size: 38rpx;
  88. margin-left: 10px;
  89. color: #999;
  90. }
  91. .input {
  92. width: 100%;
  93. line-height: 20px;
  94. text-align: left;
  95. padding-left: 15px;
  96. }
  97. }
  98. .login-btn {
  99. margin-top: 40px;
  100. height: 45px;
  101. border-radius: 20px;
  102. }
  103. }
  104. }
  105. </style>