phone-login.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <!-- 手机登录 -->
  3. <view class="page-container">
  4. <!-- 顶部标题区域 -->
  5. <image class="bg-image " src="@/static/images/bg.png" mode="aspectFill"></image>
  6. <!-- 登录表单区域 -->
  7. <view class="login-form">
  8. <!-- 账号输入框 -->
  9. <view class="input-group">
  10. <text class="input-label">账号</text>
  11. <u-input v-model="account" placeholder="请输入手机号码" :border="false" class="input-field" type="number"
  12. maxlength="11"></u-input>
  13. </view>
  14. <!-- 密码输入框 -->
  15. <view class="input-group">
  16. <text class="input-label">密码</text>
  17. <u-input v-model="password" placeholder="请输入密码" :border="false" class="input-field" type="password"
  18. :password-icon="true"></u-input>
  19. </view>
  20. <!-- 登录按钮 -->
  21. <button class="login-btn" @tap="handleLogin">
  22. <text>确定</text>
  23. </button>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. phoneLogin
  30. } from '@/config/api.js';
  31. export default {
  32. data() {
  33. return {
  34. account: '',
  35. password: ''
  36. }
  37. },
  38. methods: {
  39. // 处理登录
  40. handleLogin() {
  41. if (!this.account) {
  42. uni.showToast({
  43. title: '请输入账号',
  44. icon: 'none'
  45. });
  46. return;
  47. }
  48. if (!this.password) {
  49. uni.showToast({
  50. title: '请输入密码',
  51. icon: 'none'
  52. });
  53. return;
  54. }
  55. console.log('登录信息:', {
  56. account: this.account,
  57. password: this.password
  58. });
  59. let params = {
  60. "username": this.account,
  61. "password": this.password,
  62. "wxid": "3"
  63. }
  64. phoneLogin(params).then((res) => {
  65. console.log(res, "登陆成功")
  66. uni.setStorageSync('access_token', res.token);
  67. this.$store.commit('isLogin', true);
  68. uni.showToast({
  69. title: '登录成功',
  70. icon: 'success',
  71. duration: 1000
  72. });
  73. // 登录成功后的跳转
  74. setTimeout(() => {
  75. uni.switchTab({
  76. url: '/pages/index/index'
  77. });
  78. }, 1000);
  79. uni.hideLoading();
  80. })
  81. }
  82. },
  83. }
  84. </script>
  85. <style>
  86. .page-container {
  87. min-height: 100vh;
  88. background: #F5F5F5;
  89. }
  90. /* 背景图片 */
  91. .bg-image {
  92. top: 0;
  93. left: 0;
  94. width: 100%;
  95. height: 300rpx;
  96. z-index: 0;
  97. }
  98. .login-form {
  99. background: #FFFFFF;
  100. border-radius: 24rpx;
  101. padding: 32rpx;
  102. margin: 32rpx;
  103. box-shadow: 0 4rpx 16rpx rgba(41, 44, 53, 0.1);
  104. .input-group {
  105. margin-bottom: 32rpx;
  106. .input-label {
  107. display: block;
  108. font-size: 28rpx;
  109. color: #292C35;
  110. margin-bottom: 16rpx;
  111. }
  112. .input-field {
  113. background: #F5F5F5;
  114. border-radius: 12rpx;
  115. height: 88rpx;
  116. padding: 0 24rpx;
  117. font-size: 28rpx;
  118. }
  119. }
  120. .login-btn {
  121. width: 100%;
  122. height: 88rpx;
  123. background: linear-gradient(135deg, #FF5B05 0%, #FF8E3C 100%);
  124. border-radius: 44rpx;
  125. color: #FFFFFF;
  126. font-size: 32rpx;
  127. font-weight: 500;
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. margin-top: 48rpx;
  132. border: none;
  133. box-shadow: 0 4rpx 16rpx rgba(255, 91, 5, 0.3);
  134. &:active {
  135. transform: translateY(2rpx);
  136. box-shadow: 0 2rpx 8rpx rgba(255, 91, 5, 0.4);
  137. }
  138. }
  139. }
  140. </style>