uptada BaiDuYun

This commit is contained in:
hrx 2025-09-19 15:58:31 +08:00
parent ed5e271099
commit d0deabd832

View File

@ -30,7 +30,7 @@ export default {
mounted() { mounted() {
window.addEventListener('message', this.receiveMessage, false); window.addEventListener('message', this.receiveMessage, false);
}, },
beforeDestroy() { // Vue2 使 beforeDestroy beforeDestroy() {
window.removeEventListener('message', this.receiveMessage, false); window.removeEventListener('message', this.receiveMessage, false);
}, },
methods: { methods: {
@ -41,11 +41,9 @@ 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 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);
@ -58,32 +56,19 @@ export default {
this.loading = false; this.loading = false;
} }
}, },
// 使 receiveMessage
receiveMessage(event) { receiveMessage(event) {
console.log('接收到消息:', event); console.log('接收到消息:', event);
//
// const expectedOrigin = 'https://console.vcp.baidu.com';
// if (event.origin !== expectedOrigin) {
// console.warn('Received message from unexpected origin:', event.origin);
// 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.refundInfo && data.refundInfo.uuidList) {
const refundInfo = data.orderInfo.refundInfo; const refundInfo = data.refundInfo.uuidList;
// ID uuidList, orderId, orderIdList // ID uuidList, orderId, orderIdList
let orderId = ''; let orderId = '';
if (refundInfo.uuidList !== undefined) { if (refundInfo.uuidList !== undefined) {
orderId = Array.isArray(refundInfo.uuidList) ? refundInfo.uuidList.join(',') : String(refundInfo.uuidList); orderId = refundInfo.uuidList[0];
} else if (refundInfo.orderId !== undefined) {
orderId = String(refundInfo.orderId);
} else if (refundInfo.orderIdList !== undefined) {
orderId = Array.isArray(refundInfo.orderIdList) ? refundInfo.orderIdList.join(',') : String(refundInfo.orderIdList);
} else { } else {
console.warn('未在 refundInfo 中找到有效的订单ID字段 (uuidList, orderId, orderIdList)'); console.warn('未在 refundInfo 中找到有效的订单ID字段 (uuidList, orderId, orderIdList)');
this.$message.warning('退订信息不完整未找到订单ID。'); this.$message.warning('退订信息不完整未找到订单ID。');
@ -113,7 +98,7 @@ export default {
reqBaiduJudgePrice(payload) reqBaiduJudgePrice(payload)
.then((res) => { .then((res) => {
console.log("调用 reqBaiduJudgePrice 接口返回:", res); console.log("调用 reqBaiduJudgePrice 接口返回:", res);
if (res.status) { // status true if (res.status) {
this.$message.success('退订成功'); this.$message.success('退订成功');
// //
this.$router.push({ this.$router.push({
@ -139,7 +124,6 @@ export default {
}); });
} else { } else {
console.log('接收到的消息不包含有效的退款信息。'); console.log('接收到的消息不包含有效的退款信息。');
//
} }
} }
} }