<script>
|
import WebSocketServices from "./utils/WebSocketServices";
|
import {
|
getOpenId,
|
setUserInfo,
|
setToken,
|
getToken,
|
getUserInfo
|
} from "./utils/auth";
|
export default {
|
onLaunch: function() {
|
console.log('App Launch')
|
// #ifdef H5
|
// 测试时,H5页面刷新会丢失WebSocket连接,需触发重连 (需要测试的时候再解除注释,否则会影响热更新)
|
// if (uni.getStorageSync("userinfo")) {
|
// if (WebSocketServices.wsInstance) { // 假设你的 WebSocket 实例存在 wsInstance 中
|
// WebSocketServices.closeConnect(); // 调用你封装的“关闭连接”方法
|
// }
|
|
// setTimeout(() => {
|
// WebSocketServices.createConnect(
|
// getUserInfo()["Czybm"],
|
// getUserInfo()["Czymc"],
|
// )
|
// }, 500)
|
|
// }
|
|
// // 关键:监听热更新模块替换,销毁旧连接
|
// if (module.hot) {
|
// module.hot.accept(); // 允许当前模块热更新
|
// module.hot.dispose(() => {
|
// // 热更新替换模块前,销毁 WebSocket 连接
|
// if (WebSocketServices.wsInstance) {
|
// WebSocketServices.closeConnect();
|
// WebSocketServices.wsInstance = null; // 重置实例
|
// }
|
// });
|
// }
|
// #endif
|
},
|
onShow: function() {
|
console.log('App Show')
|
|
},
|
onHide: function() {
|
console.log('App Hide')
|
}
|
}
|
</script>
|
|
<style>
|
/*每个页面公共css */
|
.over {
|
color: #888;
|
font-size: 28rpx;
|
text-align: center;
|
padding: 60rpx 0;
|
}
|
|
/* 用于解决picker内部设置 disabled input 时不响应的问题 */
|
.picker-overlay {
|
box-sizing: border-box;
|
position: absolute;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 100%;
|
background-color: transparent;
|
/* 透明背景 */
|
z-index: 1;
|
/* 确保在 input 上方 */
|
}
|
</style>
|