You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.6 KiB
HTML
92 lines
3.6 KiB
HTML
5 years ago
|
|
||
|
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
|
||
|
<script type="text/javascript" src="__ADDONS__/UploadImages.js"></script>
|
||
|
<link rel="stylesheet" href="__ADDONS__/UploadImages2.css">
|
||
|
<input type="file" id="upload_picture_{$name}">
|
||
|
<input type="hidden" name="{$name}" value="{$valStr}" class="icon_{$name}" />
|
||
|
<div class="upload-img-box">
|
||
|
<notempty name="valArr">
|
||
|
<volist name="valArr" id="v">
|
||
|
<div class="upload-pre-item">
|
||
|
<img src="{$v|get_cover='path'}" data-id="{$v}"/>
|
||
|
<span class='btn-close btn-close-{$name}' title='删除图片'></span>
|
||
|
</div>
|
||
|
</volist>
|
||
|
</notempty>
|
||
|
</div>
|
||
|
<script type="text/javascript">
|
||
|
//删除图片
|
||
|
$('.btn-close-{$name}').click(function(event) {
|
||
|
event.preventDefault();
|
||
|
$(this).parent().remove();
|
||
|
picsbox = $("#upload_picture_{$name}").siblings('.upload-img-box');
|
||
|
picArr = [];
|
||
|
for (var i = 0; i < picsbox.children().length ; i++) {
|
||
|
picArr.push(picsbox.children('.upload-pre-item:eq('+i+')').find('img').attr('data-id'));
|
||
|
};
|
||
|
|
||
|
//console.log(picStr);
|
||
|
var picStr = picArr.join(',');
|
||
|
$('.icon_{$name}').val(picStr);
|
||
|
});
|
||
|
//上传图片
|
||
|
$(function(){
|
||
|
/* 初始化上传插件*/
|
||
|
var multi{$name} = {$multi|default=1};
|
||
|
$("#upload_picture_{$name}").uploadify({
|
||
|
"height" : 30,
|
||
|
"swf" : "__STATIC__/uploadify/uploadify.swf",
|
||
|
"fileObjName" : "download",
|
||
|
"buttonText" : "上传图片",
|
||
|
"uploader" : "{:U('File/uploadPicture',array('session_id'=>session_id(),'flag'=>$flag))}",
|
||
|
'buttonClass' : "{$class}",
|
||
|
"width" : 120,
|
||
|
'removeTimeout' : 1,
|
||
|
'multi' : !!multi{$name},
|
||
|
'fileTypeExts' : '*.jpg; *.jpeg; *.png; *.gif;',
|
||
|
"onUploadSuccess" : uploadPicture{$name},
|
||
|
'onFallback' : function() {
|
||
|
alert('未检测到兼容版本的Flash.');
|
||
|
},
|
||
|
'onUploadStart':function(file){
|
||
|
if(file.size>2*1024*1024) {
|
||
|
layer.msg('上传文件大小不符');
|
||
|
$("#upload_picture_{$name}").uploadify('cancel',file.id);
|
||
|
}
|
||
|
},
|
||
|
});
|
||
|
|
||
|
})
|
||
|
function uploadPicture{$name}(file, data){
|
||
|
var data = $.parseJSON(data);
|
||
|
var src = '';
|
||
|
if (data.status) {
|
||
|
src = data.url || '__ROOT__' + data.path;
|
||
|
upload_img = "<div class='upload-pre-item'><img src=" + src + " title='点击显示大图' data-id=" + data.id + "> <span class='btn-close btn-close-{$name}' title='删除图片'></span></div>";
|
||
|
picsbox = $("#upload_picture_{$name}").siblings('.upload-img-box');
|
||
|
picsbox.append(upload_img)
|
||
|
picArr = [];
|
||
|
for (var i = 0; i < picsbox.children().length; i++) {
|
||
|
picArr.push(picsbox.children('.upload-pre-item:eq(' + i + ')').find('img').attr('data-id'));
|
||
|
}
|
||
|
;
|
||
|
picStr = picArr.join(',');
|
||
|
$('.icon_{$name}').val(picStr);
|
||
|
|
||
|
$('.btn-close-{$name}').click(function (event) {
|
||
|
event.preventDefault();
|
||
|
$(this).parent().remove();
|
||
|
picsbox = $("#upload_picture_{$name}").siblings('.upload-img-box');
|
||
|
picArr = [];
|
||
|
for (var i = 0; i < picsbox.children().length; i++) {
|
||
|
picArr.push(picsbox.children('.upload-pre-item:eq(' + i + ')').find('img').attr('data-id'));
|
||
|
}
|
||
|
;
|
||
|
picStr = picArr.join(',');
|
||
|
$('.icon_{$name}').val(picStr);
|
||
|
});
|
||
|
} else {
|
||
|
layer.msg(data.info);
|
||
|
}
|
||
|
}
|
||
|
</script>
|