Compare commits

..

No commits in common. "385713aa5d1e25756432cdaeb934b13afe901897" and "c35ea795370a66168cc3a6dcc100441b47a0c097" have entirely different histories.

View File

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