feat: 增加注册页面

pull/2/head
TianYu 2023-05-15 18:19:03 +08:00
parent 927568c0d9
commit a32c7378d6
6 changed files with 381 additions and 84 deletions

View File

@ -21,7 +21,7 @@ export function userShare(){
* @param data object 用户账号密码
*/
export function loginH5(data) {
return request.post("login", data, { noAuth : true });
return request.post("member/auth/login", data, { noAuth : true });
}
/**
@ -29,7 +29,7 @@ export function loginH5(data) {
* @param data object 用户手机号 也只能
*/
export function loginMobile(data) {
return request.post("login/mobile", data, { noAuth : true });
return request.post("member/auth/sms-login", data, { noAuth : true });
}
/**
@ -44,7 +44,7 @@ export function getCodeApi() {
* @param data object 用户手机号
*/
export function registerVerify(phone){
return request.post('sendCode', { phone: phone },{noAuth:true},1)
return request.post('member/auth/send-sms-code', { mobile: phone, scene: 4 },{noAuth:true},1)
}
/**
@ -52,7 +52,7 @@ export function registerVerify(phone){
* @param data object 用户手机号 验证码 密码
*/
export function register(data) {
return request.post("register", data, { noAuth : true });
return request.post("member/auth/register", data, { noAuth : true });
}
/**

View File

@ -15,7 +15,7 @@ module.exports = {
// #endif
HEADER:{
'content-type': 'application/json'
'content-type': 'application/json',
},
HEADERPARAMS:{
'content-type': 'application/x-www-form-urlencoded'

View File

@ -386,6 +386,13 @@
"navigationBarTitleText": "绑定手机号",
"navigationStyle": "custom"
}
},
{
"path": "register/index",
"style": {
"navigationBarTitleText": "注册",
"navigationStyle": "custom"
}
}
]
},

View File

@ -11,7 +11,7 @@
<div class="item">
<div class="acea-row row-middle">
<image src="/static/images/phone_1.png" style="width: 24rpx; height: 34rpx;"></image>
<input type="text" class="texts" placeholder="输入手机号码" v-model="account" required/>
<input type="text" class="texts" placeholder="输入手机号码" v-model="mobile" required/>
</div>
</div>
<div class="item">
@ -26,7 +26,7 @@
<div class="item">
<div class="acea-row row-middle">
<image src="/static/images/phone_1.png" style="width: 24rpx; height: 34rpx;"></image>
<input type="text" class="texts" placeholder="输入手机号码" v-model="account" />
<input type="text" class="texts" placeholder="输入手机号码" v-model="mobile" />
</div>
</div>
<div class="item">
@ -49,6 +49,7 @@
<div class="logon" @click="loginMobile" v-if="current !== 0"></div>
<div class="logon" @click="submit" v-if="current === 0"></div>
<div class="tips">
<div @click="jumpRegister"></div>
<div v-if="current==0" @click="current = 1"></div>
<div v-if="current==1" @click="current = 0"></div>
</div>
@ -91,7 +92,7 @@
return {
navList: ["快速登录", "账号登录"],
current: 1,
account: "",
mobile: "",
password: "",
captcha: "",
formItem: 1,
@ -136,7 +137,7 @@
//
appleLogin() {
let self = this
this.account = ''
this.mobile = ''
this.captcha = ''
uni.showLoading({
title: '登录中'
@ -200,7 +201,7 @@
// App
wxLogin() {
let self = this
this.account = ''
this.mobile = ''
this.captcha = ''
uni.showLoading({
title: '登录中'
@ -278,10 +279,10 @@
},
async loginMobile() {
let that = this;
if (!that.account) return that.$util.Tips({
if (!that.mobile) return that.$util.Tips({
title: '请填写手机号码'
});
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的手机号码'
});
if (!that.captcha) return that.$util.Tips({
@ -291,8 +292,8 @@
title: '请输入正确的验证码'
});
loginMobile({
phone: that.account,
captcha: that.captcha,
mobile: that.mobile,
code: that.captcha,
spread_spid: that.$Cache.get("spread")
})
.then(res => {
@ -310,11 +311,12 @@
});
},
async register() {
let that = this;
if (!that.account) return that.$util.Tips({
if (!that.mobile) return that.$util.Tips({
title: '请填写手机号码'
});
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的手机号码'
});
if (!that.captcha) return that.$util.Tips({
@ -330,7 +332,7 @@
title: '您输入的密码过于简单'
});
register({
account: that.account,
mobile: that.mobile,
captcha: that.captcha,
password: that.password,
spread: that.$Cache.get("spread")
@ -347,16 +349,21 @@
});
});
},
jumpRegister(){
uni.navigateTo({
url: '/pages/users/register/index'
})
},
async code() {
let that = this;
if (!that.account) return that.$util.Tips({
if (!that.mobile) return that.$util.Tips({
title: '请填写手机号码'
});
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的手机号码'
});
if (that.formItem == 2) that.type = "register";
await registerVerify(that.account)
await registerVerify(that.mobile)
.then(res => {
that.$util.Tips({title:res.message});
that.sendCode();
@ -372,17 +379,17 @@
},
async submit() {
let that = this;
if (!that.account) return that.$util.Tips({
if (!that.mobile) return that.$util.Tips({
title: '请填写账号'
});
if (!/^[\w\d]{5,16}$/i.test(that.account)) return that.$util.Tips({
if (!/^[\w\d]{5,16}$/i.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的账号'
});
if (!that.password) return that.$util.Tips({
title: '请填写密码'
});
loginH5({
account: that.account,
mobile: that.mobile,
password: that.password,
spread: that.$Cache.get("spread")
})
@ -596,3 +603,4 @@
}
}
</style>

View File

@ -0,0 +1,281 @@
<template>
<div class="login-wrapper">
<div class="shading">
<!-- <image :src="logoUrl"/> -->
<image :src="logoUrl" />
<!-- <image src="/static/images/logo2.png" v-if="!logoUrl" /> -->
</div>
<div class="whiteBg">
<div class="list">
<form @submit.prevent="submit">
<div class="item">
<div class="acea-row row-middle">
<image src="/static/images/phone_1.png" style="width: 24rpx; height: 34rpx;"></image>
<input type="text" class="texts" placeholder="请输入姓名" v-model="registerForm.realName" required />
</div>
</div>
<div class="item">
<div class="acea-row row-middle">
<image src="/static/images/phone_1.png" style="width: 28rpx; height: 32rpx;"></image>
<input type="text" class="texts" placeholder="请输入手机号" v-model="registerForm.mobile" required />
</div>
</div>
<div class="item">
<div class="acea-row row-middle">
<image src="/static/images/code_2.png" style="width: 28rpx; height: 32rpx;"></image>
<input type="text" placeholder="填写验证码" class="codeIput" v-model="registerForm.code" />
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">
{{ text }}
</button>
</div>
</div>
</form>
</div>
<button class="logon" @click="onRegister" :disabled="loading" :loading="loading">注册</button>
</div>
<div class="bottom"></div>
</div>
</template>
<script>
import sendVerifyCode from "@/mixins/SendVerifyCode"
import {
registerVerify,
register
} from "@/api/user"
export default {
name: 'Register',
mixins: [sendVerifyCode],
data() {
return {
logoUrl: '',
loading: false,
registerForm: {
realName: '',
mobile: '',
code: ''
}
}
},
methods: {
async onRegister() {
this.loading = true
try {
const res = await register(this.registerForm)
this.$util.Tips({
title: res.code === 0 ? '注册成功' : res.msg
}, '/pages/users/login/index')
} catch (err) {
//TODO handle the exception
this.$util.Tips({
title: err
})
} finally {
this.loading = false
}
},
async code() {
if (!this.registerForm.mobile) return this.$util.Tips({
title: '请填写手机号码'
});
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.registerForm.mobile)) return this.$util.Tips({
title: '请输入正确的手机号码'
});
await registerVerify(this.registerForm.mobile)
.then(res => {
this.$util.Tips({
title: res.message
});
this.sendCode();
})
.catch(err => {
return this.$util.Tips({
title: err
});
});
},
}
}
</script>
<style lang="scss" scoped>
page {
background: #fff;
}
.appLogin {
margin-top: 60rpx;
.hds {
display: flex;
justify-content: center;
align-items: center;
font-size: 24rpx;
color: #B4B4B4;
.line {
width: 68rpx;
height: 1rpx;
background: #CCCCCC;
}
p {
margin: 0 20rpx;
}
}
.btn-wrapper {
display: flex;
align-items: center;
justify-content: center;
margin-top: 30rpx;
.btn {
display: flex;
align-items: center;
justify-content: center;
width: 68rpx;
height: 68rpx;
border-radius: 50%;
}
.apple-btn {
display: flex;
align-items: center;
justify-content: center;
margin-left: 30rpx;
background: #000;
border-radius: 34rpx;
font-size: 40rpx;
.icon-s-pingguo {
color: #fff;
font-size: 40rpx;
}
}
.iconfont {
font-size: 40rpx;
color: #fff;
}
.wx {
margin-right: 30rpx;
background-color: #61C64F;
}
.mima {
background-color: #28B3E9;
}
.yanzheng {
background-color: #F89C23;
}
}
}
.code img {
width: 100%;
height: 100%;
}
.acea-row.row-middle {
input {
margin-left: 20rpx;
display: block;
}
}
.login-wrapper {
padding: 30rpx;
.shading {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
/* #ifdef APP-VUE */
margin-top: 50rpx;
/* #endif */
/* #ifndef APP-VUE */
margin-top: 200rpx;
/* #endif */
image {
width: 180rpx;
height: 180rpx;
}
}
.whiteBg {
margin-top: 100rpx;
.list {
border-radius: 16rpx;
overflow: hidden;
.item {
border-bottom: 1px solid #F0F0F0;
background: #fff;
.row-middle {
position: relative;
padding: 16rpx 45rpx;
.texts {
flex: 1;
font-size: 28rpx;
height: 80rpx;
line-height: 80rpx;
display: flex;
justify-content: center;
align-items: center;
}
input {
flex: 1;
font-size: 28rpx;
height: 80rpx;
line-height: 80rpx;
display: flex;
justify-content: center;
align-items: center;
}
.code {
position: absolute;
right: 30rpx;
top: 50%;
color: $theme-color;
font-size: 26rpx;
transform: translateY(-50%);
}
}
}
}
.logon {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 86rpx;
margin-top: 80rpx;
background-color: $theme-color;
border-radius: 120rpx;
color: #FFFFFF;
font-size: 30rpx;
}
.tips {
margin: 30rpx;
text-align: center;
color: #999;
}
}
}
</style>

View File

@ -19,9 +19,10 @@ function baseRequest(url, method, data, {
noVerify = false
}, params) {
let Url = HTTP_REQUEST_URL,header = HEADER
if (params != undefined) {
header = HEADERPARAMS;
}
// if (params != undefined) {
// header = HEADERPARAMS;
// }
header['tenant-id'] = 1
if (!noAuth) {
//登录过期自动登录
if (!store.state.app.token && !checkLogin()) {
@ -34,20 +35,20 @@ function baseRequest(url, method, data, {
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
return new Promise((reslove, reject) => {
uni.request({
url: Url + '/api/front/' + url,
url: Url + '/app-api/' + url,
method: method || 'GET',
header: header,
data: data || {},
success: (res) => {
if (noVerify)
reslove(res.data, res);
else if (res.data.code == 200)
else if (res.data.code == 0)
reslove(res.data, res);
else if ([410000, 410001, 410002, 401].indexOf(res.data.code) !== -1) {
toLogin();
reject(res.data);
} else
reject(res.data.message || '系统错误');
reject(res.data.msg || '系统错误');
},
fail: (msg) => {
reject('请求失败');