| xqd
@@ -314,6 +314,100 @@ EOF;
|
|
|
return $html;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 统一多张图片
|
|
|
+ * @param $folder
|
|
|
+ * @param $id
|
|
|
+ * @param string $name
|
|
|
+ * @param array $imgs
|
|
|
+ * @param null $callBackFun
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function multiN($id, $name = "data[image]", $files = [], $option = [])
|
|
|
+ {
|
|
|
+ $url = U("/Base/Photos/index");
|
|
|
+ $maxCount = isset($option['maxCount']) ? $option['maxCount'] : 0;
|
|
|
+
|
|
|
+ $name = $name . '[]';
|
|
|
+ $imgHtml = "";
|
|
|
+ if (!empty($files)) {
|
|
|
+ foreach ($files as $file) {
|
|
|
+ $imgHtml .= "<div class='file-preview-frame krajee-default kv-preview-thumb file-preview-success'>
|
|
|
+ <div class='kv-file-content'>
|
|
|
+ <img src=\"{$file}\" style='width:100%;'/>
|
|
|
+
|
|
|
+ <input type='hidden' class='$id' name=\"{$name}\" value=\"{$file}\">
|
|
|
+ </div>
|
|
|
+ <div class='file-thumbnail-footer'>
|
|
|
+ <div class='file-footer-caption'>
|
|
|
+ <div class='file-caption-info'></div>
|
|
|
+ <div class='file-size-info'></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class='file-actions'>
|
|
|
+ <div class='file-footer-buttons'>
|
|
|
+ <button type='button' onclick='$(this).parent().parent().parent().parent().remove()' class='kv-file-remove btn btn-sm btn-kv btn-default btn-outline-secondary' title='删除文件'><i class='glyphicon glyphicon-trash'></i></button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $idbutton = $id . '_button';
|
|
|
+ $html = <<<EOF
|
|
|
+ <div style="clear:both">
|
|
|
+ <div id="$id" class="file-preview">
|
|
|
+ <div class="file-preview-thumbnails">
|
|
|
+ $imgHtml
|
|
|
+ </div>
|
|
|
+ <div class="clearfix"></div>
|
|
|
+ </div>
|
|
|
+ <button class="btn btn-primary" id="$idbutton" type="button">选择图片</button>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <script type="text/javascript">
|
|
|
+
|
|
|
+ $("#$idbutton").click(function() {
|
|
|
+ max = '$maxCount'
|
|
|
+ current_num = $('.$id').length;
|
|
|
+
|
|
|
+ if(max > 0 && max != current_num){
|
|
|
+ max = max - current_num
|
|
|
+ }
|
|
|
+ console.log(current_num)
|
|
|
+ layer.open({
|
|
|
+ type: 2,
|
|
|
+ title: '选择图片',
|
|
|
+ shadeClose: true,
|
|
|
+ shade: 0.8,
|
|
|
+ area: ['80%', '90%'],
|
|
|
+ content: '$url',
|
|
|
+ btn: ['确定'],
|
|
|
+ yes:function(index, layero){
|
|
|
+ var body = layer.getChildFrame('body',index);//建立父子联系
|
|
|
+ var imglist = body.find('div.img-card span.checked');
|
|
|
+ if(imglist.length > max){
|
|
|
+ layer.alert('只能选择'+max+'张图片')
|
|
|
+ }else{
|
|
|
+ $.each(imglist,function(i) {
|
|
|
+ $("#$id .file-preview-thumbnails").append("<div class='file-preview-frame krajee-default kv-preview-thumb file-preview-success'><div class='kv-file-content'><img src=" + $(this).attr('data-src') + " style='width:100%' /> <input class='$id' type='hidden' name='{$name}' value="+ $(this).attr('data-src')+"></div><div class='file-thumbnail-footer'><div class='file-footer-caption'> <div class='file-caption-info'></div><div class='file-size-info'></div></div><div class='file-actions'><div class='file-footer-buttons'><button type='button' class='kv-file-remove btn btn-sm btn-kv btn-default btn-outline-secondary' onclick='$(this).parent().parent().parent().parent().remove()' title='删除文件'><i class='glyphicon glyphicon-trash'></i></button></div></div></div></div>");
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ layer.close(index);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ </script>
|
|
|
+
|
|
|
+EOF;
|
|
|
+ return $html;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 统一多张图片
|
|
|
* @param $folder
|