123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <view class="container">
- <view class="container_box"></view>
- <view class="loginTitle"><text>请注册。</text></view>
- <view class="login_text">
- <view class="login_input flex">
- <!-- <view class="login_img"><image src="/static/icon/img03.png"></image></view> -->
- <view class="login_name"><input class="uni-input" v-model="username" focus placeholder="请输入用户名" /></view>
- </view>
- <view class="login_input flex">
- <!-- <view class="login_img"><image src="/static/icon/img03.png"></image></view> -->
- <view class="login_name"><input class="uni-input" v-model="phone" focus placeholder="请输入手机号" /></view>
- </view>
- <view class="login_input flex">
- <!-- <view class="login_img"><image src="/static/icon/img03.png"></image></view> -->
- <view class="login_name"><input class="uni-input" v-model="email" focus placeholder="请输入邮箱" /></view>
- </view>
- <view class="login_input flex">
- <!-- <view class="login_img"><image src="/static/icon/img04.png"></image></view> -->
- <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder="请输入密码" /></view>
- </view>
- <view class="login_input flex">
- <!-- <view class="login_img"><image src="/static/icon/img04.png"></image></view> -->
- <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus placeholder="请重复输入密码" /></view>
- </view>
- <!-- <view class="login_input flex">
- <view class="login_img"><image src="/static/icon/img07.png"></image></view>
- <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
- </view> -->
- <view class="login_input flex">
- <!-- <view class="login_img"><image src="/static/icon/img06.png"></image></view> -->
- <view class="login_name flex">
- <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
- <view class="code" @click="verification">{{ countDown == 0 ? '获取验证码' : countDown }}</view>
- </view>
- </view>
- <view><button type="green" @click="register" class="uni-button uni-button-red">注册</button></view>
- <!-- <view class="forget" @click="forget">忘记密码?</view> -->
- <view class="forget" @click="login">已有账号?立即登录。</view>
- <!-- <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true" hover-class="none" @click="login">返回登录</button></view> -->
- </view>
- </view>
- </template>
- <script>
- import { register, verify } from '@/api/login.js';
- export default {
- data() {
- return {
- email: '',//邮箱
- username: '',//用户名
- phone: '', //手机号
- password: '', //密码
- repassword: '',
- invitation: '', //邀请码
- code: '', //验证码
- time: '', //保存倒计时对象
- countDown: 0 //倒计时
- };
- },
- onLoad() {},
- watch: {
- // 监听倒计时
- countDown(i) {
- if (i == 0) {
- clearInterval(this.time);
- }
- }
- },
- methods: {
- // 注册
- register() {
- let obj = this;
- if (obj.phone == '') {
- obj.$api.msg('请输入电话号码');
- return;
- }
- if (obj.phone.length != 11) {
- obj.$api.msg('请输入正确的手机号');
- return;
- }
- if (obj.password == '') {
- obj.$api.msg('请输入密码');
- return;
- }
- if (obj.repassword == '') {
- obj.$api.msg('请再次输入密码');
- return;
- }
- if (obj.repassword != obj.password) {
- obj.$api.msg('两次密码不正确');
- return;
- }
- if ((obj.invitation = '')) {
- obj.$api.msg('请输入邀请码');
- return;
- }
- if (obj.code == '') {
- obj.$api.msg('请输入验证码');
- return;
- }
- register({
- email: obj.email,
- username: obj.username,
- mobile: obj.phone, //账号
- captcha: obj.code, //验证码
- password: obj.password //密码
- }).then(function(e) {
- uni.showToast({
- title:'注册成功',
- duration:2000,
- position:'top',
- icon:'none'
- });
- setTimeout(function () {
- uni.navigateTo({
- url: '/pages/login/login'
- });
- },1000)
-
- });
- //调用注册接口,成功跳转登录页
- },
- //发送验证码
- verification() {
- let obj = this;
- if (this.phone == '') {
- this.$api.msg('请输入电话号码');
- return;
- }
- if (this.phone.length < 11) {
- this.$api.msg('请输入正确的手机号');
- return;
- }
- // 判断是否在倒计时
- if (obj.countDown > 0) {
- return false;
- } else {
- obj.countDown = 60;
- obj.time = setInterval(() => {
- obj.countDown--;
- }, 1000);
- //调用验证码接口
- verify({
- phone: obj.phone,
- type: 'VERIFICATION_CODE'
- })
- .then(({ data }) => {})
- .catch(err => {
- console.log(err);
- });
- }
- },
- login() {
- //返回登录
- uni.navigateTo({
- url: '/pages/login/login'
- });
- },
- //跳转忘记密码
- // forget() {
- // uni.navigateTo({
- // url: `/pages/public/forget`
- // });
- // },
- }
- };
- </script>
- <style>
- page {
- height: 100%;
- background-color: #FFFFFF;
- }
- .container {
- width: 100%;
- height: 100%;
- background-size: 100%;
- }
- .container_box {
- width: 100%;
- height: 200rpx;
- }
- .login_text {
- margin: auto 30rpx;
- position: relative;
- margin-top: 150rpx !important;
- }
- .login_input {
- border: 1px solid #f0f0f0;
- padding: 35rpx 25rpx;
- margin-bottom: 35rpx;
- border-radius: 15rpx;
- }
- .login_img image {
- height: 35rpx;
- width: 29rpx;
- }
- .uni-input {
- text-align: left;
- width: 100%;
- flex-shrink: 1;
- font-size: 28rpx !important;
- }
- .login_name {
- color: #333333;
- flex-grow: 1;
- padding-left: 20rpx;
- }
- .forget {
- width: 100rpx;
- font-size: 24rpx;
- color: #ffffff;
- margin: 0px auto;
- border-bottom: 1px solid #ffffff;
- }
- .width {
- width: 325rpx !important;
- }
- .code {
- color: #1B1B1B;
- font-size: 23rpx;
- border-left: 1px solid #1B1B1B;
- width: 180rpx;
- flex-shrink: 0;
- text-align: center;
- }
- uni-button {
- height: 80rpx !important;
- line-height: 80rpx !important;
- }
- .loginTitle {
- position: absolute;
- width: 100%;
- text-align: left;
- color: #333333;
- font-size: 56rpx;
- padding-left: 25rpx;
- font-weight: bold;
- }
- .uni-button-red {
- color: #FFFFFF;
- background-color:#FB4849;
- margin: 40rpx 10rpx;
- border-radius: 15rpx;
- }
- .uni-button-green-plain {
- border: 1px solid #FB4849;
- margin: 40rpx 10rpx;
- border-radius: 50rpx;
- color: #457DBF;
- background-color: #ffffff;
- }
- .uni-button {
- height: 100rpx !important;
- line-height: 100rpx !important;
- }
- .forget {
- font-size: 28rpx;
- width: 100%;
- text-align: left;
- color: #313131;
- margin-bottom: 25rpx;
- }
- .forget:hover{
- cursor: pointer;
- }
- </style>
|