Browse Source

判断当前项目的类别,高度随着发生改变

iframe-展示详情页
aBin 4 years ago
parent
commit
a65f3c77a7
  1. 58
      index.html

58
index.html

@ -47,14 +47,17 @@
<!-- 示例插件2 id=100-->
<button class="bg-blue-500 py-2 px-5 rounded text-white" onclick="p100.show()">测试组建2</button>
<div data-tname="静脉溶栓" data-param='{"url":"http://www.baidu.com"}' data-pid="1420652719055839232" data-uid="1323567842540523520" data-rid="rid333" data-tid="tid444" data-did="did555" data-pstart="1627560659000" data-rstart="1627564259000" style="height:300px;width:100%">
<div data-tname="静脉溶栓" data-param='{"url":"http://www.baidu.com"}' data-pid="1455842392497463296" data-uid="1443567335800705024" data-rid="rid333" data-tid="tid444" data-did="did555" data-pstart="1627560659000" data-rstart="1627564259000" style="height:300px;width:100%">
<!-- 详情页插件 -->
<div id="iDom-box" data-root="p1432643387798069249" class="flex flex-column flex-wrap items-center" style="height:calc(80vh - 104px);width:100%;">
<div id="iDom-box" data-root="p1432643387798069249" class="flex flex-column flex-wrap items-center">
</div>
</div>
<script>
var p1432643387798069249 = {
token: null,
data: null,
init() {
var domBox = document.getElementById('iDom-box');
var param = domBox.parentNode.getAttribute('data-param');
@ -69,6 +72,7 @@
var rId = domBox.parentNode.getAttribute('data-rid');
var uId = domBox.parentNode.getAttribute('data-uid');
var tId = domBox.parentNode.getAttribute('data-tid');
this.getTokenByUserId(uId,pId)
let jumpUrl = `${url}?projectId=${pId}&roleId=${rId}&userId=${uId}&id=${tId}`;
for(let key in paramData) {
if(key !== 'url'){
@ -78,6 +82,56 @@
iDom.src = jumpUrl;
domBox.appendChild(iDom)
},
// 获取token
getTokenByUserId(userId,projectId){
var that = this
fetch(`https://www.tall.wiki/gateway/tall3/v3.0/users/userId?userId=${userId}`)
.then(function(response) {
return response.json();
})
.then(function(res) {
var { success, code, data, msg } = res;
if (success && code === 200) {
that.token = data.token;
console.log('data: ', data);
that.getByProject(projectId)
} else {
alert(msg || '获取失败')
}
});
},
getByProject(projectId){
var that = this;
var params = JSON.stringify({ param: { projectId:'1455842392497463296' }});
fetch('https://www.tall.wiki/gateway/carbasics/v4.0/organization/getByProject', {
headers: new Headers({
'Authorization': 'Bearer ' + that.token,
'Content-Type': 'application/json;charset=utf-8'
}),
method: 'POST',
mode: 'cors',
body: params
}).then(function(response) {
return response.json();
}).catch(function(error){
console.error('Error:', error)
// TODO: 测试数据
// TODO:
}).then(function(res){
var { success, code, data, msg } = res;
if (success && code === 200) {
console.log('data: ', data);
if(data && data.organizationType === 0) {
var domBox = document.getElementById('iDom-box');
domBox.style.height = '100vh'
} else {
domBox.style.height = 'calc(80vh - 104px);width:100%'
}
} else {
console.log(msg)
}
})
},
}
p1432643387798069249.init()
</script>

Loading…
Cancel
Save