Browse Source

资源详情页面

jack 8 years ago
parent
commit
d8dfa839bb
2 changed files with 196 additions and 90 deletions
  1. 180 60
      js/resourceInfo.js
  2. 16 30
      resourceInfo.html

+ 180 - 60
js/resourceInfo.js

@ -1,6 +1,8 @@
1 1
$(document).ready(function() {
2 2
	/*获取资源ID*/
3 3
	var resourceId = GetQueryString("resourceId");
4
	var professorId;
5
	var userid = $.cookie("userid");
4 6
	/*判断是否登录*/
5 7
	loginStatus();
6 8
	//填充学术领域
@ -38,76 +40,194 @@ $(document).ready(function() {
38 40
		}
39 41
		/*获取资源的数据的函数*/
40 42
	var resourceData = function() {
41
		$.ajax({
42
			"url": "/ajax/resource/resourceInfo",
43
			data: {
44
				'resourceId': resourceId
45
			},
46
			"type": "get",
47
			"async": true,
48
			"success": function(info) {
49
				if(info.success) {
50
					var $info = info.data;
51
					console.log(info);
52
					$(".h2Font").text($info.resourceName);
53
					$("#application").text($info.supportedServices);
54
					if($info.subject) {
55
						subjectShow($info.subject)
56
					}else{
57
						$("span:contains('学术领域')").hide();
58
					}
59
					if($info.industry) {
60
						industryShow($info.industry)
61
					}else{
62
						$("span:contains('应用行业')").hide();
63
					}
64
					if($info.cooperationNotes) {
65
						$("#cooperationNote").text($info.cooperationNotes);
66
					}else{
67
						$("span:contains('合作备注')").hide();
68
					}
69
					if(!$info.subject&&!$info.industry&&!$info.cooperationNotes){
70
						$(".resAbout").hide();
71
					}
72
					if($info.images) {
73
						$("#resouImg").attr("src", "/images/resource/" + $info.resourceId + ".jpg")
74
					}
75
					if($info.descp) {
76
						$(".resMore").html($info.descp)
77
					}
78
					$("#nameS").text($info.professor.name);
79
					if($info.professor.title) {
80
						if($info.professor.office) {
81
							$("#title").text($info.professor.title + ",");
43
			$.ajax({
44
				"url": "/ajax/resource/resourceInfo",
45
				data: {
46
					'resourceId': resourceId
47
				},
48
				"type": "get",
49
				"async": true,
50
				"success": function(info) {
51
					if(info.success) {
52
						var $info = info.data;
53
						if($info.professor.authType) {
54
							$("#authFlag").addClass("authicon authicon-cu");
82 55
						} else {
83
							$("#title").text($info.professor.title);
56
							if($info.professor.authStatus) {
57
								if($info.professor.authentication == 1) {
58
									$("#authFlag").addClass("authicon2 authicon-mana");
59
								} else if($info.professor.authentication == 2) {
60
									$("#authFlag").addClass("authicon2 authicon-staff");
61
								} else {
62
									$("#authFlag").addClass("authicon2 authicon-stu");
63
								}
64
							}
84 65
						}
85
					}
86
					if($info.professor.office) {
66
						$(".h2Font").text($info.resourceName);
67
						$("#application").text($info.supportedServices);
68
						professorId = $info.professorId;
69
						if($info.subject) {
70
							subjectShow($info.subject)
71
						} else {
72
							$("span:contains('学术领域')").hide();
73
						}
74
						if($info.industry) {
75
							industryShow($info.industry)
76
						} else {
77
							$("span:contains('应用行业')").hide();
78
						}
79
						if($info.cooperationNotes) {
80
							$("#cooperationNote").text($info.cooperationNotes);
81
						} else {
82
							$("span:contains('合作备注')").hide();
83
						}
84
						if(!$info.subject && !$info.industry && !$info.cooperationNotes) {
85
							$(".resAbout").hide();
86
						}
87
						if($info.images.length) {
88
							$("#resouImg").attr("src", "/images/resource/" + $info.resourceId + ".jpg")
89
						}
90
						if($info.descp) {
91
							$(".resMore").html($info.descp);
92
							var pWidth = $(".resMore").find("p").width();
93
							var leng = $(".resMore").find("img").length;
94
							for(var i = 0; i < leng; i++) {
95
								(function(i) {
96
									$(".resMore").find("img").eq(i).load(function() {
97
										var imgWidth = $(".resMore").find("img").eq(i).width();
98
										if(imgWidth > pWidth) {
99
											$(".resMore").find("img").eq(i).css({
100
												"width": "100%"
101
											})
102
										}
103
									})
104
								})(i)
87 105

88
						$("#office").text($info.professor.office);
89
					}
90
					if($info.professor.department) {
91
						$("#department").text($info.professor.department);
92
					}
93
					if($info.professor.orgName) {
94
						$("#orgName").text($info.professor.orgName);
95
					}
96
					if($info.professor.address) {
97
						$("#address").text($info.professor.address);
106
							}
107
						}
108
						$("#nameS").text($info.professor.name);
109
						if($info.professor.title) {
110
							if($info.professor.office) {
111
								$("#title").text($info.professor.title + ",");
112
							} else {
113
								$("#title").text($info.professor.title);
114
							}
115
						}
116
						if($info.professor.office) {
117

118
							$("#office").text($info.professor.office);
119
						}
120
						if($info.professor.department) {
121
							$("#department").text($info.professor.department);
122
						}
123
						if($info.professor.orgName) {
124
							$("#orgName").text($info.professor.orgName);
125
						}
126
						if($info.professor.address) {
127
							$("#address").text($info.professor.address);
128
						}
129
						if($info.professor.hasHeadImage) {
130
							$("#headImg").attr("src", "/images/head/" + $info.professorId + "_l.jpg")
131
						}
132
						//专家相关资源
133
						relevantResource($info.professorId,$info.resourceId)
134
					} else {
135
						$.MsgBox.Alert('消息提醒', info.msg);
98 136
					}
99
					if($info.professor.hasHeadImage) {
100
						$("#headImg").attr("src", "/images/head/" + $info.professorId + "_l.jpg")
137
				},
138
				"error": function() {
139
					$.MsgBox.Alert('message', 'failed')
140
				}
141
			});
142
		}
143
		/*资源信息*/
144
	resourceData();
145
	/*点击专家头像进入专家页面*/
146
	$("#headImg").on("click", function() {
147
		location.href = "information-brow.html?professorId=" + professorId;
148
	});
149
	/*点击咨询*/
150
	$("#consultin").on("click", function() {
151
		clickResouceConsultHandler();
152
	});
153
	/*咨询函数*/
154
	function clickResouceConsultHandler() {
155
		if(userid) {
156
			ConsultApply();
157
			concultProInfo(professorId); //专家信息common.js中
158
			//默认选中资源咨询和标题
159
			for(var i = 0; i < $("ul.menucon").children().length; i++) {
160
				$("ul.menucon").children().eq(i).removeClass("clicknow");
161
				$("ul.menucon").children().eq(1).addClass("clicknow");
162
			}
163
			var consultTitleVal = $(".h2Font").text();
164
			$("#consultTitle").val("关于" + consultTitleVal + "的咨询");
165
			//点击的发送
166
			$("#sendConsultBtn").click(function() {
167
				sendConsultHandler(professorId); //common.js中
168
			});
169
		} else {
170

171
			$.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
172
			$("#mb_btn_ok").val("去登录");
173
			var aele = document.createElement('a');
174
			$("#mb_btnbox").append(aele);
175
			$("#mb_btnbox a").css({
176
				'display': "block",
177
				'width': '100%',
178
				'height': '40px',
179
				'position': 'absolute',
180
				'bottom': '-6px',
181
				'left': '0'
182
			});
183
			aele.setAttribute('href', '../login.html');
184
		}
185

186
	};
187
	/*专家相关资源*/
188
	var relevantResource = function(id, reid) {
189
		$.ajax({
190
			"url": "/ajax/resource/qapro",
191
			"type": "get",
192
			"data": {
193
				"professorId": id
194
			},
195
			"async": true,
196
			"success": function(data) {
197
				if(data.success) {
198
					var $info = data.data;
199
					var reId = reid;
200
					var j = 0;
201
					for(var i = 0; i < $info.length; i++) {
202
						if($info[i].resourceId != reId) {							
203
							var string = ""
204
							string += '<li>'
205
							string += '<a class="resoumag" href="resourceInfo.html?resourceId='+$info[i].resourceId+'">'
206
							string += '<div class="ResImgBox beforMargin resourceImgBox">'
207
							if($info[i].images.length) {
208
								string += '<img class="resImg headRadius resourceImg" src="/images/resource/' + $info[i].resourceId + '.jpg" />'
209
							} else {
210
								string += '<img class="resImg headRadius resourceImg" src="images/default-resource.jpg" />'
211
							}
212
							string += '</div>'
213
							string += '<h2>' + $info[i].resourceName + '</h2>'
214
							string += '</a>'
215
							string += '</li>'
216
							j++;
217
							if(j==4){
218
								return;
219
							}
220
							$(".otherRes").append(string);
221
						}
101 222
					}
102 223
				} else {
103
					$.MsgBox.Alert('消息提醒', "系统异常!");
224
					$.MsgBox.Alert("消息", data.msg);
104 225
				}
105 226
			},
106 227
			"error": function() {
107
				$.MsgBox.Alert('message', 'failed')
228
				$.MsgBox.Alert('message', 'fail')
108 229
			}
109 230
		});
110 231
	}
111
	resourceData();
112
	
232

113 233
})

+ 16 - 30
resourceInfo.html

@ -11,7 +11,14 @@
11 11
<link rel="stylesheet" type="text/css" href="css/style.css" />
12 12
<link type="text/css" href="css/index.css" rel="stylesheet">
13 13
<link type="text/css" href="css/common.css" rel="stylesheet">
14
14
<link type="text/css" href="css/popup.css" rel="stylesheet">
15
<style type="text/css">
16
	/*.resMore p img{width:100%;height:100%;}*/
17
	.resMore p{line-height:2;margin-top:15px;}
18
	.resMore{
19
		padding:0px 15px;
20
	}
21
</style>
15 22
</head>
16 23
17 24
<body>
@ -78,7 +85,7 @@
78 85
						</div>
79 86
					</div>
80 87
					<div class="coulstbtn" style="position:absolute;bottom:30px;">
81
						<span>咨询</span>
88
						<span  id="consultin">咨询</span>
82 89
					</div>
83 90
				</div>
84 91
			</div>
@ -93,12 +100,12 @@
93 100
			<div class="rightBlock">
94 101
				<a style="display: block;" >
95 102
					<div class="proImg">
96
						<img class=" headRadius" src="images/default-photo.jpg" id="headImg" style="display:block;">
103
						<img class=" headRadius" src="images/default-photo.jpg" id="headImg" style="display:block;cursor:pointer">
97 104
					</div>
98 105
					<div class="proInfo">
99 106
						<div class="h3Font clearfix">
100 107
							<span class="named" id="nameS"></span>
101
							<span class="modifyicon authicon authicon-cu" style="margin-top:3px;" ></span>
108
							<span class="modifyicon authicon authicon-cu" style="margin-top:3px;" id="authFlag"></span>
102 109
						</div>
103 110
						<p class="h5Font"><span id="title">职称</span><span id="office">,职位</span></p>
104 111
						<p class="h5Font"><span id="department">所属部门</span></p>
@ -110,30 +117,7 @@
110 117
			<div class="rightBlock">
111 118
				<div class="left-title" >相关资源</div>
112 119
				<ul class="otherRes">
113
					<li>
114
						<a class="resoumag" href="resourceInfo.html">
115
							<div class="ResImgBox beforMargin resourceImgBox">
116
								<img class="resImg headRadius resourceImg" src="images/default-resource.jpg" />
117
							</div>
118
							<h2>资源名称</h2>
119
						</a>
120
					</li>
121
					<li>
122
						<a class="resoumag" href="resourceInfo.html">
123
							<div class="ResImgBox beforMargin resourceImgBox">
124
								<img class="resImg headRadius resourceImg" src="images/default-resource.jpg" />
125
							</div>
126
							<h2>资源名称</h2>
127
						</a>
128
					</li>
129
					<li>
130
						<a class="resoumag" href="resourceInfo.html">
131
							<div class="ResImgBox beforMargin resourceImgBox">
132
								<img class="resImg headRadius resourceImg" src="images/default-resource.jpg" />
133
							</div>
134
							<h2>资源名称</h2>
135
						</a>
136
					</li>
120
					
137 121
				</ul>
138 122
				<!--<div style="text-align: center;margin: 10px;"><a href="" style="text-align: center;color: #FF9900;">查看更多</a></div>-->
139 123
			</div>
@ -154,7 +138,7 @@
154 138
            <a class="listlink codehover" href="javascript:void(0);" rel="nofollow">科袖APP
155 139
            	<div class="code app_code"></div> 
156 140
            </a><span> | </span>
157
            <span class="listlink">客服邮箱:<a style="color:#fff" target="_black" rel="nofollow" href=""> service@ekexiu.com</a></span>
141
            <span class="listlink">客服邮箱:<a style="color:#fff" rel="nofollow" href="mailto:service@ekexiu.com"> service@ekexiu.com</a></span>
158 142
            <span> | </span>
159 143
            <span class="listlink">客服热线: 010-62343359(9:00-17:00)</span>
160 144
        </div>
@ -184,13 +168,15 @@
184 168
			<div class="position"><span id="foot_protitle"></span><span></span ></div>				
185 169
			<div class="science"><span id="foot_prodepar"></span><span id="foot_proorgname"></span ><span class="address" id="foot_proaddress"></span></div>								
186 170
    	</div>
187
        <div class="coulstbtn floatR"><span>咨询</span></div>
171
        <div class="coulstbtn floatR"><span >咨询</span></div>
188 172
    </div>
189 173
</div>
190 174
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
191 175
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
192 176
<script type="text/javascript" src="js/jquery.similar.msgbox.js"></script>
177
<script type="text/javascript" src="js/index.js"></script>
193 178
<script type="text/javascript" src="/js/common.js"></script>
179
<script type="text/javascript" src="/js/popup.js"></script>
194 180
<script type="text/javascript" src="/js/resourceInfo.js"></script>
195 181
</body>
196 182
</html>