|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
|
|
import { CacheTokenService } from '../http-interceptors/cache-token.service';
|
|
|
|
import { Viewer } from 'photo-sphere-viewer';
|
|
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
|
|
|
|
|
|
declare var CryptoJS
|
|
|
|
@Component({
|
|
|
|
selector: 'app-external-links-plan',
|
|
|
|
templateUrl: './external-links-plan.component.html',
|
|
|
|
styleUrls: ['./external-links-plan.component.scss']
|
|
|
|
})
|
|
|
|
export class ExternalLinksPlanComponent implements OnInit {
|
|
|
|
|
|
|
|
constructor(private http: HttpClient, private token: CacheTokenService, public route: ActivatedRoute, private sanitizer: DomSanitizer) { }
|
|
|
|
planId: any//预案id
|
|
|
|
viewer//全景图对象
|
|
|
|
fetchUrl//预案文件地址
|
|
|
|
showType//预案类型 1:全景图
|
|
|
|
planData//预案信息
|
|
|
|
async ngOnInit(): Promise<void> {
|
|
|
|
await this.login()//登录存储token
|
|
|
|
this.route.queryParams.subscribe(paramsData => {
|
|
|
|
this.planId = paramsData.planId
|
|
|
|
let planId = paramsData.planId
|
|
|
|
this.http.get(`/api/PlanComponents/${planId}`).subscribe((data: any) => {
|
|
|
|
console.log('单个预案详细信息', data)
|
|
|
|
this.planData = data
|
|
|
|
if (data.planType != 1 && data.planType != 2) {
|
|
|
|
this.fetchUrl = data.attachmentUrls[0]
|
|
|
|
var index = this.fetchUrl.indexOf("\/")
|
|
|
|
if (this.fetchUrl.substr(0, index) == 'psw') {
|
|
|
|
this.showType = 1
|
|
|
|
var obj = document.getElementById('viewer')
|
|
|
|
if (obj != null) {
|
|
|
|
obj.innerHTML = ''
|
|
|
|
}
|
|
|
|
window.setTimeout(() => {
|
|
|
|
this.viewer = new Viewer({
|
|
|
|
container: document.querySelector('#viewer'),
|
|
|
|
panorama: '/api/Objects/PlanPlatform/' + this.fetchUrl,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
//毕生
|
|
|
|
this.lookWord()
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// 二维三维预案
|
|
|
|
this.handleData()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
async login() {
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
this.http.post('/api/Account/SignIn', {
|
|
|
|
name: 'zhuzhouyuanchakan',
|
|
|
|
password: '12345678'
|
|
|
|
}).subscribe((data: any) => {
|
|
|
|
sessionStorage.setItem("level", data.level);
|
|
|
|
sessionStorage.setItem("token", data.token);
|
|
|
|
sessionStorage.setItem("refreshToken", data.refreshToken);
|
|
|
|
console.log('登录成功', data)
|
|
|
|
resolve(data)
|
|
|
|
this.token.startUp()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
iframeSrc//毕生服务器链接
|
|
|
|
src//文件存储地址
|
|
|
|
lookWord() {
|
|
|
|
let docIdWordArray = CryptoJS.enc.Utf8.parse(`PlanPlatform/` + this.fetchUrl);
|
|
|
|
let docId = CryptoJS.enc.Base64.stringify(docIdWordArray);
|
|
|
|
let jwt = sessionStorage.getItem("token");
|
|
|
|
let rawJwt = CryptoJS.enc.Base64.parse(jwt.split('.')[1]);
|
|
|
|
let identityJson = CryptoJS.enc.Utf8.stringify(rawJwt);
|
|
|
|
let identityJsonparse = JSON.parse(identityJson)
|
|
|
|
let filename: string
|
|
|
|
this.http.get(`/api/ObjectMetadata/PlanPlatform/${this.fetchUrl}`).subscribe((data: any) => {
|
|
|
|
filename = data.fileName
|
|
|
|
let json = {
|
|
|
|
doc: {
|
|
|
|
docId: docId,
|
|
|
|
title: filename,
|
|
|
|
//title: filename,
|
|
|
|
fetchUrl: `http://172.18.0.1:8000/api/Objects/PlanPlatform/` + this.fetchUrl
|
|
|
|
},
|
|
|
|
user: {
|
|
|
|
uid: identityJsonparse.sub,
|
|
|
|
nickName: identityJsonparse.name,
|
|
|
|
avatar: "",
|
|
|
|
privilege: [
|
|
|
|
'FILE_READ', 'FILE_DOWNLOAD', 'FILE_PRINT'
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
var stringjson = JSON.stringify(json)
|
|
|
|
var wordArray = CryptoJS.enc.Utf8.parse(stringjson);
|
|
|
|
var base64 = CryptoJS.enc.Base64.stringify(wordArray);
|
|
|
|
this.src = `http://10.81.73.39:18080/apps/editor/openPreview?data=${base64}`
|
|
|
|
this.iframeSrc = this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
|
|
|
|
this.showType = 0
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
companyData//当前公司信息
|
|
|
|
thirdPartyURL
|
|
|
|
threedUrl: any
|
|
|
|
handleData() {
|
|
|
|
let data = this.planData
|
|
|
|
if (this.planData.planMode == 2) { //预案planMode=2时, 跳查看页面组件
|
|
|
|
|
|
|
|
this.http.get(`/api/Plans/${data.companyId}`).subscribe((data: any) => {
|
|
|
|
console.log(data)
|
|
|
|
data && data.company ? this.companyData = data.company : null
|
|
|
|
sessionStorage.setItem("buildingTypeId", this.companyData.buildingTypes.length ? this.companyData.buildingTypes[0].id : undefined);
|
|
|
|
sessionStorage.setItem("companyId", data.companyId);
|
|
|
|
sessionStorage.setItem("planId", this.planId);
|
|
|
|
sessionStorage.setItem("editable", '0');
|
|
|
|
sessionStorage.setItem("planName", this.planData.name)
|
|
|
|
this.showType = 3
|
|
|
|
// this.threedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(`/keyUnit/viewunitinfoplans?id=${data.companyId}`)
|
|
|
|
})
|
|
|
|
} else if (this.planData.planMode == 3) { //预案planMode=3时, 第三方网址'
|
|
|
|
this.http.get(`/api/Plans/${data.companyId}`).subscribe((data: any) => {
|
|
|
|
data && data.company ? this.companyData = data.company : null
|
|
|
|
this.threedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(data.url)
|
|
|
|
this.showType = 2
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|