chenhaozhe
2026-01-15 9e825bb9263ed29897bfaf467bfd0f86da8d3e5f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<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>