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

98

99

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

203

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

245

242
		   $percent.css( 'width', percentage * 100 + '%' );
246
		   $percent.css( 'width', percentage * 100 + '%' );
247
			
243
		});		
248
		});		
244
		// 文件上传成功,给item添加成功class, 用样式标记上传成功。
249
		// 文件上传成功,给item添加成功class, 用样式标记上传成功。
245
		cacheImageKey=null;
250
		cacheImageKey=null;
246
		uploader.on( 'uploadSuccess', function(file,data) {
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
	$("#saveImage").on("click",function(){
271
	$("#saveImage").on("click",function(){
272
	  
264
	if(cacheImageKey==null) {
273
	if(cacheImageKey==null) {
265
		$.MsgBox.Alert("消息","请选择图片");
274
		$.MsgBox.Alert("消息","请选择图片");
266
		return;
275
		return;
306
		$("#smallImage").attr("src","/images/head/"+id+"_s.jpg");
315
		$("#smallImage").attr("src","/images/head/"+id+"_s.jpg");
307
		$("#middleImage").attr("src","/images/head/"+id+"_m.jpg");
316
		$("#middleImage").attr("src","/images/head/"+id+"_m.jpg");
308
		$("#largeImage").attr("src","/images/head/"+id+"_l.jpg");
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
	    $('#largeImage').attr("style","");
319
	    $('#largeImage').attr("style","");
313
 		$('#middleImage').attr("style","");
320
 		$('#middleImage').attr("style","");
314
 		$('#smallImage').attr("style","");	
321
 		$('#smallImage').attr("style","");
322
 		$('#headImage').attr("style","");	
315
	})
323
	})
316
    
324
    
317
    //返回
325
    //返回
318
	$("#back").on("click",function(){
326
	$("#back").on("click",function(){
319
		window.history.back(-1); 
327
		window.history.back(-1); 
320
	}) 
328
	}) 
329
	
330
	
321

331

322
})
332
})
333

334

335

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