<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort() + path+"/";
    request.setAttribute("contextPath", basePath);
	
	String redirectUrl= request.getParameter("redirectUrl");
	request.setAttribute("redirectUrl", redirectUrl);
%>
<!DOCTYPE html>
<html>
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <title>关注产品</title>
    <script src="<%=basePath %>app/lib/flexible.js"></script>
    <link rel="stylesheet" href="<%=basePath %>app/lib/flexible.css">
    <link rel="stylesheet" href="<%=basePath %>app/lib/swiper-4.3.2.min.css" />
    <link rel="stylesheet" href="<%=basePath %>app/css/basem.css">
    <link rel="stylesheet" href="<%=basePath %>app/css/public.css">
    <link rel="stylesheet" href="<%=basePath %>app/css/index.css">
    <link rel="stylesheet" href="<%=basePath %>app/css/logome.css">

</head>
<body>
    <div class="titbox blubg">
    <%-- <a class="titreturn fl" href="javascript:void(0)" onclick="back()"><img src="<%=basePath %>app/img/fanhui16@2x.png" alt=""></a> --%>
        <h1>关注产品</h1>
        <a href="javascript:void(0)" class="check attenManage">
            <span class="smtxt" num="1">管理</span>
        </a>
    </div>
    <input type="hidden" value="${flist.page }" id="pagef"/>
    <input type="hidden" value="${flist.pageTotal }" id="pageft"/>
     <!-- 房产推介 -->
    <div class="referrals top50" style="margin-bottom:1.30rem;">
        <ul id="products">
        <c:forEach items="${flist.results}" var="p1" varStatus="status">
            <li>
            
            <a href="<%=basePath%>web/mgmProduct/detail.cs?productid=${p1.productId }&plat=H5">
                                <label class="mycheck hide">
                                <input type="hidden" class="mid" value="${p1.productId }" />
                                      <input type="checkbox" name="checkid" value="1" value="" />
                                      <div class="option"></div><!--该div盛放的是优化后的按钮图片-->
                                </label>

                                <div class="referinfo">
                                    <img src="${p1.productImg }" alt="">
                                    <div class="referCont">
                                        <p class="refertit">${p1.productName }</p>
                                        <p>
                                            <span class="designation graytxt">${p1.productRemark }</span>
                                            <c:if test="${p1.commissionRate != '0' }">
                                            <span class="commission">佣金：${p1.commissionRate }%</span>
                                            </c:if>
                                        </p>
                                        <p>
                                            <span class="designation graytxt">价格：</span>
                                            <span class="price">${p1.productPrice }</span>
                                        </p>
                                        <p>
                                            <span class="designation graytxt">类型：</span>
                                            <span class="graytxt">${p1.gc }</span>
                                        </p>
                                    </div>
                                </div>
                            </a>
                            <div class="buy">
                                <a href="<%=basePath %>web/mgmProduct/buyNow.cs?productId=${p1.id }" class="buygo">立即购买</a>
                                <a href="<%=basePath %>web/mgmProduct/recommend.cs?productids=${p1.productId}" class="buyt">我要推介</a>
                            </div>
                            
            </li>
         </c:forEach>  

            
        </ul>
      <div class="nomore" id="moreno">
                      	没有更多了。。。
                    </div>
    </div>
    <footer>
        <a href="<%=basePath %>web/mgmUserCtl/index.cs">
            <img src="<%=basePath %>app/img/shouye@2x.png" class="img1">
            <img src="<%=basePath %>app/img/shouygao@2x.png" class="img2">
            <p>首页</p>
        </a>
         <a href="<%=basePath%>web/mgmProduct/followList.cs?page=1"  class="active">
            <img src="<%=basePath %>app/img/guanz@2x.png" class="img1">
            <img src="<%=basePath %>app/img/guanzgao@2x.png" class="img2">
            <p>关注</p>
        </a>
         <a href="${contextPath}web/mgmOrder/getOrderList.cs">
            <img src="<%=basePath %>app/img/jindu@2x.png" class="img1">
            <img src="<%=basePath %>app/img/jindgao@2x.png" class="img2">
            <p>进度</p>
        </a>
         <a href="${contextPath }web/meWebCtl/me.cs" >
            <img src="<%=basePath %>app/img/my.png" class="img1">
            <img src="<%=basePath %>app/img/wode@2x.png" class="img2">
            <p>我的</p>
        </a>
    </footer>  

	
</body>
<script src="<%=basePath %>app/lib/swiper-4.3.2.min.js"></script>
<script type="text/javascript" src="<%=basePath %>app/lib/jquery.min.js">
</script>
<script type="text/javascript" src="<%=basePath %>res/js/layer/layer.min.js"></script>
<script type="text/javascript" src="<%=basePath %>app/js/public.js"></script>
<script type="text/javascript">
$(".attenManage").click(function(){
	var num = $(this).find("span").attr("num");
	if(num == "1"){
	    $(this).find("span").html("\u53d6\u6d88\u5173\u6ce8");
	    $(this).find("span").attr("num", "2");
	    $(".buygo").css("display","none");
	}else if(num == "2"){
	    var ids = "";
	    var all = $('input:checkbox[name="checkid"]:checked');
	    if(all.length == 0){
	    	layer.msg("请选择要取消的关注");
	    	return false;
	    }
	    all.each(function(index){
	    	if(index == 0){
	    		ids += $(this).parent().children('.mid').val();
	    	}else{
	    		ids += "," + $(this).parent().children('.mid').val();
	    	}
	    });
	    
	    $.ajax({
            type: 'POST',
            url: '<%=basePath%>web/mgmProduct/delFollow.cs?ids=' + ids,
            dataType: 'json',
            success: function (data) {
                   if(data.ret == "0"){
                	   layer.msg(data.msg);
                	   return false;
                   }else if(data.ret == "1"){
                	   layer.msg(data.msg);
                	   window.location.href = window.location.href;
                   }
                   
            }
        });
	}
})

		$(function(){
       		// 滚动刷新
               // 页数，每页展示10个，请求的地址
            var url = '<%=basePath%>web/mgmProduct/follows.cs';
            
            var page = $("#pagef").val();
            var pageTotal = $("#pageft").val();
            
            if(parseInt(page)>0 && parseInt(page) < parseInt(pageTotal)){
	      		$("#moreno").text("下拉加载更多");
      		}else{
      			$("#moreno").text("没有更多了。。。");
      		}
            
            if(typeof(kindul) == "undefined"){
	       		var totalheight=0 ;
	       		var totalheight2=0 ;
	           	$(window).unbind('scroll').scroll(function(){  
	       		   	totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());  
	       		 	totalheight2=parseInt($(document).height());
	       	      	if( totalheight2 == parseInt(totalheight)){
	       	      		if(parseInt(page)>0 && parseInt(page) < parseInt(pageTotal)){
	       		      		page = parseInt(page) + 1;
	       		      		$("#moreno").text("下拉加载更多");
	       	      		}else{
	       	      			$("#moreno").text("没有更多了。。。");
	       	      			return false;
	       	      			
	       	      		}
	       	      	   $.ajax({
	                          type: 'POST',
	                          url: url + '?page=' + page ,
	                          dataType: 'json',
	                          success: function (data) {
	    	                         var html="";
	    	                        	 data.results.forEach(function(value,index,array){
	    	                        		 html += "<li>";
	    	                        		 html += "<a href='<%=basePath%>web/mgmProduct/detail.cs?productid="+value.productId+"&plat=H5'>";
	    	                        		 html += "<label class='mycheck hide'>";
	    	                        		 html += "<input type='hidden' class='mid' value='"+value.productId+"' />";                   
	    	                        		 html += "<input type='checkbox' name='checkid' value='1' value='' />";                        
	    	                        		 html += "<div class='option'></div>";                           
	    	                        		 html += "</label>";                                
	    	                        		 html += "<div class='referinfo'>";                          
	    	                        		 html += "<img src='"+value.productImg+"' alt=''>";         
	    	                        		 html += "<div class='referCont'>";                                          
	    	                        		 html += "<p class='refertit'>"+value.productName+"</p>";                          
	    	                        		 html += "<p>";                                
	    	                        		 html += "<span class='designation graytxt'>"+value.productRemark+"</span>"; 
                                             if(value.commissionRate != '0'){
                                            	 html += "<span class='commission'>佣金："+value.commissionRate+"%</span>"; 
                                             }
                                             html += " </p>";                                     
                                             html += "  <p>";                                  
                                             html += " <span class='designation graytxt'>价格：</span>";
                                             html += "<span class='price'>"+value.productPrice+"</span>";                                   
                                             html += " </p>";                                   
                                             html += " <p>";                                
                                             html += "<span class='designation graytxt'>类型：</span>";                                     
                                             html += "<span class='graytxt'>"+value.gc+"</span>";                                     
                                             html += "</p>";                    
                                             html += "</div>";                                 
                                             html += "</div>";                                
                                             html += "</a>";                          
                                             html += "<div class='buy'>";                          
                                             html += " <a href='<%=basePath %>web/mgmProduct/buyNow.cs?productId="+value.productId+"' class='buygo'>立即购买</a>";                   
                                             html += " <a href='<%=basePath %>web/mgmProduct/recommend.cs?productids="+value.productId+"' class='buyt'>我要推介</a>";                  
                                             html += "</div>";             
                                             html += "</li>";                    
	    	                                                     
	    	                             
	    	                        	 });
	    	                         	$('#products').html($('#products').html() + html);
	                          }
	                      });
	       	 		}
	       		});
            }
        });
</script>



</html>
