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
257
258
259
260
261
262
263
264
<?php
/**
* 视频上传
* $Id: media_upload.php,v 1.1 2020/01/03 11:18:46 Exp $
* @author lixq
* @package manager.public_html
**/
?>
<div id="change">
<p class="edit_title">视频上传</p>
<form id="form" name="media_upload" action="media_upload_result.php" method="post" enctype="multipart/form-data">
<input name="post_max" type="hidden" value="<?=ini_get('post_max_size')?>">
<input name="upload_max" type="hidden" value="<?=ini_get('upload_max_filesize')?>">
<input type="hidden" name="parent_category_id" value="<?=$parent_category_id?>"/>
<input type="hidden" name="sub_category_id" value="<?=$sub_category_id?>"/>
<div class="edit_content">
<p><b>视频名称:</b><el-input v-model="title" name="title" class="input_200"></el-input><br /></p>
<p><b>视频标签:</b><el-input v-model="media_tags" name="media_tags" class="input_200 popselect" readonly onfocus="doCheckPopup('media_upload','media_tags','tags','pop_tag_list.php');"></el-input>
<input type="hidden" name="tags" />
<el-button type="primary" class="height_30" @click="selectClear('media_upload', 'media_tags', 'tags');">清空</el-button>
<el-button type="primary" class="height_30" @click="popAddTag()">添加标签</el-button></p>
<p><b>讲师姓名:</b><el-input v-model="teacher" name="teacher" class="input_200"></el-input><br /></p>
<p><b>讲师介绍:</b><textarea v-model="teacher_profile" name="teacher_profile" rows="5"></textarea><br /></p>
<p><b>视频封面图:</b><a href='javascript:void(0);' class="el-button el-button--primary blueButton">选择文件</a>
<input id="image_file" class="myFileUpload" name="front_image" type="file" accept="image/*"/>
</p>
<div id="img_thumbnail">
<img id="imgshow" height="150px" alt="封面图" />
</div>
<p><b>视频类型:</b><template>
<el-radio v-model="media_type" name="media_type" label="0">单个</el-radio>
<el-radio v-model="media_type" name="media_type" label="1">合集</el-radio>
</template></p>
<div v-if="is_category_show">
<p><b>一级分类名称:</b><el-select v-model="parent_category_id" size="small">
<el-option
v-for="item in parent_category_list"
:key="item.id"
:label="item.title"
:value="item.id">
</el-option>
</el-select></p>
<p><b>二级分类名称:</b><el-select v-model="sub_category_id" size="small">
<el-option
v-for="item in new_sub_category_list"
:key="item.id"
:label="item.title"
:value="item.id">
</el-option>
</el-select></p>
</div>
<div v-if="is_course_show">
<p><b>选择合集:</b></p>
<el-input v-model="course_name" name="course_name" class="input_200 popselect" readonly onfocus="doRadioPopup('media_upload','course_name','course_id','pop_media_list.php');"></el-input>
<input type="hidden" name="course_id" value="0" />
<el-button type="primary" class="height_30" @click="selectClear('media_upload', 'course_name', 'course_id');">清空</el-button>
<el-button type="primary" class="height_30" @click="popAddCourse()">创建合集</el-button>
<br />
</div>
<p><b>视频种类:</b><template>
<el-radio v-model="media_kind" name="media_kind" label="false">志愿免费</el-radio>
<el-radio v-model="media_kind" name="media_kind" label="true">公益收费</el-radio>
</template></p>
<div v-if="is_price_show">
<p><b>收费价格:</b><el-input v-model="price" name="price" type="number" class="input_200"></el-input></p>
</div>
<p><b>课程简介:</b><textarea v-model="comment" name="comment" rows="5"></textarea></p>
<p><b>上传视频:</b><a href='javascript:void(0);' class="el-button el-button--primary blueButton">选择文件</a>
<input id="media_file" class="myFileUpload" name="media" type="file" accept="audio/mp4,video/mp4" style="margin-left: 120px;">
</p>
<i class="el-icon-upload img-uploader-icon" style="padding-left: 110px;">文件大小限制<span id="file_max_size"></span>M!</i><br/>
<span id="media_thumbnail" style="height: 20px;margin-left: 120px;"></span><br/><br/>
<el-button type="primary" @click="submit()" class="edit_btn" style="margin-left: 110px;">上传发布</el-button><br/><br/><br/><br/>
</div>
</form>
</div>
<script type="text/javascript">
var v = new Vue({
el:'#change',
data:{
title:'',
media_tags:'',
media_type:'0',
teacher:'',
media_kind:'true',
price:'',
course_name:'',
is_category_show:true,
is_course_show:false,
is_price_show:true,
teacher_profile:'',
comment:'',
parent_category_id:'',
sub_category_id:'',
sub_category_list:<?=json_encode($sub_category_list)?>,
new_sub_category_list:<?=json_encode($new_sub_category_list)?>,
parent_category_list:<?=json_encode($parent_category_list)?>
},
watch:{
media_type(val,oldval){
if(val == "0"){
this.is_course_show = false;
this.is_category_show = true;
}else{
this.is_course_show = true;
this.is_category_show = false;
}
},
media_kind(val,oldval){
if(val == 'false'){
this.is_price_show = false;
}else{
this.is_price_show = true;
}
},
parent_category_id(val,oldval){
var new_list = [];
this.sub_category_list.map(function(item) {
if (item.parent_id == val) {
new_list.push(item);
}
});
this.new_sub_category_list = new_list;
this.sub_category_id = this.new_sub_category_list[0]["id"];
}
},
methods:{
submit:function(){
if(!this.title){
this.$message({
type: 'error',
message: '请输入视频名称!'
});
return;
}
if($("input[name='tags']").val().length < 1){
this.$message({
type: 'error',
message: '请选择视频标签!'
});
return;
}
if(!$('#image_file').get(0).files[0]){
this.$message({
type: 'error',
message: '请选择封面图!'
});
return;
}
if(this.media_type == '0' && !this.parent_category_id){
this.$message({
type: 'error',
message: '请选择视频一级分类名称!'
});
return;
}
if(this.media_type == '0' && !this.sub_category_id){
this.$message({
type: 'error',
message: '请选择视频二级分类名称!'
});
return;
}
if(this.media_type == '1' && $("input[name='course_id']").val() == '0'){
this.$message({
type: 'error',
message: '请选择合集名称!'
});
return;
}
if(this.media_kind == 'true' && !this.price){
this.$message({
type: 'error',
message: '请输入收费价格!'
});
return;
}
if(this.media_kind == 'true' && !isPointNumber(this.price)){
this.$message({
type: 'error',
message: '请输入正确格式收费价格!'
});
return;
}
if(!$('#media_file').get(0).files[0]){
this.$message({
type: 'error',
message: '请选择上传视频!'
});
return;
}
$("input[name='parent_category_id']").val(this.parent_category_id);
$("input[name='sub_category_id']").val(this.sub_category_id);
$('#form').submit();
},
}
})
window.onload = function(){
$('#image_file').change(function(){
var file = $('#image_file').get(0).files[0];
if(file.type !== 'image/png'&&file.type !=='image/gif'&&file.type !=='image/jpg'&&file.type !=='image/jpeg'){
v.$message({
type: 'error',
message: '上传文件只能是图片格式!'
});
return;
}
if(file.size / 1024 / 1024 > 2){
v.$message({
type: 'error',
message: '上传文件大小不能超过 2MB!'
});
return;
}
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload=function(e){
$('#imgshow').get(0).src = e.target.result;
}
$('#img_thumbnail').css("visibility","visible");
$('#img_thumbnail').css("display","block");
})
$('#media_file').change(function(){
var file = $('#media_file').get(0).files[0];
if(file.type !== 'audio/mp4'&&file.type !=='video/mp4'){
v.$message({
type: 'error',
message: '上传文件只能是mp4格式!'
});
return;
}
var max_size = parseInt($('#file_max_size').html());
if(file.size / 1024 / 1024 > max_size){
v.$message({
type: 'error',
message: '上传文件大小不能超过 '+max_size+'MB!'
});
return;
}
$('#media_thumbnail').html(file.name);
})
}
</script>