|
|
|
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
|
|
|
|
<script type="text/javascript" src="__ADDONROOT__/script/UploadImages.js"></script>
|
|
|
|
<link rel="stylesheet" href="__ADDONROOT__/style/UploadImages.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">
|
|
|
|
<span class="placeholder-graphic placeholder-graphic_{$name}">
|
|
|
|
<img src="{$v|get_cover='path'}" data-id="{$v}"/>
|
|
|
|
</span>
|
|
|
|
<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(){
|
|
|
|
/* 初始化上传插件*/
|
|
|
|
$("#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,
|
|
|
|
'fileTypeExts' : '*.jpg; *.jpeg; *.png; *.gif;',
|
|
|
|
"onUploadSuccess" : uploadPicture{$name},
|
|
|
|
'onFallback' : function() {
|
|
|
|
// alert('未检测到兼容版本的Flash.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
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'><span class='placeholder-graphic placeholder-graphic_{$name}'><img src=" + src + " title='点击显示大图' data-id=" + data.id + "> </span><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 {
|
|
|
|
alert(data.info);
|
|
|
|
setTimeout(function(){
|
|
|
|
$('#top-alert').find('button').click();
|
|
|
|
$(that).removeClass('disabled').prop('disabled',false);
|
|
|
|
},1500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|