main #34

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

View File

@ -40,6 +40,9 @@ export default {
<style lang="scss" >
$n: 9; //items.length
$t: .1s;
*{
box-sizing: border-box;
}
.share-dropdown-menu {
width: 250px;
position: relative;

View File

@ -30,7 +30,7 @@ export default {
mounted() {
window.addEventListener('message', this.receiveMessage, false);
},
beforeDestroy() { // Vue2 使 beforeDestroy
beforeDestroy() { // Vue2 使 beforeDestroy
window.removeEventListener('message', this.receiveMessage, false);
},
methods: {
@ -41,62 +41,62 @@ export default {
const response = await baiducloudAPI();
this.userToken = response.data;
if (this.userToken) {
// URL
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 token = encodeURIComponent(this.userToken);
this.url = `${baseUrl}&redirectUrl=${redirectUrl}&signinSecurityToken=${token}`;
// 使 '?'
this.url = `${baseUrl}?redirectUrl=${redirectUrl}&signinSecurityToken=${token}`;
} else {
console.error('未能从API响应中获取到token:', response);
this.$message.error('获取登录信息失败,请重试。');
}
} catch (error) {
console.error('获取百度云Token失败:', error);
// this.$message.error('Token');
this.$message.error('网络错误,获取登录信息失败。');
} finally {
this.loading = false;
}
},
// 使 receiveMessage
receiveMessage(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);
// return;
// }
const data = event.data;
console.log('data是', data);
console.log('接收到的 data :', data);
// 退
if (data && data.orderInfo && data.orderInfo.refundInfo) {
// ID
const refundInfo = data.orderInfo.refundInfo;
let orderId = '';
// orderId orderIdList ( uuidList )
// ID uuidList, orderId, orderIdList
let orderId = '';
if (refundInfo.uuidList !== undefined) {
// uuidList
//
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 {
console.warn('未在 refundInfo 中找到 orderId 或 orderIdList');
this.$message.warning('退订信息不完整');
console.warn('未在 refundInfo 中找到有效的订单ID字段 (uuidList, orderId, orderIdList)');
this.$message.warning('退订信息不完整未找到订单ID。');
return; // ID
}
console.log('接收到订单ID:', orderId);
console.log('处理后的订单ID:', orderId);
// ID
this.userid = sessionStorage.getItem('userId');
if (!this.userid) {
console.error('未获取到用户ID');
this.$message.error('用户信息获取失败');
console.error('未获取到用户ID (sessionStorage 中缺少 userId)');
this.$message.error('用户信息获取失败,请重新登录。');
return;
}
@ -112,7 +112,7 @@ export default {
// 退API
reqBaiduJudgePrice(payload)
.then((res) => {
console.log("二级接口返回:", res);
console.log("调用 reqBaiduJudgePrice 接口返回:", res);
if (res.status) { // status true
this.$message.success('退订成功');
//
@ -124,19 +124,22 @@ export default {
}
});
} else {
//
this.$message.error(res.msg || '退订失败');
this.$message.error(res.msg || '退订失败,请稍后重试。');
}
})
.catch((error) => {
//
console.error("调用退订接口失败:", error);
this.$message.error('网络错误或服务异常,请稍后重试');
// ()
console.error("调用退订接口 reqBaiduJudgePrice 失败 (网络/请求错误):", error);
// error
this.$message.error('网络请求失败或服务异常,请检查网络连接后重试。');
})
.finally(() => {
//
this.loading = false;
});
} else {
console.log('接收到的消息不包含有效的退款信息。');
//
}
}
}