App-Android(使用App+htnl5框架,解决消息推送兼容SignalR问题)
loulijun2021
2022-09-20 eb23a7c7faefe86330a88f9118b8211f6b86e75b
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <meta name="HandheldFriendly" content="true"/>
        <meta name="MobileOptimized" content="320"/>
        <title>水平仪</title>
        <script type="text/javascript" src="../js/common.js"></script>
        <script type="text/javascript" >
// H5 plus事件处理
function plusReady(){
    // 锁定只能竖屏显示
    plus.screen.lockOrientation( "portrait-primary" );
}
if(window.plus){
    plusReady();
}else{
    document.addEventListener("plusready",plusReady,false);
}
// 解锁并关闭
var _back=window.back;
function unlockback(){
    plus.screen.unlockOrientation();
    _back();
}
window.back=unlockback;
 
var t, xh, xv;
var R = 100;
function update(h, v) {
    var ch = 0, cv = 0;
    if (h > 90) {
        h = 180 - h;
    } else if (h < -90) {
        h = -180 - h;
    }
    if (v > 90) {
        v = 180 - v;
    } else if (v < -90) {
        v = -180 - v;
    }
    var r = Math.max(Math.abs(h), Math.abs(v)) / 90;
    var range = Math.round(R * r);
    if (h == 0) {
        cv = range * v / 90;
    } else if (v == 0) {
        ch = range * h / 90;
    } else {
        var a = Math.atan2(v, h);
        ch = range * Math.cos(a);
        cv = range * Math.sin(a);
    }
    ch = Math.round(ch);
    cv = Math.round(cv);
 
    t.style.webkitTransform = "translate(" + ch + "px," + cv + "px)";
 
    h = h.toFixed(1);
    v = v.toFixed(1);
    xh.innerHTML = "" + (-h);
    xv.innerHTML = "" + (-v);
}
document.addEventListener("plusready", function() {
    t = document.getElementById("bubble");
    R = Math.floor(t.offsetWidth * 130 / 320);
    xh = document.getElementById("h");
    xv = document.getElementById("v");
 
    plus.orientation.watchOrientation(function(r) {
        update(-r.gamma, -r.beta);
    }, function(e) {
        // error
    }, {
        frequency : 100
    });
}, false);
// Adjective select.
document.onselectstart = function() {
    return false;
}
        </script>
        <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
        <style type="text/css">
#front {
    width: 60%;
    height: 80px;
    margin: auto;
    margin-top: 20px;
    text-align: center;
}
.inf {
    width: 50%;
    height: 50%;
    line-height: 40px;
    font-size: 28px;
    text-align: center;
    text-align: center;
    vertical-align: middle;
    float: left;
}
#container {
    width: 80%;
    position: relative;
    margin: auto;
    text-align: center;
    line-height: 100%;
    overflow: hidden;
}
.bg {
    width: 100%;
    position: absolute;
    left: 0px;
    top: 0px;
    z-index: -1;
}
#bubble {
    width: 100%;
    vertical-align: middle;
    -webkit-transition: all 0.1s linear;
}
a.bh {
    width: 100%;
    height: 10%;
    position: fixed;
    bottom: 0px;
    background: rgb(128,128,128);
    text-align: center;
    vertical-align: middle;
}
a.bh:active {
    background: rgb(64,64,64);
}
#hi {
    height: 80%;
    margin: auto;
    margin-top: 5px;
    vertical-align: middle;
}
        </style>
    </head>
    <body>
        <div id="front">
            <div class="inf" style="font-weight:bold;">
                横向
            </div>
            <div class="inf" style="font-weight:bold;">
                纵向
            </div>
            <div id="h" class="inf">
                0
            </div>
            <span id="v" class="inf">0</span>
        </div>
        <div id="container">
            <img class="bg" src="../img/orientationbg.png"/>
            <img class="bg" src="../img/orientationl.png"/>
            <img id="bubble" src="../img/orientationb.png"/>
        </div>
    </body>
</html>