点赞、踩及收藏功能

		/*点赞点踩收藏*/
		.link_reward .link_box {
		    float: left;
		    margin-right: 20px;
		}	
		.link_reward .link_box a {
		    display: inline-block;
		}	
		.zan_statue{background:url(dianzan_huise.png) no-repeat left;background-position-y: 10px;background-size: 26%;}
		.yizan_curs i {background: url(dianzan_hongse.png) no-repeat;background-size: contain;}		
		.link_box_support .yizan_curs span, .link_box_support .yizan_curs em {color: #f04748;}		
		.oppse_icon1{
			background: url(cai_huise.png) no-repeat;
	        background-size: contain;			
		}
		.oppse_icon{
			background: url(cai_hongse.png) no-repeat;
	        background-size: contain;
		}	
		.manage_sc{
		    background: url(shoucang_huise.png) no-repeat;
		        background-size: contain;
		}
		.manage_qxsc{
		    background: url(shoucang_hongsese.png) no-repeat;
		        background-size: contain;
		}	

 

		//点踩
		$('.manage_oppose').on('click',function(e){
			var _id = $(this).attr('id').split('_');
			if($('.link_box_support a').hasClass('yizan_curs')){
				pl_pop('已赞过了!');
				return;
			}else{
				$('.link_reward .tools_oppose i').removeClass('oppse_icon1');
				$('.link_reward .tools_oppose i').addClass('oppse_icon');
				$('#e_support_'+_id[1]).css('color','#f04748');
//				$('#e_support_'+_id[1]).html('踩'+parseInt(cont.oppose_num)+1);
				$('#e_support_'+_id[1]).html('踩'+(parseInt(cont.oppose_num)+1));
		        $.post(
		            "xxxxxxxxxxxxxxxxxxxx",
		            {kind:'express', id:_id, type:"oppose"},
		            function(data){
		            	localStorage.setItem("oppose_status_express_"+_id,"yes");
		            }
		        );
			}
		});
    //点赞
    function pub_support(_id){
        if($('.link_box_oppose i').hasClass('oppse_icon')){
			pl_pop('已踩过了!');
			return;        	
        }else{
	        if(storage.getItem("praised_status_live_msg_"+_id)=="yes"){
	            return;
	        }
	        if (support_list.indexOf(_id) >= 0){
	            return;
	        }
	        support_list.push(_id);
	    	var support_num = parseInt(jQuery(".sup_number").html());
	        jQuery(".sup_number").html(support_num+1);
	        jQuery(".sup_number").parents('a').addClass("yizan_curs");
	        jQuery(".sup_number").parents('a').removeClass("zan_statue");
	        jQuery.post(
	            "xxxxxxxxxxxxxxxxxxxxxxxxx",
	            {kind:"express", id:_id, type:"support"},
	            function(data){
	                localStorage.setItem("praised_status_live_msg_"+_id,"yes");
	            }
	        ); 
        }
    }
       	//收藏
       	$('.manage_list').on('click',function(e){
       		var _id = $(this).attr('id').split('_');
       		if($('.admini_collect span').html()=='收藏'){
       			$('.mp_det_inner').html('收藏成功!')
     			$('.managePopdet').show().delay (500).fadeOut();
       			$('.admini_collect span').html('已收藏');
       			$('.link_reward .manage_list i').removeClass('manage_sc');
       			$('.link_reward .manage_list i').addClass('manage_qxsc');       			
       		}else{
//     			$('.mp_det_inner').html('您已取消收藏!')
//   			$('.managePopdet').show().delay (3000).fadeOut();
				$('.managePopup').show();
				$('.mP_psg').hide();
				$('.manageBg').show();
				$('.mP_confirm').on('click',function(){
	       			$('.admini_collect span').html('收藏');
	       			$('.managePopup').hide();
					$('.manageBg').hide();
	       			$('.link_reward .manage_list i').removeClass('manage_qxsc');
	       			$('.link_reward .manage_list i').addClass('manage_sc');	
				})
       			
       		}
	        $.post(
	            "xxxxxxxxxxxxxxxxxxxxxxx",
	            {kind:'express',md:_Libs.md, o_id:_id},
	            function(data){
	            	localStorage.setItem("oppose_status_express_"+_id,"yes");
	            }
	        );       		
       	});

 

你可能感兴趣的:(前端开发经验之谈,Javascript)