You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
8.7 KiB

5 years ago
<template>
<div>
<!-- 机构注册 -->
<a-row class="d-flex flex-nowrap mt-4 pb-10" type="flex">
<a-col :span="8" class="explain" flex="auto">
<a-form :form="form" @submit="handleSignUp">
<a-form-item
:label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol"
help="支持中文、字母、数字、“_”的组合且不能为纯数字,4-20位字符"
label="登录用户名"
required
>
<a-input v-decorator="['account']" />
</a-form-item>
5 years ago
<a-form-item
:label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol"
label="单位性质"
required
>
5 years ago
<a-select placeholder="请选择单位性质" v-decorator="['nature']">
<a-select-option value="1">高校</a-select-option>
<a-select-option value="2">初中</a-select-option>
</a-select>
</a-form-item>
<a-form-item
:label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol"
help="不能超过100个字符"
label="机构全称"
required
>
<a-input v-decorator="['fullName']" />
</a-form-item>
<a-form-item
:label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol"
help="统一社会信用代码、组织机构代码由字母和数字组成,分别为18/9位字符"
label="统一社会信用代码或组织机构代码"
required
>
5 years ago
<a-input v-decorator="['code1']" />
5 years ago
</a-form-item>
5 years ago
<a-form-item
:label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol"
label="登录密码"
required
>
<a-input-password
placeholder="密码由字母和数字混合组成,6-16位字符"
v-decorator="['password', { rules: passwordRules }]"
/>
5 years ago
</a-form-item>
5 years ago
<a-form-item
:label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol"
label="确认密码"
>
<a-input-password
placeholder="请再次输入您设置的密码"
v-decorator="['againCredential', { rules: againPassword }]"
/>
5 years ago
</a-form-item>
5 years ago
<a-form-item
:label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol"
label="手机"
>
5 years ago
<a-input
@change="changePhone"
placeholder="该手机号用于账号激活、登录及找回密码"
type="number"
v-decorator="['phone', { rules: phoneRules }]"
/>
</a-form-item>
5 years ago
<a-form-item
:label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol"
label="图片验证码"
required
>
5 years ago
<div class="d-flex flex-nowrap">
<a-input placeholder="请输入图片验证码" type="number" v-model="codeNum" />
5 years ago
<img
:src="picCode.imageBase64"
@click="changePicCode"
class="code_img ml-2"
v-if="picCode && picCode.imageBase64"
/>
<a-button
@click="changePicCode"
class="code_img ml-2"
size="small"
type="primary"
v-else
>重新获取</a-button>
5 years ago
</div>
</a-form-item>
5 years ago
<a-form-item
:label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol"
label="短信验证码"
required
>
5 years ago
<div class="d-flex flex-nowrap">
5 years ago
<a-input
placeholder="请输入验证码"
type="number"
v-decorator="['smsCode', { rules: codeRules }]"
/>
5 years ago
<a-button class="ml-2" disabled type="primary" v-if="showInterval">重新发送 {{ interval }}</a-button>
5 years ago
<a-button
:disabled="phone && phone.length !== 11"
@click="getCode"
class="ml-2"
type="primary"
v-else
>获取验证码</a-button>
5 years ago
</div>
</a-form-item>
5 years ago
<a-form-item
:label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol"
label="来源"
>
5 years ago
<a-select placeholder="请选择来源" v-decorator="['source', {initialValue: source }]">
5 years ago
<a-select-option value="1">绿谷</a-select-option>
</a-select>
</a-form-item>
<div class="d-flex flex-row-reverse">
<a-button block class="my-5" html-type="submit" style="width: 75%" type="primary">立即注册</a-button>
</div>
</a-form>
<div class="d-flex flex-row-reverse mt-1">
<div class="d-flex flex-wrap" style="width: 75%">
<div class="flex-1"></div>
<router-link tag="span" to="/login">
<span class="baseColor">已有账号去登录</span>
</router-link>
</div>
</div>
</a-col>
<a-col :span="4" flex="150px">
<div class="d-flex flex-column">
<div>说明</div>
<div>1. 注册后即可登录部分功能需平台人员审核后才能使用</div>
</div>
</a-col>
</a-row>
</div>
</template>
<script>
import { mapActions, mapState } from 'vuex';
import mixin from 'views/User/mixin';
5 years ago
import { saveUserMes } from '@/config/api';
5 years ago
const formItemLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 18 },
};
const formTailLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 18, offset: 6 },
};
export default {
name: 'MechanismSignUp',
mixins: [mixin],
data() {
return {
formItemLayout,
formTailLayout,
form: this.$form.createForm(this, { name: 'mechanismSignUp' }),
phone: '',
codeNum: '',
5 years ago
source: '1',
info: null,
5 years ago
};
},
5 years ago
computed: mapState('user', ['picCode']),
5 years ago
created() {
this.sendPicCode();
},
methods: {
5 years ago
...mapActions('user', ['signUp', 'sendCode', 'sendPicCode']),
5 years ago
changePhone(e) {
this.phone = e.target.value;
},
// 刷新验证码
changePicCode() {
this.sendPicCode();
},
// 获取验证码
async getCode() {
try {
const params = {
phone: this.form.getFieldValue('phone'),
verificationCodeId: this.picCode.verificationCodeId,
verificationCodeValue: this.codeNum,
};
await this.sendCode(params);
this.getCodeInterval();
} catch (error) {
throw new Error(`mechanismSignUp.vue method getCode: ${error}`);
}
},
// 注册
async handleSignUp(e) {
e.preventDefault();
this.form.validateFields(async (err, values) => {
if (!err) {
console.log('Received values of form: ', values);
try {
5 years ago
const { account, nature, fullName, code1, password, phone, smsCode, source } = values;
this.info = values;
5 years ago
const params = { account, password, phone, smsCode, source };
await this.signUp(params);
5 years ago
this.saveUserMes();
5 years ago
} catch (error) {
console.log(`mechanismSignUp.vue methods handleSignUp: ${error}`);
}
}
});
return;
},
5 years ago
// 登陆人信息保存
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}`);
}
},
5 years ago
},
};
</script>
<style lang="stylus" scoped>
.explain {
padding-right: 28px;
margin-right: 28px;
border-right: 1px solid #EEEEEE;
}
.code_img {
width: 102px !important;
height: 32px !important;
}
</style>