edit_up_video.html
10.1 KB
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<include file="public/layout"/>
<style type="text/css">
.up_video_btn{ width: 100px; height: 80px; text-align: center; color: grey; position: relative;
border: dashed 1px grey; font-size: 40px; line-height: 80px;}
.txt, .txt2, .select {
height: 34px;
line-height: 34px;
width: 180px;
}
.up_video_btn.small{width: 30px; height: 30px;font-size: 20px; line-height: 30px; display: inline-block; position: relative; top:-10px}
.simg{border: dashed 1px grey; width: 160px; height: 160px;}
.file-up{position: absolute; width: 100%; opacity:0;filter:alpha(opacity=0);
height:100%; top: 0; left: 0; }
#video{ max-width: 400px; max-height: 200px; display: none;}
.title_div{ height: 60px; border-bottom: 1px gainsboro solid; line-height: 60px; padding: 0 20px}
.title_div span{width: 80px; display:inline-block; height: 59px; text-align: center;
font-weight: bold; color: #666 }
.title_div span.on{ border-bottom: 2px blue solid }
body{min-width: 600px}
.add_grp{ display:inline-block; width: 80px; height: 30px; border:1px solid #999; position: relative;
border-radius:5px; text-align: center; line-height: 30px }
</style>
<body>
<include file="public/v_group"/>
<form method="post" id="videodata">
<input type="hidden" name="oldurl" value="{$oldurl}" class="input-txt">
<input id="v_id" type="hidden" name="id" value="{$info.id}" class="input-txt">
<!--通用信息-->
<div class="ncap-form-default tab_div_1">
<dl class="row">
<dt class="tit">
<label for="goods_name">本地视频</label>
</dt>
<dd class="opt">
<input id="video_time" name="video_time" value="{$info.video_time}" type="hidden">
<input id="file_size" name="file_size" value="{$info.file_size}" type="hidden">
<input id="video_url" name="video_url" value="{$info.video_url}" type="hidden">
<video id="video" src="{$qclurl}{$info.video_url}" controls oncanplaythrough="myFunction(this)" style="display:inline-block"></video>
<div class="up_video_btn small">+
<input id="upfile" type="file" class="file-up" name="upfile" onchange="upvideo()">
</div>
<div style="margin-top: 10px">点击"+"选择视频,视频大小不超过30MB,建议宽高比16:9,支持的视频文件类型包括:MP4,mov,m4v,flv,x-flv,mkv,wmv,avi,rmvb,3gp</div>
</dd>
</dl>
<dl class="row">
<dt class="tit">
<label for="video_name">名称</label>
</dt>
<dd class="opt">
<input id="video_name" type="text" maxlength="180" value="{$info.video_name}"
onkeydown="strkeydown(event, this, 'sumbbtn')" name="video_name" class="input-txt">
<span class="err cr"></span>
</dd>
</dl>
<dl class="row">
<dt class="tit">
<label for="sku">分组</label>
</dt>
<dd class="opt">
<select name="group_id" id="group_id" class="select" value="{$info.group_id}"
onkeydown="strkeydown(event, this, 'submitBtn')">
<option value="">选择分组</option>
<foreach name="grpList" item="v" key="k">
<option value="{$v['id']}" <if condition="$info.group_id eq $v['id']"> selected </if> >{$v['gpname']}</option>
</foreach>
</select>
<div class="add_grp" onclick="group_marnger()">
<span>分组管理</span>
</div>
</dd>
</dl>
<dl class="row">
<dt class="tit">封面图片</dt>
<dd class="opt">
<div class="ncsc-goods-default-pic">
<div class="goodspic-uplaod">
<img id="original_img2" style="width: 240px; border:#eee solid 1px" onmouseout="layer.closeAll();"
onmouseover="layer.tips('<img src='+this.src+'>',this, {tips: [1, '#fff'],time:10000});"
src="{:getImg($info.video_img,'__PUBLIC__/images/default_goods_image_240.gif')}">
<input type="hidden" id="video_img" name="video_img"
value="{$info.video_img}">
<p class="hint">请上传图片格式文件,<Font color="red">大小建议为:600*600像素。</Font></p>
<div class="handle">
<if condition="$isnowater eq 1">
<p style="color: red">请到系统水印配置上传水印图片!</p>
<else/>
<div class="ncsc-upload-btn">
<a onClick="GetUploadify_new(1,'video_img','up_video','{:getAdmStoId()}','up_video','id','video_img','','call_back')">
<p><i class="icon-upload-alt"></i>图片上传</p>
</a>
</div>
</if>
</div>
</div>
</div>
</dd>
</dl>
</div>
<!-- 确认提交-->
<div class="ncap-form-default">
<div class="bot">
<a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" id="sumbbtn" onClick="ajax_submit_form()">确认提交</a>
</div>
</div>
</form>
<input type="hidden" id="qclurl" value="{$qclurl}">
</body>
<script>
var is_uping=0;
//以下是图片上传方法
//上传商品图片成功回调函数
function call_back(fileurl_tmp, obj) {
var getqclurl = $("#qclurl").val();
$(obj).val(fileurl_tmp);
$(obj).prev().attr('src', getqclurl + fileurl_tmp);
}
//上传图片
function ajax_submit_form() {
if(is_uping==1) return false;
var file=$("#upfile")[0].files[0];
var video_name=$("#video_name").val();
var group_id=$("#group_id").val();
var video_img=$("#video_img").val();
var video_time=$("#video_time").val();
var video_id=$("#v_id").val();
var video_size=$("#file_size").val();
var video_url=$("#video_url").val();
if(file!=undefined){
if(file.size>30*1024*1024){
layer.msg("视频大小不能超出30M");
$("#video").hide();
$("#upfile").val("");
$(".up_video_btn").removeClass("small");
$("#video_url").val("");
return false;
}
var name=file.name;
var index= name.indexOf(".");
tv_id=name.substring(index); //截断"."之前的,得到后缀
if(tv_id!=".mp4"&&tv_id!=".rmvb"&&tv_id!=".avi"&&tv_id!=".ts"){
layer.msg("不是指定视频格式,重新选择");
$("#video").hide();
$("#upfile").val("");
$(".up_video_btn").removeClass("small");
$("#video_url").val("");
return false;
}
}
if(file==undefined && video_url=="") {
layer.msg("请上传视频", {icon: 2,time: 1000});
return false;
}
if(video_name=='') {
layer.msg("请填写名称", { icon: 2,time: 1000 });
return false;
}
if(video_img=='') {
layer.msg("请上传视频封面", {icon: 2,time: 1000});
return false;
}
var formData = new FormData();
formData.append('video_name',video_name);
formData.append('video_img',video_img);
formData.append('file',file);
formData.append('video_time',video_time);
formData.append('id',video_id);
formData.append('is_ajax',1);
formData.append('file_size',video_size);
formData.append('video_url',video_url);
if(group_id!="") formData.append('group_id',group_id);
is_uping=1
var men=layer.msg('加载中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '200px', time:0}) ;
$.ajax({
type: "POST",
url: "/index.php?m=Admin&c=Uploadify&a=edit_up_video", //同目录下的php文件
data:formData,
dataType:"json", //声明成功使用json数据类型回调
//如果传递的是FormData数据类型,那么下来的三个参数是必须的,否则会报错
cache:false, //默认是true,但是一般不做缓存
processData:false, //用于对data参数进行序列化处理,这里必须false;如果是true,就会将FormData转换为String类型
contentType:false, //如果上传的有文件,那么只能设置为false
success: function(res){ //请求成功后的回调函数
layer.close(men);
if(res.code==0){
//删除本地视频
del_file(res.full);
layer.msg("上传成功", {
icon: 1,time: 1000
});
setTimeout(function () {
is_uping=0;
window.parent.call_back_video( res.vd_url, video_img,video_id)
},1000)
}else {
layer.msg(res.msg, {
icon: 2,time: 1000
});
is_uping=0;
return false;
}
}
});
}
function del_file(file) {
$.ajax({
type: "POST",
url: "/index.php/admin/Uploadify/del_local_video?filename="+file,
success: function (res) { //请求成功后的回调函数
}
});
}
function upvideo() {
console.log("upvideo");
var file = document.getElementById('upfile').files[0];
if(file.size>30*1024*1024){
layer.msg("视频大小不能超出30M");
$("#video").hide();
$("#upfile").val("");
$(".up_video_btn").removeClass("small");
$("#video_url").val("");
return false;
}
var name=file.name;
var index= name.indexOf(".");
tv_id=name.substring(index); //截断"."之前的,得到后缀
if(tv_id!=".mp4"&&tv_id!=".rmvb"&&tv_id!=".avi"&&tv_id!=".ts"){
layer.msg("不是指定视频格式,重新选择");
$("#video").hide();
$("#upfile").val("");
$(".up_video_btn").removeClass("small");
$("#video_url").val("");
return false;
}
var url = URL.createObjectURL(file);
console.log(url);
document.getElementById("video").src = url;
$("#video").show();
$(".up_video_btn").addClass("small");
}
function myFunction(ele) {
$("#video_time").val(ele.duration)
}
function go_url(ind) {
if(ind==1){
window.location.href="/index.php/admin/Uploadify/up_my_video"
}else {
window.location.href="/index.php//admin/Uploadify/up_load_video"
}
}
</script>
</html>