uptada BaiDuYun

This commit is contained in:
hrx 2025-09-19 10:57:14 +08:00
parent 835e1bff46
commit ea954613f3
3 changed files with 69 additions and 25 deletions

View File

@ -6,3 +6,11 @@ export function baiducloudAPI() {
method: 'get', method: 'get',
}) })
} }
// 退订回调
export function cancelCallbackAPI(params) {
return request({
url: `/baiducloud/get_baidu_orderlist.dspy`,
method: 'get',
params: params
})
}

View File

@ -1,58 +1,76 @@
<template> <template>
<div class="box"> <div class="box">
<div v-if="loading">正在加载...</div> <div v-if="loading">正在加载...</div>
<iframe <iframe v-else-if="url" :src="url" frameborder="0" class="baidu-style" ref="baiduIframe">
v-else-if="url"
:src="url"
frameborder="0"
class="baidu-style">
</iframe> </iframe>
<div v-else> <div v-else>
<p>请先登录百度云账号</p> <p>无法加载内容请检查配置</p>
<button @click="getToken">重试</button> <button @click="getToken">重试</button>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { baiducloudAPI } from '@/api/BaiDuTokenapi'
export default { export default {
name: 'baiduProductShow', name: 'BaiduProductShow',
data() { data() {
return { return {
userToken: '', userToken: '',
url: '', url: '',
loading: true, loading: true,
} // session storage userId
userid: 'USER_001'
};
}, },
async created() { async created() {
// sessionStorage userId
// this.userid = sessionStorage.getItem('userId') || 'DEFAULT_USER';
await this.getToken(); await this.getToken();
}, },
mounted() {
window.addEventListener('message', this.receiveMessage, false);
},
beforeDestroy() { // Vue 2 使 beforeDestroy
window.removeEventListener('message', this.receiveMessage, false);
},
methods: { methods: {
// 退 // token
// token
// this.userid = sessionStorage.getItem('userId')
async getToken() { async getToken() {
try { try {
this.loading = true; this.loading = true;
const response = await baiducloudAPI(); const response = await mockBaiducloudAPI();
this.userToken = response.data; this.userToken = response.data;
let resultUrlLast = 'https://console.vcp.baidu.com/api/loginvcp/login/securitytoken?' console.log('获取到模拟Token:', this.userToken);
if (this.userToken) { if (this.userToken) {
// URL // 使 iframe URL
resultUrlLast = resultUrlLast + '&redirectUrl=' + encodeURIComponent('https://console.vcp.baidu.com/billing/#/refund/list') + '&signinSecurityToken=' + encodeURIComponent(this.userToken) const baseUrl = 'https://example.com'; // URL
this.url = resultUrlLast const redirectUrl = encodeURIComponent(`${baseUrl}/billing/#/refund/list`);
const token = encodeURIComponent(this.userToken);
// URL ()
this.url = `${baseUrl}/api/loginvcp/login/securitytoken?redirectUrl=${redirectUrl}&signinSecurityToken=${token}`;
console.log('构建的 iframe URL:', this.url);
} else { } else {
console.error('未能从API响应中获取到token:', response); console.error('未能从API响应中获取到token:', response);
this.url = ''; // url 便
} }
} catch (error) { } catch (error) {
console.error('获取百度云Token失败:', error); console.error('获取Token失败:', error);
this.url = ''; // URL
} finally { } finally {
this.loading = false; // loading = false
// iframe
// iframe load
// setTimeout
setTimeout(() => {
this.loading = false;
}, 1500); //
} }
}, },
receiveMessage(event) { receiveMessage(event) {
// if (event.origin !== "https://example.com") { // if (event.origin !== "https://example.com") {
// // // //
// return; // return;
@ -83,7 +101,21 @@ export default {
url: this.$route.params.url url: this.$route.params.url
} }
}) })
this.$message.success('退订成功') this.$message.success('购买成功')
// reqBaiduOrderCost(lastPloay).then(res => {
// if (res.status) {
// this.loading = false
// this.$message.success('')
// this.$router.push({
// name: 'userResource',
// params: {
// listUrl: this.$route.params.listUrl,
// url: this.$route.params.url
// }
// })
// }
//
// })
} else { } else {
this.loading = false this.loading = false
this.$message.error(res.msg) this.$message.error(res.msg)
@ -91,21 +123,25 @@ export default {
}) })
// ID // ID
const orderLog = data const orderLog = data
} }
}
},
} }
} };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.box { .box {
padding: 10px; padding: 10px;
height: 100%; height: 100%;
border: 1px solid #ccc; //
} }
.baidu-style { .baidu-style {
width: 100%; width: 100%;
height: calc(100vh - 100px); height: calc(100vh - 100px);
border: 2px dashed #007bff; // 线 iframe
} }
</style> </style>

View File

@ -139,7 +139,7 @@ export default {
this.childComponents = [0] this.childComponents = [0]
} }
}) })
if (JSON.stringify(this.levels) === {}) { if (JSON.stringify(this.levels) == {}) {
this.childComponents = [0] this.childComponents = [0]
} else { } else {
this.addAndDeleteBtn = true this.addAndDeleteBtn = true
@ -181,7 +181,7 @@ export default {
lastResult['user_id'] = this.user_id lastResult['user_id'] = this.user_id
lastResult['orgid'] = this.orgid lastResult['orgid'] = this.orgid
lastResult['business_id'] = this.approvalType lastResult['business_id'] = this.approvalType
lastResult['flag'] = JSON.stringify(this.approvalAllPeople) === {} ? "add" : "update" lastResult['flag'] = JSON.stringify(this.approvalAllPeople) =={} ? "add" : "update"
lastResult["level_data"] = this.approvalAllPeople lastResult["level_data"] = this.approvalAllPeople
reqSaveAllPeople(lastResult).then(res => { reqSaveAllPeople(lastResult).then(res => {
if (res.status) { if (res.status) {