kimi
2021-02-18 749a5510a9f014446a3cd6ba57b3cb0cc8148dc1
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
<!DOCTYPE html>
<html>
 
    <head>
        <meta charset="utf-8">
        <title>Hello MUI</title>
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
 
        <!--标准mui.css-->
        <link rel="stylesheet" href="../css/mui.min.css">
        <!--App自定义的css-->
        <!--<link rel="stylesheet" type="text/css" href="../css/app.css"/>-->
        <style>
            p {
                text-indent: 22px;
            }
            span.mui-icon {
                font-size: 14px;
                color: #007aff;
                margin-left: -15px;
                padding-right: 10px;
            }
            #info{
                  padding: 20px 10px ;
              }
              .des{
                  margin: .5em 0;
              }
              .des>li{
                  font-size: 14px;
                color: #8f8f94;
              }
        </style>
    </head>
 
    <body>
 
        <header class="mui-bar mui-bar-nav">
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
            <h1 class="mui-title">原生模式actionsheet</h1>
        </header>
        <nav class="mui-bar mui-bar-tab">
            <a id="delete-btn" class="mui-tab-item">
                <span class="mui-icon mui-icon-trash"></span>
            </a>
            <a class="mui-tab-item" href="#">
            </a>
            <a class="mui-tab-item" href="#">
            </a>
            <a class="mui-tab-item" href="#">
            </a>
        </nav>
        <div class="mui-content">
            <div class="mui-content-padded">
                <p>这是5+ runtime封装的原生actionsheet,该模式具备如下优点:</p>
                <ul class="des">
                    <li>支持覆盖顶部状态栏</li>
                    <li>支持跨webview的遮罩</li>
                    <li>在有map等原生组件时,依然会显示在最顶层,不会被遮挡</li>
                </ul>    
                <p>另一方面,原生模式的actionsheet目前不支持自定义样式</p>    
                
                <p>
                    <a id="picture-btn" class="mui-btn mui-btn-primary mui-btn-block mui-btn-outlined" style="padding: 5px 20px;">打开actionsheet</a>
                </p>
            </div>
        </div>
        <p id="info"></p>
    </body>
    <script src="../js/mui.min.js"></script>
    <script>
        mui.init({
            swipeBack:true //启用右滑关闭功能
        });
        mui('body').on('shown', '.mui-popover', function(e) {
            //console.log('shown', e.detail.id);//detail为当前popover元素
        });
        mui('body').on('hidden', '.mui-popover', function(e) {
            //console.log('hidden', e.detail.id);//detail为当前popover元素
        });
        var info = document.getElementById("info");
        document.getElementById("picture-btn").addEventListener('tap',function () {
            var btnArray = [{title:"拍照或录像"},{title:"选取现有的"}];
            plus.nativeUI.actionSheet( {
                title:"选择照片",
                cancel:"取消",
                buttons:btnArray
            }, function(e){
                var index = e.index;
                var text = "你刚点击了\"";
                switch (index){
                    case 0:
                        text += "取消";
                        break;
                    case 1:
                        text += "拍照或录像";
                        break;
                    case 2:
                        text += "选取现有的";
                        break;
                }
                info.innerHTML = text+"\"按钮";
            } );
        });
        document.getElementById("delete-btn").addEventListener('tap',function () {
            var btnArray = [{title:"删除信息",style:"destructive"}];
            plus.nativeUI.actionSheet( {
                cancel:"取消",
                buttons:btnArray
            }, function(e){
                var index = e.index;
                var text = "你刚点击了\"";
                switch (index){
                    case 0:
                        text += "取消";
                        break;
                    case 1:
                        text += "删除信息";
                        break;
                }
                info.innerHTML = text+"\"按钮";
            } );
        });
    </script>
 
</html>