<?php defined('G_IN_SYSTEM')or exit('No permission resources.'); ?><?php include templates("index","header");?>
<?php include templates("member","top");?>	
<div class="c_person_record">
<ul class="c_person_list">
	<li class=""><a href="<?php echo WEB_PATH; ?>/member/home/userbuylist" hidefocus="">云购记录</a></li>
	<li class=""><a href="<?php echo WEB_PATH; ?>/member/home/singlelist" hidefocus="">我的晒单</a></li>
	<li class=""><a href="<?php echo WEB_PATH; ?>/member/home/orderlist" hidefocus="">中奖记录</a></li>
	<li class=""><a href="<?php echo WEB_PATH; ?>/member/home/userfufen" hidefocus="">我的福分</a></li>
	<li class=""><a href="<?php echo WEB_PATH; ?>/member/home/userbalance" hidefocus="">账户管理</a></li>
	<li class=""><a href="<?php echo WEB_PATH; ?>/member/home/commissions" hidefocus="">奖励专区</a></li>
	<li class=""><a href="<?php echo WEB_PATH; ?>/member/home/invitefriends" hidefocus="">邀请好友</a></li>
	<li class=""><a href="<?php echo WEB_PATH; ?>/member/home/address" hidefocus="">收货地址</a></li>
</ul>
<div class="main-content clearfix">
<?php include templates("member","left");?>
<link rel="stylesheet" type="text/css" href="<?php echo G_TEMPLATES_STYLE; ?>/css/layout-setUp.css"/>
<script type="text/javascript">
//裁剪图片
function showCoords(obj){
	$("#x").val(obj.x);$("#y").val(obj.y);$("#w").val(obj.w);$("#h").val(obj.h);
	if(parseInt(obj.w) > 0){
		var rx = $("#w160").width() / obj.w; 
		var ry = $("#w160").height() / obj.h;
		$("#crop_preview").css({
			width:Math.round(rx * $("#xuwanting").width()) + "px",	
			height:Math.round(rx * $("#xuwanting").height()) + "px",	
			marginLeft:"-" + Math.round(rx * obj.x) + "px",
			marginTop:"-" + Math.round(ry * obj.y) + "px"
		});
		var rx2 = $("#w80").width() / obj.w; 
		var ry2 = $("#w80").height() / obj.h;
		$("#crop_preview2").css({
			width:Math.round(rx2 * $("#xuwanting").width()) + "px",	
			height:Math.round(rx2 * $("#xuwanting").height()) + "px",	
			marginLeft:"-" + Math.round(rx2 * obj.x) + "px",
			marginTop:"-" + Math.round(ry2 * obj.y) + "px"
		});
		var rx3 = $("#w30").width() / obj.w; 
		var ry3 = $("#w30").height() / obj.h;
		$("#crop_preview3").css({
			width:Math.round(rx3 * $("#xuwanting").width()) + "px",	
			height:Math.round(rx3 * $("#xuwanting").height()) + "px",
			marginLeft:"-" + Math.round(rx3 * obj.x) + "px",
			marginTop:"-" + Math.round(ry3 * obj.y) + "px"
		});
	}
}
//上传文件
function stripscript(s) 
{ 
var pattern = new RegExp("[%--`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]")        //格式 RegExp("[在中间定义特殊过滤字符]")
var rs = ""; 
for (var i = 0; i < s.length; i++) { 
 rs = rs+s.substr(i, 1).replace(pattern, ''); 
}
return rs;
}
$(function(){
    $('#file_upload').uploadify({
    	'auto'     : true,
    	'removeTimeout' : 1,
		'removeCompleted' :true,
		'progressData' :'speed',
        'swf'      : '<?php echo G_TEMPLATES_STYLE; ?>/js/uploadify.swf',
        'uploader' : '<?php echo WEB_PATH; ?>/member/home/userphotoup',
        'method'   : 'post',
		'buttonText' : '选择图片',
		'buttonImage': '<?php echo G_TEMPLATES_STYLE; ?>/img/upload.gif',
		'width': 94,
		'height': 27,
        'multi'    : true,
        'uploadLimit' : 5,
        'fileTypeDesc' : 'Image Files',
        'fileTypeExts' : '*.jpeg; *.jpg; *.png',
        'fileSizeLimit' : '20000KB',

		'formData'        : {
			'typeCode'   : '<?php echo time(); ?>',
			'uid': '<?php echo $uid; ?>',			
			'ushell':'<?php echo $ushell; ?>'
		},
		'onSelect' :function(){
			var hide=$("#divImgTip").css("display");
			if(hide=="none"){
				$(".pic #xuwanting,.pic .jcrop-holder").remove();
				$("#divImgTip").show();
			}
		},
		'onUploadSuccess' : function(file,data,response){	
			data =  data.replace(/^(\s|\xA0)+|(\s|\xA0)+$/g,'');   			
			$(".photo ul li").remove();
			$("#divImgTip").hide();
			$(".pic").append(SetImgContent(data));
			$(".photo ul").append(SetImgphoto(data));		
			$("#membimg").val(data);	
			$("#xuwanting").Jcrop({
				aspectRatio:1,
				setSelect:[160,160,0,0],
				onChange:showCoords,
				onSelect:showCoords
			});
		}
    });
});
//显示上传的图片
function SetImgContent(data){

	if(data == ''){
		alert('上传失败！');
		return;
	}else{
		var sLi = "";
		sLi += '<img  id="xuwanting" src="<?php echo G_UPLOAD_PATH; ?>/'+data+'">';
		return sLi;
	}
}
function SetImgphoto(data){
	if(data == ''){		
		return;
	}else{
		var sLi160 = "";
		sLi160 += '<li class="li160"><div class="w160"><div id="w160">';
		sLi160 += '<img id="crop_preview" src="<?php echo G_UPLOAD_PATH; ?>/'+data+'">';
		sLi160 += '</div></div>160X160 像素</li>';
		sLi160 += '<li class="li80"><div class="w80"><div id="w80">';
		sLi160 += '<img id="crop_preview2" src="<?php echo G_UPLOAD_PATH; ?>/'+data+'">';
		sLi160 += '</div></div>80X80 像素</li>';
		sLi160 += '<li class="li30"><div class="w30"><div id="w30">';
		sLi160 += '<img id="crop_preview3" src="<?php echo G_UPLOAD_PATH; ?>/'+data+'">';
		sLi160 += '</div></div>30X30 像素</li>';
		return sLi160;
	}
}
</script>

<style>
#file_upload{float:left;}
#file_upload-queue{display:block; margin:30px 0 0 0;}
</style>
<div class="R-content">
	<?php include templates("member","shezhi");?>
	<div id="urlxx"></div>
	<div class="uploadCon" style="margin-top:20px;">
		<div class="upLeft">
            <div class="gray02">支持  png,  jpg,  jpeg 图片上传</div>
			<div class="upload" style="float:left; width:300px;"><input type="file" name="file_upload"  id="file_upload" multiple="true" /></div>
			<div class="frameCut">
				<div class="zhix"></div>
				<div id="divImgTip" class="text">选择一张本地的图片编辑后上传成为头像</div>
				<div class="pic">					
				</div>
			</div>
			<span class="tishi gray02">点击图片并拉动以选择需要裁剪的区域</span>
			<div class="savePhoto">
				<form action="<?php echo WEB_PATH; ?>/member/home/userphotoinsert" method="post" id="crop_form">
					<input type="hidden" id="x" name="x" />
					<input type="hidden" id="y" name="y" />
					<input type="hidden" id="w" name="w" />
					<input type="hidden" id="h" name="h" />
					<input type="hidden" id="membimg" name="img" />
					<input id="crop_submit" type="submit"name="submit" class="bluebut" value="保存头像" title="保存头像"/>
				</form>
			</div>
		</div>
		<div class="upRight">
			<p class="gray02">您上传的头像将会自动生成三种尺寸，请注意头像是否清晰：</p>
			<div class="photo gray02">
				<ul>
					<?php if(empty($member['img']) || $member['img'] == "photo/member.jpg"): ?>				
					<li class="li160"><div class="w160"><div id="w160"><img id="crop_preview" src="<?php echo G_UPLOAD_PATH; ?>/photo/member.jpg_160160.jpg" width="160" height="160"  /></div></div>160X160 像素</li>
					<li class="li80"><div class="w80"><div id="w80"><img id="crop_preview2" src="<?php echo G_UPLOAD_PATH; ?>/photo/member.jpg_8080.jpg" width="80" height="80"  /></div></div>80X80 像素</li>
					<li class="li30"><div class="w30"><div id="w30"><img id="crop_preview3" src="<?php echo G_UPLOAD_PATH; ?>/photo/member.jpg_3030.jpg" width="30" height="30"  /></div></div>30X30 像素</li>					
					<?php  else: ?>			
					<li class="li160"><div class="w160"><div id="w160"><img id="crop_preview" src="<?php echo G_UPLOAD_PATH; ?>/<?php echo $member['img']; ?>_160160.<?php echo img($member['img']); ?>" /></div></div>160X160 像素</li>
					<li class="li80"><div class="w80"><div id="w80"><img id="crop_preview2" src="<?php echo G_UPLOAD_PATH; ?>/<?php echo $member['img']; ?>_8080.<?php echo img($member['img']); ?>" /></div></div>80X80 像素</li>
					<li class="li30"><div class="w30"><div id="w30"><img id="crop_preview3" src="<?php echo G_UPLOAD_PATH; ?>/<?php echo $member['img']; ?>_3030.<?php echo img($member['img']); ?>" /></div></div>30X30 像素</li>					
					<?php endif; ?>
				</ul>
			</div>
		</div>
	</div>
</div>


</div>
		</div>
	</div>
<!--center_center_end-->
<div class="right">				
</div>
<!--center_rjght_end-->

</div>
<?php include templates("index","footer");?>