This commit is contained in:
devil_gong 2018-10-18 18:33:55 +08:00
parent f02d647e7a
commit 1ce94380ff
5 changed files with 124 additions and 6 deletions

View File

@ -97,5 +97,8 @@ return array(
'goods_home_recommended_images_tips'=> '留空则取相册第一张图',
'goods_brand_id_text' => '品牌',
'goods_video_text' => '短视频',
'goods_video_tips' => '视频比图文更有具带入感,仅支持 mp4 格式',
);
?>

View File

@ -25,9 +25,9 @@
<li>
<a href="#goods-nav-photo">{{:L('goods_nav_photo_name')}}</a>
</li>
<!-- <li>
<li>
<a href="#goods-nav-video">{{:L('goods_nav_video_name')}}</a>
</li> -->
</li>
<li>
<a href="#goods-nav-attribute">{{:L('goods_nav_attribute_name')}}</a>
</li>
@ -178,10 +178,22 @@
</if>
</ul>
</div>
<!-- <div id="goods-nav-video" class="division-block">
<div id="goods-nav-video" class="division-block">
<label class="block nav-detail-title">{{:L('goods_nav_video_name')}}</label>
视频
</div> -->
<div class="am-form-group am-form-file">
<label class="block">{{:L('goods_video_text')}}<span class="fs-12 fw-100 cr-999">{{:L('goods_video_tips')}}</span></label>
<button type="button" class="am-btn am-btn-default am-btn-sm am-radius">
<i class="am-icon-cloud-upload"></i> {{:L('common_select_video_text')}}</button>
<input type="text" name="video" class="am-radius js-choice-one original-images-url original-video-images-url" data-choice-one-to='input[name="file_video"]' <notempty name="data"> value="{{$data.video}}"</notempty>" data-validation-message="{{:L('common_select_video_tips')}}" readonly="readonly" />
<i class="am-icon-trash-o am-icon-sm original-images-url-delete" data-input-tag="input.original-video-images-url" data-video-tag="#form-view-video" data-tips-tag="#form-video-tips" data-file-tag="input.file_video-tag"></i>
<input type="file" name="file_video" multiple data-validation-message="{{:L('common_select_images_tips')}}" accept=".mp4" class="js-choice-one video-file-event file_video-tag" data-choice-one-to=".original-video-images-url" data-tips-tag="#form-video-tips" data-video-tag="#form-view-video" />
<div id="form-video-tips" class="m-t-5"></div>
<video src="<if condition="!empty($data['video'])">{{$image_host}}{{$data.video}}</if>" id="form-view-video" class="block m-t-5 am-img-thumbnail am-radius" width="150" height="150" data-default="<if condition="!empty($data['video'])">{{$image_host}}{{$data.video}}</if>" controls>
your browser does not support the video tag
</video>
</div>
</div>
<div id="goods-nav-attribute" class="division-block">
<label class="block nav-detail-title">{{:L('goods_nav_attribute_name')}}</label>
<ul class="goods-attribute-items" data-name="attribute" data-attribute-type-name="{{:L('goods_attribute_type_name')}}" data-attribute-type-placeholder="{{:L('goods_attribute_type_placeholder')}}" data-attribute-type-format="{{:L('goods_attribute_type_format')}}" data-attribute-type-type-name="{{:L('goods_attribute_type_type_name')}}" data-attribute-type-type-show="{{:L('goods_attribute_type_type_show')}}" data-attribute-type-type-choose="{{:L('goods_attribute_type_type_choose')}}" data-attribute-type-type-format="{{:L('goods_attribute_type_type_format')}}" data-attribute-add-sub-text="{{:L('goods_attribute_add_sub_text')}}" data-attribute-name="{{:L('goods_attribute_name')}}" data-attribute-placeholder="{{:L('goods_attribute_placeholder')}}" data-attribute-format="{{:L('goods_attribute_format')}}" data-drag-sort-text="{{:L('common_drag_sort_title')}}">

View File

@ -94,6 +94,8 @@ return array(
'common_select_file_tips' => '请选择需要上传的文件',
'common_select_images_text' => '选择图片',
'common_select_images_tips' => '请选择需要上传的图片',
'common_select_video_text' => '选择视频',
'common_select_video_tips' => '请选择需要上传的视频',
'common_unknown_error' => '未知错误',
'common_on_fill_in_images' => '暂无图片',
'common_unlimited_text' => '不限',

View File

@ -396,7 +396,6 @@ ul {margin-top:0;}
.common-left-menu a:hover,.common-left-menu-active {background:#ececec;color:#333 !important;}
#ifcontent {border:0px;width:100%;overflow-x:hidden;}
.am-table > tbody > tr > td {vertical-align:top;}
.am-form-file input[type="file"] { margin-top: 0; }
/**
* excel导入窗口

View File

@ -628,6 +628,83 @@ function ImageFileUploadShow(class_name, show_img, default_images)
});
}
/**
* [VideoFileUploadShow 视频上传预览]
* @param {[string]} class_name [class名称]
* @param {[string]} show_video [预览视频id或class]
* @param {[string]} default_video [默认视频]
*/
function VideoFileUploadShow(class_name, show_video, default_video)
{
$(document).on("change", class_name, function(imgFile)
{
show_video = $(this).data('video-tag') || null;
var status = false;
if((imgFile.target.value || null) != null)
{
var filextension = imgFile.target.value.substring(imgFile.target.value.lastIndexOf("."),imgFile.target.value.length);
filextension = filextension.toLowerCase();
if(filextension != '.mp4')
{
Prompt("视频格式错误,请重新上传");
} else {
if(document.all)
{
Prompt('ie浏览器不可用');
/*imgFile.select();
path = document.selection.createRange().text;
$(this).parent().parent().find('img').attr('src', '');
$(this).parent().parent().find('img').attr('src', path); //使用滤镜效果 */
} else {
var url = window.URL.createObjectURL(imgFile.target.files[0]);// FF 7.0以上
$(show_video).attr('src', url);
status = true;
}
}
}
var default_video = $(show_video).data('default') || null;
if(status == false && ((default_video || null) != null || default_video != null))
{
$(show_video).attr('src', default_video || default_video);
}
});
}
// 校验浏览器是否支持视频播放
function CheckVideo()
{
if(document.createElement('video').canPlayType)
{
var vid_test = document.createElement("video");
var ogg_test = vid_test.canPlayType('video/ogg; codecs="theora, vorbis"');
if(!ogg_test)
{
h264_test = vid_test.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
if(!h264_test)
{
document.getElementById("checkVideoResult").innerHTML = "Sorry. No video support."
} else {
if(h264_test == "probably")
{
document.getElementById("checkVideoResult").innerHTML = "Yes! Full support!";
} else {
document.getElementById("checkVideoResult").innerHTML = "Well. Some support.";
}
}
} else {
if(ogg_test == "probably")
{
document.getElementById("checkVideoResult").innerHTML = "Yes! Full support!";
} else {
document.getElementById("checkVideoResult").innerHTML = "Well. Some support.";
}
}
} else {
document.getElementById("checkVideoResult").innerHTML = "Sorry. No video support."
}
}
/**
* 弹窗加载
* @author Devil
@ -1369,6 +1446,31 @@ $(function()
ImageFileUploadShow('.images-file-event');
}
// 视频上传
$(document).on('change', '.video-file-event', function()
{
// 显示选择的图片名称
var fileNames = '';
$.each(this.files, function()
{
fileNames += '<span class="am-badge">' + this.name + '</span> ';
});
$($(this).data('tips-tag')).html(fileNames);
// 触发配合显示input地址事件
var input_tag = $(this).data('choice-one-to') || null;
if(input_tag != null)
{
$(input_tag).trigger('blur');
}
});
// 视频预览
if($('.video-file-event').length > 0)
{
VideoFileUploadShow('.video-file-event');
}
// 图片组合input清除按钮
$(document).on('click', '.original-images-url-delete', function()
{