App-Android(使用App+htnl5框架,解决消息推送兼容SignalR问题)
loulijun2021
2022-10-22 40711118c33369ccad7ceda0fdd729bd9f117f65
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"/>
        <meta name="HandheldFriendly" content="true"/>
        <meta name="MobileOptimized" content="320"/>
        <title>titleNView</title>
        <script type="text/javascript" src="../js/common.js"></script>
        <script type="text/javascript">
var ws = null;
// H5 plus事件处理
function plusReady(){
    ws = plus.webview.currentWebview();
}
document.addEventListener('plusready', plusReady, false);
// 自定义按钮
var bButton = false;
function setButtons(){
    ws.setStyle({
        titleNView: {
            'padding-right': '10px',
            buttons:[{
                type: 'favorite',
                redDot: true
            },{
                text: '分享',
                fontSize: '16px',
                width: 'auto'
            },{
                'float': 'left',
                text: '测试',
                fontSize: '16px',
                select: true,
                width: 'auto',
                onclick: onClickedButton
            }]
        }
    });
    bButton = true;
}
// 按钮点击事件
function onClickedButton(){
    plus.nativeUI.toast('点击了测试按钮');
}
// 设置红点
function showRedDot(){
    if(!bButton){
        plus.nativeUI.toast('标题栏未设置自定义按钮');
    }
    ws.showTitleNViewButtonRedDot({index:0});
}
// 隐藏红点
function hideRedDot(){
    if(!bButton){
        plus.nativeUI.toast('标题栏未设置自定义按钮');
    }
    ws.hideTitleNViewButtonRedDot({index:0});
}
// 设置角标
function setBadge(){
    if(!bButton){
        plus.nativeUI.toast('标题栏未设置自定义按钮');
    }
    ws.setTitleNViewButtonBadge({index:0,text:'9'});
}
// 移除角标
function removeBadge(){
    if(!bButton){
        plus.nativeUI.toast('标题栏未设置自定义按钮');
    }
    ws.removeTitleNViewButtonBadge({index:0});
}
// 隐藏/显示按钮
var bShow = true;
function switchButton(){
    bShow = !bShow;
    ws.setTitleNViewButtonStyle(1, {width:(bShow?'auto':'0px')})
}
        </script>
        <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
    </head>
    <body>
        <br/><br/>
        <span class="des">向上滚动显示标题栏</span>
        <br/><br/>
        <div class="button" onclick="setButtons()">标题栏自定义按钮</div>
        <div class="button" onclick="showRedDot()">显示红点</div>
        <div class="button" onclick="hideRedDot()">隐藏红点</div>
        <div class="button" onclick="setBadge()">设置角标</div>
        <div class="button" onclick="removeBadge()">移除角标</div>
        <br/>
        <div class="button" onclick="switchButton()">隐藏/显示按钮</div>
        <br/>
        <div style="width:100%;height:1000px"></div>
    </body>
</html>