Browse Source

资源详情页面及搜索资源专家标志

jack 8 years ago
parent
commit
e7527536d3
3 changed files with 117 additions and 104 deletions
  1. 7 7
      app/html/resinforbrow.html
  2. 102 88
      app/js/resinforbrow.js
  3. 8 9
      app/js/searchhome.js

+ 7 - 7
app/html/resinforbrow.html

106
					</li>
106
					</li>
107
				</ul>
107
				</ul>
108
			</div>
108
			</div>
109
			<div class="mui-input-group mainbox resouinfoword marginbox " id="detaildiv">
109
			<div class="mui-input-group mainbox resouinfoword marginbox " id="hezuodiv">
110
				<ul class="resouinfobox">
110
				<ul class="resouinfobox">
111
					<li>
111
					<li>
112
						<div class="infocontit">详细描述</div>
112
						<div class="infocontit">合作备注</div>
113
						<div class="infocon">
113
						<div class="infocon">
114
							<p class="listtit3 mutlinebox" id="detail"></p>
114
							<p class="listtit3 mutlinebox" id="hezuo"></p>
115
						</div>
115
						</div>
116
					</li>
116
					</li>
117
				</ul>
117
				</ul>
118
			</div>
118
			</div>
119
			<div class="mui-input-group mainbox resouinfoword marginbox " id="hezuodiv">
119
			<div class="mui-input-group mainbox resouinfoword marginbox " id="detaildiv">
120
				<ul class="resouinfobox">
120
				<ul class="resouinfobox">
121
					<li>
121
					<li>
122
						<div class="infocontit">合作备注</div>
122
						<div class="infocontit">详细描述</div>
123
						<div class="infocon">
123
						<div class="infocon">
124
							<p class="listtit3 mutlinebox" id="hezuo"></p>
124
							<p class="listtit3 mutlinebox" id="detail"></p>
125
						</div>
125
						</div>
126
					</li>
126
					</li>
127
				</ul>
127
				</ul>
128
			</div>
128
			</div>
129
129
		
130
		</div>
130
		</div>
131
131
132
		<script src="../js/public/mui.min.js"></script>
132
		<script src="../js/public/mui.min.js"></script>

+ 102 - 88
app/js/resinforbrow.js

46
					//资源名称
46
					//资源名称
47
					professorId = mydata['professor']['id'];
47
					professorId = mydata['professor']['id'];
48
					var userid = plus.storage.getItem('userid');
48
					var userid = plus.storage.getItem('userid');
49
					if(professorId==userid){
50
						document.getElementsByClassName("footbox")[0].style.display="none";
49
					if(professorId == userid) {
50
						document.getElementsByClassName("footbox")[0].style.display = "none";
51
					}
51
					}
52
					resourceName=mydata['resourceName'];
52
					resourceName = mydata['resourceName'];
53
					(mydata['resourceName']) ? oresorcename.innerHTML = mydata['resourceName']: oresorcename.innerHTML = '';
53
					(mydata['resourceName']) ? oresorcename.innerHTML = mydata['resourceName']: oresorcename.innerHTML = '';
54
					(mydata['resourceName']) ? oresourceName.innerHTML = mydata['resourceName']: oresourceName.innerHTML = '';
54
					(mydata['resourceName']) ? oresourceName.innerHTML = mydata['resourceName']: oresourceName.innerHTML = '';
55
55
77
					if(mydata['professor']["authType"]) {
77
					if(mydata['professor']["authType"]) {
78
						opromodify.classList.add('icon-vip');
78
						opromodify.classList.add('icon-vip');
79
						opromodify.classList.add('authicon-cu');
79
						opromodify.classList.add('authicon-cu');
80
						opromodify.style.float = "left";
80
					} else {
81
					} else {
81
						if(mydata['professor']["authStatus"]) {
82
						if(mydata['professor']["authStatus"]) {
82
							if(mydata['professor']["authentication"]  == 1) {
83
							if(mydata['professor']["authentication"] == 1) {
83
								opromodify.classList.add('icon-renzheng');
84
								opromodify.classList.add('icon-renzheng');
84
								opromodify.classList.add('authicon-mana');
85
								opromodify.classList.add('authicon-mana');
85
							} else if(mydata['professor']["authentication"]  == 2) {
86
								opromodify.style.position = "static";
87
								opromodify.style.margin = "3px 0 0 0";
88
							} else if(mydata['professor']["authentication"] == 2) {
86
								opromodify.classList.add('icon-renzheng');
89
								opromodify.classList.add('icon-renzheng');
87
								opromodify.classList.add('authicon-staff');
90
								opromodify.classList.add('authicon-staff');
91
								opromodify.style.position = "static";
92
								opromodify.style.margin = "3px 0 0 0";
88
							} else {
93
							} else {
89
								opromodify.classList.add('icon-renzheng');
94
								opromodify.classList.add('icon-renzheng');
90
								opromodify.classList.add('authicon-stu');
95
								opromodify.classList.add('authicon-stu');
96
								opromodify.style.position = "static";
97
								opromodify.style.margin = "3px 0 0 0";
91
							}
98
							}
92
						}
99
						}
93
					}
100
					}
101
94
					/*专家头像*/
102
					/*专家头像*/
95
					(mydata['professor']["hasHeadImage"] == 0) ? oproimg.setAttribute('src', '../images/default-photo.jpg'): oproimg.setAttribute('src', baseUrl + '/images/head/' + mydata['professor']['id'] + '_m.jpg');
103
					(mydata['professor']["hasHeadImage"] == 0) ? oproimg.setAttribute('src', '../images/default-photo.jpg'): oproimg.setAttribute('src', baseUrl + '/images/head/' + mydata['professor']['id'] + '_m.jpg');
96
104
111
						if(mydata['subject'].indexOf(',') != -1) { //字符串是否包含,
119
						if(mydata['subject'].indexOf(',') != -1) { //字符串是否包含,
112
							var fieldlist = mydata['subject'].split(",");
120
							var fieldlist = mydata['subject'].split(",");
113
							console.log(fieldlist.length);
121
							console.log(fieldlist.length);
114
							for(var i = 0; i < fieldlist; i++) {
122
							for(var i = 0; i < fieldlist.length; i++) {
115
								var oli = document.createElement('li');
123
								var oli = document.createElement('li');
116
								oli.innerText = fieldlist[i];
124
								oli.innerText = fieldlist[i];
117
								ofield.appendChild(oli);
125
								ofield.appendChild(oli);
131
						if(mydata['industry'].indexOf(',') != -1) { //字符串是否包含,
139
						if(mydata['industry'].indexOf(',') != -1) { //字符串是否包含,
132
							var applylist = mydata['industry'].split(",");
140
							var applylist = mydata['industry'].split(",");
133
							console.log(applylist.length);
141
							console.log(applylist.length);
134
							for(var i = 0; i < applylist; i++) {
142
							for(var i = 0; i < applylist.length; i++) {
135
								var oli = document.createElement('li');
143
								var oli = document.createElement('li');
136
								oli.innerText = fieldlist[i];
144
								oli.innerText = fieldlist[i];
137
								oapply.appendChild(oli);
145
								oapply.appendChild(oli);
147
155
148
					//详细描述
156
					//详细描述
149
					if(mydata['descp']) {
157
					if(mydata['descp']) {
150
						odetail.innerHTML = mydata['descp']
158
						odetail.innerHTML = mydata['descp'];
159
						var oImg = document.getElementById("detail").getElementsByTagName("img");
160
						for(var i = 0; i < oImg.length; i++) {
161
							(function(n) {
162
								var att = oImg[n].src.substr(7);
163
								oImg[n].setAttribute("src", baseUrl + att);
164
							})(i);
165
						}
151
					} else {
166
					} else {
152
						odetaildiv.style.display = 'none';
167
						odetaildiv.style.display = 'none';
153
					}
168
					}
181
		judge()
196
		judge()
182
	})
197
	})
183
	var judge = function() {
198
	var judge = function() {
184
		mui.ajax(baseUrl + "/ajax/professor/editBaseInfo/" + professorId, {
185
			dataType: 'json', //数据格式类型
186
			type: 'GET', //http请求类型
187
			timeout: 10000, //超时设置
188
			async: false,
189
			success: function(data) {
199
			mui.ajax(baseUrl + "/ajax/professor/editBaseInfo/" + professorId, {
200
				dataType: 'json', //数据格式类型
201
				type: 'GET', //http请求类型
202
				timeout: 10000, //超时设置
203
				async: false,
204
				success: function(data) {
205
206
					var $info = data.data || {}
207
208
					if(data.success && data.data) {
209
						if($info.authentication == 1) {
210
							mui.openWindow({
211
								url: '../html/proinforbrow.html',
212
								id: 'html/proinforbrow.html',
213
								show: {
214
									autoShow: false,
215
									aniShow: "slide-in-left"
216
								},
217
								extras: {
218
									proid: professorId
219
								},
220
							});
221
						} else if($info.authentication == 2) {
222
							mui.openWindow({
223
								url: '../html/companybrowse.html',
224
								id: 'html/companybrowse.html',
225
								show: {
226
									autoShow: false,
227
									aniShow: "slide-in-left"
228
								},
229
								extras: {
230
									proid: professorId
231
								},
232
							});
233
						} else if($info.authentication == 3) {
234
							mui.openWindow({
235
								url: '../html/studentbrowse.html',
236
								id: 'html/studentbrowse.html',
237
								show: {
238
									autoShow: false,
239
									aniShow: "slide-in-left"
240
								},
241
								extras: {
242
									proid: professorId
243
								},
244
							});
245
						}
190
246
191
				var $info = data.data || {}
192
193
				if(data.success && data.data) {
194
					if($info.authentication == 1) {
195
						mui.openWindow({
196
							url: '../html/proinforbrow.html',
197
							id: 'html/proinforbrow.html',
198
							show: {
199
								autoShow: false,
200
								aniShow: "slide-in-left"
201
							},
202
							extras: {
203
								proid: professorId
204
							},
205
						});
206
					} else if($info.authentication == 2) {
207
						mui.openWindow({
208
							url: '../html/companybrowse.html',
209
							id: 'html/companybrowse.html',
210
							show: {
211
								autoShow: false,
212
								aniShow: "slide-in-left"
213
							},
214
							extras: {
215
								proid: professorId
216
							},
217
						});
218
					} else if($info.authentication == 3) {
219
						mui.openWindow({
220
							url: '../html/studentbrowse.html',
221
							id: 'html/studentbrowse.html',
222
							show: {
223
								autoShow: false,
224
								aniShow: "slide-in-left"
225
							},
226
							extras: {
227
								proid: professorId
228
							},
229
						});
230
					}
247
					}
231
248
				},
249
				error: function() {
250
					plus.nativeUI.toast("服务器链接超时", toastStyle);
251
					return;
232
				}
252
				}
233
			},
234
			error: function() {
235
				plus.nativeUI.toast("服务器链接超时", toastStyle);
236
				return;
237
			}
238
		});
239
	}
240
	//console.log("资源id==" + resourceId);
241
	//资源信息
253
			});
254
		}
255
		//console.log("资源id==" + resourceId);
256
		//资源信息
242
	ziyuaninfo(resourceId);
257
	ziyuaninfo(resourceId);
243
	/*点击咨询*/
258
	/*点击咨询*/
244
	//判断是否登录,登录才可咨询,否则登录
259
	//判断是否登录,登录才可咨询,否则登录
245
	function isLogin(){
260
	function isLogin() {
246
		var userid = plus.storage.getItem('userid');
261
		var userid = plus.storage.getItem('userid');
247
	
248
		if(userid && userid != null && userid != 'null' && userid != undefined && userid != 'undefined'){
249
			
262
263
		if(userid && userid != null && userid != 'null' && userid != undefined && userid != 'undefined') {
264
250
			var flag = 'ziyuan';
265
			var flag = 'ziyuan';
251
			var consulttitle = oresorcename.innerHTML;
266
			var consulttitle = oresorcename.innerHTML;
252
			var nwaiting = plus.nativeUI.showWaiting(); //显示原生等待框
267
			var nwaiting = plus.nativeUI.showWaiting(); //显示原生等待框
259
			webviewShow.addEventListener("loaded", function() {
274
			webviewShow.addEventListener("loaded", function() {
260
275
261
			}, false);
276
			}, false);
262
			
263
		}else {
277
278
		} else {
264
			mui.openWindow({
279
			mui.openWindow({
265
			    url:'../html/login.html',
266
			    id:'login.html'
280
				url: '../html/login.html',
281
				id: 'login.html'
267
			})
282
			})
268
				
283
269
		}
284
		}
270
	};
285
	};
271
	oconsult.addEventListener('tap', function() {
286
	oconsult.addEventListener('tap', function() {
272
		isLogin();
287
		isLogin();
273
	});
288
	});
274
	
275
 
289
276
	/*咨询成功,返回资源信息*/
290
	/*咨询成功,返回资源信息*/
277
	window.addEventListener('backziyuaninfo', function(event) {
291
	window.addEventListener('backziyuaninfo', function(event) {
278
292
285
		if(userid && userid != null && userid != "null") {
299
		if(userid && userid != null && userid != "null") {
286
			collectionExpert($this);
300
			collectionExpert($this);
287
		} else {
301
		} else {
288
//			plus.nativeUI.toast("请先登录");
302
			//			plus.nativeUI.toast("请先登录");
289
			isLogin();
303
			isLogin();
290
		}
304
		}
291
	});
305
	});
377
		});
391
		});
378
392
379
	}
393
	}
380
	
394
381
	/*微信及微信朋友圈分享专家*/
395
	/*微信及微信朋友圈分享专家*/
382
	var auths, shares;
396
	var auths, shares;
383
	document.getElementById("shareBtn").addEventListener("tap", function() {
397
	document.getElementById("shareBtn").addEventListener("tap", function() {
423
					x: 'WXSceneTimeline'
437
					x: 'WXSceneTimeline'
424
				}));
438
				}));
425
		}
439
		}
426
		
440
427
		//// 弹出分享列表
441
		//// 弹出分享列表
428
		shareBts.length > 0 ? plus.nativeUI.actionSheet({
442
		shareBts.length > 0 ? plus.nativeUI.actionSheet({
429
			title: '分享',
443
			title: '分享',
431
			buttons: shareBts
445
			buttons: shareBts
432
		}, function(e) {
446
		}, function(e) {
433
			var str;
447
			var str;
434
			if(supportedServices) {
435
				str = "应用用途:" + supportedServices
448
			if(supportedServices) {
449
				str = "应用用途:" + supportedServices
436
			}
450
			}
437
			if(e.index == 1) {
451
			if(e.index == 1) {
438
				var share = buildShareService();
452
				var share = buildShareService();
439
				if(share) {
453
				if(share) {
440
					shareMessage(share, "WXSceneSession", {
454
					shareMessage(share, "WXSceneSession", {
441
						content: str,
455
						content: str,
442
						title: "【科袖资源】" + resourceName + "" ,
443
						href: baseUrl+"/shareResinfor.html?resourceId=" + resourceId,
444
						thumbs: [baseUrl+"/images/resource/" + resourceId + ".jpg"]
456
						title: "【科袖资源】" + resourceName + "",
457
						href: baseUrl + "/shareResinfor.html?resourceId=" + resourceId,
458
						thumbs: [baseUrl + "/images/resource/" + resourceId + ".jpg"]
445
					});
459
					});
446
				}
460
				}
447
			} else if(e.index == 2) {
461
			} else if(e.index == 2) {
449
				if(share) {
463
				if(share) {
450
					shareMessage(share, "WXSceneTimeline", {
464
					shareMessage(share, "WXSceneTimeline", {
451
						content: str,
465
						content: str,
452
						title: "【科袖资源】" + resourceName + " " ,
453
						href: baseUrl+"/shareResinfor.html?resourceId=" + resourceId,
454
						thumbs: [baseUrl+"/images/resource/" + resourceId + ".jpg"]
466
						title: "【科袖资源】" + resourceName + " ",
467
						href: baseUrl + "/shareResinfor.html?resourceId=" + resourceId,
468
						thumbs: [baseUrl + "/images/resource/" + resourceId + ".jpg"]
455
					});
469
					});
456
				}
470
				}
457
			}
471
			}
481
		}
495
		}
482
496
483
	}
497
	}
484
	
498
485
	function shareMessage(share, ex, msg) {
499
	function shareMessage(share, ex, msg) {
486
		msg.extra = {
500
		msg.extra = {
487
			scene: ex
501
			scene: ex
502
			}
516
			}
503
		});
517
		});
504
	}
518
	}
505
	
506
/*图像预览*/
519
520
	/*图像预览*/
507
	mui.previewImage();
521
	mui.previewImage();
508
});
522
});

+ 8 - 9
app/js/searchhome.js

487
		}
487
		}
488

488

489
		/*判断用户是否认证*/
489
		/*判断用户是否认证*/
490
		var icon = '';
491
		if(item.authType) {
490
		var icon = '';		
491
		if(item.professor.authType) {			
492
			icon='<em class="mui-icon iconfont icon-vip authicon-cu"> </em>';
492
			icon='<em class="mui-icon iconfont icon-vip authicon-cu"> </em>';
493
		} else {
493
		} else {
494
			if(item.authStatus) {
495
				if(item.authentication == 1) {
496
					icon='<em class="mui-icon iconfont icon-renzheng authicon-mana"><span>科研</span></em>';
497
				} else if(item.authentication == 2) {
498
					icon='<em class="mui-icon iconfont icon-renzheng authicon-staff"><span>企业</span></em>';
494
			if(item.professor.authStatus) {
495
				if(item.professor.authentication == 1) {					
496
					icon='<em class="mui-icon iconfont "></em>';
497
				} else if(item.professor.authentication == 2) {					
498
					icon='<em class="mui-icon iconfont icon-renzheng authicon-staff"></em>';
499
				} else {
499
				} else {
500
					icon='<em class="mui-icon iconfont icon-renzheng authicon-stu"><span>学生</span></em>';
500
					icon='<em class="mui-icon iconfont icon-renzheng authicon-stu"></em>';
501
				}
501
				}
502
			}
502
			}
503
		}
503
		}
519
		if(address != "") {
519
		if(address != "") {
520
			address = " | " + address;
520
			address = " | " + address;
521
		}
521
		}
522

523
		var li = document.createElement('li');
522
		var li = document.createElement('li');
524
		li.className = 'mui-table-view-cell mui-media';
523
		li.className = 'mui-table-view-cell mui-media';
525

524