123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- <template>
- <view class="login-container">
- <navBar title="登录" color="#000" />
- <view class="login-content">
- <!-- 表单区域 -->
- <view class="login-form">
- <!-- 手机号码输入 -->
- <view class="form-item">
- <view class="item-label"> 手机号码 </view>
- <u-input
- placeholder="请输入登录的手机号码"
- v-model="phoneNumber"
- clearable
- class="custom-input"
- :customStyle="{ padding: '8rpx 24rpx ' }"
- >
- <template #prefix>
- <u-icon name="phone" size="36rpx" color="#999" marginRight="20rpx"></u-icon>
- </template>
- </u-input>
- </view>
- <!-- 密码输入 -->
- <view class="form-item">
- <view class="item-label"> 登录密码 </view>
- <u-input
- placeholder="请输入密码"
- v-model="password"
- clearable
- type="password"
- class="custom-input"
- :customStyle="{ padding: '8rpx 24rpx ' }"
- >
- <template #prefix>
- <u-icon name="lock" size="36rpx" color="#999" marginRight="20rpx"></u-icon>
- </template>
- </u-input>
- <!-- 忘记密码 -->
- <view class="forgot-password">
- <view @click="forgotPassword">忘记密码</view>
- </view>
- </view>
- <!-- 登录按钮 -->
- <u-button
- type="primary"
- @click="handleLogin"
- :customStyle="{
- marginTop: '32rpx',
- height: '90rpx',
- fontSize: '32rpx',
- borderRadius: '100rpx',
- }"
- :disabled="!canLogin"
- >登录</u-button
- >
- <!-- 注册链接 -->
- <view class="register-section">
- <view @click="goToRegister">注册</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import navBar from "@/components/nav-bar/index.vue";
- export default {
- data() {
- return {
- phoneNumber: "", // 手机号码
- password: "", // 密码
- };
- },
- components: {
- navBar,
- },
- computed: {
- // 判断是否可以登录
- canLogin() {
- return this.phoneNumber.length >= 11 && this.password.length >= 6;
- },
- },
- methods: {
- // 处理登录
- handleLogin() {
- if (!this.validateForm()) {
- return;
- }
- uni.showLoading({
- title: "登录中...",
- });
- // 模拟登录请求
- setTimeout(() => {
- uni.hideLoading();
- uni.showToast({
- title: "登录成功",
- icon: "success",
- });
- // 登录成功后的操作,比如跳转到首页
- setTimeout(() => {
- uni.switchTab({
- url: "/pages/index/index",
- });
- }, 1500);
- }, 2000);
- },
- // 表单验证
- validateForm() {
- if (!this.phoneNumber) {
- uni.showToast({
- title: "请输入手机号码",
- icon: "none",
- });
- return false;
- }
- if (!/^1[3-9]\d{9}$/.test(this.phoneNumber)) {
- uni.showToast({
- title: "请输入正确的手机号码",
- icon: "none",
- });
- return false;
- }
- if (!this.password) {
- uni.showToast({
- title: "请输入密码",
- icon: "none",
- });
- return false;
- }
- if (this.password.length < 6) {
- uni.showToast({
- title: "密码长度不能少于6位",
- icon: "none",
- });
- return false;
- }
- return true;
- },
- // 忘记密码
- forgotPassword() {
- uni.navigateTo({
- url: "/pages/forgot-password/forgot-password",
- });
- },
- // 跳转到注册页面
- goToRegister() {
- uni.navigateTo({
- url: "/pages/my/jobApplicant/register",
- });
- },
- },
- };
- </script>
- <style scoped lang="scss">
- .login-container {
- background: #fff;
- position: absolute;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- .login-content {
- padding: 32rpx;
- box-sizing: border-box;
- }
- }
- .login-header {
- text-align: center;
- margin-bottom: 100rpx;
- margin-top: 60rpx;
- }
- .login-form {
- }
- .form-item {
- margin-bottom: 32rpx;
- }
- .item-label {
- color: rgba(18, 26, 44, 1);
- font-family: Roboto;
- font-size: 32rpx;
- font-weight: 400;
- line-height: 51.2rpx;
- letter-spacing: 0px;
- text-align: left;
- padding-bottom: 6rpx;
- }
- .custom-input {
- box-sizing: border-box;
- border: 2rpx solid rgba(158, 161, 168, 1);
- border-radius: 24rpx;
- background: rgba(255, 255, 255, 1);
- padding: 8rpx 24rpx !important;
- }
- .forgot-password {
- text-align: left;
- margin-top: 8rpx;
- color: rgba(102, 112, 133, 1);
- font-family: Inter;
- font-size: 24rpx;
- font-weight: 400;
- line-height: 40rpx;
- }
- .register-section {
- display: flex;
- justify-content: center;
- align-items: center;
- margin-top: 32rpx;
- color: #016bf6;
- font-family: Inter;
- font-size: 12px;
- font-weight: 400;
- line-height: 20px;
- letter-spacing: 0%;
- text-align: right;
- text-decoration-line: underline;
- }
- .other-login {
- margin-top: 100rpx;
- }
- .divider-line {
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 60rpx;
- }
- .line {
- flex: 1;
- height: 1rpx;
- background: #e0e0e0;
- }
- ::v-deep .u-input {
- text-align: left !important;
- }
- </style>
|