export const API_BASE_URL = "ws://192.168.0.134:7015"; // ws://192.168.0.134:7015 // wss://4dart.4dage.com/4dart // 88888888 export const VIDEO_BASE_URL = "https://houseoss.4dkankan.com/"; export const CDN_URL = "https://culture.4dage.com/air_show/resource"; export let app = { id: "77777777", longtime:null, websocket: null, is_connect_ok: null, is_send_msg: null, noOperationTimeout: 35, closeByVideoHandle: false, showAlert(msg, comfirm,confirmText='确定') { if (comfirm) { return (() => { wx.showModal({ title: "提示", confirmText, content: msg, showCancel: false, success(res) { if (res.confirm) { comfirm(); } }, }); })(); } return (() => { wx.showModal({ title: "提示", showCancel: false, content: msg, success() {}, }); })(); }, send(msg) { if (!app.websocket) { return } if (msg === "request") { app.websocket.send({ data: msg + " " + this.id }); } else if (msg === "close") { app.websocket.send({ data: msg + " 0" }); } else { if (app.is_connect_ok == null) { app.websocket.send({ data: "request " + this.id }); } setTimeout(function () { app.websocket.send({ data: msg }); }, 300); } }, showLoading: function () { return (() => { wx.showLoading({ mask: true, title: "加载中", }); })(); }, hideLoading: function () { return (() => { try { wx.hideLoading(); } catch (error) {} })(); }, sendCheck() { console.log(this.is_connect,this.is_connect_ok,this.is_other_used); if (!this.is_connect) { this.hideLoading() app.showAlert("服务器连接失败,请重新连接", () => { app.send("request"); },'重新连接'); return false; } else if (this.is_connect_ok === false) { this.hideLoading() app.showAlert("服务器已断开,请重新连接", () => { setTimeout(() => { wx.showLoading({ title: "重新连接...", mask: true }); }); setTimeout(() => { app.send("request"); }, 1000); },'重新连接'); return false; } else if (this.is_other_used) { this.hideLoading() app.showAlert("当前画屏正在被使用,请稍后", () => { app.send("request"); }); return false; } this.is_send_msg = true; return true; }, checkOperationTimeout(stop) { this.operationTimer && clearTimeout(this.operationTimer); this.operationTimer = null; if (stop) { // 暂停检测 return; } this.operationTimer = setTimeout(function () { if (app.is_connect_ok) { app.send("close"); this.is_other_used = true this.is_connect_ok = false app.checkOperationTimeout(true); app.showAlert("抱歉,因您长时间使用,让下一位小伙伴体验吧"); } }, (this.noOperationTimeout || 120) * 1000); }, };