main #34

Merged
charles merged 191 commits from main into prod 2025-11-19 16:18:39 +08:00
2 changed files with 27 additions and 89 deletions
Showing only changes of commit 861653ce8f - Show all commits

View File

@ -1,31 +1,12 @@
<template> <template>
<div class="box"> <div class="box">
<!-- 使用全屏加载效果 --> <!-- 添加全屏加载效果 -->
<div v-loading="loading" <div v-loading="loading" class="loading-container">
element-loading-text="页面加载中..." <iframe v-if="url" :src="url" frameborder="0" class="baidu-style">
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(255, 255, 255, 0.8)"
class="loading-container">
<iframe
v-if="url && !loading"
:src="url"
frameborder="0"
class="baidu-style"
@load="onIframeLoad">
</iframe> </iframe>
<div v-else class="login-prompt">
<div v-if="!url && !loading" class="login-prompt"> <p>请先登录百度云账号</p>
<el-alert <button @click="getToken">重试</button>
title="登录提示"
description="请先登录百度云账号"
type="warning"
show-icon
:closable="false">
</el-alert>
<el-button type="primary" @click="getToken" style="margin-top: 20px;">
重新获取登录信息
</el-button>
</div> </div>
</div> </div>
</div> </div>
@ -43,7 +24,6 @@ export default {
url: '', url: '',
loading: true, loading: true,
userid: '', userid: '',
iframeLoading: false // iframe
} }
}, },
async created() { async created() {
@ -60,11 +40,8 @@ export default {
async getToken() { async getToken() {
try { try {
this.loading = true; this.loading = true;
this.url = ''; // urliframe
const response = await baiducloudAPI(); const response = await baiducloudAPI();
this.userToken = response.data; this.userToken = response.data;
if (this.userToken) { if (this.userToken) {
const baseUrl = 'https://console.vcp.baidu.com/api/loginvcp/login/securitytoken'; const baseUrl = 'https://console.vcp.baidu.com/api/loginvcp/login/securitytoken';
const redirectUrl = encodeURIComponent('https://console.vcp.baidu.com/billing/#/refund/list'); const redirectUrl = encodeURIComponent('https://console.vcp.baidu.com/billing/#/refund/list');
@ -78,15 +55,8 @@ export default {
console.error('获取百度云Token失败:', error); console.error('获取百度云Token失败:', error);
this.$message.error('网络错误,获取登录信息失败'); this.$message.error('网络错误,获取登录信息失败');
} finally { } finally {
// loadingiframe
}
},
// iframe
onIframeLoad() {
console.log('iframe加载完成');
this.loading = false; this.loading = false;
this.iframeLoading = false; }
}, },
receiveMessage(event) { receiveMessage(event) {
@ -94,65 +64,55 @@ export default {
const data = event.data; const data = event.data;
console.log('接收到的 data 是:', data); console.log('接收到的 data 是:', data);
// 2. refundInfo uuidList
if (data && data.refundInfo && Array.isArray(data.refundInfo.uuidList) && data.refundInfo.uuidList.length > 0) { if (data && data.refundInfo && Array.isArray(data.refundInfo.uuidList) && data.refundInfo.uuidList.length > 0) {
const uuidListArray = data.refundInfo.uuidList; const uuidListArray = data.refundInfo.uuidList; //
console.log('提取到的订单ID:', uuidListArray); console.log('提取到的订单ID:', uuidListArray);
// 4. ID
this.userid = sessionStorage.getItem('userId'); this.userid = sessionStorage.getItem('userId');
if (!this.userid) { if (!this.userid) {
console.error('未获取到用户ID'); console.error('未获取到用户ID (sessionStorage 中缺少 userId)');
this.$message.error('用户信息获取失败,请重新登录'); this.$message.error('用户信息获取失败,请重新登录');
return; return;
} }
// 5.
const payload = { const payload = {
order_id: uuidListArray, order_id: uuidListArray,
userid: this.userid userid: this.userid
}; };
// 退 // 6.
const loadingInstance = this.$loading({ this.loading = true;
lock: true,
text: '退订处理中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
// 7. 退API
reqConfirmBtn(payload) reqConfirmBtn(payload)
.then((res) => { .then((res) => {
console.log("退订接口返回:", res); console.log("调用 reqBaiduJudgePrice 接口返回:", res);
if (res.status) { if (res.status) { // status true
this.$message.success('退订成功'); this.$message.success('退订成功');
// - 使 path url
this.$router.push({ this.$router.push({
path: '/BaiduNetdisk', path: '/BaiduNetdisk',
}); });
// - 使 path url
// this.$router.push({
// path: '/customer/unsubscribe/BaiduNetdisk',
// });
//
if (this.$router) {
this.$router.go(0); // 使 Vue Router
} else {
window.location.reload(); //
}
} else { } else {
//
this.$message.error(res.msg || '退订失败,请稍后重试'); this.$message.error(res.msg || '退订失败,请稍后重试');
} }
}) })
.catch((error) => { .catch((error) => {
console.error("退订接口调用失败:", error); // ()
this.$message.error('网络请求失败,请检查网络连接后重试'); console.error("调用退订接口 reqBaiduJudgePrice 失败 (网络/请求错误):", error);
this.$message.error('网络请求失败或服务异常,请检查网络连接后重试');
}) })
.finally(() => { .finally(() => {
loadingInstance.close(); //
this.loading = false;
}); });
} else { } else {
console.log('接收到的消息不包含有效的退款信息'); console.log('接收到的消息不包含有效的退款信息或 uuidList 为空');
} }
} }
} }
@ -163,44 +123,21 @@ export default {
.box { .box {
padding: 10px; padding: 10px;
height: 100%; height: 100%;
position: relative;
} }
.loading-container { .loading-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: relative; position: relative;
min-height: 400px;
} }
.login-prompt { .login-prompt {
text-align: center; text-align: center;
padding: 50px; padding: 50px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
} }
.baidu-style { .baidu-style {
width: 100%; width: 100%;
height: calc(100vh - 100px); height: calc(100vh - 100px);
border: none;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
//
::v-deep .el-loading-spinner {
.el-icon-loading {
color: #409EFF;
font-size: 40px;
}
.el-loading-text {
color: #409EFF;
font-size: 16px;
margin-top: 10px;
}
} }
</style> </style>

View File

@ -907,7 +907,8 @@ export default Vue.extend({
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background: linear-gradient(90deg, #275AFF 0%, #2EBDFA 100%); background: linear-gradient(90deg, #275AFF 0%, #2EBDFA 100%);
border-radius: 12px 12px 12px 12px; border-radius: 10px;
padding: 6px 10px;
color: white; color: white;
&:hover { &:hover {