loginInput.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view class="login-container">
  3. <navBar title="登录" color="#000" />
  4. <view class="login-content">
  5. <!-- 表单区域 -->
  6. <view class="login-form">
  7. <!-- 手机号码输入 -->
  8. <view class="form-item">
  9. <view class="item-label"> 手机号码 </view>
  10. <u-input
  11. placeholder="请输入登录的手机号码"
  12. v-model="phoneNumber"
  13. clearable
  14. class="custom-input"
  15. :customStyle="{ padding: '8rpx 24rpx ' }"
  16. >
  17. <template #prefix>
  18. <u-icon name="phone" size="36rpx" color="#999" marginRight="20rpx"></u-icon>
  19. </template>
  20. </u-input>
  21. </view>
  22. <!-- 密码输入 -->
  23. <view class="form-item">
  24. <view class="item-label"> 登录密码 </view>
  25. <u-input
  26. placeholder="请输入密码"
  27. v-model="password"
  28. clearable
  29. type="password"
  30. class="custom-input"
  31. :customStyle="{ padding: '8rpx 24rpx ' }"
  32. >
  33. <template #prefix>
  34. <u-icon name="lock" size="36rpx" color="#999" marginRight="20rpx"></u-icon>
  35. </template>
  36. </u-input>
  37. <!-- 忘记密码 -->
  38. <view class="forgot-password">
  39. <view @click="forgotPassword">忘记密码</view>
  40. </view>
  41. </view>
  42. <!-- 登录按钮 -->
  43. <u-button
  44. type="primary"
  45. @click="handleLogin"
  46. :customStyle="{
  47. marginTop: '32rpx',
  48. height: '90rpx',
  49. fontSize: '32rpx',
  50. borderRadius: '100rpx',
  51. }"
  52. :disabled="!canLogin"
  53. >登录</u-button
  54. >
  55. <!-- 注册链接 -->
  56. <view class="register-section">
  57. <view @click="goToRegister">注册</view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import navBar from "@/components/nav-bar/index.vue";
  65. export default {
  66. data() {
  67. return {
  68. phoneNumber: "", // 手机号码
  69. password: "", // 密码
  70. };
  71. },
  72. components: {
  73. navBar,
  74. },
  75. computed: {
  76. // 判断是否可以登录
  77. canLogin() {
  78. return this.phoneNumber.length >= 11 && this.password.length >= 6;
  79. },
  80. },
  81. methods: {
  82. // 处理登录
  83. handleLogin() {
  84. if (!this.validateForm()) {
  85. return;
  86. }
  87. uni.showLoading({
  88. title: "登录中...",
  89. });
  90. // 模拟登录请求
  91. setTimeout(() => {
  92. uni.hideLoading();
  93. uni.showToast({
  94. title: "登录成功",
  95. icon: "success",
  96. });
  97. // 登录成功后的操作,比如跳转到首页
  98. setTimeout(() => {
  99. uni.switchTab({
  100. url: "/pages/index/index",
  101. });
  102. }, 1500);
  103. }, 2000);
  104. },
  105. // 表单验证
  106. validateForm() {
  107. if (!this.phoneNumber) {
  108. uni.showToast({
  109. title: "请输入手机号码",
  110. icon: "none",
  111. });
  112. return false;
  113. }
  114. if (!/^1[3-9]\d{9}$/.test(this.phoneNumber)) {
  115. uni.showToast({
  116. title: "请输入正确的手机号码",
  117. icon: "none",
  118. });
  119. return false;
  120. }
  121. if (!this.password) {
  122. uni.showToast({
  123. title: "请输入密码",
  124. icon: "none",
  125. });
  126. return false;
  127. }
  128. if (this.password.length < 6) {
  129. uni.showToast({
  130. title: "密码长度不能少于6位",
  131. icon: "none",
  132. });
  133. return false;
  134. }
  135. return true;
  136. },
  137. // 忘记密码
  138. forgotPassword() {
  139. uni.navigateTo({
  140. url: "/pages/forgot-password/forgot-password",
  141. });
  142. },
  143. // 跳转到注册页面
  144. goToRegister() {
  145. uni.navigateTo({
  146. url: "/pages/my/jobApplicant/register",
  147. });
  148. },
  149. },
  150. };
  151. </script>
  152. <style scoped lang="scss">
  153. .login-container {
  154. background: #fff;
  155. position: absolute;
  156. left: 0;
  157. right: 0;
  158. top: 0;
  159. bottom: 0;
  160. .login-content {
  161. padding: 32rpx;
  162. box-sizing: border-box;
  163. }
  164. }
  165. .login-header {
  166. text-align: center;
  167. margin-bottom: 100rpx;
  168. margin-top: 60rpx;
  169. }
  170. .login-form {
  171. }
  172. .form-item {
  173. margin-bottom: 32rpx;
  174. }
  175. .item-label {
  176. color: rgba(18, 26, 44, 1);
  177. font-family: Roboto;
  178. font-size: 32rpx;
  179. font-weight: 400;
  180. line-height: 51.2rpx;
  181. letter-spacing: 0px;
  182. text-align: left;
  183. padding-bottom: 6rpx;
  184. }
  185. .custom-input {
  186. box-sizing: border-box;
  187. border: 2rpx solid rgba(158, 161, 168, 1);
  188. border-radius: 24rpx;
  189. background: rgba(255, 255, 255, 1);
  190. padding: 8rpx 24rpx !important;
  191. }
  192. .forgot-password {
  193. text-align: left;
  194. margin-top: 8rpx;
  195. color: rgba(102, 112, 133, 1);
  196. font-family: Inter;
  197. font-size: 24rpx;
  198. font-weight: 400;
  199. line-height: 40rpx;
  200. }
  201. .register-section {
  202. display: flex;
  203. justify-content: center;
  204. align-items: center;
  205. margin-top: 32rpx;
  206. color: #016bf6;
  207. font-family: Inter;
  208. font-size: 12px;
  209. font-weight: 400;
  210. line-height: 20px;
  211. letter-spacing: 0%;
  212. text-align: right;
  213. text-decoration-line: underline;
  214. }
  215. .other-login {
  216. margin-top: 100rpx;
  217. }
  218. .divider-line {
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. margin-bottom: 60rpx;
  223. }
  224. .line {
  225. flex: 1;
  226. height: 1rpx;
  227. background: #e0e0e0;
  228. }
  229. ::v-deep .u-input {
  230. text-align: left !important;
  231. }
  232. </style>