Browse Source

判断头像和机构是否存在,不存在时显示默认图片

luyanan 8 years ago
parent
commit
aeff26cabb

+ 11 - 5
src/main/webapp/account-set.html

@ -14,8 +14,8 @@
14 14
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
15 15
<!-- <script type="text/javascript" src="js/form.js"></script> -->
16 16
<script type="text/javascript" src="js/index.js"></script>
17
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
18
<script type="text/javascript" src="/js/common.js"></script>
17
<script type="text/javascript" src="js/jquery.cookie.js"></script>
18
<script type="text/javascript" src="js/common.js"></script>
19 19
<!-- <script type="text/javascript" src="js/account-set.js"></script> -->
20 20
<script type="text/javascript" src="js/jquery.similar.msgbox.js"></script>
21 21
<script type="text/javascript" >
@ -24,10 +24,15 @@
24 24
		var servPath = "http://121.42.53.174:81";
25 25
		var userid = $.cookie("userid");
26 26
	 	if(userid){
27
	 		$(".head-portrait").css("background","url("+servPath+"/images/head/"+userid+"_m.jpg)");
28
	 		$(".head-portrait").show();
27
			$(".head-portrait").show();
29 28
			$(".unlogin").hide();
30
				}
29
	 		$(".portrait-p").attr("src",servPath+"/images/head/"+userid+"_m.jpg");
30
			$(".portrait-p").load(function(){									
31
			})
32
			.error(function(){
33
				$(".portrait-p").attr("src",servPath+"/images/default-photo.jpg");
34
			});
35
		}
31 36
		valUser();
32 37
		$("#hsearch").on("click",function (){
33 38
	   		var searchContent = $("#hsearchContent").val();
@ -354,6 +359,7 @@
354 359
    <a href="login-invite-code.html"><div class="unlogin">特邀专家登录</div></a>
355 360
    <!--已登录-->
356 361
    <div class="head-portrait">
362
    	<img class="portrait-p" />
357 363
        <div class="personal-infor">
358 364
            <div class="triangleB"></div>
359 365
            <div class="personal-box">

+ 3 - 2
src/main/webapp/css/index.css

@ -15,7 +15,8 @@ url(../images/index-icon.png) no-repeat; background-position:left; margin:8px;}
15 15
/*未登录*/
16 16
.unlogin{ width:130px; height:35px; border:1px #fff solid; border-radius:10px;font:14px/35px \5FAE\8F6F\96C5\9ED1,"Microsoft YaHei"; color:#fff; text-align:center; float:right; margin-right:80px; margin-top:10px; cursor:pointer; }
17 17
/*已登录*/
18
.head-portrait{ display:none; width:50px; height:50px; border-radius:50%; background:url(../images/default-photo.jpg) no-repeat center center;background-size:100% 100%;-moz-background-size:100% 100%; float:right; margin-right:80px; margin-top:5px; cursor:pointer; border:1px solid #f8f8f8; }
18
.head-portrait{ display:none; width:50px; height:50px; border-radius:50%;background-size:100% 100%;-moz-background-size:100% 100%; float:right; margin-right:80px; margin-top:5px; cursor:pointer; border:1px solid #f8f8f8; overflow:hidden; }
19
.portrait-p{ width:100%;}
19 20
.personal-infor{width:202px; height:179px; position:absolute; top:42px; right:80px; display:none;}
20 21
.triangleB{ display:block; width:0; height:0; border:8px solid transparent; border-bottom-color:#f3a36c; float:right; margin-right:20px; margin-top:15px;}
21 22
.personal-box{ width:202px; /*height:160px;*/ border-radius:10px; background:#f3a36c; clear:both; overflow:hidden;}
@ -113,7 +114,7 @@ h5{font:20px/30px \5FAE\8F6F\96C5\9ED1,"Microsoft YaHei"; }
113 114
.about-in{ width:920px; max-height:850px; height:auto; margin:auto; margin-top:10px;}
114 115
.item{ width:100%;overflow: hidden; border:1px #ffa544 solid;box-shadow:1px 1px 1px #ff8400 inset; border-radius:10px; margin-top:18px; }
115 116
/*.photo{ width:132px; height:132px; border-radius:50%; border:2px #fca72d solid; margin:20px; background:url(../images/pic1.jpg) no-repeat center center; float:left;}*/ 	
116
.photo1{width:132px;height:132px;border-radius:50%;border:1px #fca72d solid;margin:20px;float:left;/*background:url(../images/default-photo.jpg)  no-repeat center center;*/background-size:100% 100%;-moz-background-size:100% 100%;}
117
.photo1{width:132px;height:132px;border-radius:50%;border:1px #fca72d solid;margin:20px;float:left;/*background:url(../images/default-photo.jpg)  no-repeat center center;*/background-size:100% 100%;-moz-background-size:100% 100%; overflow:hidden;}
117 118

118 119
.synopsis{ float:left; padding:20px 0;color:#000; width:720px;}
119 120
.named{display:block;font:24px/34px \5FAE\8F6F\96C5\9ED1,"Microsoft YaHei"; color:#000; float:left;}

+ 15 - 2
src/main/webapp/index.html

@ -14,11 +14,23 @@
14 14
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
15 15
<script type="text/javascript" src="js/index.js"></script>
16 16
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
17
<script type="text/javascript" src="/js/common.js"></script>
17
<script type="text/javascript" src="js/common.js"></script>
18 18
<script type="text/javascript">
19 19
	$(function(){  
20 20
		loginStatus();
21

21
		var servPath = "http://121.42.53.174:81";
22
		//var userid = $.cookie("userid");
23
	 	if(userid && userid != "null" && userid!=null){
24
			$(".head-portrait").show();
25
			$(".unlogin").hide();
26
	 		$(".portrait-p").attr("src",servPath+"/images/head/"+userid+"_m.jpg");
27
			$(".portrait-p").load(function(){									
28
			})
29
			.error(function(){
30
				$(".portrait-p").attr("src",servPath+"/images/default-photo.jpg");
31
			});
32
		}
33
		
22 34
	   $("#search").on("click",function (){
23 35
	   		var searchContent = $("#searchContent").val();
24 36
	   		location.href = "search.html?searchContent="+encodeURI(searchContent);
@ -52,6 +64,7 @@
52 64
        <a href="login-invite-code.html"><div class="unlogin">特邀专家登录</div></a>
53 65
        <!--已登录-->
54 66
        <div class="head-portrait">
67
        	<img class="portrait-p" />
55 68
            <div class="personal-infor">
56 69
                <div class="triangleB"></div>
57 70
                <div class="personal-box">

+ 28 - 5
src/main/webapp/information-brow.html

@ -32,7 +32,12 @@
32 32
	 	var userid = $.cookie("userid");
33 33
	 	var professorId = GetQueryString("professorId");
34 34
	 	if(professorId){
35
	 		$(".head-portrait").css("background","url("+servPath+"/images/head/"+userid+"_m.jpg");
35
	 		$(".portrait-p").attr("src",servPath+"/images/head/"+userid+"_m.jpg");
36
			$(".portrait-p").load(function(){									
37
			})
38
			.error(function(){
39
				$(".portrait-p").attr("src",servPath+"/images/default-photo.jpg");
40
			});
36 41
         
37 42
	 		var subjectShow = function (data){
38 43

@ -200,19 +205,26 @@
200 205
						}
201 206
						var isAgree = $.inArray(userid, $photos);
202 207

203
						var showDiv= "<div class='listbox listbox-browse clear'><div class='list-browse'><span class='like'>"+$data.count+"</span>"+$data.caption+"</div><span  class='plus' data-pid='"+$data.professorId+"' data-caption='"+$data.caption+"' data-isagree='"+isAgree+"'></span><div class='like-num'>";
208
						var showDiv= "<div class='listbox listbox-browse clear'><div class='list-browse'><span class='like'>"+$data.count+"</span>"+$data.caption+"</div><span class='plus' data-pid='"+$data.professorId+"' data-caption='"+$data.caption+"' data-isagree='"+isAgree+"'></span><div class='like-num'>";
204 209
						if($photos.length>10){
205 210
							showDiv += "<div class='triangleR'></div>";
206 211
						}
207 212
						
208 213
						if($photos.length>0){
209 214
							for(var j =0 ; j< $photos.length;++j){
210
								showDiv += "<span class='like-people'><img src='"+servPath+"/images/head/"+$photos[j]+"_s.jpg'></span>";
215
								showDiv += "<span class='like-people'><img class='like-h' src='"+servPath+"/images/head/"+$photos[j]+"_s.jpg'></span>";
216
								
211 217
							} 
212 218
						}
213 219
						showDiv += "</div></div>";
214 220
						$("#researchAreaShow").append(showDiv);
215
				
221
						
222
						$(".like-h").load(function(){								
223
						})
224
						.error(function(){
225
							$(this).attr("src",servPath+"/images/default-photo.jpg");
226
						});	
227
							
216 228
					}
217 229
				}			
218 230
			}
@ -258,7 +270,17 @@
258 270
							$("#titleS").text($info.title);
259 271
							$("#orgNameS").text($info.orgName);
260 272
							$("#headImage").attr("src",servPath+"/images/head/"+professorId+"_l.jpg");
261
							$("#orgImage").attr("src","/images/org/"+$info.orgId+".jpg");
273
								$("#headImage").load(function(){									
274
								})
275
								.error(function(){
276
									$("#headImage").attr("src",servPath+"/images/default-photo.jpg");
277
								});
278
							$("#orgImage").attr("src",servPath+"/images/org/"+$info.orgId+".jpg");
279
								$("#orgImage").load(function(){									
280
								})
281
								.error(function(){
282
									$("#orgImage").attr("src",servPath+"/images/default-icon.jpg");
283
								});
262 284
							$("#descpS").text($info.descp);
263 285
							//显示专家信息到保存数据
264 286
							$("#name").val($info.name);
@ -333,6 +355,7 @@
333 355
	<a href="login-invite-code.html"><div class="unlogin">特邀专家登录</div></a>
334 356
	<!--已登录-->
335 357
	<div class="head-portrait">
358
    	<img class="portrait-p" />
336 359
		<div class="personal-infor">
337 360
			<div class="triangleB"></div>
338 361
			<div class="personal-box">

+ 20 - 2
src/main/webapp/information.html

@ -33,8 +33,16 @@
33 33
		var servPath = "http://121.42.53.174:81";
34 34
	 	var userid = $.cookie("userid");
35 35
	 	if(userid){
36
	 		$(".head-portrait").css("background","url("+servPath+"/images/head/"+userid+"_m.jpg)");
37
	 		$(".head-portrait").show();
36
	 		
37
			$(".head-portrait").show();
38
			$(".unlogin").hide();
39
	 		$(".portrait-p").attr("src",servPath+"/images/head/"+userid+"_m.jpg");
40
			$(".portrait-p").load(function(){									
41
			})
42
			.error(function(){
43
				$(".portrait-p").attr("src",servPath+"/images/default-photo.jpg");
44
			});
45
			
38 46
	 		var subjectShow = function (data){
39 47

40 48
				if(data != undefined &&  data.length != 0 ){
@ -210,7 +218,17 @@
210 218
							$("#titleS").text($info.title);
211 219
							$("#orgNameS").text($info.orgName);
212 220
							$("#headImage").attr("src",servPath+"/images/head/"+userid+"_l.jpg");
221
								$("#headImage").load(function(){									
222
								})
223
								.error(function(){
224
									$("#headImage").attr("src",servPath+"/images/default-photo.jpg");
225
								});
213 226
							$("#orgImage").attr("src",servPath+"/images/org/"+$info.orgId+".jpg");
227
								$("#orgImage").load(function(){									
228
								})
229
								.error(function(){
230
									$("#orgImage").attr("src",servPath+"/images/default-icon.jpg");
231
								});
214 232
							$("#descpS").text($info.descp);
215 233
							//显示专家信息到保存数据
216 234
							$("#name").val($info.name);

+ 21 - 15
src/main/webapp/search.html

@ -36,9 +36,14 @@ $.get("/ajax/org/qa",function($da) {
36 36
		var servPath = "http://121.42.53.174:81";
37 37
		var userid = $.cookie("userid");
38 38
	 	if(userid){
39
	 		$(".head-portrait").css("background","url("+servPath+"/images/head/"+userid+"_m.jpg)");
40
	 		$(".head-portrait").show();
39
			$(".head-portrait").show();
41 40
			$(".unlogin").hide();
41
	 		$(".portrait-p").attr("src",servPath+"/images/head/"+userid+"_m.jpg");
42
			$(".portrait-p").load(function(){									
43
			})
44
			.error(function(){
45
				$(".portrait-p").attr("src",servPath+"/images/default-photo.jpg");
46
			});
42 47
		}
43 48

44 49
		$("#searchContent").val(GetQueryString("searchContent")); 
@ -53,21 +58,12 @@ $.get("/ajax/org/qa",function($da) {
53 58
						"success" : function($data) {
54 59
							if ($data.success) {
55 60
								for(var i = 0 ; i < $data.data.data.length ; i++){
56
									   
61
									//创建HTML标签  
57 62
									var dataHtml = "<div class='item'>";
58 63
									
59
									dataHtml += "<a  id='infoi'  href='information-brow.html?professorId="+$data.data.data[i].id+"' ><div class='photo1'><img class='images' style='width:100%;'  src='images/head/"+$data.data.data[i].id+"_l.jpg'/></div></a>";
60
								
61
									$(".images").eq(i).load(function(){
62
										
63
										})
64
									.error(function(){
65
										
66
										$(this).attr("src","images/default-photo.jpg");
67
									  });
68
									
69
									
70
									
64
									dataHtml += "<a  id='infoi'  href='information-brow.html?professorId="+$data.data.data[i].id+"' ><div class='photo1'><img class='images' style='width:100%;'  src='"+servPath+"/images/head/"+$data.data.data[i].id+"_l.jpg'/></div></a>";
65

66

71 67
									dataHtml += "<div class='synopsis'>";
72 68
									dataHtml += "<a href='information-brow.html?professorId="+$data.data.data[i].id+"' class='named'>";
73 69
									if(typeof($data.data.data[i].name) !== "undefined"){
@ -108,6 +104,15 @@ $.get("/ajax/org/qa",function($da) {
108 104

109 105
									$("#professorList").append(dataHtml);
110 106
									
107
									
108
									//获取头像		
109
									$(".images").load(function(){								
110
									})
111
									.error(function(){
112
										$(this).attr("src",servPath+"/images/default-photo.jpg");
113
									});	
114
									
115
									//点击查看当前信息
111 116
									(function(i){
112 117
										$('.photo1').click(function()
113 118
									{
@ -201,6 +206,7 @@ $.get("/ajax/org/qa",function($da) {
201 206
	<a href="login-invite-code.html"><div class="unlogin">特邀专家登录</div></a>
202 207
	<!--已登录-->
203 208
	<div class="head-portrait">
209
    	<img class="portrait-p" />
204 210
		<div class="personal-infor">
205 211
			<div class="triangleB"></div>
206 212
			<div class="personal-box">