锘?** 姝e紡 */ const BASE_URL = "http://zshaitu.com"; // 鍚庡彴绠$悊鎺ュ彛鍦板潃 const SOCKET_URL = "zshaitu.com"; /** 娴嬭瘯 */ // const BASE_URL = "http://dinganwang.top:38080"; // 鍓嶅彴鐣岄潰閮ㄧ讲璺緞 娴嬭瘯 // const SOCKET_URL = "dinganwang.top:38080"; // websocket鍦板潃 const MAIN_URL = ""; /** 鏈湴 */ // const MAIN_URL = "http://localhost:5500"; // 鍓嶅彴鐣岄潰閮ㄧ讲璺緞 鏈湴 let columnTreeData = null; const IS_ENCRYPT = true; /** 浣跨敤fetch灏佽post璇锋眰 */ async function requestPostApi({ url, data = {}, params = {}, headers = {} }) { const Authorization = getToken(); let body = {}; if (Object.values(data).length !== 0) { body = { body: JSON.stringify(data) }; } const result = await fetch(joinApiParams({ url, params }), { method: "POST", headers: { Authorization, // "Access-Control-Allow-Origin": "*", "Content-Type": "application/json", ...headers, }, ...body, }); return result.json(); } /** 浣跨敤fetch灏佽get璇锋眰 */ async function requestGetApi({ url, params = {}, headers = {} }) { const result = await fetch(joinApiParams({ url, params }), { method: "GET", headers: { Authorization: getToken(), ContentType: "application/json", ...headers, }, }); return result.json(); } function joinApiParams({ url, params = {} }) { let resultUrl = Object.keys(params).length ? `${BASE_URL}${url}?` : `${BASE_URL}${url}`; if (Object.keys(params).length) { Object.keys(params).forEach((ele, index) => { resultUrl = index !== Object.keys(params).length - 1 ? `${resultUrl}${ele}=${params[ele]}&` : `${resultUrl}${ele}=${params[ele]}`; }); } return resultUrl; } function getToken() { const token = getStore({ name: "accessToken" }); return token ? `bearer ${token}` : ""; } /** * 璁剧疆storage缂撳瓨 */ function setStore(params) { let { name, content, session } = params; name = `zsseamap-${name}`; if (typeof content === "function") { content = content.toString(); } const obj = { dataType: typeof content, content: content, type: session ? "sessionstorage" : "localstorage", datetime: new Date().getTime(), }; if (session) window.sessionStorage.setItem(name, JSON.stringify(obj)); else window.localStorage.setItem(name, JSON.stringify(obj)); } /** * 鑾峰彇storage缂撳瓨 */ function getStore(params = {}) { let { name } = params; name = `zsseamap-${name}`; let obj = {}; obj = window.sessionStorage.getItem(name); if (obj === null) { obj = window.localStorage.getItem(name); } if (obj === null) { console.warn(`鏈壘鍒扮紦瀛橈紝${name}涓嶅瓨鍦紒`); return; } try { obj = JSON.parse(obj); } catch (e) { return obj; } const basicTypes = ["string", "number", "boolean", "object"]; if (basicTypes.includes(obj.type)) { return obj.content; } else if (obj.type === "function") { return stringParseToFunction(obj.content); } return obj.content; } /** * 娓呯┖storage */ function clearLocalStore() { window.localStorage.clear(); } function asxyTemplateInit() { let tps = $(".asxyTemplate"); if (tps.length > 0) { tps.each(function () { let tp = $(this); let url = tp.attr("url"); let init = tp.attr("init"); $.ajax({ type: "get", url: MAIN_URL + url, dataType: "html", success: function (html) { tp[0].outerHTML = html.replace( /\"\/template/gi, '"' + MAIN_URL + "/template" ); eval(init); }, }); }); } } let customResources = [ "/template/uHeader/uHeader.js", "/template/uFooter/uFooter.js", "/template/uContact/uContact.js", "/template/uBreadcrumb/uBreadcrumb.js", "/template/uNavsSheet/uNavsSheet.js", "/template/uNavsSheetProduct/uNavsSheet.js", "/template/uBanner/uBanner.js", "/utils/message/message.js", ]; // 鍔ㄦ€佸姞杞絁S鏂囦欢鐨勫嚱鏁 async function initPageCommon(callback) { // beforePageYOffset(); // afterLoadPageYOffset(); customResources.forEach((src, index) => { let script = document.createElement("script"); script.src = src; // 鍙€夌殑锛氫负鑴氭湰鍔犺浇娣诲姞浜嬩欢鐩戝惉鍣 script.onload = () => { // 濡傛灉杩欐槸鏈€鍚庝竴涓剼鏈紝鎵ц鏌愪簺鎿嶄綔 if (index === customResources.length - 1) { getColumnTreeApi().then((data) => { columnTreeData = data; // columnTreeData = addData1; asxyTemplateInit(); callback(); }); } }; // 鍙€夌殑锛氫负鑴氭湰鍔犺浇閿欒娣诲姞浜嬩欢鐩戝惉鍣 script.onerror = () => { console.error(`Failed to load script ${src}.`); }; // 灏咟script>鏍囩娣诲姞鍒?body>涓 document.body.appendChild(script); }); } const routerPageList = [ { id: "aCompany-gsgk", currentName: "aCompany-profile", name: "鍏徃姒傚喌", bannerData: { content: "涓€瀹朵笓涓氭彁渚涘叏鐞冭埅娴峰浘涔﹁祫鏂欍€佸畼鏂圭數瀛愭捣鍥炬暟鎹湇鍔″拰鍩轰簬鐢靛瓙娴峰浘浜у搧鐮斿彂鐨勬妧鏈湇鍔″晢銆?, bgImg: "/template/uBanner/img/common-banner-type1.png", }, subNameArr: [ "aCompany-profile", "aCompany-history", "aCompany-honor", "aCompany-culture", "aCompany-partner", ], link: "/pages/aCompany-profile/aCompany-profile.html", children: [ { id: "aCompany-profile", name: "鍏徃绠€浠?, link: "/pages/aCompany-profile/aCompany-profile.html", }, { id: "aCompany-history", name: "鍙戝睍鍘嗙▼", link: "/pages/aCompany-history/aCompany-history.html", }, { id: "aCompany-honor", name: "鑽h獕璧勮川", link: "/pages/aCompany-honor/aCompany-honor.html", }, { id: "aCompany-culture", name: "浼佷笟鏂囧寲", link: "/pages/aCompany-culture/aCompany-culture.html", }, { id: "aCompany-partner", name: "鍚堜綔浼欎即", link: "/pages/aCompany-partner/aCompany-partner.html", }, ], }, { id: "aLine-zxxg", currentName: "aLine-shopping", name: "鍦ㄧ嚎閫夎喘", bannerData: { content: "涓€瀹朵笓涓氭彁渚涘叏鐞冭埅娴峰浘涔﹁祫鏂欍€佸畼鏂圭數瀛愭捣鍥炬暟鎹湇鍔″拰鍩轰簬鐢靛瓙娴峰浘浜у搧鐮斿彂鐨勬妧鏈湇鍔″晢銆?, bgImg: "/template/uBanner/img/common-banner-type4.png", }, subNameArr: ["aLine-shopping"], link: "/pages/aLine-shopping/aLine-shopping.html", children: [ { id: "aLine-shopping", name: "鍦ㄧ嚎閫夎喘", link: "/pages/aLine-shopping/aLine-shopping.html", }, ], }, { id: "aProduct-cpfw", currentName: "aProduct-books", name: "浜у搧鏈嶅姟", bannerData: { content: "鎻愪緵鑸捣鍥句功銆佺數瀛愭捣鍥俱€佽埅鏍囩淮鎶ゃ€佽埅娴峰伐鍏?, bgImg: "/template/uBanner/img/common-banner-type3.png", }, subNameArr: [ "aProduct-books", "aProduct-seamap", "aProduct-marks", "aProduct-tools", ], link: "/pages/aProduct-books/aProduct-books.html", children: [ { id: "aProduct-books", name: "鑸捣鍥句功", link: "/pages/aProduct-books/aProduct-books.html", children: [ { id: "aProduct-books-information", name: "鍥句功璧勬枡", children: [ { id: "aProduct-books-information-seaway", name: "娴峰啗娴烽亾娴嬮噺灞€", }, { id: "aProduct-books-information-marineboard", name: "娴蜂簨灞€", }, { id: "aProduct-books-information-Changjiangchannel", name: "闀挎睙鑸亾", }, { id: "aProduct-books-information-UK", name: "鑻辩増", }, { id: "aProduct-books-information-else", name: "鍏朵粬", }, ], }, { id: "aProduct-books-seamap", name: "娴峰浘璧勬枡", children: [ { id: "aProduct-books-seamap-seaway", name: "娴峰啗娴烽亾娴嬮噺灞€", }, { id: "aProduct-books-seamap-marineboard", name: "娴蜂簨灞€", }, { id: "aProduct-books-seamap-Changjiangchannel", name: "闀挎睙鑸亾", }, { id: "aProduct-books-seamap-UK", name: "鑻辩増", }, ], }, ], }, { id: "aProduct-seamap", name: "鐢靛瓙娴峰浘", link: "/pages/aProduct-seamap/aProduct-seamap.html", children: [ { id: "aProduct-seamap-type", name: "鏁版嵁绫诲埆", children: [], }, { id: "aProduct-seamap-equipment", name: "娴峰浘璁惧", children: [], }, { id: "aProduct-seamap-software", name: "娴峰浘杞欢", children: [], }, { id: "aProduct-seamap-exploit", name: "娴峰浘寮€鍙?, children: [], }, { id: "aProduct-seamap-case", name: "缁忓吀妗堜緥", children: [], }, ], }, { id: "aProduct-marks", name: "鑸爣缁存姢", link: "/pages/aProduct-marks/aProduct-marks.html", children: [ { id: "aProduct-marks-maintain", name: "鑸爣缁存姢", children: [], }, ], }, { id: "aProduct-tools", name: "鑸捣宸ュ叿", link: "/pages/aProduct-tools/aProduct-tools.html", children: [ { id: "aProduct-tools-plot", name: "缁樺浘宸ュ叿", children: [], }, { id: "aProduct-tools-measure", name: "娴嬮噺浠櫒", children: [], }, { id: "aProduct-tools-instrument", name: "鏅埅浠櫒", children: [], }, { id: "aProduct-tools-time", name: "璁℃椂浠櫒", children: [], }, ], }, ], }, { id: "aDownload-xzzx", currentName: "aDownload-hangbao", name: "涓嬭浇涓績", bannerData: { content: "鎻愪緵鑸繚閮ㄧ數瀛愭捣鍥剧瓑鏁版嵁涓嬭浇", bgImg: "/template/uBanner/img/common-banner-type4.png", }, subNameArr: [ "aDownload-hangbao", "aDownload-haishi", "aDownload-UKHO", "aDownload-hbtg", "aDownload-hsgztg", "aDownload-UKHOybgg", "aDownload-ADC", "aDownload-HK", "aDownload-changjiang", "aDownload-yydzht", "aDownload-cssj", "aDownload-gnhhts", "aDownload-htggsycz", ], link: "/pages/aDownload-hangbao/aDownload-hangbao.html", children: [ { id: "aDownload-hangbao", name: "鑸繚閮ㄧ數瀛愭捣鍥炬暟鎹?, link: "/pages/aDownload-hangbao/aDownload-hangbao.html", }, { id: "aDownload-haishi", name: "娴蜂簨灞€鐢靛瓙娴峰浘鏁版嵁", link: "/pages/aDownload-haishi/aDownload-haishi.html", }, { id: "aDownload-UKHO", name: "UKHO鐢靛瓙娴峰浘鏁版嵁", link: "/pages/aDownload-UKHO/aDownload-UKHO.html", }, { id: "aDownload-hbtg", name: "鑸繚閮ㄨ埅娴烽€氬憡", link: "/pages/aDownload-hbtg/aDownload-hbtg.html", }, { id: "aDownload-hsgztg", name: "娴蜂簨灞€鏀规閫氬憡", link: "/pages/aDownload-hsgztg/aDownload-hsgztg.html", }, { id: "aDownload-UKHOybgg", name: "UKHO鑻辩増閫氬憡", link: "/pages/aDownload-UKHOybgg/aDownload-UKHOybgg.html", }, { id: "aDownload-ADC", name: "ADC鑻辩増閫夊浘宸ュ叿", link: "/pages/aDownload-ADC/aDownload-ADC.html", }, { id: "aDownload-HK", name: "HK鑸捣閫氬憡", link: "/pages/aDownload-HK/aDownload-HK.html", }, { id: "aDownload-changjiang", name: "闀挎睙涓嬫父鑸亾閫氬憡", link: "/pages/aDownload-changjiang/aDownload-changjiang.html", }, { id: "aDownload-yydzht", name: "娓斾笟鐢靛瓙娴峰浘", link: "/pages/aDownload-yydzht/aDownload-yydzht.html", }, { id: "aDownload-cssj", name: "娴嬭瘯鏁版嵁", link: "/pages/aDownload-cssj/aDownload-cssj.html", }, { id: "aDownload-gnhhts", name: "鍥藉唴鑸捣鍥句功璧勬枡琛?, link: "/pages/aDownload-gnhhts/aDownload-gnhhts.html", }, { id: "aDownload-htggsycz", name: "娴峰浘閫氬憡绱㈠紩璧勬枡", link: "/pages/aDownload-htggsycz/aDownload-htggsycz.html", }, ], }, { id: "aNews-xwzx", currentName: "aNews-company", name: "鏂伴椈璧勮", bannerData: { content: "鍙戝竷鏈€鏂板叕鍙告柊闂汇€佽涓氬姩鎬併€佹秷鎭€氱煡", bgImg: "/template/uBanner/img/common-banner-type5.png", }, subNameArr: ["aNews-company", "aNews-industry", "aNews-message"], link: "/pages/aNews-company/aNews-company.html", children: [ { id: "aNews-company", name: "鍏徃鏂伴椈", link: "/pages/aNews-company/aNews-company.html", }, { id: "aNews-industry", name: "琛屼笟鍔ㄦ€?, link: "/pages/aNews-industry/aNews-industry.html", }, { id: "aNews-message", name: "娑堟伅閫氱煡", link: "/pages/aNews-message/aNews-message.html", }, ], }, { id: "aSupport-khzc", currentName: "aSupport-seamap", name: "瀹㈡埛鏀寔", bannerData: { content: "鍙戝竷鏈€鏂板叕鍙告柊闂汇€佽涓氬姩鎬併€佹秷鎭€氱煡", bgImg: "/template/uBanner/img/common-banner-type6.png", }, link: "/pages/aSupport-seamap/aSupport-seamap.html", subNameArr: [ "aSupport-seamap", "aSupport-amendment", "aSupport-maintain", "aSupport-equipment", "aSupport-case", ], children: [ { id: "aSupport-seamap", name: "鐢靛瓙娴峰浘", link: "/pages/aSupport-seamap/aSupport-seamap.html", }, { id: "aSupport-amendment", name: "娴峰浘鏍℃敼", link: "/pages/aSupport-amendment/aSupport-amendment.html", }, { id: "aSupport-maintain", name: "鑸爣缁存姢", link: "/pages/aSupport-maintain/aSupport-maintain.html", }, { id: "aSupport-equipment", name: "閫氬璁惧", link: "/pages/aSupport-equipment/aSupport-equipment.html", }, { id: "aSupport-case", name: "搴旂敤妗堜緥", link: "/pages/aSupport-case/aSupport-case.html", }, ], }, { id: "aContact-zpfb", currentName: "aZContact-invite", name: "鑱旂郴鎴戜滑", bannerData: { content: "鍙戝竷鑱旂郴鏂瑰紡銆佹渶鏂版嫑鑱樻秷鎭?, bgImg: "/template/uBanner/img/common-banner-type6.png", }, subNameArr: ["aZContact-invite"], link: "/pages/aZContact-invite/aZContact-invite.html", }, { id: "aContact-lxwm", currentName: "aContact-us", name: "鑱旂郴鎴戜滑", bannerData: { content: "鍙戝竷鑱旂郴鏂瑰紡銆佹渶鏂版嫑鑱樻秷鎭?, bgImg: "/template/uBanner/img/common-banner-type6.png", }, subNameArr: ["aContact-us", "aContact-invite"], link: "/pages/aContact-us/aContact-us.html", children: [ { id: "aContact-us", name: "鑱旂郴鎴戜滑", link: "/pages/aContact-us/aContact-us.html", }, { id: "aContact-invite", name: "鎷涜搐绾冲+", link: "/pages/aContact-invite/aContact-invite.html", }, ], }, ]; function handleBreadcrumb() { let url = window.location.href; let lastComponentName = url.lastIndexOf("/"); // 濡傛灉鎵惧埌浜?/'锛屽垯缁х画鏌ユ壘'.html'鐨勪綅缃 if (lastComponentName !== -1) { // 浠庢渶鍚庝竴涓?/'涔嬪悗寮€濮嬫煡鎵?.html'鐨勪綅缃 let htmlIndex = url.indexOf(".html", lastComponentName); // 濡傛灉鎵惧埌浜?.html'锛屽垯鎴彇涓よ€呬箣闂寸殑瀛楃涓 if (htmlIndex !== -1) { let filename = url.slice(lastComponentName + 1, htmlIndex); return filename; } } return "index"; } function getCommonApi({ data = {}, isAuth = false }) { const url = isAuth ? "/haituWebApi/rest/auth/web/article/getPage" : "/haituWebApi/rest/web/article/getPage"; return new Promise((resolve, reject) => { requestPostApi({ url, data, }) .then(({ data }) => { resolve(data); }) .catch((e) => { reject(e); }); }); } function getCommonArticleDetailApi(id) { return new Promise((resolve, reject) => { requestPostApi({ url: "/haituWebApi/rest/web/article/getDetail", data: { id, }, }) .then(({ data }) => { resolve(data); }) .catch((e) => { reject(e); }); }); } // 鑾峰彇鏍忕洰鍒楄〃鏁版嵁 async function getColumnTreeApi() { const currentURL = window.location.href; if (currentURL.includes("index")) { localStorage.removeItem("zsseamap-columnTree"); const result = await requestPostApi({ url: "/haituWebApi/rest/web/column/getTree", data: { id: 1, }, }); setStore({ name: "columnTree", content: result?.data }); return result.data; } else { let data = getStore({ name: "columnTree" }); if (data) { return data; } else { const result = await requestPostApi({ url: "/haituWebApi/rest/web/column/getTree", data: { id: 1, }, }); setStore({ name: "columnTree", content: result?.data }); return result.data; } } } // 璺宠浆鍔ㄦ€乸age椤 function gotoPageHref(url, type) { if (type == 1) { return url; } else { return MAIN_URL + `/pages/${url}/${url}.html`; // window.location.href = MAIN_URL + `/pages/${url}/${url}.html`; } } // 椤甸潰璺宠浆 function setHref(path, query = "") { let str = escape(query); if (query) { window.location.href = MAIN_URL + path + "?" + str; } else { window.location.href = MAIN_URL + path; } } // 椤甸潰璺宠浆 function setHrefNews(path, query = "", win = "_self") { let str = escape(query); if (query) { window.open(MAIN_URL + path + "?" + str, "_blank"); } else { window.open(MAIN_URL + path, "_blank"); } } // 瑙e瘑url function decryptUrl(url) { // 鍒涘缓涓€涓猆RL瀵硅薄 const urlObj = new URL(url); // 鑾峰彇URLSearchParams瀵硅薄 const params = new URLSearchParams(urlObj.search); // 鍒涘缓涓€涓┖瀵硅薄鏉ュ瓨鍌ㄩ敭鍊煎 const queryParams = {}; // 閬嶅巻URLSearchParams瀵硅薄锛屽皢閿€煎娣诲姞鍒版柊瀵硅薄涓 for (const [key, value] of params.entries()) { // 浣跨敤decodeURIComponent瑙g爜閿拰鍊 queryParams[decodeURIComponent(key)] = decodeURIComponent(value); } let urlArr = Object.keys(queryParams)[0]; if (!urlArr) { return {}; } let urlArr2 = urlArr.split("&"); let lastUrlObj = {}; urlArr2.forEach((item) => { let key = item.split("=")[0]; let value = item.split("=")[1]; lastUrlObj[key] = value; }); return lastUrlObj; } /** * 鏃ユ湡鏍煎紡鍖 */ function dateFormat(DATE, format) { format = format || "yyyy-MM-dd hh:mm:ss"; if (typeof DATE === "string") { DATE = DATE.replace(/-/g, "/"); } const date = new Date(DATE); if (date !== "Invalid Date") { const o = { "M+": date.getMonth() + 1, // month "d+": date.getDate(), // day "h+": date.getHours(), // hour "m+": date.getMinutes(), // minute "s+": date.getSeconds(), // second "q+": Math.floor((date.getMonth() + 3) / 3), // quarter S: date.getMilliseconds(), // millisecond }; if (/(y+)/.test(format)) { format = format.replace( RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length) ); } for (const k in o) { if (new RegExp("(" + k + ")").test(format)) { format = format.replace( RegExp.$1, RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length) ); } } return format; } return ""; } // 鍦ㄥ綋鍓嶉〉闈㈢寮€涔嬪墠 function beforePageYOffset() { window.addEventListener("beforeunload", function () { // 鑾峰彇褰撳墠婊氬姩浣嶇疆 const scrollTop = window.scrollY || window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; // 淇濆瓨婊氬姩浣嶇疆鍒發ocalStorage localStorage.setItem("scrollPosition", scrollTop); }); } // 鍦ㄦ柊椤甸潰鍔犺浇鏃剁殑椤甸潰浣嶇疆 function afterLoadPageYOffset() { window.addEventListener("load", function () { // 浠巐ocalStorage璇诲彇婊氬姩浣嶇疆 const scrollPosition = localStorage.getItem("scrollPosition"); if (scrollPosition) { // 婊氬姩鍒版柊浣嶇疆 window.scrollTo(0, scrollPosition); // 娓呴櫎localStorage涓殑鍊硷紝閬垮厤涓嬫鍔犺浇鏃堕噸澶嶆粴鍔 localStorage.removeItem("scrollPosition"); } }); } // 鍒ゆ柇鑳藉惁涓嬭浇 function handleIsDownload(url = "", isDown) { if (!isDown) { return; } if (!url) { MessagePrompt("鏃犳枃浠跺湴鍧€", "error"); return; } let urlArr = url.split(","); let urlPdf = ""; if (urlArr.length === 1) { window.open(url); } else if (urlArr.length >= 2) { urlArr.forEach((item) => { let urlArrItem = item.split("."); if (urlArrItem[1] === "pdf" || urlArrItem[1] === "PDF") { urlPdf = item; } else { window.open(item); } }); } } // 鏄惁鏄剧ず鍐呭璇︽儏鎸夐挳 function isShowPreviewPDFbtn(url) { console.log(url,'urlurl'); let urlPdf = ""; if (!url) { return false; } let urlArr = url.split(","); if (urlArr.length >= 2) { urlArr.forEach((item) => { let urlArrItem = item.split("."); if (urlArrItem[1] == "pdf" || urlArrItem[1] == "PDF") { urlPdf = item; } }); if (urlPdf) return true; }else { return true; } return false; } // 棰勮鍦板潃澶勭悊 function handlePreviewPDF(url) { let urlPdf = ""; if (!url) { return false; } let urlArr = url.split(","); if (urlArr.length >= 2) { urlArr.forEach((item) => { let urlArrItem = item.split("."); if (urlArrItem[1] == "pdf" || urlArrItem[1] == "PDF" || urlArrItem[1] == "png" || urlArrItem[1] == "PNG") { urlPdf = item; } }); if (urlPdf) return urlPdf; }else if (urlArr.length == 1){ let urlArrItem = url.split("."); if (urlArrItem[1] == "pdf" || urlArrItem[1] == "PDF" || urlArrItem[1] == "png" || urlArrItem[1] == "PNG") { url = url + ".preview"; } return url; } return urlPdf; } let enumProductGroupData = { "aProduct-books": { cjg: "浠锋牸", czzvalue: "缂栧埗", ccbfx: "鍑虹増鍙戣", cfxbb: "鍙戣鐗堟湰", cbbyc: "鐗堟湰鍗版", csjkb: "涔︾睄寮€鏈?, }, "aProduct-seamap": { cjg: "浠锋牸", cformat: "鏁版嵁鏍煎紡", corganization: "鍙戣鏈烘瀯", }, "aProduct-marks": { cprice: "浠锋牸", cjsyq: "鎶€鏈姹?, czxrx: "鍜ㄨ鐑嚎", }, "aProduct-tools": { cjg: "浠锋牸", cggxh: "鍨嬪彿瑙勬牸", }, }; let booksListPage = { cjg: "浠锋牸", czzvalue: "缂栧埗", ccbfx: "鍑虹増鍙戣", }; let dataProductType=[['2323','2324','2325','2326','2327','2328','2329','2330','2331'], ['2332'],['2337'],['2391','2401','2402','2403']] // 缃戠珯椤甸潰杩涘叆娆℃暟缁熻 function countPageAdd(pageName = "") { requestPostApi({ url: `/haituWebApi/rest/web/view/record/${pageName}`, }).then(() => {}); } // 鑾峰彇ip鎺ュ彛 async function getIpAddress() { let address = getStore({ name: "address" }); if (!address) { await requestGetApi({ url: "/haituWebApi/rest/auth/getIp", }).then((data) => { if (data.code == "200") { setStore({ name: "address", content: data?.data }); return data?.data; } }); } else { return address; } } async function websocketMonitor() { let address = await getIpAddress(); let socket = new WebSocket( `ws://${SOCKET_URL}/haituWebSocket/api/websocket/${address}` ); let heartbeatInterval; // 褰 WebSocket 杩炴帴鎵撳紑鏃舵墽琛 socket.onopen = function (event) { // console.log("WebSocket is open."); startHeartbeat(); // 寮€濮嬪績璺 }; // 褰撴敹鍒版秷鎭椂鎵ц socket.onmessage = function (event) { // console.log("Received message: " + event.data); // 鍦ㄦ澶勭悊鎺ユ敹鍒扮殑娑堟伅 }; // 鍙戦€佸績璺虫秷鎭 function sendHeartbeat() { // console.log("Sending heartbeat..."); socket.send("heartbeat"); } // 寮€濮嬪績璺冲畾鏃跺櫒 function startHeartbeat() { heartbeatInterval = setInterval(sendHeartbeat, 5000); // 姣?绉掑彂閫佷竴娆″績璺 } // 褰 WebSocket 杩炴帴鍏抽棴鏃舵墽琛 socket.onclose = function (event) { // console.log("WebSocket is closed."); clearInterval(heartbeatInterval); // 娓呴櫎蹇冭烦瀹氭椂鍣 }; function sendMessage() { let message = document.getElementById("message").value; socket.send(message); } } // 鍒涘缓涓€涓嚱鏁版潵瑙傚療鍏锋湁鐗瑰畾绫诲悕鐨勫厓绱 function observeDivsWithClass(className) { let divsToObserve = document.querySelectorAll(`.${className}`); divsToObserve.forEach(function (div) { var observer = new IntersectionObserver( function (entries, observer) { entries.forEach(function (entry) { if (entry.isIntersecting) { // 搴旂敤鏍峰紡 entry.target.classList.add(typeAnimate[className] || "noanimate"); // 濡傛灉浣犱笉鎯冲啀娆¤Е鍙戯紝鍙互鍙栨秷瑙傚療 observer.unobserve(entry.target); } }); }, { root: null, // 浣跨敤瑙嗗彛浣滀负鏍 rootMargin: "0px", // 鏍硅竟鐣 threshold: 0.1, // 浜ゅ弶姣斾緥闃堝€ } ); // 寮€濮嬭瀵熻繖涓猟iv observer.observe(div); }); } function replaceSpecialChar(content) { content = content.replace(/"/g, '"'); content = content.replace(/&/g, "&"); content = content.replace(//g, ">"); content = content.replace(/ /g, " "); content = content.replace(/