Browse Source

注册接口

master
lucky 5 years ago
parent
commit
185f45b36d
  1. 19
      src/App.vue
  2. 21
      src/components/HeadNav/HeadNav.vue
  3. 35
      src/components/User/MechanismSignUp.vue
  4. 37
      src/components/User/PersonalSignUp.vue
  5. 3
      src/config/api.js
  6. 13
      src/views/User/Login.vue
  7. 16
      src/views/User/Register.vue
  8. 4
      src/views/User/mixin.js

19
src/App.vue

@ -33,16 +33,15 @@ export default {
window.scroll(0, 0); window.scroll(0, 0);
}, },
created() { created() {
console.log('process.env ', process.env); // const userId = '1218763410024566784';
const userId = '1218763410024566784'; // const params = { userId };
const params = { userId }; // this.getUserId(params);
this.getUserId(params); // if (sessionStorage.getItem('store')) {
if (sessionStorage.getItem('store')) { // this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store'))));
this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store')))); // }
} // window.addEventListener('beforeunload', () => {
window.addEventListener('beforeunload', () => { // sessionStorage.setItem('store', JSON.stringify(this.$store.state));
sessionStorage.setItem('store', JSON.stringify(this.$store.state)); // });
});
}, },
methods: { ...mapActions('user', ['getUserId']) }, methods: { ...mapActions('user', ['getUserId']) },

21
src/components/HeadNav/HeadNav.vue

@ -36,15 +36,16 @@
type="shopping-cart" type="shopping-cart"
/> />
</a-tooltip> </a-tooltip>
<router-link tag="span" to="/login"> <router-link tag="span" to="/login" v-if="!nickName">
<a-icon class="icon-head pointer" style="right: 50px" type="user" /> <a-icon class="icon-head pointer" style="right: 50px" type="user" />
</router-link> </router-link>
<div class="icon-head" v-else>{{ nickName }}</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { mapMutations } from 'vuex'; import { mapState, mapMutations } from 'vuex';
export default { export default {
data() { data() {
return { return {
@ -188,6 +189,22 @@ export default {
], ],
}; };
}, },
computed: {
...mapState('user', ['anyringToken', 'user']),
nickName() {
const anyringToken = sessionStorage.getItem('anyringToken');
const user = JSON.parse(sessionStorage.getItem('user'));
if (anyringToken) {
if (user.wxInfo && user.wxInfo.nickname) {
return user.wxInfo.nickname;
}
return user.account;
}
return '';
},
},
methods: { methods: {
jumUrl(url) { jumUrl(url) {
if (this.$route.path !== url) { if (this.$route.path !== url) {

35
src/components/User/MechanismSignUp.vue

@ -40,7 +40,7 @@
label="统一社会信用代码或组织机构代码" label="统一社会信用代码或组织机构代码"
required required
> >
<a-input v-decorator="['code']" /> <a-input v-decorator="['code1']" />
</a-form-item> </a-form-item>
<a-form-item <a-form-item
:label-col="formItemLayout.labelCol" :label-col="formItemLayout.labelCol"
@ -125,7 +125,7 @@
:wrapper-col="formItemLayout.wrapperCol" :wrapper-col="formItemLayout.wrapperCol"
label="来源" label="来源"
> >
<a-select placeholder="请选择来源" v-decorator="['source']"> <a-select placeholder="请选择来源" v-decorator="['source', {initialValue: source }]">
<a-select-option value="1">绿谷</a-select-option> <a-select-option value="1">绿谷</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
@ -155,6 +155,7 @@
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import mixin from 'views/User/mixin'; import mixin from 'views/User/mixin';
import { saveUserMes } from '@/config/api';
const formItemLayout = { const formItemLayout = {
labelCol: { span: 6 }, labelCol: { span: 6 },
@ -175,6 +176,8 @@ export default {
form: this.$form.createForm(this, { name: 'mechanismSignUp' }), form: this.$form.createForm(this, { name: 'mechanismSignUp' }),
phone: '', phone: '',
codeNum: '', codeNum: '',
source: '1',
info: null,
}; };
}, },
@ -218,11 +221,11 @@ export default {
if (!err) { if (!err) {
console.log('Received values of form: ', values); console.log('Received values of form: ', values);
try { try {
const { account, password, phone, smsCode, source } = values; const { account, nature, fullName, code1, password, phone, smsCode, source } = values;
this.info = values;
const params = { account, password, phone, smsCode, source }; const params = { account, password, phone, smsCode, source };
console.log('params: ', params);
await this.signUp(params); await this.signUp(params);
// TODO: this.saveUserMes();
} catch (error) { } catch (error) {
console.log(`mechanismSignUp.vue methods handleSignUp: ${error}`); console.log(`mechanismSignUp.vue methods handleSignUp: ${error}`);
} }
@ -230,6 +233,28 @@ export default {
}); });
return; return;
}, },
//
async saveUserMes() {
try {
const { account, nature, fullName, code1, password, phone, smsCode, source } = this.info;
console.log('this.info: ', this.info);
const params = { code: code1, companyName: fullName, mold: nature, name: account, nickname: '', phone, type: 2 };
console.log('params: ', params);
const res = await saveUserMes(params);
const { code, msg, data } = res.data;
if (code === 200) {
// //
const { query } = this.$route;
this.$router.replace({ path: '/', query });
} else {
message.error(msg || '注册失败');
throw msg;
}
} catch (error) {
console.log(`mechanismSignUp.vue methods saveUserMes: ${error}`);
}
},
}, },
}; };
</script> </script>

37
src/components/User/PersonalSignUp.vue

@ -105,7 +105,7 @@
:wrapper-col="formItemLayout.wrapperCol" :wrapper-col="formItemLayout.wrapperCol"
label="来源" label="来源"
> >
<a-select placeholder="请选择来源" v-decorator="['source']"> <a-select placeholder="请选择来源" v-decorator="['source', {initialValue: source }]">
<a-select-option value="1">绿谷</a-select-option> <a-select-option value="1">绿谷</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
@ -135,6 +135,7 @@
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import mixin from 'views/User/mixin'; import mixin from 'views/User/mixin';
import { saveUserMes } from '@/config/api';
const formItemLayout = { const formItemLayout = {
labelCol: { span: 6 }, labelCol: { span: 6 },
@ -155,6 +156,8 @@ export default {
form: this.$form.createForm(this, { name: 'personalSignUp' }), form: this.$form.createForm(this, { name: 'personalSignUp' }),
phone: '', phone: '',
codeNum: '', codeNum: '',
source: '1',
info: null,
}; };
}, },
@ -184,7 +187,7 @@ export default {
verificationCodeId: this.picCode.verificationCodeId, verificationCodeId: this.picCode.verificationCodeId,
verificationCodeValue: this.codeNum, verificationCodeValue: this.codeNum,
}; };
await this.sendCode(params); // await this.sendCode(params);
this.getCodeInterval(); this.getCodeInterval();
} catch (error) { } catch (error) {
throw new Error(`personalSignUp.vue method getCode: ${error}`); throw new Error(`personalSignUp.vue method getCode: ${error}`);
@ -198,13 +201,11 @@ export default {
if (!err) { if (!err) {
console.log('Received values of form: ', values); console.log('Received values of form: ', values);
try { try {
const { account, password, phone, smsCode, source } = values; const { account, nickname, password, phone, smsCode, source } = values;
this.info = values;
const params = { account, password, phone, smsCode, source }; const params = { account, password, phone, smsCode, source };
console.log('params: ', params);
await this.signUp(params); await this.signUp(params);
// this.saveUserMes();
const { query } = this.$route;
this.$router.replace({ path: '/', query });
} catch (error) { } catch (error) {
console.log(`personalSignUp.vue methods handleSignUp: ${error}`); console.log(`personalSignUp.vue methods handleSignUp: ${error}`);
} }
@ -212,6 +213,28 @@ export default {
}); });
return; return;
}, },
//
async saveUserMes() {
try {
const { account, nickname, password, phone, smsCode, source } = this.info;
console.log('this.info: ', this.info);
const params = { name: account, nickname, phone, type: 1 };
console.log('params: ', params);
const res = await saveUserMes(params);
const { code, msg, data } = res.data;
if (code === 200) {
// //
const { query } = this.$route;
this.$router.replace({ path: '/', query });
} else {
message.error(msg || '注册失败');
throw msg;
}
} catch (error) {
console.log(`personalSignUp.vue methods saveUserMes: ${error}`);
}
},
}, },
}; };
</script> </script>

3
src/config/api.js

@ -22,6 +22,9 @@ const tutorRelated = `${greenvalley}/tutorRelated`; // 导师相关接口
// websocket基础地址 // websocket基础地址
export const WS_BASE_URL = msgUrl; export const WS_BASE_URL = msgUrl;
// 登陆人信息保存
export const saveUserMes = params => axios.post(`${greenvalley}/userMes/saveUserMes`, params);
// 查询政策列表 // 查询政策列表
export const selLikePolicy = params => axios.post(`${policy}/selLikePolicy`, params); export const selLikePolicy = params => axios.post(`${policy}/selLikePolicy`, params);

13
src/views/User/Login.vue

@ -84,7 +84,7 @@
>获取验证码</a-button> >获取验证码</a-button>
</div> </div>
</a-form-item> </a-form-item>
<a-form-item <!-- <a-form-item
:label-col="formItemLayout.labelCol" :label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol" :wrapper-col="formItemLayout.wrapperCol"
label="来源" label="来源"
@ -92,7 +92,7 @@
<a-select placeholder="请选择来源" v-decorator="['source']"> <a-select placeholder="请选择来源" v-decorator="['source']">
<a-select-option value="1">绿谷</a-select-option> <a-select-option value="1">绿谷</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>-->
<div class="d-flex flex-row-reverse"> <div class="d-flex flex-row-reverse">
<a-button block class="my-5" html-type="submit" style="width: 75%" type="primary">现在登录</a-button> <a-button block class="my-5" html-type="submit" style="width: 75%" type="primary">现在登录</a-button>
@ -141,7 +141,7 @@
v-decorator="['credential', { rules: passwordRules }]" v-decorator="['credential', { rules: passwordRules }]"
/> />
</a-form-item> </a-form-item>
<a-form-item <!-- <a-form-item
:label-col="formItemLayout.labelCol" :label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol" :wrapper-col="formItemLayout.wrapperCol"
label="来源" label="来源"
@ -149,7 +149,7 @@
<a-select placeholder="请选择来源" v-decorator="['source']"> <a-select placeholder="请选择来源" v-decorator="['source']">
<a-select-option value="1">绿谷</a-select-option> <a-select-option value="1">绿谷</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>-->
<div class="d-flex flex-row-reverse"> <div class="d-flex flex-row-reverse">
<a-button block class="my-5" html-type="submit" style="width: 75%" type="primary">现在登录</a-button> <a-button block class="my-5" html-type="submit" style="width: 75%" type="primary">现在登录</a-button>
</div> </div>
@ -244,10 +244,9 @@ export default {
if (!err) { if (!err) {
console.log('Received values of form: ', values); console.log('Received values of form: ', values);
try { try {
const { identifier, credential, source } = values; const { identifier, credential } = values;
const { type } = this; const { type } = this;
const params = { data: { identifier, credential, source }, type, client: SIGN_IN_CLIENTS.h5 }; const params = { data: { identifier, credential, source: 1 }, type, client: SIGN_IN_CLIENTS.h5 };
console.log('params: ', params);
await this.signIn(params); await this.signIn(params);
// //
const { query } = this.$route; const { query } = this.$route;

16
src/views/User/Register.vue

@ -3,11 +3,21 @@
<div class="d-flex flex-column box1"> <div class="d-flex flex-column box1">
<!-- 切换注册方式 --> <!-- 切换注册方式 -->
<div class="d-flex justify-center my-4"> <div class="d-flex justify-center my-4">
<a-button :class="type === 1 ? 'baseColor ' : 'textColor'" @click="type = 1" class="d-flex flex-column" type="link"> <a-button
:class="type === 1 ? 'baseColor ' : 'textColor'"
@click="type = 1"
class="d-flex flex-column"
type="link"
>
<span>个人注册</span> <span>个人注册</span>
<div class="head-top mt-1" v-if="type === 1"></div> <div class="head-top mt-1" v-if="type === 1"></div>
</a-button> </a-button>
<a-button :class="type === 3 ? 'baseColor ' : 'textColor'" @click="type = 3" class="d-flex flex-column" type="link"> <a-button
:class="type === 3 ? 'baseColor ' : 'textColor'"
@click="type = 3"
class="d-flex flex-column"
type="link"
>
<span>机构注册</span> <span>机构注册</span>
<div class="head-top mt-1" v-if="type === 3"></div> <div class="head-top mt-1" v-if="type === 3"></div>
</a-button> </a-button>
@ -34,7 +44,7 @@ const formTailLayout = {
export default { export default {
name: 'Register', name: 'Register',
components: { personalSignUp, mechanismSignUp }, components: { PersonalSignUp, MechanismSignUp },
data() { data() {
return { return {
formItemLayout, formItemLayout,

4
src/views/User/mixin.js

@ -7,9 +7,7 @@ const mixin = {
{ required: true, message: '请输入验证码' }, { required: true, message: '请输入验证码' },
{ min: 4, max: 4, message: '请输入4位短信验证码' }, { min: 4, max: 4, message: '请输入4位短信验证码' },
], ],
passwordRules: [ passwordRules: [{ required: true, pattern: new RegExp(/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/), message: '请输入密码' }],
{ required: true, pattern: new RegExp(/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/), message: '请输入6-16位数字和字母密码' },
],
againPassword: [{ required: true, validator: this.pwdAgainCheck, trigger: 'blur' }], againPassword: [{ required: true, validator: this.pwdAgainCheck, trigger: 'blur' }],
activeBtn: 0, activeBtn: 0,
showInterval: false, showInterval: false,

Loading…
Cancel
Save