|
@@ -1,143 +1,148 @@
|
|
|
-var strUrl=window.location.href;
|
|
|
-var strIp = "";
|
|
|
-strIp = strUrl.split('//') [1].split('/')[0]
|
|
|
-// if(strIp == 'localhost:8080')
|
|
|
-// {
|
|
|
-// strIp = '172.16.50.4:18080'
|
|
|
-// }
|
|
|
+var strUrl = window.location.href;
|
|
|
+var strIp = '';
|
|
|
|
|
|
-if(strIp == '127.0.0.1:8080')
|
|
|
-{
|
|
|
+strIp = strUrl.split('//')[1].split('/')[0]
|
|
|
+
|
|
|
+if (strIp == 'localhost:8080') {
|
|
|
strIp = '172.16.50.4:18080'
|
|
|
}
|
|
|
-
|
|
|
-if(strIp == '172.16.30.57:8080')
|
|
|
-{
|
|
|
+if (strIp == '127.0.0.1:8080') {
|
|
|
strIp = '172.16.50.4:18080'
|
|
|
}
|
|
|
|
|
|
-const urlBaseSet = {
|
|
|
- OSS: "https://bucket-model.oss-cn-beijing.aliyuncs.com",
|
|
|
- //CDN: "http://127.0.0.1:8080",
|
|
|
- //ICDN: "http://127.0.0.1:8080",
|
|
|
- //TCDN: "http://127.0.0.1:8080",
|
|
|
- //CDN: "https://modelcdn2.3dnest.cn",
|
|
|
- //ICDN: "https://infocdn2.3dnest.cn",
|
|
|
- //TCDN: "https://template2.3dnest.cn",
|
|
|
- //CDN: "http://172.16.50.4:18080",
|
|
|
- //ICDN: "http://172.16.50.4:18080",
|
|
|
- //TCDN: "http://172.16.50.4:18080",
|
|
|
- CDN: "http://" + strIp,
|
|
|
- ICDN: "http://" + strIp,
|
|
|
- TCDN: "http://" + strIp,
|
|
|
- EDIT: "/manager_house/model/rtiframedata/",
|
|
|
+console.log("strIp", strIp)
|
|
|
+
|
|
|
+// 众趣公有云域名
|
|
|
+// const urlBaseSet = {
|
|
|
+// OSS: "https://bucket-model.oss-cn-beijing.aliyuncs.com",
|
|
|
+// CDN: "https://modelcdn2.3dnest.cn",
|
|
|
+// ICDN: "https://infocdn2.3dnest.cn",
|
|
|
+// TCDN: "https://template2.3dnest.cn",
|
|
|
+// EDIT: "/manager_house/model/rtiframedata/",
|
|
|
+// };
|
|
|
+
|
|
|
+const urlBaseSet = {
|
|
|
+ OSS: "https://bucket-model.oss-cn-beijing.aliyuncs.com",
|
|
|
+ //CDN: "http://127.0.0.1:8080",
|
|
|
+ //ICDN: "http://127.0.0.1:8080",
|
|
|
+ //TCDN: "http://127.0.0.1:8080",
|
|
|
+ // CDN: "http://172.16.50.4:18080",
|
|
|
+ // ICDN: "http://172.16.50.4:18080",
|
|
|
+ // TCDN: "http://172.16.50.4:18080",
|
|
|
+ CDN: "http://" + strIp,
|
|
|
+ ICDN: "http://" + strIp,
|
|
|
+ TCDN: "http://" + strIp,
|
|
|
+ EDIT: "/manager_house/model/rtiframedata/",
|
|
|
};
|
|
|
-let modelId; // 模型id
|
|
|
+
|
|
|
+let modelId; // 模型id
|
|
|
let modelVersion; // 模型版本号
|
|
|
let modelSetting; // 模型版本设置
|
|
|
let companyId; // 公司Id
|
|
|
-let globalSetting = null;
|
|
|
+let globalSetting = null;
|
|
|
+
|
|
|
// 获取页面对应的单个参数 start by ytj
|
|
|
function getParams(key) {
|
|
|
- let search = window.location.search.replace(/^\?/, "");
|
|
|
- let pairs = search.split("&");
|
|
|
- let paramsMap = pairs.map(pair => {
|
|
|
- let [key, value] = pair.split("=");
|
|
|
- return [decodeURIComponent(key), decodeURIComponent(value)];
|
|
|
- }).reduce((res, [key, value]) => Object.assign(res, { [key]: value }), {});
|
|
|
- return paramsMap[key] || "";
|
|
|
+ let search = window.location.search.replace(/^\?/, "");
|
|
|
+ let pairs = search.split("&");
|
|
|
+ let paramsMap = pairs.map(pair => {
|
|
|
+ let [key, value] = pair.split("=");
|
|
|
+ return [decodeURIComponent(key), decodeURIComponent(value)];
|
|
|
+ }).reduce((res, [key, value]) => Object.assign(res, { [key]: value }), {});
|
|
|
+ return paramsMap[key] || "";
|
|
|
}
|
|
|
// 获取页面对应的单个参数 end by ytj
|
|
|
|
|
|
-
|
|
|
// 获取模型版本信息
|
|
|
-const getModelVesionUrl = (urlBaseSet)=>{
|
|
|
- modelId = getParams('m');
|
|
|
- let currentDate = new Date().getTime();
|
|
|
- return `${urlBaseSet.CDN }/${modelId}/version.txt?f=${currentDate}`
|
|
|
+const getModelVesionUrl = (urlBaseSet) => {
|
|
|
+ modelId = getParams('m');
|
|
|
+ console.log(modelId)
|
|
|
+ let currentDate = new Date().getTime();
|
|
|
+ return `${urlBaseSet.CDN}/${modelId}/version.txt?f=${currentDate}`
|
|
|
}
|
|
|
// 获取模型配置信息
|
|
|
-const getModelSettingUrl = (urlBaseSet,modelVersion,modelSetting)=>{
|
|
|
- return `${urlBaseSet.ICDN}/${modelId}/${modelVersion}/settings.txt?s=${ modelSetting}`
|
|
|
+const getModelSettingUrl = (urlBaseSet, modelVersion, modelSetting) => {
|
|
|
+ return `${urlBaseSet.ICDN}/${modelId}/${modelVersion}/settings.txt?s=${modelSetting}`
|
|
|
}
|
|
|
// 获取模型公司配置
|
|
|
-const getCompanySettingUrl = (companyId)=>{
|
|
|
- let currentDate = new Date().getTime();
|
|
|
- return `${urlBaseSet.TCDN} /company/${companyId}/company.txt?t=${currrentDate}`
|
|
|
- }
|
|
|
+const getCompanySettingUrl = (companyId) => {
|
|
|
+ let currentDate = new Date().getTime();
|
|
|
+ return `${urlBaseSet.TCDN} /company/${companyId}/company.txt?t=${currrentDate}`
|
|
|
+}
|
|
|
const fetchData = (url) => {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- const xhr = new XMLHttpRequest();
|
|
|
- xhr.open('GET', url);
|
|
|
- xhr.onload = () => {
|
|
|
- if (xhr.status >= 200 && xhr.status < 300) {
|
|
|
- resolve(JSON.parse(xhr.responseText));
|
|
|
- } else {
|
|
|
- reject(xhr.statusText);
|
|
|
- }
|
|
|
- };
|
|
|
- xhr.onerror = () => reject(xhr.statusText);
|
|
|
- xhr.send();
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 这是我们的包装函数,它返回一个数组
|
|
|
- const awaitWrap = (promise) => {
|
|
|
- return promise
|
|
|
- .then(data => [null, data])
|
|
|
- .catch(err => [err, null]);
|
|
|
- }
|
|
|
-
|
|
|
- // 这是我们的主函数,它按顺序执行三个请求,并合并返回的数据
|
|
|
- const fetchAndCombine = async () => {
|
|
|
- console.log('房间加载start', Date.now())
|
|
|
- let combinedData = {};
|
|
|
- let backgroundBgUrl = `${urlBaseSet.ICDN}/${modelId}/https://infocdn2.3dnest.cn/881f840a_q8X6_b6f9_DAP/background.jpg?`
|
|
|
- try {
|
|
|
- let modelVersionUrl = getModelVesionUrl(urlBaseSet);
|
|
|
- const [err1, modelVersionData] = await awaitWrap(fetchData(modelVersionUrl));
|
|
|
- if (err1) {
|
|
|
- throw new Error(`Error fetching data from ${modelVersionUrl}: ${err1}`);
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
+ xhr.open('GET', url);
|
|
|
+ xhr.onload = () => {
|
|
|
+ if (xhr.status >= 200 && xhr.status < 300) {
|
|
|
+ resolve(JSON.parse(xhr.responseText));
|
|
|
+ } else {
|
|
|
+ reject(xhr.statusText);
|
|
|
}
|
|
|
- console.log('=====模型版本数据========',modelVersionData);
|
|
|
- // combinedData = { ...combinedData, ...modelVersionData };
|
|
|
- let modelSettingUrl = getModelSettingUrl(urlBaseSet,modelVersionData.version,modelVersionData.setting)
|
|
|
- const [err2, modelSettingData] = await awaitWrap(fetchData(modelSettingUrl));
|
|
|
- if (err2) throw new Error(`Error fetching data from url2: ${err2}`);
|
|
|
- // onsole.log('=====模型版本数据========',modelSettingData);
|
|
|
- // combinedData = { ...combinedData, ...modelSettingData };
|
|
|
- console.log('=====模型配置数据========',modelSettingData);
|
|
|
- if(!!modelSettingData?.basic?.user?.group&&!!modelSettingData?.basic?.user?.group>1){
|
|
|
- let companySettingUrl = getCompanySettingUrl(modelSettingData.basic.user.group)
|
|
|
- const [err3, data3] = await awaitWrap(fetchData(companySettingUrl));
|
|
|
- if (err3) throw new Error(`Error fetching data from url3: ${err3}`);
|
|
|
- }else {
|
|
|
+ };
|
|
|
+ xhr.onerror = () => reject(xhr.statusText);
|
|
|
+ xhr.send();
|
|
|
+ });
|
|
|
+}
|
|
|
+// 这是我们的包装函数,它返回一个数组
|
|
|
+const awaitWrap = (promise) => {
|
|
|
+ return promise
|
|
|
+ .then(data => [null, data])
|
|
|
+ .catch(err => [err, null]);
|
|
|
+}
|
|
|
+
|
|
|
+// 这是我们的主函数,它按顺序执行三个请求,并合并返回的数据
|
|
|
+const fetchAndCombine = async () => {
|
|
|
+ console.log('房间加载start', Date.now())
|
|
|
+ let combinedData = {};
|
|
|
+ let backgroundBgUrl = `${urlBaseSet.ICDN}/${modelId}/https://infocdn2.3dnest.cn/881f840a_q8X6_b6f9_DAP/background.jpg?`
|
|
|
+ try {
|
|
|
+ let modelVersionUrl = getModelVesionUrl(urlBaseSet);
|
|
|
+ console.log('modelVersionUrl', modelVersionUrl)
|
|
|
+ const [err1, modelVersionData] = await awaitWrap(fetchData(modelVersionUrl));
|
|
|
+ if (err1) throw new Error(`Error fetching data from ${modelVersionUrl}: ${err1}`);
|
|
|
+ console.log('=====模型版本数据========', modelVersionData);
|
|
|
+ // combinedData = { ...combinedData, ...modelVersionData };
|
|
|
+
|
|
|
+ let modelSettingUrl = getModelSettingUrl(urlBaseSet, modelVersionData.version, modelVersionData.setting)
|
|
|
+ console.log('modelSettingUrl', modelSettingUrl)
|
|
|
+ const [err2, modelSettingData] = await awaitWrap(fetchData(modelSettingUrl));
|
|
|
+ if (err2) throw new Error(`Error fetching data from url2: ${err2}`);
|
|
|
+ // combinedData = { ...combinedData, ...modelSettingData };
|
|
|
+ console.log('=====模型配置数据========', modelSettingData);
|
|
|
+
|
|
|
+ if (!!modelSettingData?.basic?.user?.group && !!modelSettingData?.basic?.user?.group > 1) {
|
|
|
+ let companySettingUrl = getCompanySettingUrl(modelSettingData.basic.user.group)
|
|
|
+ console.log('companySettingUrl', companySettingUrl)
|
|
|
+ const [err3, data3] = await awaitWrap(fetchData(companySettingUrl));
|
|
|
+ if (err3) throw new Error(`Error fetching data from url3: ${err3}`);
|
|
|
+ console.log('=====模型公司配置========', data3);
|
|
|
+ } else {
|
|
|
|
|
|
- }
|
|
|
- let siteConf = {
|
|
|
- "type": "display",
|
|
|
- "versionpre": `${urlBaseSet.CDN}/${modelId}/`,
|
|
|
- "modelpre": `${urlBaseSet.CDN}/${modelId}/`,
|
|
|
- "infopre": `${urlBaseSet.ICDN}/${modelId}/`,
|
|
|
- "setpre": `${urlBaseSet.ICDN}/${modelId}/`
|
|
|
-
|
|
|
- }
|
|
|
- globalSetting = {
|
|
|
- modelId: modelId,
|
|
|
- settings: modelSettingData,
|
|
|
- version: modelVersionData,
|
|
|
- siteConf: siteConf,
|
|
|
- enterType: 3
|
|
|
- }
|
|
|
- return [null, globalSetting];
|
|
|
- // combinedData = { ...combinedData, ...data3 };
|
|
|
- } catch (error) {
|
|
|
- return [error, null];
|
|
|
}
|
|
|
-
|
|
|
+ let siteConf = {
|
|
|
+ "type": "display",
|
|
|
+ "versionpre": `${urlBaseSet.CDN}/${modelId}/`,
|
|
|
+ "modelpre": `${urlBaseSet.CDN}/${modelId}/`,
|
|
|
+ "infopre": `${urlBaseSet.ICDN}/${modelId}/`,
|
|
|
+ "setpre": `${urlBaseSet.ICDN}/${modelId}/`
|
|
|
+
|
|
|
+ }
|
|
|
+ globalSetting = {
|
|
|
+ modelId: modelId,
|
|
|
+ settings: modelSettingData,
|
|
|
+ version: modelVersionData,
|
|
|
+ siteConf: siteConf,
|
|
|
+ enterType: 3
|
|
|
+ }
|
|
|
return [null, globalSetting];
|
|
|
+ // combinedData = { ...combinedData, ...data3 };
|
|
|
+ } catch (error) {
|
|
|
+ return [error, null];
|
|
|
}
|
|
|
-
|
|
|
- // 导出主函数
|
|
|
- export default fetchAndCombine;
|
|
|
-
|
|
|
+
|
|
|
+ return [null, globalSetting];
|
|
|
+}
|
|
|
+
|
|
|
+// 导出主函数
|
|
|
+export default fetchAndCombine;
|