1
hao
2025-04-16 8f175e836561887b940ae5d3a125425ee9095370
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
<!documentTYPE html>
    <html class="ui-page-login">
 
        <head>
            <meta charset="utf-8">
            <meta name="viewport"
                content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
            <title></title>
            <script src="js/mui.js"></script>
            <script src="js/api.js"></script>
            <link href="css/mui.min.css" rel="stylesheet" />
 
            <script src="js/jquery-1.11.1.js"></script>
            <script src="js/jquery.xml2json.js.js"></script>
 
            <link href="css/mui.min.css" rel="stylesheet" />
            <link href="css/style.css" rel="stylesheet" />
            <style>
                .mui-input-group {
                    margin-top: 10px;
                }
 
                .mui-input-group:first-child {
                    margin-top: 20px;
                }
 
                .mui-input-group label {
                    width: 30%;
                }
 
                .mui-input-row label~input,
                .mui-input-row label~textarea {
                    width: 70%;
                }
 
                .mui-content-padded {
                    margin-top: 20px;
                }
 
                .mui-btn {
                    padding: 10px;
                }
            </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">设置服务器信息</h1>
            </header>
            <div class="mui-content">
 
                <form id='login-form' class="mui-input-group">
                    <div class="mui-input-row account">
                        <label>IP</label>
                        <input id='ip' type="text" class="mui-input-clear mui-input" placeholder="请输入IP">
                    </div>
                    <div class="mui-input-row">
                        <label>端口</label>
                        <input id='post' type="text" class="mui-input-clear mui-input" placeholder="请输入端口">
                    </div>
                    <div class="mui-input-row">
                        <label>war包名</label>
                        <input id='index' type="text" class="mui-input-clear mui-input" placeholder="请输入war包名">
                    </div>
                </form>
 
                <div class="mui-content-padded">
                    <button type="button" onclick="savebtn()" class="mui-btn mui-btn-block mui-btn-primary">保存</button>
                </div>
 
            </div>
            <script src="js/mui.min.js"></script>
            <script src="js/mui.enterfocus.js"></script>
            <script src="js/app.js"></script>
            <script src="js/utils.js"></script>
            <script>
                mui.plusReady(function() {
                    plus.screen.lockOrientation("portrait-primary");
                });
                mui.ready(function() {
                    //判断缓存里面有无ip,port已经war,无则去API.webPath中取
                    var storage = window.localStorage;
                    if(storage["ip"]==null||storage["post"]==null||storage["index"]==null){
                        storage["ip"] = API.webPath.split("//")[1].split('/')[0].split(':')[0]
                        storage["post"] = API.webPath.split("//")[1].split('/')[0].split(':')[1]
                        storage["index"] = API.webPath.split("//")[1].split('/')[1]
                        var _basePath = "http://" + storage["ip"] + ":" + storage["post"] + "/" + storage["index"];
                        storage["_basePath"] = _basePath;
                    }
                    //存储到loaclStage
                    document.getElementById('ip').value = storage["ip"];
                    document.getElementById('post').value = storage["post"];
                    document.getElementById('index').value = storage["index"];
 
 
                })
                // 保存信息
                function savebtn() {
                    var ip = document.getElementById('ip').value;
                    var post = document.getElementById('post').value;
                    var index = document.getElementById('index').value;
                    if (!inputValueNotNull("ip", ip)) {
                        mui.toast("IP:不允许为空!!!");
                        return;
                    }
                    if (!inputValueNotNull("post", post)) {
                        mui.toast("端口:不允许为空!!!");
                        return;
                    }
                    if (!inputValueNotNull("index", index)) {
                        index = '';
                    }
                    var btnArray = ['否', '是'];
                    mui.confirm('是否确认保存服务器信息?', '确认保存', btnArray, function(e) {
                        if (e.index == 1) {
                            //存储到loaclStage
                            var storage = window.localStorage;
                            storage["ip"] = ip;
                            storage["post"] = post;
                            storage["index"] = index;
                            var _basePath = "http://" + ip + ":" + post + "/" + index;
                            storage["_basePath"] = _basePath;
                            closeme();
                        } else {
 
                        }
                    })
                }
                // 关闭自身窗口
                function closeme() {
                    var ws = plus.webview.currentWebview();
                    plus.webview.close(ws);
                    var list = plus.webview.currentWebview().opener();
                    //触发列表界面的自定义事件(refresh),从而进行数据刷新
                    mui.fire(list, 'refresh');
                }
            </script>
        </body>
 
    </html>