App-Android(使用App+htnl5框架,解决消息推送兼容SignalR问题)
loulijun2021
2022-10-22 40711118c33369ccad7ceda0fdd729bd9f117f65
1.安灯响应静态实现
已修改3个文件
182 ■■■■■ 文件已修改
js/msg.js 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/adgl/adhj.html 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/adgl/adxy.html 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
js/msg.js
@@ -14,21 +14,21 @@
    // 监听plusready事件
    document.addEventListener("plusready", function() {
        var main = plus.android.runtimeMainActivity();
        console.log(main,JSON.stringify(main))
        var Context = plus.android.importClass("android.content.Context");
        console.log(Context)
        var PowerManager = plus.android.importClass("android.os.PowerManager");
        console.log(PowerManager)
        var pm = main.getSystemService(Context.POWER_SERVICE);
        console.log(JSON.stringify(pm))
        g_wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ANY_NAME");
        console.log(JSON.stringify(g_wakelock))
        g_wakelock.acquire();
        // var main = plus.android.runtimeMainActivity();
        // // console.log(main,JSON.stringify(main))
        // var Context = plus.android.importClass("android.content.Context");
        // // console.log(Context)
        // var PowerManager = plus.android.importClass("android.os.PowerManager");
        // // console.log(PowerManager)
        // var pm = main.getSystemService(Context.POWER_SERVICE);
        // // console.log(JSON.stringify(pm))
        // g_wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ANY_NAME");
        // // console.log(JSON.stringify(g_wakelock))
        // g_wakelock.acquire();
        message = document.getElementById("message");
        // 监听点击消息事件
        plus.push.addEventListener("click", function(msg) {
@@ -185,9 +185,9 @@
    //允许程序后台运行,以持续获取GPS位置
    function wakeLock() {
        //Android
        console.log(1)
        var main = plus.android.runtimeMainActivity();
        var Context = plus.android.importClass("android.content.Context");
        var PowerManager = plus.android.importClass("android.os.PowerManager");
@@ -212,35 +212,23 @@
            //     message: msg,
            //     duration: 5000
            // })
            console.log('我是后端返回的消息:',msg)
            console.log('我是后端返回的消息:', msg)
            // CreateNotification(msg, Math.random())
            createLocalPushMsg(msg)
        };
        $.connection.hub.url = 'http://121.196.36.24:8001/signalr'
        //hub连接开启
        $.connection.hub.start().done(function() {
        var connection = $.connection.hub.start().done(function() {
            // $.connection.serverTimeoutInMilliseconds = 1000 * 60 * 30
            var username = localStorage.getItem('username');
            //发送上线信息
            work.server.sendLogin(username);
        })
            //         console.log('222')
            //         const aaa = [{
            //             "code": "Q",
            //             "name": "呼叫质量",
            //             "children": [{
            //                 "usercode": "999",
            //                 "username": "楼先生"
            //             }]
            //         }]
            //         work.server.sendByGroupList('楼先生', 'CJ002', 'SB001', aaa)
        });
    });
pages/adgl/adhj.html
@@ -255,12 +255,10 @@
                $.connection.hub.url = 'http://121.196.36.24:8001/signalr'
                //hub连接开启
                $.connection.hub.start().done(function() {
                    // $.connection.serverTimeoutInMilliseconds = 1000 * 60 * 30
                    var username = localStorage.getItem('username');
                    //发送上线信息
                    work.server.sendLogin(username);
                    // const aaa = [{
                    //     "code": "Q",
                    //     "name": "呼叫质量",
@@ -269,9 +267,7 @@
                    //         "username": "楼先生"
                    //     }]
                    // }]
                    // work.server.sendByGroupList('楼先生', 'CJ002', 'SB001', aaa)
                    $('#submit').click(function() {
                        // vant.Notify('点击了')
                        // const data = {
@@ -321,10 +317,13 @@
                        //             })
                        //         }
                        //     })
                    })
                });
            });
@@ -382,7 +381,7 @@
                        falseArray.push({
                            id: '1'
                        })
                    }else{
                    } else {
                        topContentClick(topContent[0].code, topContent[0].wksp_code)
                    }
@@ -423,8 +422,8 @@
        </script>
    </head>
    <!-- <body onload="scaned('SB001')"> -->
    <body>
    <body onload="scaned('SB001')">
        <!-- <body> -->
        <div id="app">
            <div class="body">
pages/adgl/adxy.html
@@ -113,7 +113,8 @@
                        res.data.forEach(i => {
                            children.push({
                                typecode: i.typecode,
                                typename: i.typename
                                typename: i.typename,
                                isTrue: false
                            })
                        })
@@ -132,7 +133,7 @@
                        //     }
                        // })
                        console.log(cneterContent, 1)
                        console.log(JSON.stringify(topContent), 1)
                        falseArray.push({
                            id: '1'
@@ -149,8 +150,8 @@
        </script>
    </head>
    <!-- <body onload="scaned('SB001')"> -->
    <body>
    <body onload="scaned('SB001')">
        <!-- <body> -->
        <div id="app">
            <div class="body">
@@ -229,13 +230,13 @@
                        <div style="padding: 10px;display: flex;flex-direction: column"
                            v-for="(item,index) in topContent[0].children">
                            v-for="(item,index) in topContent[topContent.map(i => i.eqp_code).indexOf(radioValue)].children">
                            <!-- v-for="(item,index) in centerContent"> -->
                            <div style="display: flex;justify-content: space-between;align-items: center;">
                                <div style="margin-left: 10px;">{{item.typename}}</div>
                                <div style="margin-right: 10px;">
                                    <van-switch size="24" v-model="item.typecode" @change='val=>switchChange(val,item)'
                                    <van-switch size="24" v-model="item.isTrue" @change='val=>switchChange(val,item)'
                                        active-color="#ee0a24" inactive-color="#dcdee0" />
                                </div>
                            </div>
@@ -319,74 +320,50 @@
                    this.$forceUpdate()
                },
                submit() {
                    setTimeout(() => {
                        const data = {
                            username: localStorage.getItem('username'),
                            eqpcode: topContent.find(i => i.code === radioValue).code,
                            wkshpcode: topContent.find(i => i.code === radioValue).wksp_code
                    const data = {
                        username: localStorage.getItem('username'),
                        eqpcode: topContent.find(i => i.eqp_code === radioValue).eqp_code,
                        // wkshpcode: topContent.find(i => i.code === radioValue).wksp_code
                    }
                    const DATA = topContent.find(i => i.eqp_code === radioValue).children.map(r => {
                        if (r.isTrue) {
                            return {
                                code: r.typecode,
                                name: r.typename
                            }
                        }
                        const DATA = []
                    })
                    console.log(data, DATA)
                    console.log(data, DATA.filter(i=>i!==undefined))
                        submitIsDisabled = true
                        // falseArray.push({
                        //     id: '1'
                        // })
                        this.$forceUpdate()
                        post('AppDeviceManage/AppDeviceAnDengCallSave' + formatParams(data), DATA).then(
                            res => {
                                if (res.code === '200') {
                                    vant.Notify({
                                        type: 'primary',
                                        message: '提交成功!'
                                    })
                                    topContent.forEach((r, i) => {
                                        if (r.code === radioValue) {
                                            topContent.splice(i, 1)
                                        }
                                    })
                                    if (topContent.length >= 1) {
                                        radioValue = topContent[0].code
                                        this.topContentClick(radioValue)
                    submitIsDisabled = true
                    this.$forceUpdate()
                    post('AppDeviceManage/AppDeviceAnDengLampResponseSave' + formatParams(data), DATA.filter(i=>i!==undefined)).then(
                        res => {
                            if (res.code === '200') {
                                vant.Notify({
                                    type: 'primary',
                                    message: '提交成功!'
                                })
                                topContent.forEach((r, i) => {
                                    if (r.eqp_code === radioValue) {
                                        topContent.splice(i, 1)
                                    }
                                    submitIsDisabled = false
                                    this.$forceUpdate()
                                })
                                if (topContent.length >= 1) {
                                    radioValue = topContent[0].eqp_code
                                }
                            })
                    }, 100)
                                submitIsDisabled = false
                                this.$forceUpdate()
                            }
                        })
                },
                topContentClick(code) {
                    // 明天研究一下  列表选项切换问题
                    radioValue = code
                    // this.$forceUpdate()
                    // console.log(JSON.stringify(radioValue), JSON.stringify(topContent))
                    let children = []
                    topContent.find(i => i.eqp_code === radioValue).forEach(i => {
                        children.push({
                            typecode: i.typecode,
                            typename: i.typename
                        })
                    })
                    topContent.unshift({
                        eqp_code: res.data[0].eqp_code,
                        eqp_name: res.data[0].eqp_name,
                        org_name: res.data[0].org_name,
                        children
                    })
                    console.log(JSON.stringify(topContent))
                    this.$forceUpdate()
                },