Browse Source

资源中添加关注企业

luyanan 7 years ago
parent
commit
0eddef4e62
3 changed files with 45 additions and 294 deletions
  1. 2 158
      js/resourcePreview.js
  2. 38 134
      js/resourceShow.js
  3. 5 2
      resourceShow.html

+ 2 - 158
js/resourcePreview.js

@ -188,165 +188,9 @@ $(document).ready(function() {
188 188
		}
189 189

190 190
	};
191
	//点击专家关注
192
$('.attenSpan').click(function(){
193
	if (userid && userid != "null" && userid != null) {
194
		if($(this).is('.attenSpanyes')){
195
			 cancelCollectionExpert(professorId,1)
196
		}else{
197
			collectionExpert(professorId,1);
198
		}	
199
	}else{
200
		$.MsgBox.Alert('提示',"请先登录再进行关注");
201
		$("#mb_btn_ok").val("去登录");
202
		var aele = document.createElement('a');
203
		$("#mb_btnbox").append(aele);
204
		$("#mb_btnbox a").css({
205
			'display': "block",
206
			'width': '100%',
207
			'height': '40px',
208
			'position': 'absolute',
209
			'bottom': '-6px',
210
			'left': '0'
211
		});
212
		aele.setAttribute('href', '../login.html');
213
	}
214
})
215

216
//点击资源收藏
217
$('#attention em').click(function(){
218
	if (userid && userid != "null" && userid != null) {
219
		if($(this).is('.icon-collected')){
220
			 cancelCollectionExpert(resourceId,2)
221
		}else{
222
			 collectionExpert(resourceId,2);
223
		}	
224
	}else{
225
		$.MsgBox.Alert('提示',"请先登录再进行收藏");
226
		$("#mb_btn_ok").val("去登录");
227
		var aele = document.createElement('a');
228
		$("#mb_btnbox").append(aele);
229
		$("#mb_btnbox a").css({
230
			'display': "block",
231
			'width': '100%',
232
			'height': '40px',
233
			'position': 'absolute',
234
			'bottom': '-6px',
235
			'left': '0'
236
		});
237
		aele.setAttribute('href', '../login.html');
238
	}
239
})
240

241
/*判断是非关注专家*/
242
function ifCollection(getid,num) {
243
	var data = {"professorId": userid,"watchObject": getid}
244
	//alert(JSON.stringify(data))
245
	$.ajax({		
246
		url:"/ajax/watch/hasWatch",
247
		data:data,
248
		dataType: 'json', //数据格式类型
249
		type: 'get', //http请求类型
250
		timeout: 10000,
251
		async: true,
252
		success: function(data) {
253
			if(num==1){
254
				if(data.success && data.data != null) {
255
					$('.attenSpan').addClass("attenSpanyes");
256
					$('.attenSpan').text('已关注');
257
					zjreturnId = data.data.watchObject;
258
				} else {
259
					$('.attenSpan').removeClass("attenSpanyes");
260
					$('.attenSpan').text('关注');
261
				}
262
			}
263
			if(num==2){
264
				if(data.success && data.data != null) {
265
					$('#attention em').addClass("icon-collected").removeClass("icon-collect");
266
					wzreturnId = data.data.watchObject;
267
				} else {
268
					$('#attention em').removeClass("icon-collected").addClass("icon-collect");
269
				}
270
			}
271
			
272
		},
273
		error: function() {
274
			$.MsgBox.Alert('提示',"服务器链接超时");
275
		}
276
	});
277
}
278

279
/*关注专家*/
280
function collectionExpert(watchObject,num) {
281
	if(num==1){
282
		var data = {"professorId": userid,"watchObject": watchObject,"watchType": 1}
283
	}else{
284
		var data = {"professorId": userid,"watchObject": watchObject,"watchType": 3}
285
	}
286
	$.ajax({		
287
		url:"/ajax/watch",
288
		data:data,
289
		dataType: 'json', //数据格式类型
290
		type: 'POST', //http请求类型
291
		timeout: 10000,
292
		async: false,
293
		success: function(data) {
294
			if(num==1){
295
				if(data.success) {
296
					$('.attenSpan').addClass("attenSpanyes");
297
					$('.attenSpan').text('已关注');
298
					zjreturnId = data.data.watchObject;
299
				}
300
			}
301
			
302
			if(num==2){
303
				if(data.success) {
304
					$('#attention em').addClass("icon-collected").removeClass("icon-collect");
305
					wzreturnId = data.data.watchObject;
306
				}
307
			}
308
			
309
		},
310
		error: function() {
311
			$.MsgBox.Alert('提示',"服务器链接超时");
312
		}
313
	});
314
}
191
	
315 192

316
/*取消收藏专家*/
317
function cancelCollectionExpert(watchObject,num) {
318
	$.ajax({		
319
		url:"/ajax/watch/delete",
320
		data: {
321
			professorId: userid,
322
			watchObject: watchObject
323
		},
324
		dataType: 'json', //数据格式类型
325
		type: 'post', //http请求类型
326
		timeout: 10000,
327
		async: true,
328
		success: function(data) {
329
			console.log(data.success)
330
			if(num==1){
331
				if(data.success) {
332
					$('.attenSpan').removeClass("attenSpanyes");
333
					$('.attenSpan').text('关注');
334
				}	
335
			}
336
			if(num==2){
337
				if(data.success) {
338
					$('#attention em').removeClass("icon-collected").addClass("icon-collect");
339
				}	
340
			}
341
			
342
		},
343
		error: function(data) {
344
			$.MsgBox.Alert('提示',"服务器链接超时");
345
		}
346
	});
347

348
}
349
selUse();
193
	selUse();
350 194
	function selUse() {
351 195
		$.ajax({
352 196
			url: "/ajax/resource/qaLinkman",

+ 38 - 134
js/resourceShow.js

@ -11,7 +11,7 @@ $(document).ready(function() {
11 11
		$('.shareCode').stop(true, false).fadeToggle();
12 12
	});
13 13
	var resourceId = GetQueryString("resourceId");
14
	ifCollection(resourceId, 2)
14
	ifcollectionAbout(resourceId,$("#attention").find("em"), 2)
15 15
	var professorId = "";
16 16
	getRecourceMe();
17 17
	/*获取资源信息*/
@ -75,7 +75,7 @@ $(document).ready(function() {
75 75
			console.log(professorId);
76 76
			console.log(userid);
77 77
			if(userid != professorId) {
78
				ifCollection(professorId, 1)
78
				ifcollectionAbout(professorId,$("#person").find(".attenSpan"), 1)
79 79
				$(".goSpan").show();
80 80
			}
81 81
			var professorFlag = autho($da.editProfessor.authType, $da.editProfessor.orgAuth, $da.editProfessor.authStatus);
@ -85,6 +85,7 @@ $(document).ready(function() {
85 85
			}
86 86
		}else{
87 87
			$("#enterprise,#resPerson").show();
88
			$(".qiyego").attr('dataid',$da.organization.id);
88 89
			$(".qiyego").attr("href","cmpInforShow.html?orgId="+$da.organization.id);
89 90
			if($da.organization.hasOrgLogo) {
90 91
				$("#companyImg").attr("src", "/images/org/" + $da.organization.id + ".jpg");
@ -102,6 +103,9 @@ $(document).ready(function() {
102 103
			
103 104
			$("#Qindustry").text($da.organization.subject);
104 105
			$("#QorgType").text(orgTypeShow[$da.organization.orgType])
106
			if(userid){
107
				ifcollectionAbout($da.organization.id,$("#enterprise").find(".attenSpan"), 6)
108
			}
105 109
		}
106 110
		if($da.spec) { //厂商型号
107 111
			$("#modelNumber").text($da.spec).parents("li").show();
@ -389,13 +393,13 @@ $(document).ready(function() {
389 393

390 394
	};
391 395
	//点击专家关注
392
	$('.attenSpan').click(function() {
396
	$("#person").on("click",'.attenSpan',function() {
393 397
		if(userid && userid != "null" && userid != null) {
394
			if($(this).is('.attenSpanyes')) {
395
				cancelCollectionExpert(professorId, 1)
398
			if($(this).is('.attenedSpan')){
399
				cancelCollectionAbout(professorId,$(this), 1)
396 400
			} else {
397
				collectionExpert(professorId, 1);
398
			}
401
				collectionAbout(professorId,$(this),1);
402
			}	
399 403
		} else {
400 404
			$.MsgBox.Alert('提示', "请先登录再进行关注");
401 405
			$("#mb_btn_ok").val("去登录");
@ -412,17 +416,15 @@ $(document).ready(function() {
412 416
			aele.setAttribute('href', '../login.html');
413 417
		}
414 418
	})
415

416
	//点击资源收藏
417
	$('#attention em').click(function() {
419
	$("#enterprise").on("click",'.attenSpan',function() {
418 420
		if(userid && userid != "null" && userid != null) {
419
			if($(this).is('.icon-collected')) {
420
				cancelCollectionExpert(resourceId, 2)
421
			if($(this).is('.attenedSpan')){
422
				cancelCollectionAbout($(".qiyego").attr('dataid'),$(this), 6)
421 423
			} else {
422
				collectionExpert(resourceId, 2);
423
			}
424
				collectionAbout($(".qiyego").attr('dataid'),$(this),6);
425
			}	
424 426
		} else {
425
			$.MsgBox.Alert('提示', "请先登录再进行收藏");
427
			$.MsgBox.Alert('提示', "请先登录再进行关注");
426 428
			$("#mb_btn_ok").val("去登录");
427 429
			var aele = document.createElement('a');
428 430
			$("#mb_btnbox").append(aele);
@ -438,129 +440,31 @@ $(document).ready(function() {
438 440
		}
439 441
	})
440 442

441
	/*判断是非关注专家*/
442
	function ifCollection(getid, num) {
443
		var data = {
444
			"professorId": userid,
445
			"watchObject": getid
446
		}
447
		//alert(JSON.stringify(data))
448
		$.ajax({
449
			url: "/ajax/watch/hasWatch",
450
			data: data,
451
			dataType: 'json', //数据格式类型
452
			type: 'get', //http请求类型
453
			timeout: 10000,
454
			async: true,
455
			success: function(data) {
456
				if(num == 1) {
457
					if(data.success && data.data != null) {
458
						$('.attenSpan').addClass("attenSpanyes");
459
						$('.attenSpan').addClass("attenedSpan");
460
						$('.attenSpan').text('已关注');
461
						zjreturnId = data.data.watchObject;
462
					} else {
463
						$('.attenSpan').removeClass("attenSpanyes");
464
						$('.attenSpan').removeClass("attenedSpan");
465
						$('.attenSpan').text('关注');
466
					}
467
				}
468
				if(num == 2) {
469
					if(data.success && data.data != null) {
470
						$('#attention em').addClass("icon-collected").removeClass("icon-collect");
471
						wzreturnId = data.data.watchObject;
472
					} else {
473
						$('#attention em').removeClass("icon-collected").addClass("icon-collect");
474
					}
475
				}
476

477
			},
478
			error: function() {
479
				$.MsgBox.Alert('提示', "服务器链接超时");
480
			}
481
		});
482
	}
483

484
	/*关注专家*/
485
	function collectionExpert(watchObject, num) {
486
		if(num == 1) {
487
			var data = {
488
				"professorId": userid,
489
				"watchObject": watchObject,
490
				"watchType": 1
443
	//点击资源收藏
444
	$('#attention em').click(function() {
445
		if (userid && userid != "null" && userid != null) {
446
			if($(this).is('.icon-collected')){
447
				cancelCollectionAbout(resourceId,$(this),3)
448
			}else{
449
				collectionAbout(resourceId,$(this),3)
491 450
			}
492 451
		} else {
493
			var data = {
494
				"professorId": userid,
495
				"watchObject": watchObject,
496
				"watchType": 2
497
			}
452
			$.MsgBox.Alert('提示', "请先登录再进行收藏");
453
			$("#mb_btn_ok").val("去登录");
454
			var aele = document.createElement('a');
455
			$("#mb_btnbox").append(aele);
456
			$("#mb_btnbox a").css({
457
				'display': "block",
458
				'width': '100%',
459
				'height': '40px',
460
				'position': 'absolute',
461
				'bottom': '-6px',
462
				'left': '0'
463
			});
464
			aele.setAttribute('href', '../login.html');
498 465
		}
499
		$.ajax({
500
			url: "/ajax/watch",
501
			data: data,
502
			dataType: 'json', //数据格式类型
503
			type: 'POST', //http请求类型
504
			timeout: 10000,
505
			async: false,
506
			success: function(data) {
507
				if(num == 1) {
508
					if(data.success) {
509
						$('.attenSpan').addClass("attenSpanyes");
510
						$('.attenSpan').addClass("attenedSpan");
511
						$('.attenSpan').text('已关注');
512
						zjreturnId = data.data.watchObject;
513
					}
514
				}
515

516
				if(num == 2) {
517
					if(data.success) {
518
						$('#attention em').addClass("icon-collected").removeClass("icon-collect");
519
						wzreturnId = data.data.watchObject;
520
					}
521
				}
522

523
			},
524
			error: function() {
525
				$.MsgBox.Alert('提示', "服务器链接超时");
526
			}
527
		});
528
	}
529

530
	/*取消收藏专家*/
531
	function cancelCollectionExpert(watchObject, num) {
532
		$.ajax({
533
			url: "/ajax/watch/delete",
534
			data: {
535
				professorId: userid,
536
				watchObject: watchObject
537
			},
538
			dataType: 'json', //数据格式类型
539
			type: 'post', //http请求类型
540
			timeout: 10000,
541
			async: true,
542
			success: function(data) {
543
				console.log(data.success)
544
				if(num == 1) {
545
					if(data.success) {
546
						$('.attenSpan').removeClass("attenSpanyes");
547
						$('.attenSpan').removeClass("attenedSpan");
548
						$('.attenSpan').text('关注');
549
					}
550
				}
551
				if(num == 2) {
552
					if(data.success) {
553
						$('#attention em').removeClass("icon-collected").addClass("icon-collect");
554
					}
555
				}
556

557
			},
558
			error: function(data) {
559
				$.MsgBox.Alert('提示', "服务器链接超时");
560
			}
561
		});
466
	})
562 467

563
	}
564 468
	//资源浏览量
565 469
	function pageViewsVal() {
566 470
		$.ajax({

+ 5 - 2
resourceShow.html

@ -129,7 +129,7 @@
129 129
						<span class="attenSpan">关注</span>
130 130
					</div>
131 131
				</div>
132
				<div class="conItem conItemG displayNone" id="enterprise" style="border:none;padding:30px;">
132
				<div class="conItem conItemG alignCenter displayNone" id="enterprise" style="border:none;padding:30px;">
133 133
					<a href="" class="qiyego">
134 134
						<div class="madiaHead cmpHead" id="Qimg">
135 135
							<div class="boxBlock" style="width:98px;height:98px">
@ -137,7 +137,7 @@
137 137
							</div>
138 138
						</div>
139 139
					</a>
140
					<div class="proInfo alignCenter">
140
					<div class="proInfo">
141 141
						<div class="h3Font clearfix">
142 142
							<a  class="h1Font qiyego" id="Qname"></a>
143 143
							<span class="authiconNew" title="" id="QauthFlag"></span>
@ -145,6 +145,9 @@
145 145
						<p class="h2Font ellipsisSty" id="Qindustry"></p>
146 146
						<p class="h2Font" id="QorgType"></p>
147 147
					</div>
148
					<div class="goSpan">
149
						<span class="attenSpan">关注</span>
150
					</div>
148 151
				</div>
149 152
				<div class="conItem displayNone" id="resPerson">
150 153
					<div class="form-item otherBlock">