接口配置
This commit is contained in:
@@ -55,6 +55,12 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
AccountSendLoginCode,
|
||||
AccountLogin,
|
||||
AccountRegister,
|
||||
AccountSendVerifyCode
|
||||
} from '@/api/account'
|
||||
import { computed, ref, markRaw, watch, onBeforeUnmount } from 'vue'
|
||||
import md5 from 'md5'
|
||||
import login from './login.vue'
|
||||
@@ -63,6 +69,8 @@
|
||||
import registerSuccess from './register-success.vue'
|
||||
import retrievePassword from './retrieve-password.vue'
|
||||
import myEvent from '@/utils/myEvent'
|
||||
import { useUserInfoStore } from '@/stores/userInfo'
|
||||
const userStore = useUserInfoStore()
|
||||
const data = ref({
|
||||
name: '',
|
||||
email: '',
|
||||
@@ -121,22 +129,42 @@
|
||||
})
|
||||
|
||||
const onLogin = (res: any) => {
|
||||
data.value = res
|
||||
data.value.type = TabNames.login
|
||||
currentTab.value = TabNames.email_verify
|
||||
AccountSendLoginCode({
|
||||
email: res.email,
|
||||
password: md5(res.password)
|
||||
}).then((v) => {
|
||||
data.value = res
|
||||
data.value.type = TabNames.login
|
||||
currentTab.value = TabNames.email_verify
|
||||
})
|
||||
}
|
||||
const onRegister = (res: any) => {
|
||||
data.value = res
|
||||
data.value.type = TabNames.register
|
||||
currentTab.value = TabNames.email_verify
|
||||
const value = {
|
||||
email: res.email,
|
||||
operationType: 'REGISTER'
|
||||
}
|
||||
AccountSendVerifyCode(value).then((v) => {
|
||||
data.value = res
|
||||
data.value.type = TabNames.register
|
||||
currentTab.value = TabNames.email_verify
|
||||
})
|
||||
}
|
||||
const onSubmitEmailCode = (code: string) => {
|
||||
const value = {
|
||||
email: data.value.email,
|
||||
password: md5(data.value.password),
|
||||
emailVerifyCode: code
|
||||
}
|
||||
if (data.value.type === TabNames.login) {
|
||||
console.log('登录', code)
|
||||
show.value = false
|
||||
AccountLogin(value).then((v) => {
|
||||
userStore.setUserInfo(v)
|
||||
show.value = false
|
||||
})
|
||||
} else {
|
||||
console.log('注册', code)
|
||||
currentTab.value = TabNames.register_success
|
||||
value['username'] = data.value.name
|
||||
AccountRegister(value).then((v) => {
|
||||
currentTab.value = TabNames.register_success
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user