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

@ -2,7 +2,7 @@ import request from "@/utils/request.js";
import Cache from "@/utils/cache.js"
/**
* 获取用户信息
*
*
*/
export function getUserInfo(){
return request.get('user');
@ -10,7 +10,7 @@ export function getUserInfo(){
/**
* 设置用户分享
*
*
*/
export function userShare(){
return request.post('user/share');
@ -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 });
}
/**
@ -80,7 +80,7 @@ export function postSignUser(sign) {
/**
* 获取签到配置
*
*
*/
export function getSignConfig(){
return request.get('user/sign/config')
@ -104,7 +104,7 @@ export function setSignIntegral(){
/**
* 签到列表(年月)
* @param object data
*
*
*/
export function getSignMonthList(data){
return request.get('user/sign/month',data)
@ -112,7 +112,7 @@ export function getSignMonthList(data){
/**
* 活动状态
*
*
*/
export function userActivity(){
return request.get('user/activity');
@ -133,7 +133,7 @@ export function getRecordApi(q) {
}
/*
* 提现总金额
* 提现总金额
* */
export function getCountApi() {
return request.get("extract/totalMoney");
@ -148,7 +148,7 @@ export function getIntegralList(q) {
/**
* 获取分销海报图片
*
*
*/
export function spreadBanner(data){
return request.get('user/spread/banner',data);
@ -164,7 +164,7 @@ export function spreadPeople(data){
}
/**
*
*
* 推广佣金/提现总和
* @param int type
*/
@ -181,7 +181,7 @@ export function getSpreadInfo() {
/**
*
*
* 推广订单
* @param object data
*/
@ -213,7 +213,7 @@ export function extractCash(data){
/**
* 提现银行/提现最低金额
*
*
*/
export function extractBank(){
return request.get('extract/bank');
@ -221,7 +221,7 @@ export function extractBank(){
/**
* 会员等级列表
*
*
*/
export function userLevelGrade(){
return request.get('user/level/grade');
@ -237,14 +237,14 @@ export function userLevelTask(id){
/**
* 检查用户是否可以成为会员
*
*
*/
export function userLevelDetection(){
return request.get('user/level/detection');
}
/**
*
*
* 地址列表
* @param object data
*/
@ -271,7 +271,7 @@ export function editAddress(data){
/**
* 删除地址
* @param int id
*
*
*/
export function delAddress(id){
return request.post('address/del',{id:id})
@ -279,7 +279,7 @@ export function delAddress(id){
/**
* 获取单个地址
* @param int id
* @param int id
*/
export function getAddressDetail(id){
return request.get('address/detail/'+id);
@ -301,7 +301,7 @@ export function getLogout() {
}
/**
* 小程序充值
*
*
*/
export function rechargeRoutine(data){
return request.post('recharge/routine',data)
@ -329,7 +329,7 @@ export function transferIn(data) {
/**
* 获取默认地址
*
*
*/
export function getAddressDefault(){
return request.get('address/default');
@ -374,7 +374,7 @@ export function spread(puid)
/**
* 当前用户在佣金排行第几名
*
*
*/
export function brokerageRankNumber(data)
{
@ -383,7 +383,7 @@ export function brokerageRankNumber(data)
/**
* 会员等级经验值
*
*
*/
export function getlevelInfo()
{
@ -392,7 +392,7 @@ export function getlevelInfo()
/**
* 经验值明细
*
*
*/
export function getlevelExpList(data)
{
@ -401,7 +401,7 @@ export function getlevelExpList(data)
/**
* 经验值明细
*
*
*/
export function getuserDalance()
{
@ -411,7 +411,7 @@ export function getuserDalance()
/**
* 账单记录
*
*
*/
export function getBillList(data)
{
@ -457,4 +457,4 @@ export function computeUser(){
dataType:'json',
success: (res) => {}
});
}
}

View File

@ -13,9 +13,9 @@ module.exports = {
// http://api.java.crmeb.net:20001
HTTP_REQUEST_URL:domain,
// #endif
HEADER:{
'content-type': 'application/json'
'content-type': 'application/json',
},
HEADERPARAMS:{
'content-type': 'application/x-www-form-urlencoded'

View File

@ -386,7 +386,14 @@
"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")
})
@ -392,7 +399,7 @@
this.$store.commit("LOGIN", {
'token': data.token
});
that.getUserInfo(data);
that.getUserInfo(data);
})
.catch(e => {
that.$util.Tips({
@ -422,31 +429,31 @@
}
.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;
@ -455,7 +462,7 @@
height: 68rpx;
border-radius: 50%;
}
.apple-btn {
display: flex;
align-items: center;
@ -464,85 +471,85 @@
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;
@ -552,7 +559,7 @@
justify-content: center;
align-items: center;
}
input {
flex: 1;
font-size: 28rpx;
@ -562,7 +569,7 @@
justify-content: center;
align-items: center;
}
.code {
position: absolute;
right: 30rpx;
@ -574,7 +581,7 @@
}
}
}
.logon {
display: flex;
align-items: center;
@ -587,7 +594,7 @@
color: #FFFFFF;
font-size: 30rpx;
}
.tips {
margin: 30rpx;
text-align: center;
@ -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('请求失败');