mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-01 22:53:29 +08:00
65 lines
3.0 KiB
HTML
65 lines
3.0 KiB
HTML
<div>
|
|
<h3>绑定第三方账号</h3>
|
|
<%- include("./third-party-login-button.html"); %>
|
|
<div id="withdraw-container" style="display: none;">
|
|
<h3>取消第三方账号绑定</h3>
|
|
<div id="withdraw-buttons"></div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
function thirdPartyWithdraw(platform) {
|
|
postRequest("/third-party/withdrawThirdPartyBings", { token: localStorageUtils.getToken(), platform: platform })
|
|
.then(function (response) {
|
|
var axiosData = response.data;
|
|
var status = axiosData.status;
|
|
var data = axiosData.data;
|
|
if (status === "success") {
|
|
console.log(data);
|
|
if (data == "success") {
|
|
alert("取消绑定成功!");
|
|
location.reload();
|
|
} else {
|
|
alert("出错啦,刷新页面重新试试吧");
|
|
}
|
|
} else {
|
|
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
|
location.reload();
|
|
}
|
|
}).catch(function (error) {
|
|
console.log(error);
|
|
alert("无法连接到服务器,请检查网络连接!");
|
|
});
|
|
}
|
|
if (localStorageUtils.getLoginStatus() != null) {
|
|
getRequest("/third-party/getBindingStatus", { token: localStorageUtils.getToken() })
|
|
.then(function (response) {
|
|
var axiosData = response.data;
|
|
var status = axiosData.status;
|
|
var data = axiosData.data;
|
|
if (status === "success") {
|
|
console.log(data);
|
|
if (data) {
|
|
$("#withdraw-container").show();
|
|
data.forEach(platformName => {
|
|
// 隐藏绑定按钮
|
|
var btn = $(`#btn_${platformName.toLowerCase()}`);
|
|
var platformChineseName = btn.html();
|
|
btn.attr("disabled", true);
|
|
btn.html(platformChineseName + "(已绑定)");
|
|
|
|
// 添加取消绑定按钮
|
|
var withdrawBtn = $(`<button class="btn-third-party" id="btn_${platformName.toLowerCase()}_withdraw" onclick="thirdPartyWithdraw('${platformName}')">取消绑定${platformChineseName}</button>`);
|
|
$("#withdraw-buttons").append(withdrawBtn);
|
|
$("#withdraw-buttons").append(" ");
|
|
});
|
|
}
|
|
} else {
|
|
$(".btn-third-party").hide();
|
|
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
|
}
|
|
}).catch(function (error) {
|
|
console.log(error);
|
|
alert("无法连接到服务器,请检查网络连接!");
|
|
});
|
|
}
|
|
</script> |