login.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. userStore.Login(loginForm.value).then(() => {
  44. $modal.closeLoading()
  45. loginSuccess()
  46. })
  47. }
  48. }
  49. function loginSuccess() {
  50. userStore.GetInfo()
  51. $tab.reLaunch('/pages/message/index')
  52. }
  53. </script>
  54. <style lang="scss">
  55. @import "@/static/scss/colorui.css";
  56. @import '@/static/font/iconfont.css';
  57. page {
  58. background-color: #ffffff;
  59. }
  60. .normal-login-container {
  61. width: 100%;
  62. .logo-content {
  63. width: 100%;
  64. font-size: 21px;
  65. text-align: center;
  66. padding-top: 15%;
  67. image {
  68. border-radius: 4px;
  69. }
  70. .title {
  71. margin-left: 10px;
  72. }
  73. }
  74. .login-form-content {
  75. text-align: center;
  76. margin: 20px auto;
  77. margin-top: 15%;
  78. width: 80%;
  79. .input-item {
  80. margin: 20px auto;
  81. background-color: #f5f6f7;
  82. height: 45px;
  83. border-radius: 20px;
  84. .icon {
  85. font-size: 38rpx;
  86. margin-left: 10px;
  87. color: #999;
  88. }
  89. .input {
  90. width: 100%;
  91. line-height: 20px;
  92. text-align: left;
  93. padding-left: 15px;
  94. }
  95. }
  96. .login-btn {
  97. margin-top: 40px;
  98. height: 45px;
  99. border-radius: 20px;
  100. }
  101. }
  102. }
  103. </style>