uptada BaiDuYun

This commit is contained in:
hrx 2025-09-19 16:19:20 +08:00
parent ded931d01d
commit 1998ed5cf2

View File

@ -62,22 +62,27 @@ export default {
const data = event.data; const data = event.data;
console.log('接收到的 data 是:', data); console.log('接收到的 data 是:', data);
// 退 // --- ---
if (data && data.refundInfo && data.refundInfo.uuidList) { // 1. ()
const refundInfo = data.refundInfo.uuidList; // const expectedOrigin = 'https://console.vcp.baidu.com';
// ID uuidList, orderId, orderIdList // if (event.origin !== expectedOrigin) {
let orderId = ''; // console.warn('Received message from unexpected origin:', event.origin);
if (refundInfo.uuidList !== undefined) { // return;
orderId = refundInfo.uuidList[0]; // }
} else {
console.warn('未在 refundInfo 中找到有效的订单ID字段 (uuidList, orderId, orderIdList)');
this.$message.warning('退订信息不完整未找到订单ID');
return; // ID
}
console.log('处理后的订单ID:', orderId); // 2. refundInfo uuidList
if (data && data.refundInfo && Array.isArray(data.refundInfo.uuidList) && data.refundInfo.uuidList.length > 0) {
const uuidListArray = data.refundInfo.uuidList; //
// ID // 3. ID ()
// ID退
const orderId = String(uuidListArray[0]);
// ID
// const orderId = uuidListArray.join(',');
console.log('提取到的订单ID:', orderId);
// 4. ID
this.userid = sessionStorage.getItem('userId'); this.userid = sessionStorage.getItem('userId');
if (!this.userid) { if (!this.userid) {
console.error('未获取到用户ID (sessionStorage 中缺少 userId)'); console.error('未获取到用户ID (sessionStorage 中缺少 userId)');
@ -85,20 +90,20 @@ export default {
return; return;
} }
// // 5.
const payload = { const payload = {
order_id: orderId, order_id: orderId,
userid: this.userid userid: this.userid
}; };
// // 6.
this.loading = true; this.loading = true;
// 退API // 7. 退API
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({
@ -109,13 +114,13 @@ export default {
} }
}); });
} else { } else {
//
this.$message.error(res.msg || '退订失败,请稍后重试'); this.$message.error(res.msg || '退订失败,请稍后重试');
} }
}) })
.catch((error) => { .catch((error) => {
// () // ()
console.error("调用退订接口 reqBaiduJudgePrice 失败 (网络/请求错误):", error); console.error("调用退订接口 reqBaiduJudgePrice 失败 (网络/请求错误):", error);
// error
this.$message.error('网络请求失败或服务异常,请检查网络连接后重试'); this.$message.error('网络请求失败或服务异常,请检查网络连接后重试');
}) })
.finally(() => { .finally(() => {
@ -123,7 +128,8 @@ export default {
this.loading = false; this.loading = false;
}); });
} else { } else {
console.log('接收到的消息不包含有效的退款信息'); console.log('接收到的消息不包含有效的退款信息或 uuidList 为空');
//
} }
} }
} }
@ -138,7 +144,7 @@ export default {
.baidu-style { .baidu-style {
width: 100%; width: 100%;
height: calc(100vh - 100px); // Adjust based on your layout needs height: calc(100vh - 100px);
} }
</style> </style>