Refactor API requests and update global methods
This commit is contained in:
@ -36,7 +36,7 @@ export const creatFile = (params: fileCreateReqVO) => {
|
|||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
export const getUserInfo = () => {
|
export const getUserInfo = () => {
|
||||||
return useFetchRequest.get<IResponse<AppMemberUserInfoRespVO>>('/prod-api/app-api/member/user/get')
|
return useDollarFetchRequest.get<IResponse<AppMemberUserInfoRespVO>>('/prod-api/app-api/member/user/get')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
<el-form ref="formRef" :model="loginForm" :rules="rules" class="login-form">
|
<el-form ref="formRef" :model="loginForm" :rules="rules" class="login-form">
|
||||||
<template v-if="activeTab === 'account'">
|
<template v-if="activeTab === 'account'">
|
||||||
<el-form-item prop="mobile">
|
<el-form-item prop="mobile">
|
||||||
<el-input v-model="loginForm.mobile" placeholder="请输入用户名" :prefix-icon="User" class="w-322px!" />
|
<el-input v-model="loginForm.mobile" placeholder="请输入用户名" :prefix-icon="User" class="w-[322px]!" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="password">
|
<el-form-item prop="password">
|
||||||
<el-input v-model="loginForm.password" placeholder="请输入密码" :prefix-icon="Lock" type="password" />
|
<el-input v-model="loginForm.password" placeholder="请输入密码" :prefix-icon="Lock" type="password" />
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<!-- 验证码登录 -->
|
<!-- 验证码登录 -->
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<el-form-item prop="phone">
|
<el-form-item prop="phone">
|
||||||
<el-input v-model="loginForm.phone" placeholder="请输入手机号" class="w-322px!" />
|
<el-input v-model="loginForm.phone" placeholder="请输入手机号" class="w-[322px]!" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="code">
|
<el-form-item prop="code">
|
||||||
<div class="verify-code-input">
|
<div class="verify-code-input">
|
||||||
@ -89,7 +89,7 @@
|
|||||||
import REFRESHTOKEN from '~/utils/RefreshToken'
|
import REFRESHTOKEN from '~/utils/RefreshToken'
|
||||||
import { handleLoginQQ, handleLoginWechat } from '~/utils/login'
|
import { handleLoginQQ, handleLoginWechat } from '~/utils/login'
|
||||||
import useUserStore from '~/store/user'
|
import useUserStore from '~/store/user'
|
||||||
const { $openRegister, $openLogin, $openLoginEmail } = useNuxtApp()
|
const app = useNuxtApp()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -157,7 +157,7 @@
|
|||||||
const handleRegister = () => {
|
const handleRegister = () => {
|
||||||
props.onClose()
|
props.onClose()
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
// $openRegister()
|
app.$openRegister()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 发送验证码
|
// 发送验证码
|
||||||
@ -262,7 +262,7 @@
|
|||||||
const handleLoginEmail = () => {
|
const handleLoginEmail = () => {
|
||||||
props.onClose()
|
props.onClose()
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
// $openLoginEmail()
|
app.$openLoginEmail()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="absolute right-[10px] flex items-center">
|
<div class="absolute right-[10px] flex items-center">
|
||||||
<div class="h-[36px] w-[36px] border-rd-[50%] bg-[#F5F5F5] text-center line-height-[44px]">
|
<div class="h-[36px] w-[36px] border-rd-[50%] bg-[#F5F5F5] text-center line-height-[44px]">
|
||||||
<img v-if="!isLogin" src="~/assets/images/user.png" alt="" srcset="" class="h-[19px] w-[17px]" />
|
<img v-if="!isLogin" src="~/assets/images/user.png" alt="" srcset="" class="h-[19px] w-[17px] relative top-[7px] left-[10px]" />
|
||||||
<img v-else :src="userStore.userInfoRes.avatar" alt="" srcset="" class="h-[19px] w-[17px] rd-[50%]" />
|
<img v-else :src="userStore.userInfoRes.avatar" alt="" srcset="" class="h-[19px] w-[17px] rd-[50%]" />
|
||||||
</div>
|
</div>
|
||||||
<span v-if="!isLogin" class="ml-[14px] cursor-pointer text-[14px] text-[#1A65FF] font-normal" @click="handleLogin">立即登录</span>
|
<span v-if="!isLogin" class="ml-[14px] cursor-pointer text-[14px] text-[#1A65FF] font-normal" @click="handleLogin">立即登录</span>
|
||||||
@ -69,8 +69,7 @@
|
|||||||
import { Search } from '@element-plus/icons-vue'
|
import { Search } from '@element-plus/icons-vue'
|
||||||
import useUserStore from '~/store/user'
|
import useUserStore from '~/store/user'
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const { $openLogin } = useNuxtApp()
|
const app = useNuxtApp()
|
||||||
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
active: {
|
active: {
|
||||||
@ -174,7 +173,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const handleLogin = () => {
|
const handleLogin = () => {
|
||||||
// $openLogin()
|
app?.$openLogin() // 调用全局方法
|
||||||
}
|
}
|
||||||
const handleCommand = (command: string) => {
|
const handleCommand = (command: string) => {
|
||||||
if (command === '退出') {
|
if (command === '退出') {
|
||||||
|
|||||||
@ -1,16 +1,20 @@
|
|||||||
import { openLogin } from "~/components/kl-login";
|
import { openLogin } from "~/components/kl-login/index";
|
||||||
import { closeLogin } from "~/components/kl-login";
|
import { closeLogin } from "~/components/kl-login/index";
|
||||||
import { openRegister } from "~/components/kl-register";
|
import { openRegister } from "~/components/kl-register/index";
|
||||||
import { closeRegister } from "~/components/kl-register";
|
import { closeRegister } from "~/components/kl-register/index";
|
||||||
import { openLoginEmail } from "~/components/kl-email";
|
import { openLoginEmail } from "~/components/kl-email/index";
|
||||||
import { closeLoginEmail } from "~/components/kl-email";
|
import { closeLoginEmail } from "~/components/kl-email/index";
|
||||||
|
|
||||||
// plugins/global.ts
|
// plugins/global.ts
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
nuxtApp.vueApp.config.globalProperties.$openLogin = openLogin;
|
return {
|
||||||
nuxtApp.vueApp.config.globalProperties.$closeLogin = closeLogin;
|
provide: {
|
||||||
nuxtApp.vueApp.config.globalProperties.$openRegister = openRegister;
|
openLogin,
|
||||||
nuxtApp.vueApp.config.globalProperties.$closeRegister = closeRegister;
|
closeLogin,
|
||||||
nuxtApp.vueApp.config.globalProperties.$openLoginEmail = openLoginEmail;
|
openRegister,
|
||||||
nuxtApp.vueApp.config.globalProperties.$closeLoginEmail = closeLoginEmail;
|
closeRegister,
|
||||||
|
openLoginEmail,
|
||||||
|
closeLoginEmail,
|
||||||
|
},
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user