<style type="text/css">
	.layui-upload-drag {
	    position: relative;
	    padding: 10px;
	    border: 1px dashed #e2e2e2;
	    background-color: #fff;
	    text-align: center;
	    cursor: pointer;
	    color: #999;
	}
</style>
<div class="layui-input-block">
	<div class="layui-upload-drag">
		<a href="<?php echo $imgUrl;?>" target="black">
			<img id="<?php echo $name?>_show_id" src="<?php echo $imgUrl;?>" alt="上传{$title}" title="上传{$title}" width="{$imgWidth}" height="{$imgHeight}">
		</a>
	 	<input type="hidden" id="<?php echo $name?>" name="<?php echo $name?>" value="<?php echo $imgHidden;?>">
	</div>
	<div style="margin-top:10px;">
		<button type="button" class="layui-btn" id="btnUploadImg_<?php echo $name?>"><i class="layui-icon">&#xe67c;</i>上传{$title}</button>
	</div>
	{if $showTips neq null}
	<div class="layui-form-mid layui-word-aux">建议尺寸：{$showTips}</div>
	{/if}
</div>
<script type="text/javascript">
layui.use(['upload','croppers'],function(){
	//声明变量
	var layer = layui.layer
	,upload = layui.upload
	,croppers = layui.croppers
	,$ = layui.$;
	
	if("{$isCrop}"==1) {
		
		//图片裁剪组件
	    croppers.render({
	        elem: '#btnUploadImg_<?php echo $name?>'
	        ,name:"<?php echo $name?>"
	        ,saveW:{$cropWidth}     //保存宽度
	        ,saveH:{$cropHeight}
	        ,mark:{$cropRate}    //选取比例
	        ,area:['750px','500px']  //弹窗宽度
	        ,url: "/upload/uploadImage"
	        ,done: function(url){
	        	//上传完毕回调
	            $('#<?php echo $name?>').val(url);
	            $('#<?php echo $name?>_show_id').attr('src',url);
	        }
	    });
		
	}else{
		
		/**
		 * 普通图片上传
		 */
		var uploadInst = upload.render({
		    elem: '#btnUploadImg_<?php echo $name?>'
			,url: "/upload/uploadImage"
			,accept:'images'
			,acceptMime:'image/*'
			,exts: "{$imgExts}"
			,field:'file'//文件域字段名
			,size: {$imgSize} //最大允许上传的文件大小
			,before: function(obj){
				//预读本地文件
			}
			,done: function(res){
				//上传完毕回调
				
				if(!res.success){
					layer.msg(res.msg,{ icon: 5 });
					return false;
				}

				//上传成功
				$('#<?php echo $name?>_show_id').attr('src', res.data);
	    		$('#<?php echo $name?>').val(res.data);
			}
			,error: function(){
				//请求异常回调
				return layer.msg('数据请求异常');
			}
		});
		
	}
	
});

</script>