Browse Source

1、修改了教育背景不能保存问题;2、在professor页面的头像上传功能

luyanan 8 years ago
parent
commit
d678500c4b

+ 1 - 1
src/main/webapp/information.html

@ -449,7 +449,7 @@
449 449
			$data.college = $("#college").val();
450 450
			$data.major = $("#major").val();
451 451
			$data.degree = $("#degree").val();
452
			$data.student = 0;
452
			$data.student = false;
453 453
			$.ajax({
454 454
				"url" : "/ajax/edu",
455 455
				"type" : $id ? "PUT" : "POST",

+ 187 - 0
src/main/webapp/page/photo-set1.html

@ -0,0 +1,187 @@
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
6

7
<meta http-equiv="X-UA-Compatible" content="IE=edge">
8

9
<title>头像上传</title>
10
<link href="../css/basic.css" rel="stylesheet" type="text/css" />
11
<link href="../css/jquery.Jcrop.css" rel="stylesheet" type="text/css" />
12
<link type="text/css" href="../css/login.css" rel="stylesheet">
13
	
14
<style>
15

16
.photo-title {
17
    color: #3a3a3a;
18
}
19
.save {   
20
    margin-left: 40px;
21
}
22
.photo-set {
23
	width:auto;
24
}
25
.photo-box { 
26
    margin-left: -300px;
27
}
28
</style>
29
</head>
30
<body>
31
  <div id="header"></div>
32

33
          <div class="photo-box">
34
				<div class="photo-title">头像设置</div>
35
                <div class="photo-set">
36
                    <div class="photo-upload">
37
                        <!--点击上传按钮-->
38
                        <div class="load">
39
                             <div class="upbtn" style="Margin:auto" ><span class="plus">+</span>本地上传<input type="file" class="filebtn"  name="file" id="uploadInput" ></div>
40
                            <p>只支持JPG、PNG、GIF,大小不超过5M</p>
41
                            
42
                        </div>
43
                        <!---->
44
                        <!--选择图片尺寸-->
45
                        <div class="wrap" id="jcropdiv">
46
                                    <div class="wl">
47
                                        <div class="jc-demo-box" data="0">
48
                                            <div id="target" class="jcrop_w" >
49
                                                <img src="" width="602" height="400" id="headImage" />
50
                                            </div>
51
                                        </div>
52
                                        <div class="jy-up-ch">
53
                                            <a id="idLeft" href="" class="bch bch1"></a>
54
                                            <a id="idSmall" href="" class="bch bch2"></a>
55
                                            <a id="idBig" href="" class="bch bch3"></a>
56
                                            <a id="idRight" href="" class="bch bch4"></a>
57
                                        </div>
58
                                    </div>
59
                        </div>
60
                        <!---->
61
                    </div>
62
        
63
                   
64
                </div>	
65
				<input id="x" type="hidden"/>
66
				<input id="y" type="hidden"/>
67
				<input id="w" type="hidden"/>
68
				<input id="h" type="hidden"/>
69
                <div class="upload-file">
70
                	  <!--<div class="fl">
71
                       <div class="upbtn"><span class="plus">+</span>本地上传<input type="file" class="filebtn"  name="file" id="uploadInput" ></div>
72
                        <p>只支持JPG、PNG、GIF,大小不超过5M</p> 
73
                    </div>
74
                    <div class="fl">
75
                    	<button type="button" id="uploadBtn">UPLOAD</button>
76
                    </div>
77
                    -->
78
                    <div class="clear"></div>
79
                </div>
80
				<input type="button" value="保存" class="save" id="saveImage">
81
				<input type="button" value="取消" class="close" >
82
				<input type="button" value="返回" id="back" >
83
				
84
			 </div>
85
             
86
<script type="text/javascript" src="../js/jquery-1.11.1.js"></script>
87
<script type="text/javascript" src="../js/jquery.HeadP.js"> </script>
88
<script type="text/javascript" src="../js/jquery.Jcrop.js"> </script>
89
<script type="text/javascript" src="../js/basic.js"> </script>
90
<script type="text/javascript" src="../js/ajaxfileupload.js"></script>
91
<script type="text/javascript" src="../js/jquery.similar.msgbox.js"></script>	
92

93
<script type="text/javascript">
94
$(function (){
95
	var getUrlParameter=function(sParam) {
96
    		    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
97
    		        sURLVariables = sPageURL.split('&'),
98
    		        sParameterName,
99
    		        i;
100

101
    		    for (i = 0; i < sURLVariables.length; i++) {
102
    		        sParameterName = sURLVariables[i].split('=');		
103
    		        if (sParameterName[0] === sParam) {
104
    		            return sParameterName[1] === undefined ? true : sParameterName[1];
105
    		        }
106
    		    }
107
    		};
108
    		
109
	var id =getUrlParameter("id");
110
	console.log(id);
111
	var cacheImageKey=null;
112
	var servPath = "http://121.42.53.174:81";
113
	if(id){
114
		$("#headImage").attr("src",servPath+"/images/head/"+id+"_l.jpg");
115
//		$("#smallImage").attr("src",servPath+"/images/head/"+id+"_l.jpg");
116
//		$("#middleImage").attr("src",servPath+"/images/head/"+id+"_l.jpg");
117
//		$("#largeImage").attr("src",servPath+"/images/head/"+id+"_l.jpg");
118
		$('#uploadInput').live('change',function(){ 
119
			$("#jcropdiv").show();
120
			$(".load").hide();
121
			$.ajaxFileUpload({
122
				url:"../ajax/cachedFileUpload",
123
				secureuri:false,
124
				fileElementId:"uploadInput",
125
				dataType:"json",
126
				success:function($data){
127
					if($data.success){
128
						cacheImageKey =$data.data[0].cacheKey
129
						$("#headImage").attr("src",servPath+"/images/tmp/"+cacheImageKey);
130
//						$("#smallImage").attr("src",servPath+"/images/tmp/"+cacheImageKey);
131
//						$("#middleImage").attr("src",servPath+"/images/tmp/"+cacheImageKey);
132
//						$("#largeImage").attr("src",servPath+"/images/tmp/"+cacheImageKey);
133
					}else{
134
						alert($data.msg);
135
					}
136
				},
137
				error:function(){
138
					$.MsgBox.Alert("message","upload error");
139
				}    					
140
			});
141
		});
142
		
143
	}
144
	$("#saveImage").on("click",function(){
145
		var x = parseInt($("#x").val()/395*100);
146
		var y = parseInt($("#y").val()/340*100);
147
		var w = parseInt($("#w").val()/395*100);
148
		var h = parseInt($("#h").val()/340*100);
149
		if(cacheImageKey){
150
			$.ajax({
151
				url:"../ajax/image/head",
152
				type:"POST",
153
				data:{"id":id,"fn":cacheImageKey,"x":x,"y":y,"w":w,"h":h},
154
				dataType:"json",
155
				success:function($data){
156
					if($data.success){
157
						alert("上传成功");
158
						location.reload(true);
159
					}else{
160
						alert($data.msg);
161
					}
162
				}
163
			});
164
		}
165
	});
166

167

168
	$(".close").on("click",function(){
169
		$(".load").show();
170
		$("#jcropdiv").hide();
171
		$("#headImage").attr("src","");
172
//		$("#smallImage").attr("src","");
173
//		$("#middleImage").attr("src","");
174
//		$("#largeImage").attr("src","");
175
	})
176

177
	$("#back").on("click",function(){
178

179
		location.href = "professor.html?id="+encodeURI(id);
180
	})
181

182
})
183

184
</script>
185
<div id="footer"></div>
186
</body>
187
</html>

+ 5 - 1
src/main/webapp/page/professor.html

@ -72,7 +72,7 @@
72 72
		</div>
73 73
		<div class="row">
74 74
			<div class="col-sm-3">
75
				<a href='professor.html'><image id="headImage" src=""></image></a>
75
				<div id="headChange"><image id="headImage" src=""></image></div>
76 76
			</div>
77 77
			<div class="col-sm-6">
78 78
				<form class="form-horizontal">
@ -576,6 +576,10 @@
576 576
					}
577 577
				}
578 578
			};
579
			 $("#headChange").on("click",function (){
580
	   		var headChange1 =getUrlParameter("id"); 
581
	   		location.href = "photo-set1.html?id="+encodeURI(headChange1);
582
	   })
579 583
			var fillRA=function($caption,$descp){
580 584
				$li =$("<li></li>").addClass("rablock");
581 585
				$("<span></span>").html($caption).addClass("raCaption").appendTo($li);