feat: 新增推广员申请注册功能

pull/16/head
TianYu 2023-06-05 15:56:27 +08:00
parent 7c79be72d2
commit ba7e34e82a
10 changed files with 138 additions and 295 deletions

View File

@ -342,7 +342,7 @@ export default {
this.resetForm('form');
},
handleQRCode(row) {
const url =`${config.spreadDomain}${config.spreadLink}?redirectUrl=${config.spreadDomain}&tenantId=${row.id}`
const url =`${config.spreadDomain}${config.spreadLink}?redirectUrl=${config.spreadDomain}&tenantId=${row.id}&isProperty=1`
QRCode.toCanvas(document.getElementById(`id-${row.id}`), url, {
scale: 2
}, function (error) {

View File

@ -186,6 +186,7 @@
methods: {
async initLoad() {
this.isQRCode()
this.isProperty()
this.setSpreadId()
if (this.$store.getters.isLogin && !this.$Cache.get('USER_INFO')) {
await this.$store.dispatch('USERINFO');
@ -215,6 +216,13 @@
`${wechatUrl}&redirect_uri=${redirectUrl}/pages/member_application/index?tenantId=${tenantId}&spreadId=${spreadId}&response_type=code&scope=snsapi_base#wechat_redirect`
}
},
//
isProperty() {
const is_property = this.$route.query.isProperty || false
if(parseInt(is_property) === 1){
this.$store.commit("SET_IS_PROPERTY", !!is_property)
}
},
//
getTenantInfo() {
fetchTenantInfo(this.tenantId).then(res => {

View File

@ -59,6 +59,11 @@ export function register(data) {
return request.post("member/auth/register", data, { noAuth : true });
}
// 注册推广员
export function registerPromoter(data) {
return request.post("member/user/create", data, { noAuth : true });
}
/**
* 用户手机号修改密码
* @param data object 用户手机号 验证码 密码

View File

@ -10,6 +10,8 @@ module.exports = {
OPEN_ID: 'OPEN_ID',
// 推广员ID
SPREAD_ID: 'SPREAD_ID',
// 是否扫物业推广码
IS_PROPERTY: 'IS_PROPERTY',
//用户信息
USER_INFO: 'USER_INFO',
//租户信息

View File

@ -75,7 +75,6 @@ export function _toLogin(push, pathLogin) {
export function isWhiteList(){
let path = prePage();
console.log('path111', path)
return whiteListPage.indexOf(path) > -1
}

View File

@ -35,8 +35,10 @@
</div>
</form>
</div>
<u-button class="logon" @click="loginMobile" v-if="current !== 0" :loading="loading" loading-text="登录中" :disabled="loading"></u-button>
<u-button class="logon" @click="submit" v-if="current === 0" :loading="loading" loading-text="登录中" :disabled="loading"></u-button>
<u-button class="logon" @click="loginMobile" v-if="current !== 0" :loading="loading" loading-text=""
:disabled="loading">登录</u-button>
<u-button class="logon" @click="submit" v-if="current === 0" :loading="loading" loading-text=""
:disabled="loading">登录</u-button>
<div class="tips">
<!-- <div @click="jumpRegister"></div> -->
<div @click="current = current === 1 ? 0 : 1">{{ current === 1 ? '账号密码登录' : '短信验证码登录' }}</div>
@ -44,7 +46,7 @@
</div>
<div class="protocol-wrap">
<u-checkbox-group v-model="checked">
<u-checkbox size="30" shape="circle" activeColor="#F35981" name="同意"></u-checkbox>
<u-checkbox size="30" shape="circle" activeColor="#F35981" name="同意"></u-checkbox>
</u-checkbox-group>
<view class="text">我已阅读并同意 <span class="link" @click="onLinkUserPrivacy"></span></view>
</div>
@ -79,7 +81,9 @@
import {
VUE_APP_API_URL
} from "@/utils";
import {
mapGetters
} from 'vuex'
const BACK_URL = "login_back_url";
export default {
@ -97,6 +101,9 @@
loading: false
};
},
computed: {
...mapGetters(['isProperty'])
},
mounted: function() {
// this.getLogoImage();
},
@ -104,7 +111,7 @@
},
methods: {
onLinkUserPrivacy(){
onLinkUserPrivacy() {
uni.navigateTo({
url: '/pages/users/privacy/index'
})
@ -120,16 +127,17 @@
if (!that.mobile) return that.$util.Tips({
title: '请填写手机号码'
});
if (!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的手机号码'
});
if (!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(that.mobile))
return that.$util.Tips({
title: '请输入正确的手机号码'
});
if (!that.captcha) return that.$util.Tips({
title: '请填写验证码'
});
if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
title: '请输入正确的验证码'
});
if(that.checked.length === 0) return that.$util.Tips({
if (that.checked.length === 0) return that.$util.Tips({
title: '请勾选同意用户协议'
});
that.loading = true
@ -151,7 +159,7 @@
that.$util.Tips({
title: res
});
}).finally(()=>{
}).finally(() => {
that.loading = false
})
},
@ -161,9 +169,10 @@
if (!that.mobile) return that.$util.Tips({
title: '请填写手机号码'
});
if (!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的手机号码'
});
if (!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(that.mobile))
return that.$util.Tips({
title: '请输入正确的手机号码'
});
if (!that.captcha) return that.$util.Tips({
title: '请填写验证码'
});
@ -209,9 +218,10 @@
if (!that.mobile) return that.$util.Tips({
title: '请填写手机号码'
});
if (!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的手机号码'
});
if (!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(that.mobile))
return that.$util.Tips({
title: '请输入正确的手机号码'
});
await registerVerify(that.mobile, 1)
.then(res => {
that.$util.Tips({
@ -239,7 +249,7 @@
if (!that.password) return that.$util.Tips({
title: '请填写密码'
});
if(that.checked.length === 0) return that.$util.Tips({
if (that.checked.length === 0) return that.$util.Tips({
title: '请勾选同意用户协议'
});
that.loading = true
@ -261,7 +271,7 @@
that.$util.Tips({
title: e
});
}).finally(()=>{
}).finally(() => {
that.loading = false
})
},
@ -274,15 +284,20 @@
getUserInfo().then(res => {
this.$store.commit("UPDATE_USERINFO", res.data);
// let backUrl = this.$Cache.get(BACK_URL) || "/pages/index/index";
let backUrl = "/pages/member_application/index";
// let backUrl = "/pages/index/index";
// if (backUrl.indexOf('/pages/users/login/index') !== -1) {
// backUrl = '/pages/index/index';
// }
let backUrl = ''
if (this.isProperty && !res.data.isPromoter) {
backUrl = "/pages/users/promoter/index"
} else {
backUrl = "/pages/member_application/index"
}
uni.reLaunch({
url: backUrl
});
}).finally(()=>{
}).finally(() => {
uni.hideLoading()
})
}
@ -381,14 +396,15 @@
.login-wrapper {
padding: 30rpx 52rpx;
background: url('@/static/images/bg-linear.png') center 0 no-repeat;
background-size:100% 672rpx;
background-size: 100% 672rpx;
.logo-wrap {
margin: 185rpx 0 85rpx 0;
display:flex;
align-items:center;
img{
margin-right: 20rpx;
display: flex;
align-items: center;
img {
margin-right: 20rpx;
}
}
@ -430,6 +446,7 @@
margin-bottom: 38rpx;
height: 98rpx;
display: flex;
&:last-child {
margin-bottom: 0;
}
@ -498,14 +515,16 @@
justify-content: space-between;
}
.protocol-wrap{
margin: 131rpx 0 80rpx 0;
.protocol-wrap {
margin: 131rpx 0 80rpx 0;
display: flex;
justify-content: center;
.text{
.text {
font-size: 24rpx;
color: #000;
.link{
.link {
color: #F35981;
}
}

View File

@ -4,291 +4,83 @@
<img src="/static/images/mallLogo.png" style="width:105rpx;height:105rpx;"></image>
<img src="/static/images/mall.png" style="width:233rpx;height:43rpx;"></image>
</div>
<view class="title">登录</view>
<view class="title">注册推广员</view>
<div class="whiteBg">
<div class="list">
<form @submit.prevent="submit">
<div class="item">
<div class="acea-row row-middle" v-if="current === 0">
<image src="/static/images/user_1.png" style="width: 40rpx; height: 40rpx;"></image>
<input type="text" class="texts" placeholder="请输入您的账号" v-model="mobile" required />
</div>
<div class="acea-row row-middle" v-else>
<image src="/static/images/phone_2.png" style="width: 40rpx; height: 40rpx;"></image>
<input type="text" class="texts" placeholder="请输入您的手机号" v-model="mobile" required />
<div class="acea-row row-middle">
<text class="label">所属公司</text>
<input type="text" disabled class="texts" :value="tenantInfo.name"/>
</div>
</div>
<div class="item" v-if="current === 0">
<div class="item">
<div class="acea-row row-middle">
<image src="/static/images/code_3.png" style="width: 40rpx; height: 40rpx;"></image>
<input type="password" class="texts" placeholder="填写登录密码" v-model="password" required />
<text class="label">手机号</text>
<input type="text" class="texts" :value="userInfo.mobile" disabled />
</div>
</div>
<div class="item" v-else>
<div class="item">
<div class="acea-row row-middle">
<image src="/static/images/code_4.png" style="width: 40rpx; height: 40rpx;"></image>
<input type="text" maxlength="6" placeholder="请输入您的验证码" class="texts" v-model="captcha" />
<text class="label">姓名</text>
<input type="text" v-model="nickname" class="texts" placeholder="请输入" />
</div>
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">
{{ text }}
</button>
</div>
</form>
</div>
<u-button class="logon" @click="loginMobile" v-if="current !== 0" :loading="loading" loading-text="登录中" :disabled="loading"></u-button>
<u-button class="logon" @click="submit" v-if="current === 0" :loading="loading" loading-text="登录中" :disabled="loading"></u-button>
<div class="tips">
<!-- <div @click="jumpRegister"></div> -->
<div @click="current = current === 1 ? 0 : 1">{{ current === 1 ? '账号密码登录' : '短信验证码登录' }}</div>
<div @click="jumpRetrievePassword"></div>
</div>
<div class="protocol-wrap">
<u-checkbox-group v-model="checked">
<u-checkbox size="30" shape="circle" activeColor="#F35981" name="同意"></u-checkbox>
</u-checkbox-group>
<view class="text">我已阅读并同意 <span class="link" @click="onLinkUserPrivacy"></span></view>
</div>
<button class="logon" @click="onRegister" :disabled="loading" :loading="loading">注册推广员</button>
</div>
<div class="bottom"></div>
</div>
</template>
<script>
import dayjs from "@/plugin/dayjs/dayjs.min.js";
import sendVerifyCode from "@/mixins/SendVerifyCode";
import {
loginH5,
loginMobile,
registerVerify,
register,
// getCodeApi,
getUserInfo
} from "@/api/user";
import attrs, {
required,
alpha_num,
chs_phone
} from "@/utils/validate";
mapGetters
} from 'vuex'
import {
validatorDefaultCatch
} from "@/utils/dialog";
import {
getLogo,
appAuth,
appleLogin
} from "@/api/public";
import {
VUE_APP_API_URL
} from "@/utils";
const BACK_URL = "login_back_url";
registerPromoter
} from "@/api/user"
export default {
name: "Login",
mixins: [sendVerifyCode],
data: function() {
name: 'Register',
data() {
return {
current: 1,
mobile: "",
password: "",
captcha: "",
type: "login",
logoUrl: "",
checked: [],
loading: false
};
loading: false,
nickname: ''
}
},
mounted: function() {
// this.getLogoImage();
},
onLoad() {
computed: {
...mapGetters(['tenantInfo', 'userInfo'])
},
methods: {
onLinkUserPrivacy(){
uni.navigateTo({
url: '/pages/users/privacy/index'
})
},
async getLogoImage() {
let that = this;
getLogo().then(res => {
that.logoUrl = res.data.logoUrl ? res.data.logoUrl : '/static/images/logo2.png';
});
},
async loginMobile() {
let that = this;
if (!that.mobile) return that.$util.Tips({
title: '请填写手机号码'
});
if (!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的手机号码'
});
if (!that.captcha) return that.$util.Tips({
title: '请填写验证码'
});
if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
title: '请输入正确的验证码'
});
if(that.checked.length === 0) return that.$util.Tips({
title: '请勾选同意用户协议'
});
that.loading = true
loginMobile({
mobile: that.mobile,
code: that.captcha,
spread_spid: that.$Cache.get("spread")
async onRegister() {
this.loading = true
try {
const res = await registerPromoter({
nickname: this.nickname,
mobile: this.userInfo.mobile,
status: 1,
sourceType: 2
})
.then(res => {
let data = res.data;
let newTime = Math.round(new Date() / 1000);
this.$store.commit("LOGIN", {
'token': res.data.accessToken,
'refreshToken': res.data.refreshToken
});
that.getUserInfo(data);
this.$util.Tips({
title: res.code === 0 ? '注册成功' : res.msg
}, {
tab: 1,
url: '/pages/member_application/index'
})
.catch(res => {
that.$util.Tips({
title: res
});
}).finally(()=>{
that.loading = false
} catch (err) {
//TODO handle the exception
this.$util.Tips({
title: err
})
},
async register() {
let that = this;
if (!that.mobile) return that.$util.Tips({
title: '请填写手机号码'
});
if (!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的手机号码'
});
if (!that.captcha) return that.$util.Tips({
title: '请填写验证码'
});
if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
title: '请输入正确的验证码'
});
if (!that.password) return that.$util.Tips({
title: '请填写密码'
});
if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/i.test(that.password)) return that.$util.Tips({
title: '您输入的密码过于简单'
});
register({
mobile: that.mobile,
captcha: that.captcha,
password: that.password,
spread: that.$Cache.get("spread")
})
.then(res => {
that.$util.Tips({
title: res
});
that.formItem = 1;
})
.catch(res => {
that.$util.Tips({
title: res
});
});
},
jumpRegister() {
uni.navigateTo({
url: '/pages/users/register/index'
})
},
jumpRetrievePassword() {
uni.navigateTo({
url: '/pages/users/retrievePassword/index'
})
},
async code() {
let that = this;
if (!that.mobile) return that.$util.Tips({
title: '请填写手机号码'
});
if (!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的手机号码'
});
await registerVerify(that.mobile, 1)
.then(res => {
that.$util.Tips({
title: res.message
});
that.sendCode();
})
.catch(err => {
return that.$util.Tips({
title: err
});
})
},
navTap: function(index) {
this.current = index;
},
async submit() {
let that = this;
if (!that.mobile) return that.$util.Tips({
title: '请填写账号'
});
if (!/^[\w\d]{5,16}$/i.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的账号'
});
if (!that.password) return that.$util.Tips({
title: '请填写密码'
});
if(that.checked.length === 0) return that.$util.Tips({
title: '请勾选同意用户协议'
});
that.loading = true
loginH5({
mobile: that.mobile,
password: that.password,
spread: that.$Cache.get("spread")
})
.then(({
data
}) => {
this.$store.commit("LOGIN", {
'token': data.accessToken,
'refreshToken': data.refreshToken
});
that.getUserInfo(data);
})
.catch(e => {
that.$util.Tips({
title: e
});
}).finally(()=>{
that.loading = false
})
},
getUserInfo(data) {
uni.showLoading({
title: '正在获取用户信息...',
mask: true
})
this.$store.commit("SETUID", data.userId);
getUserInfo().then(res => {
this.$store.commit("UPDATE_USERINFO", res.data);
// let backUrl = this.$Cache.get(BACK_URL) || "/pages/index/index";
let backUrl = "/pages/member_application/index";
// let backUrl = "/pages/index/index";
// if (backUrl.indexOf('/pages/users/login/index') !== -1) {
// backUrl = '/pages/index/index';
// }
uni.reLaunch({
url: backUrl
});
}).finally(()=>{
uni.hideLoading()
})
} finally {
this.loading = false
}
}
}
};
}
</script>
<style lang="scss" scoped>
page {
background: #fff;
@ -420,7 +212,6 @@
}
.whiteBg {
margin-top: 46rpx;
.list {
@ -430,6 +221,7 @@
margin-bottom: 38rpx;
height: 98rpx;
display: flex;
&:last-child {
margin-bottom: 0;
}
@ -453,6 +245,14 @@
border: 1px solid #BFBFBF;
border-radius: 15rpx;
flex: 1;
&.clear{
border: 0;
}
.label{
width: 120rpx;
margin-right: 20rpx;
}
.texts {
flex: 1;
@ -473,6 +273,7 @@
justify-content: center;
align-items: center;
}
}
}
}
@ -483,29 +284,32 @@
justify-content: center;
width: 100%;
height: 87rpx;
margin-top: 137rpx;
margin-top: 99rpx;
color: #FFFFFF;
font-size: 32rpx;
background: linear-gradient(0deg, #E63163 0%, #FF819F 100%);
border-radius: 44rpx;
font-size: 30rpx;
}
.tips {
margin: 60rpx 20rpx 0 20rpx;
margin: 125rpx 20rpx 0 20rpx;
font-size: 24rpx;
color: #000;
display: flex;
justify-content: space-between;
}
.protocol-wrap{
margin: 131rpx 0 80rpx 0;
.protocol-wrap {
margin: 131rpx 0 80rpx 0;
display: flex;
justify-content: center;
.text{
.text {
font-size: 24rpx;
color: #000;
.link{
.link {
color: #F35981;
}
}

View File

@ -1,8 +1,8 @@
<template>
<view class="register-success-wrap">
<image src="@/static/images/logo.png" class="icon"></image>
<image src="@/static/images/mallLogo.png" class="icon"></image>
<view class="text">恭喜您注册成功</view>
<u-button class="logon" @click="onBackLogin"></u-button>
<u-button class="logon" @click="onBackLogin"></u-button>
</view>
</template>
@ -16,7 +16,7 @@
methods: {
onBackLogin() {
uni.navigateTo({
url: '/pages/users/login/index'
url: '/pages/member_application/index'
})
}
}
@ -53,4 +53,4 @@
border-radius: 44rpx;
}
}
</style>
</style>

View File

@ -8,6 +8,7 @@ export default {
tenantId: state => state.app.tenantId,
openId: state => state.app.openId,
spreadId: state => state.app.spreadId,
isProperty: state => state.app.isProperty,
homeActive: state => state.app.homeActive,
home: state => state.app.home,
chatUrl: state => state.app.chatUrl,

View File

@ -6,6 +6,7 @@ import {
REFRESH_TOKEN,
UID,
TENANT_ID,
IS_PROPERTY,
OPEN_ID,
SPREAD_ID,
PLATFORM
@ -26,6 +27,7 @@ const state = {
tenantId: Cache.get(TENANT_ID) || '',
spreadId: Cache.get(SPREAD_ID) || '',
openId: Cache.get(OPEN_ID) || '',
isProperty: false,
homeActive: false,
chatUrl: Cache.get('chatUrl') || '',
systemPlatform: Cache.get(PLATFORM)?Cache.get(PLATFORM):'',
@ -62,6 +64,9 @@ const mutations = {
UPDATE_LOGIN(state, token) {
state.token = token;
},
SET_IS_PROPERTY(state, value){
state.isProperty = value
},
LOGOUT(state) {
state.token = undefined;
state.uid = undefined