admin
2025-02-20 f537abe9f3646c739beaf15076246a2f71a347e9
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
 
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="referrer" content="never">
        <title>修改视频分类</title>
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link href="css/maincontent.css" rel="stylesheet">
        <link href="css/tablestyle.css" rel="stylesheet">
    </head>
 
    <body>
        <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
        </nav>
        <div id="mainbody">
            <div id="sidebar">
                <dl>
                </dl>
            </div>
            <div id="neirong">
                <div class="header">
                    <h4 class="shujutitle">修改视频分类</h4>
                    <div class="fenge"></div>
                </div>
                <table class="table">
                    <tbody>
                        <tr>
                            <td>
                                <form class="form-horizontal" role="form">
                                    <div class="form-group">
                                        <label for="input1" class="changdu3 control-label">分类名称</label>
                                        <div class="col-sm-3">
                                            <input type="text" class="form-control" id="input1" placeholder="">
                                        </div>
                                    </div>
                                </form>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <table class="table">
                    <tbody>
                        <tr>
                            <td>
                                <form class="form-horizontal" role="form">
                                    <div class="form-group">
                                        <label for="input2" class="changdu3 control-label">分类图标</label>
                                        <div class="col-sm-3">
                                            <img src="#" />
                                            <input type="file" id="exampleInputFile" enctype="multipart/form-data">
                                            <input type="text" class="form-control" id="input2" placeholder="">
                                        </div>
                                    </div>
                                </form>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <table class="table">
                    <tbody>
                        <tr>
                            <td>
                                <form class="form-horizontal" role="form">
                                    <div class="form-group">
                                        <label for="input3" class="changdu3 control-label">排序权重</label>
                                        <div class="col-sm-3">
                                            <input type="text" class="form-control" id="input3" placeholder="">
                                        </div>
                                    </div>
                                </form>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <table class="table">
                    <tbody>
                        <tr>
                            <td>
                                <form class="form-horizontal" role="form">
                                    <div class="form-group">
                                        <label for="input3" class="changdu3 control-label">分类页面上面显示</label>
                                        <input type="checkbox" class="checkbox" id="input5" placeholder="">
                                    </div>
                                </form>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <table class="table">
                    <tbody>
                        <tr>
                            <td>
                                <form class="form-horizontal" role="form">
                                    <div class="form-group">
                                        <label for="input3" class="changdu3 control-label">主页标题上面显示</label>
                                        <input type="checkbox" class="checkbox" id="input6" placeholder="">
                                    </div>
                                </form>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <table class="table">
                    <tbody>
                        <tr>
                            <td>
                                <form class="form-horizontal" role="form">
                                    <div class="form-group">
                                        <label for="input6" class="changdu3 control-label">备注</label>
                                        <div class="col-sm-3">
                                            <textarea cols="4" class="form-control" id="input4"></textarea>
                                        </div>
                                    </div>
                                </form>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div class="button0">
                    <div class="button">
                        <button type="button" name="save" class="btn btn-primary">保存</button>
                    </div>
                    <div class="button">
                        <button type="button" name="cancel" class="btn btn-primary">取消</button>
                    </div>
                </div>
            </div>
            <script src="js/jquery.min.js"></script>
            <script src="js/bootstrap.min.js"></script>
            <script src="layer/layer.js"></script>
            <script src="js/nav.js"></script>
            <script>
                $(function() {
                    var curpath = location.href;
                    var key = getArgsFromHref(curpath, "key");
 
                    $.post("api/videoType/getVideoType", { "id": key }, function(data) {
                        if(data.code == 0) {
                            var videoType = data.videoType;
                            var name = videoType.name;
                            var beizhu = videoType.beizhu;
                            var icon = videoType.icon;
                            var orderby = videoType.orderby;
                            var show = videoType.show==1?true:false;
                            var showTitle = videoType.showTitle==1?true:false;
                            $("#input1").val(name);
                            $("#input2").val(icon);
                            $("img").attr("src", icon);
                            $("#input3").val(orderby);
                            $("#input4").val(beizhu);
                            $("#input5")[0].checked=show;
                            $("#input6")[0].checked=showTitle;
                        }
                    }, "json");
 
                    $("#input2").focusout(function() {
                        if($("#exampleInputFile").val() == "") {
                            $("img").attr("src", $(this).val());
                        }
                    });
 
                    $("#exampleInputFile").bind("change", function() {
                        var path = $(this).val();
                        if(path != "") {
                            $("img").attr("src", path);
                        }
                    });
 
                    $("button[name='cancel']").bind("click", function() {
                        window.open("shiping-fenlei.html", '_self');
                    })
 
                    $("button[name='save']").bind("click", function() {
                        var orderby = $("#input3").val();
                        var name = $("#input1").val();
                        var beizhu = $("#input4").val();
                        var iconFile = $("input[type='file']")[0].files[0];
                        var iconUrl = $("#input2").val();
                        var show = $("#input5")[0].checked?"1":"0";
                        var showtitle = $("#input6")[0].checked?"1":"0";
                        if(iconFile != null) {
                            var formData = new FormData();
                            var filename = $("input[type='file']").val();
                            formData.append("file", iconFile);
                            formData.append("name", filename);
                            $.ajax({
                                url: "api/videoType/updateVideoTypeFile",
                                type: 'POST',
                                data: formData,
                                dataType: "json",
                                // 告诉jQuery不要去处理发送的数据
                                processData: false,
                                // 告诉jQuery不要去设置Content-Type请求头
                                contentType: false,
                                beforeSend: function() {
                                    console.log("正在进行,请稍候");
                                },
                                success: function(data, responseStr) {
                                    if(data.code == 0) {
                                        updateVideoType(key, orderby, name, beizhu, data.path, iconUrl,show,showtitle);
                                    } else if(data.code == 1) {
                                        updateVideoType(key, orderby, name, beizhu, "", iconUrl,show,showtitle);
                                    } else {
                                        layer.msg("上传图片失败,请重新操作!");
                                    }
                                },
                                error: function(responseStr) {
                                    console.log("error");
                                    alert("error");
                                }
                            });
                        } else {
                            updateVideoType(key, orderby, name, beizhu, "", iconUrl,show,showtitle);
                        }
                    })
                });
            </script>
            <script>
                function updateVideoType(key, orderby, name, beizhu, iconFile, iconUrl,show,showtitle) {
                    $.post("api/videoType/updateVideoType", { "id": key, "orderby": orderby, "name": name, "beizhu": beizhu, "iconFile": iconFile, "iconUrl": iconUrl,"show":show,"showTitle":showtitle }, function(data) {
                        if(data == "yes") {
                            layer.alert('保存成功!', {
                                icon: 1,
                                skin: 'layer-ext-seaing'
                            });
                        } else {
                            layer.alert('保存失败!', {
                                icon: 2,
                                skin: 'layer-ext-seaing'
                            });
                        }
                    }, "text")
                }
 
                function getArgsFromHref(sHref, sArgName) {
                    var args = sHref.split("?");
                    var retval = "";
 
                    if(args[0] == sHref) /*参数为空*/ {
                        return retval; /*无需做任何处理*/
                    }
                    var str = args[1];
                    args = str.split("&");
                    for(var i = 0; i < args.length; i++) {
                        str = args[i];
                        var arg = str.split("=");
                        if(arg.length <= 1) continue;
                        if(arg[0] == sArgName) retval = arg[1];
                    }
                    return retval;
                }
            </script>
    </body>
 
</html>