login.vue 2.6 KB

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