login.vue 2.7 KB

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