Browse Source

头像上传修改

xuchunyang 8 years ago
parent
commit
ad2c17ee5f
1 changed files with 37 additions and 24 deletions
  1. 37 24
      src/main/webapp/photo-set.html

+ 37 - 24
src/main/webapp/photo-set.html

@ -28,7 +28,7 @@
28 28
								<div id="fileList" class="uploader-list"></div>
29 29
								<div id="filePicker">选择图片</div>
30 30
						 </div>
31
						<span class="resouimgmsg">尺寸240*240,大小在5M以内,JPG、PNG格式</span> 
31
						<span class="resouimgmsg">建议尺寸340*340,大小在5M以内,JPG、PNG格式</span> 
32 32
                     </div>
33 33
                     <!---->
34 34
                     <!--选择图片尺寸-->
@ -36,7 +36,7 @@
36 36
                                 <div class="wl">
37 37
                                     <div class="jc-demo-box" data="0">
38 38
                                         <div id="target" class="jcrop_w" >
39
                                             <img src="" width="602" height="400" id="headImage" />
39
                                            <img src="" id="headImage">
40 40
                                         </div>
41 41
                                     </div>
42 42
                                  <!--    <div class="jy-up-ch" >
@ -57,15 +57,15 @@
57 57
                             <div class="pre-1">
58 58
                                 <img  src="" class="jcrop-preview jcrop_preview_s" alt="" id="largeImage"/>
59 59
                             </div>
60
                             <p>200px*200px</p>
60
                             <p style="font-size: 14px;">200px*200px</p>
61 61
                             <div class="pre-2">
62 62
                                 <img src="" class="jcrop-preview jcrop_preview_s" alt="" id="middleImage"/>
63 63
                             </div>
64
                             <p>50px*50px</p>
64
                             <p style="font-size: 13px;">50px*50px</p>
65 65
                             <div class="pre-3">
66 66
                                 <img src="" class="jcrop-preview jcrop_preview_s" alt="" id="smallImage"/>
67 67
                             </div>
68
                             <p>26px*26px</p>
68
                             <p style="font-size: 12px;">26px*26px</p>
69 69
                         </div>
70 70
                     </div>
71 71
                 </div>
@ -95,8 +95,11 @@
95 95
<script type="text/javascript" src="js/common.js"> </script>
96 96
<script type="text/javascript"src="js/jquery.cookie.js"></script>
97 97
<script type="text/javascript">
98
$(function (){
99 98

99

100
   
101
$(function (){
102
 
100 103
     //初始化截图框
101 104
     var _Jw = ($("#target").width() - 200) / 2 ,
102 105
         _Jh = ($("#target").height() - 200) / 2 ,
@ -200,6 +203,7 @@ $(function (){
200 203

201 204
		    // $list为容器jQuery实例
202 205
		    var $list = $('#fileList');
206
		   
203 207
		    $list.empty("");
204 208
		  //  $list.append( $li );
205 209
           setTimeout(target,500);
@ -211,7 +215,7 @@ $(function (){
211 215
		            $img.replaceWith('<span>不能预览</span>');
212 216
		            return;
213 217
		        }
214
		        $img.attr( 'src', src );
218
		      
215 219
		    }, 240, 240 );
216 220
		    
217 221
		    //判断上传文件格式
@ -240,27 +244,32 @@ $(function (){
240 244
		    }
241 245

242 246
		   $percent.css( 'width', percentage * 100 + '%' );
247
			
243 248
		});		
244 249
		// 文件上传成功,给item添加成功class, 用样式标记上传成功。
245 250
		cacheImageKey=null;
246 251
		uploader.on( 'uploadSuccess', function(file,data) {
247
		console.log(file.id);
248
		$("#jcropdiv").show();
249
		$(".load").hide();
250
		uploader.removeFile(fileId);
251
		cacheImageKey =data.data[0].cacheKey;			
252
		$("#headImage").attr("src","/images/tmp/"+cacheImageKey);
253
		$("#smallImage").attr("src","/images/tmp/"+cacheImageKey);
254
		$("#middleImage").attr("src","/images/tmp/"+cacheImageKey);
255
		$("#largeImage").attr("src","/images/tmp/"+cacheImageKey);
256
		$('#largeImage').attr("style","");
257
  		$('#middleImage').attr("style","");
258
  		$('#smallImage').attr("style","");					  
252
			console.log(file);
253
			$("#jcropdiv").show();
254
			$(".load").hide();
255
			uploader.removeFile(fileId);
256
			cacheImageKey =data.data[0].cacheKey;			
257
			$("#headImage").attr("src","/images/tmp/"+cacheImageKey);
258
			$("#smallImage").attr("src","/images/tmp/"+cacheImageKey);
259
			$("#middleImage").attr("src","/images/tmp/"+cacheImageKey);
260
			$("#largeImage").attr("src","/images/tmp/"+cacheImageKey);
261
			$('#largeImage').attr("style","");
262
	  		$('#middleImage').attr("style","");
263
	  		$('#smallImage').attr("style","");
264
		     setTimeout(function(){
265
		     	cutImage($(".jcrop_w>img"))
266
		     }, 30);
259 267
		});
260 268
	}
261
    
269

262 270
    //保存
263 271
	$("#saveImage").on("click",function(){
272
	  
264 273
	if(cacheImageKey==null) {
265 274
		$.MsgBox.Alert("消息","请选择图片");
266 275
		return;
@ -306,20 +315,24 @@ $(function (){
306 315
		$("#smallImage").attr("src","/images/head/"+id+"_s.jpg");
307 316
		$("#middleImage").attr("src","/images/head/"+id+"_m.jpg");
308 317
		$("#largeImage").attr("src","/images/head/"+id+"_l.jpg");
309
 		$('#target').Jcrop({
310
	        setSelect: [_Jw, _Jh, _Jw2, _Jh2],
311
	    });
318
 		$('#target').Jcrop({ setSelect: [_Jw, _Jh, _Jw2, _Jh2],	});
312 319
	    $('#largeImage').attr("style","");
313 320
 		$('#middleImage').attr("style","");
314
 		$('#smallImage').attr("style","");	
321
 		$('#smallImage').attr("style","");
322
 		$('#headImage').attr("style","");	
315 323
	})
316 324
    
317 325
    //返回
318 326
	$("#back").on("click",function(){
319 327
		window.history.back(-1); 
320 328
	}) 
329
	
330
	
321 331

322 332
})
333

334

335

323 336
</script>
324 337
</body>
325 338
</html>