uptada BaiDuYun
This commit is contained in:
parent
251d1a70f2
commit
ed5e271099
@ -40,6 +40,9 @@ export default {
|
|||||||
<style lang="scss" >
|
<style lang="scss" >
|
||||||
$n: 9; //和items.length 相同
|
$n: 9; //和items.length 相同
|
||||||
$t: .1s;
|
$t: .1s;
|
||||||
|
*{
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
.share-dropdown-menu {
|
.share-dropdown-menu {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
window.addEventListener('message', this.receiveMessage, false);
|
window.addEventListener('message', this.receiveMessage, false);
|
||||||
},
|
},
|
||||||
beforeDestroy() { // Vue2 中推荐使用 beforeDestroy
|
beforeDestroy() { // Vue2 推荐使用 beforeDestroy
|
||||||
window.removeEventListener('message', this.receiveMessage, false);
|
window.removeEventListener('message', this.receiveMessage, false);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -41,62 +41,62 @@ export default {
|
|||||||
const response = await baiducloudAPI();
|
const response = await baiducloudAPI();
|
||||||
this.userToken = response.data;
|
this.userToken = response.data;
|
||||||
if (this.userToken) {
|
if (this.userToken) {
|
||||||
// 构建最终的 URL
|
// 修复 URL 构建:移除 baseUrl 末尾的 '?' 或者确保第一个参数用 '?'
|
||||||
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');
|
||||||
const token = encodeURIComponent(this.userToken);
|
const token = encodeURIComponent(this.userToken);
|
||||||
this.url = `${baseUrl}&redirectUrl=${redirectUrl}&signinSecurityToken=${token}`;
|
// 使用 '?' 连接第一个参数
|
||||||
|
this.url = `${baseUrl}?redirectUrl=${redirectUrl}&signinSecurityToken=${token}`;
|
||||||
} else {
|
} else {
|
||||||
console.error('未能从API响应中获取到token:', response);
|
console.error('未能从API响应中获取到token:', response);
|
||||||
|
this.$message.error('获取登录信息失败,请重试。');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取百度云Token失败:', error);
|
console.error('获取百度云Token失败:', error);
|
||||||
// 可以在这里添加用户提示,例如 this.$message.error('获取Token失败,请重试');
|
this.$message.error('网络错误,获取登录信息失败。');
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 使用更健壮的 receiveMessage 方法
|
||||||
receiveMessage(event) {
|
receiveMessage(event) {
|
||||||
console.log('接收到消息:', event);
|
console.log('接收到消息:', event);
|
||||||
|
|
||||||
// 安全性检查:验证消息来源(如果知道确切来源域名)
|
// 安全性检查:验证消息来源(如果知道确切来源域名)
|
||||||
// if (event.origin !== 'https://console.vcp.baidu.com') {
|
// const expectedOrigin = 'https://console.vcp.baidu.com';
|
||||||
|
// if (event.origin !== expectedOrigin) {
|
||||||
// console.warn('Received message from unexpected origin:', event.origin);
|
// console.warn('Received message from unexpected origin:', event.origin);
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const data = event.data;
|
const data = event.data;
|
||||||
console.log('data是', data);
|
console.log('接收到的 data 是:', data);
|
||||||
|
|
||||||
// 检查接收到的数据是否包含退款信息
|
// 检查接收到的数据是否包含退款信息
|
||||||
if (data && data.orderInfo && data.orderInfo.refundInfo) {
|
if (data && data.orderInfo && data.orderInfo.refundInfo) {
|
||||||
// 提取订单ID
|
|
||||||
const refundInfo = data.orderInfo.refundInfo;
|
const refundInfo = data.orderInfo.refundInfo;
|
||||||
let orderId = '';
|
|
||||||
|
|
||||||
// 处理可能的 orderId 或 orderIdList (这里假设 uuidList 是主要字段)
|
// 提取订单ID,按优先级处理 uuidList, orderId, orderIdList
|
||||||
|
let orderId = '';
|
||||||
if (refundInfo.uuidList !== undefined) {
|
if (refundInfo.uuidList !== undefined) {
|
||||||
// 如果 uuidList 是数组,根据后端需求决定是传递数组还是逗号分隔字符串
|
|
||||||
// 这里假设后端期望字符串
|
|
||||||
orderId = Array.isArray(refundInfo.uuidList) ? refundInfo.uuidList.join(',') : String(refundInfo.uuidList);
|
orderId = Array.isArray(refundInfo.uuidList) ? refundInfo.uuidList.join(',') : String(refundInfo.uuidList);
|
||||||
} else if (refundInfo.orderId !== undefined) {
|
} else if (refundInfo.orderId !== undefined) {
|
||||||
orderId = String(refundInfo.orderId);
|
orderId = String(refundInfo.orderId);
|
||||||
} else if (refundInfo.orderIdList !== undefined) {
|
} else if (refundInfo.orderIdList !== undefined) {
|
||||||
orderId = Array.isArray(refundInfo.orderIdList) ? refundInfo.orderIdList.join(',') : String(refundInfo.orderIdList);
|
orderId = Array.isArray(refundInfo.orderIdList) ? refundInfo.orderIdList.join(',') : String(refundInfo.orderIdList);
|
||||||
} else {
|
} else {
|
||||||
console.warn('未在 refundInfo 中找到 orderId 或 orderIdList');
|
console.warn('未在 refundInfo 中找到有效的订单ID字段 (uuidList, orderId, orderIdList)');
|
||||||
this.$message.warning('退订信息不完整');
|
this.$message.warning('退订信息不完整,未找到订单ID。');
|
||||||
return; // 如果没有订单ID,不继续执行
|
return; // 如果没有订单ID,不继续执行
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('接收到订单ID:', orderId);
|
console.log('处理后的订单ID:', orderId);
|
||||||
|
|
||||||
// 获取用户ID
|
// 获取用户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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ export default {
|
|||||||
// 调用退订API
|
// 调用退订API
|
||||||
reqBaiduJudgePrice(payload)
|
reqBaiduJudgePrice(payload)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log("二级接口返回:", res);
|
console.log("调用 reqBaiduJudgePrice 接口返回:", res);
|
||||||
if (res.status) { // 假设 status 为 true 表示成功
|
if (res.status) { // 假设 status 为 true 表示成功
|
||||||
this.$message.success('退订成功');
|
this.$message.success('退订成功');
|
||||||
// 跳转页面
|
// 跳转页面
|
||||||
@ -124,19 +124,22 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 显示后端返回的错误信息
|
this.$message.error(res.msg || '退订失败,请稍后重试。');
|
||||||
this.$message.error(res.msg || '退订失败');
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
// 捕获网络错误或请求异常
|
// 捕获网络错误或请求异常 (如超时、连接失败)
|
||||||
console.error("调用退订接口失败:", error);
|
console.error("调用退订接口 reqBaiduJudgePrice 失败 (网络/请求错误):", error);
|
||||||
this.$message.error('网络错误或服务异常,请稍后重试');
|
// 可以根据 error 对象提供更具体的提示,例如区分超时和断网
|
||||||
|
this.$message.error('网络请求失败或服务异常,请检查网络连接后重试。');
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
// 无论成功或失败,都结束加载状态
|
// 无论成功或失败,都结束加载状态
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.log('接收到的消息不包含有效的退款信息。');
|
||||||
|
// 根据需要决定是否提示用户
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user