|
@@ -1,211 +1,141 @@
|
|
|
<template>
|
|
|
- <view class="container">
|
|
|
- <!-- 顶部logo -->
|
|
|
- <div class="image">
|
|
|
- <u-image src="@/static/logo.png"></u-image>
|
|
|
- </div>
|
|
|
-
|
|
|
- <!-- 中间登录注册 -->
|
|
|
- <view class="login-form-wrap">
|
|
|
- <u--form labelPosition="left" :model="loginForm" :rules="rules" ref="loginForm">
|
|
|
- <u-form-item prop="mobile" borderBottom label="账号">
|
|
|
- <u-input
|
|
|
- v-model="loginForm.mobile"
|
|
|
- maxlength="11"
|
|
|
- border="none"
|
|
|
- focus
|
|
|
- placeholder="请输入账号/手机号"
|
|
|
- >
|
|
|
- </u-input>
|
|
|
- </u-form-item>
|
|
|
- <u-form-item prop="captcha" label="密码" borderBottom>
|
|
|
- <u-input
|
|
|
- v-model="loginForm.password"
|
|
|
- maxlength="6"
|
|
|
- border="none"
|
|
|
- :type="type"
|
|
|
- placeholder="请输入密码"
|
|
|
- >
|
|
|
- <template slot="suffix">
|
|
|
- <u-icon v-if="type == 'password'" name="eye-off" @click="onClickPW('text')"></u-icon>
|
|
|
- <u-icon v-else name="eye-fill" @click="onClickPW('password')"></u-icon>
|
|
|
- </template>
|
|
|
- </u-input>
|
|
|
- </u-form-item>
|
|
|
-
|
|
|
- <view style="display: flex; justify-content: space-between">
|
|
|
- <view style="display: flex">
|
|
|
- <u-checkbox-group>
|
|
|
- <u-checkbox
|
|
|
- @change="checkboxChange"
|
|
|
- v-model="isChecked"
|
|
|
- :checked="isChecked"
|
|
|
- shape="circle"
|
|
|
- size="mini"
|
|
|
- ></u-checkbox>
|
|
|
- </u-checkbox-group>
|
|
|
- <view class="phone-question" @click="forgetPassword">记住密码</view>
|
|
|
- </view>
|
|
|
- <view class="phone-question" @click="forgetPassword">忘记密码?</view>
|
|
|
+ <view class="t-login">
|
|
|
+ <view class="t-b">{{ headline }}</view>
|
|
|
+ <view class="t-b2">欢迎使用车旅程,为你提供便捷服务</view>
|
|
|
+
|
|
|
+ <!-- 表单数据 -->
|
|
|
+ <form class="cl">
|
|
|
+ <view class="t-a">
|
|
|
+ <image src="https://zhoukaiwen.com/img/loginImg/sj.png" />
|
|
|
+ <view class="line" />
|
|
|
+ <input
|
|
|
+ type="number"
|
|
|
+ name="phone"
|
|
|
+ placeholder="请输入手机号"
|
|
|
+ maxlength="11"
|
|
|
+ v-model="phone"
|
|
|
+ />
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="t-a">
|
|
|
+ <image src="https://zhoukaiwen.com/img/loginImg/yz.png" />
|
|
|
+ <view class="line" />
|
|
|
+ <input type="number" name="code" maxlength="6" placeholder="请输入验证码" v-model="yzm" />
|
|
|
+ <view class="t-c">
|
|
|
+ <u-toast ref="uToast" />
|
|
|
+ <u-code
|
|
|
+ :seconds="seconds"
|
|
|
+ @end="end"
|
|
|
+ @start="start"
|
|
|
+ ref="uCode"
|
|
|
+ @change="codeChange"
|
|
|
+ ></u-code>
|
|
|
+ <u-button @tap="getCode">{{ tips }}</u-button>
|
|
|
</view>
|
|
|
- <u-form-item>
|
|
|
- <u-button
|
|
|
- type="primary"
|
|
|
- :disabled="isDisabled"
|
|
|
- :loading="loading"
|
|
|
- shape="circle"
|
|
|
- @click="login"
|
|
|
- >登录</u-button
|
|
|
- >
|
|
|
- </u-form-item>
|
|
|
- <u-form-item>
|
|
|
- <u-button :loading="loading" shape="circle" @click="register">注册</u-button>
|
|
|
- </u-form-item>
|
|
|
- </u--form>
|
|
|
- <br />
|
|
|
- </view>
|
|
|
+ </view>
|
|
|
+ <button @tap="login">登 录</button>
|
|
|
+ </form>
|
|
|
|
|
|
- <!-- 底部协议 -->
|
|
|
- <view class="user-agreement">
|
|
|
- <u-checkbox-group>
|
|
|
- <u-checkbox
|
|
|
- shape="circle"
|
|
|
- @change="checkboxChange"
|
|
|
- v-model="isChecked"
|
|
|
- :checked="isChecked"
|
|
|
- ></u-checkbox>
|
|
|
+ <view class="agree">
|
|
|
+ <u-checkbox-group v-model="checked">
|
|
|
+ <u-checkbox shape="circle" name="1" />
|
|
|
</u-checkbox-group>
|
|
|
<view>我已阅读并同意</view>
|
|
|
- <view @click="click('用户协议')">《用户协议》</view>
|
|
|
- <view @click="click('隐私政策')">《隐私政策》</view>
|
|
|
+ <view @click="clickAgreement('用户协议')" class="agreement">《用户协议》</view>
|
|
|
+ <view @click="clickAgreement('隐私政策')" class="agreement">《隐私政策》</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 用户协议弹框 -->
|
|
|
+ <!-- 第三方 -->
|
|
|
+ <view class="t-f"><text>————— 第三方账号登录 —————</text></view>
|
|
|
+ <view class="t-e cl">
|
|
|
+ <view class="t-g" @click="$Router.push('/pages/login/index')">
|
|
|
+ <image src="@/static/icon/wx.png" />
|
|
|
+ </view>
|
|
|
+ <view class="t-g">
|
|
|
+ <image src="@/static/icon/qq.png" />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 用户协议 -->
|
|
|
<userAgreement v-if="show" :title="title" :show="show" @handleConfirm="handleConfirm" />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import userAgreement from '@/components/userAgreement/userAgreement.vue';
|
|
|
-import { maintainSmsCaptcha } from '@/api/login';
|
|
|
export default {
|
|
|
- components: {
|
|
|
- userAgreement,
|
|
|
- },
|
|
|
+ components: { userAgreement },
|
|
|
data() {
|
|
|
return {
|
|
|
- loginForm: {
|
|
|
- client_id: 'chelvc_client',
|
|
|
- client_secret: 'qWBe6jD%GCuPPTkP',
|
|
|
- grant_type: 'sms',
|
|
|
- token: '',
|
|
|
- mobile: '', //手机号
|
|
|
- password: '', //密码
|
|
|
- },
|
|
|
- rules: {
|
|
|
- mobile: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- trigger: ['change', 'blur'],
|
|
|
- message: '请输入您的手机号',
|
|
|
- },
|
|
|
- {
|
|
|
- validator: (rule, value, cb) => {
|
|
|
- return uni.$u.test.mobile(value);
|
|
|
- },
|
|
|
- message: '手机号码格式不正确',
|
|
|
- trigger: ['change', 'blur'],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
+ headline: '欢迎登录车旅程!',
|
|
|
+ phone: '', //手机号码
|
|
|
+ yzm: '', //验证码
|
|
|
+ checked: [],
|
|
|
title: '',
|
|
|
- type: 'password',
|
|
|
- isChecked: true,
|
|
|
show: false,
|
|
|
- loading: false,
|
|
|
+ tips: '',
|
|
|
+ seconds: 10,
|
|
|
};
|
|
|
},
|
|
|
-
|
|
|
- onReady() {
|
|
|
- this.$refs.loginForm.setRules(this.rules);
|
|
|
- },
|
|
|
-
|
|
|
- computed: {
|
|
|
- isDisabled() {
|
|
|
- return !this.loginForm.mobile;
|
|
|
- },
|
|
|
- },
|
|
|
-
|
|
|
methods: {
|
|
|
//点击用户协议
|
|
|
- click(title) {
|
|
|
+ clickAgreement(title) {
|
|
|
this.show = true; //打开弹框
|
|
|
this.title = title; //赋值标题
|
|
|
},
|
|
|
|
|
|
- //点击用户协议弹框内的确定
|
|
|
handleConfirm() {
|
|
|
this.show = false; //关闭弹框
|
|
|
},
|
|
|
|
|
|
- //点击登录
|
|
|
- async login() {
|
|
|
- if (!this.isChecked) {
|
|
|
- this.show = true;
|
|
|
+ login() {
|
|
|
+ if (!this.phone) {
|
|
|
+ uni.showToast({ title: '请输入手机号', icon: 'none' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(this.phone)) {
|
|
|
+ uni.showToast({ title: '请输入正确手机号', icon: 'none' });
|
|
|
return;
|
|
|
}
|
|
|
- const params = {
|
|
|
- ...this.loginForm,
|
|
|
- };
|
|
|
- this.loading = true;
|
|
|
- const res = await maintainSmsCaptcha(params).catch(err => err);
|
|
|
- this.loading = false;
|
|
|
- if (res.code == 200) {
|
|
|
- this.$Router.pushTab('/pages/client/tabBar/home/index');
|
|
|
- uni.$u.toast('登录成功');
|
|
|
+ if (!this.yzm) {
|
|
|
+ uni.showToast({ title: '请输入验证码', icon: 'none' });
|
|
|
+ return;
|
|
|
}
|
|
|
+ //....此处省略,这里需要调用后台验证一下验证码是否正确,根据您的需求来
|
|
|
+ uni.showToast({ title: '登录成功!', icon: 'none' });
|
|
|
},
|
|
|
|
|
|
- //点击注册
|
|
|
- register() {
|
|
|
- this.$Router.pushTab('/pages/login/register');
|
|
|
+ codeChange(text) {
|
|
|
+ this.tips = text;
|
|
|
},
|
|
|
-
|
|
|
- //点击密码后的icon
|
|
|
- onClickPW(type) {
|
|
|
- this.type = type; //切换icon 和密码显示与否
|
|
|
+ getCode() {
|
|
|
+ console.log(this.$refs.uCode);
|
|
|
+ if (this.$refs.uCode.canGetCode) {
|
|
|
+ // 模拟向后端请求验证码
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在获取验证码',
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.hideLoading();
|
|
|
+ // 这里此提示会被this.start()方法中的提示覆盖
|
|
|
+ uni.$u.toast('验证码已发送');
|
|
|
+ // 通知验证码组件内部开始倒计时
|
|
|
+ this.$refs.uCode.start();
|
|
|
+ }, 2000);
|
|
|
+ } else {
|
|
|
+ uni.$u.toast('倒计时结束后再发送');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ end() {
|
|
|
+ uni.$u.toast('倒计时结束');
|
|
|
+ },
|
|
|
+ start() {
|
|
|
+ uni.$u.toast('倒计时开始');
|
|
|
},
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
-.container {
|
|
|
- padding: 0 40rpx;
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
- flex-direction: column;
|
|
|
-}
|
|
|
-
|
|
|
-.image {
|
|
|
- margin-top: 50rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.login-form-wrap {
|
|
|
- width: 90%;
|
|
|
- margin-top: 50rpx;
|
|
|
-
|
|
|
- .phone-question {
|
|
|
- text-align: right;
|
|
|
- font-size: 24rpx;
|
|
|
- padding: 20rpx 0 20rpx 0;
|
|
|
- }
|
|
|
-}
|
|
|
-.user-agreement {
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
- font-size: 27rpx;
|
|
|
-}
|
|
|
+@import './phoneLogin.scss';
|
|
|
</style>
|