login.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="logo-content align-center justify-center flex">
  4. <image style="width: 200rpx;height: 200rpx;"
  5. src="https://50006360.s21i.huaweicloudsite.cn/4/ABUIABAEGAAg6PTOtwYohbu8vAIw8AM4gAI.png" 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 { ref } from 'vue'
  26. import { useUserStore } from '@/store/user.js'
  27. import $modal from '@/plugins/modal.js'
  28. import $tab from '@/plugins/tab.js'
  29. const userStore = useUserStore()
  30. const loginForm = ref({
  31. username: '',
  32. password: ''
  33. })
  34. function handleLogin() {
  35. const username = loginForm.value.username
  36. const password = loginForm.value.password
  37. if (username === "") {
  38. $modal.msgError("请输入您的账号")
  39. } else if (password === "") {
  40. $modal.msgError("请输入您的密码")
  41. } else {
  42. $modal.loading("登录中,请耐心等待...")
  43. // TEST: 测试登录接口
  44. userStore.Login(loginForm.value).then(() => {
  45. $modal.closeLoading()
  46. loginSuccess()
  47. })
  48. }
  49. }
  50. function loginSuccess() {
  51. userStore.GetInfo()
  52. $tab.reLaunch('/pages/message/index')
  53. }
  54. </script>
  55. <style lang="scss">
  56. @import "@/static/scss/colorui.css";
  57. @import '@/static/font/iconfont.css';
  58. page {
  59. background-color: #ffffff;
  60. }
  61. .normal-login-container {
  62. width: 100%;
  63. .logo-content {
  64. width: 100%;
  65. font-size: 21px;
  66. text-align: center;
  67. padding-top: 45%;
  68. image {
  69. border-radius: 4px;
  70. }
  71. .title {
  72. margin-left: 10px;
  73. }
  74. }
  75. .login-form-content {
  76. text-align: center;
  77. margin: 20px auto;
  78. margin-top: 15%;
  79. width: 80%;
  80. .input-item {
  81. margin: 20px auto;
  82. background-color: #f5f6f7;
  83. height: 45px;
  84. border-radius: 20px;
  85. .icon {
  86. font-size: 38rpx;
  87. margin-left: 10px;
  88. color: #999;
  89. }
  90. .input {
  91. width: 100%;
  92. line-height: 20px;
  93. text-align: left;
  94. padding-left: 15px;
  95. }
  96. }
  97. .login-btn {
  98. margin-top: 40px;
  99. height: 45px;
  100. border-radius: 20px;
  101. }
  102. }
  103. }
  104. </style>