feat: 注册

This commit is contained in:
cgd_mac 2022-02-24 20:33:24 +08:00
parent dff16ba630
commit 109f121f05
5 changed files with 40 additions and 22 deletions

View File

@ -20,7 +20,7 @@ export function getUnitNameByInvitationCode (parameter) {
return request({ return request({
url: userApi.getUnitNameByInvitationCode, url: userApi.getUnitNameByInvitationCode,
method: 'post', method: 'post',
data: parameter params: parameter
}) })
} }
@ -47,7 +47,7 @@ export function logout () {
}) })
} }
export function getSmsCaptcha (parameter) { export function getSmsCaptcha (parameter) {
return axios({ return request({
url: '/getSmsCaptcha', url: '/getSmsCaptcha',
method: 'get', method: 'get',
params: parameter params: parameter

View File

@ -310,7 +310,7 @@
if (res.code === 200) { if (res.code === 200) {
const data = res.data const data = res.data
// //
const type = data.type.split(',') const type = data.type && data.type.split(',') || []
const typeIntArr = []// const typeIntArr = []//
type.forEach(item => { type.forEach(item => {
typeIntArr.push(+item) typeIntArr.push(+item)

View File

@ -84,7 +84,10 @@
'password2', 'password2',
{ {
rules: [ rules: [
{ required: true, message: '至少6位密码区分大小写' }, {
required: true,
message: '请输入至少包括大写、小写、数字、特殊符号中的三种密码长度至少为8位。',
},
{ validator: this.handlePasswordCheck }, { validator: this.handlePasswordCheck },
], ],
validateTrigger: ['change', 'blur'], validateTrigger: ['change', 'blur'],
@ -153,7 +156,13 @@
size="large" size="large"
disabled disabled
placeholder="输入邀请码以后自动绑定" placeholder="输入邀请码以后自动绑定"
:value="unitInfo.name" v-decorator="[
'orgName',
{
rules: [{ required: true, message: '输入邀请码以后自动绑定' }],
validateTrigger: ['blur'],
},
]"
></a-input> ></a-input>
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
@ -175,7 +184,9 @@
</template> </template>
<script> <script>
import storage from 'store'
import { getSmsCaptcha, getUnitNameByInvitationCode, reqRegister } from '@/api/login' import { getSmsCaptcha, getUnitNameByInvitationCode, reqRegister } from '@/api/login'
import { ACCESS_TOKEN } from '@/store/mutation-types'
const levelNames = { const levelNames = {
0: '低', 0: '低',
@ -275,14 +286,11 @@ export default {
}, },
handlePasswordInputClick () { handlePasswordInputClick () {
if (!this.isMobile()) {
this.state.passwordLevelChecked = true
return
}
this.state.passwordLevelChecked = false this.state.passwordLevelChecked = false
}, },
handleSubmit () { handleSubmit () {
const _this = this
const { const {
form: { validateFields }, form: { validateFields },
state state
@ -290,16 +298,12 @@ export default {
validateFields({ force: true }, (err, values) => { validateFields({ force: true }, (err, values) => {
if (!err) { if (!err) {
state.passwordLevelChecked = false state.passwordLevelChecked = false
this.setRegister(values) _this.setRegister(values)
} }
}) })
}, },
// //
setRegister (data) { setRegister (data) {
if (!this.uniInfo.id) {
this.$message.warning('请输入正确的邀请码~')
return
}
const params = { const params = {
name: data.name, name: data.name,
userName: data.username, userName: data.username,
@ -309,7 +313,12 @@ export default {
} }
reqRegister(params).then(res => { reqRegister(params).then(res => {
this.$message.success('注册成功!') this.$message.success('注册成功!')
this.$router.push({ name: 'registerResult', query: data }) storage.set(ACCESS_TOKEN, res.token, 24 * 60 * 60 * 1000)
this.$store.state.token = res.token
this.$router.push({
name: 'registerResult',
query: { username: data.username, personId: res.personId }
})
}) })
}, },
getCaptcha (e) { getCaptcha (e) {
@ -359,10 +368,19 @@ export default {
const { value } = e.target const { value } = e.target
if (value && value.length === 6) { if (value && value.length === 6) {
getUnitNameByInvitationCode({ invitationCode: value }).then(res => { getUnitNameByInvitationCode({ invitationCode: value }).then(res => {
this.unitInfo = res.data this.unitInfo = {
name: res.orgName,
id: res.orgId
}
this.form.setFieldsValue({
orgName: res.orgName
})
}) })
} else { } else {
this.unitInfo = {} this.unitInfo = {}
this.form.setFieldsValue({
orgName: ''
})
} }
}, },
requestFailed (err) { requestFailed (err) {

View File

@ -13,7 +13,7 @@
</template> </template>
<script> <script>
import PersonForm from '@/views/person/PersonOrgForm.vue' import PersonForm from '@/views/person/PersonForm.vue'
export default { export default {
name: 'RegisterResult', name: 'RegisterResult',
@ -26,12 +26,12 @@ export default {
}, },
computed: { computed: {
email () { email () {
const v = (this.form && this.form.email) || 'xxx' const v = (this.form && this.form.username) || 'xxx'
return `你的账户:${v} 注册成功` return `你的账户:${v} 注册成功`
} }
}, },
created () { created () {
this.form = this.$route.params this.form = this.$route.query
}, },
methods: { methods: {
goHomeHandle () { goHomeHandle () {
@ -39,7 +39,7 @@ export default {
}, },
goUserInfo () { goUserInfo () {
// //
this.$refs.personForm.registerEdit({}) this.$refs.personForm.edit({id: this.form.personId})
} }
} }
} }

View File

@ -102,8 +102,8 @@ const vueConfig = {
// 如果需要开启代理请移除mockjs /src/main.jsL11 // 如果需要开启代理请移除mockjs /src/main.jsL11
proxy: { proxy: {
'/dawa': { // 捕获API的标志如果API中有这个字符串那么就开始匹配代理 '/dawa': { // 捕获API的标志如果API中有这个字符串那么就开始匹配代理
target: 'http://a.3a6.cn/dawa', // 地址可以是域名也可以是IP地址。比如API请求/api/getList, 会被代理到请求http://www.baidu.com/api/getList 。 // target: 'http://a.3a6.cn/dawa', // 地址可以是域名也可以是IP地址。比如API请求/api/getList, 会被代理到请求http://www.baidu.com/api/getList 。
// target: 'http://localhost:8000/dawa', // 地址可以是域名也可以是IP地址。比如API请求/api/getList, 会被代理到请求http://www.baidu.com/api/getList 。 target: 'http://192.168.2.140:8080', // 地址可以是域名也可以是IP地址。比如API请求/api/getList, 会被代理到请求http://www.baidu.com/api/getList 。
ws: false, ws: false,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {