添加登录注册接口
This commit is contained in:
@@ -60,11 +60,14 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Register } from '@/api/login'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { validateName, validateEmail, validatePass, validatePrivacy } from './tools'
|
||||
import OtherLogin from './other-login.vue'
|
||||
import VisibleCode from './visible-code.vue'
|
||||
import { useUserInfoStore } from '@/stores'
|
||||
const userInfoStore = useUserInfoStore()
|
||||
const router = useRouter()
|
||||
const ruleForm = reactive({
|
||||
name: [{ validator: validateName, trigger: 'blur' }],
|
||||
@@ -90,16 +93,31 @@
|
||||
const onSubmit = () => {
|
||||
formRef.value?.validate?.((valid) => {
|
||||
if (valid) {
|
||||
console.log('submit!')
|
||||
// console.log('submit!')
|
||||
isVisible.value = true
|
||||
} else {
|
||||
console.log('error submit!')
|
||||
console.warn('error submit!')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const onVerifyCode = (code: string) => {
|
||||
console.log(code)
|
||||
router.push({ name: 'nuic' })
|
||||
Register({
|
||||
username: formData.name,
|
||||
email: formData.email,
|
||||
password: formData.password,
|
||||
verificationCode: code
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
userInfoStore.setToken(res)
|
||||
router.push({ name: 'nuic' })
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
console.warn('error verify code!')
|
||||
})
|
||||
// router.push({ name: 'nuic' })
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user