添加登录注册接口

This commit is contained in:
2026-02-23 10:08:37 +08:00
parent 86d58330d5
commit e2632d921f
8 changed files with 101 additions and 86 deletions

View File

@@ -56,11 +56,14 @@
</template>
<script setup lang="ts">
import { Login } from '@/api/login'
import { computed, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { 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({
email: [{ validator: validateEmail, trigger: 'blur' }],
@@ -84,16 +87,29 @@
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: 'mainInput' })
// console.log(code)
Login({
email: formData.email,
password: formData.password,
verificationCode: code
})
.then((res) => {
if (res) {
userInfoStore.setToken(res)
router.push({ name: 'mainInput' })
}
})
.catch(() => {
console.warn('error verify code!')
})
}
</script>