Skip to content

Commit

Permalink
Feat: unbind bil
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyCreeper committed Nov 6, 2023
1 parent 2904622 commit 762c19a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/services/apis/vendor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@ export const getBiliBiliAccountInfo = useDefineApi<
url: "/api/vendor/bilibili/me",
method: "GET"
});

// 退出 哔哩哔哩 登录
export const logoutBiliBili = useDefineApi<{ headers: { Authorization: string } }, any>({
url: "/api/vendor/bilibili/logout",
method: "POST"
});
34 changes: 28 additions & 6 deletions src/views/user/account/bilibili.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
getBiliBiliCaptcha,
getBiliBiliPhoneCode,
veriBiliBiliPhoneCode,
getBiliBiliAccountInfo
getBiliBiliAccountInfo,
logoutBiliBili
} from "@/services/apis/vendor";
import QRCodeVue3 from "qrcode-vue3";
import { roomStore } from "@/stores/room";
Expand Down Expand Up @@ -194,16 +195,37 @@ const getAccountInfo = async () => {
}
};
const openDialog = () => {
if (!accountInfo.value) return;
if (accountInfo.value.isLogin) {
const openDialog = async () => {
await getAccountInfo();
if (accountInfo.value?.isLogin) {
infoDialog.value = true;
} else {
useBilibiliLogin();
}
};
const biliLogout = async () => {};
const biliLogout = async () => {
const { execute } = logoutBiliBili();
try {
await execute({
headers: {
Authorization: userToken
}
});
ElNotification({
type: "success",
title: "解绑成功"
});
infoDialog.value = false;
} catch (err: any) {
console.error(err);
ElNotification({
type: "error",
title: "错误",
message: err.response.data.error || err.message
});
}
};
const closeLoginDialog = () => {
loginDialog.value = false;
Expand Down Expand Up @@ -338,7 +360,7 @@ onMounted(async () => {
<p class="text-lg mb-1">{{ accountInfo?.username }}</p>
<p
v-if="accountInfo?.isVip"
class="bg-pink-500 rounded-lg text-white mx-auto w-fit py-1 px-2 shadow-sm shadow-pink-400 mb-2"
class="bg-pink-500 rounded-lg text-white text-sm mx-auto w-fit px-2 shadow-sm shadow-pink-400 mb-2"
>
大会员
</p>
Expand Down

0 comments on commit 762c19a

Please sign in to comment.