<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%@ include file="/WEB-INF/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link rel="stylesheet" href="${ctxwxsta}/css/public.css">
    <link rel="stylesheet" href="${ctxwxsta}/css/basic.css">
    <script src="${ctxwxsta}/js/flexible.js"></script>
    <script src="/static/weixin/common/layer_mobile/layer.js"></script>
    <link rel="stylesheet" href="/static/weixin/common/layer_mobile/need/right.css">
    <title>可选择产品</title>
    <style>
        html{
            height: 100%;
            padding-top: 0;
        }
        .contain{
            padding-bottom: 3.4rem;
            box-sizing: border-box;
        }
        body{
            height: 100%;
            padding-top: 0;
            box-sizing: border-box;
            position: relative;
        }
        .pro-steps{
            position: absolute;
        }
    </style>
</head>
<body id="contain">
<div class="contain">
    <div class="bai-head">
        <span>可选择产品</span>
        <c:if test="${not empty newType}">
            <a href="javascript:;" onclick="fanhui(0)" class="left">
                <img src="${ctxwxsta}/images/head-left.png"/>
            </a>
        </c:if>
        <c:if test="${ empty newType}">
            <a href="javascript:;" onclick="fanhui(1)" class="left">
                <img src="${ctxwxsta}/images/head-left.png"/>
            </a>
        </c:if>

        <%--<i class="she">设置</i>--%>
        <%--<div class="she-content">--%>
            <%--<ul>--%>
                <%--<li>--%>
                    <%--<a href="javascript:;">价格升序</a>--%>
                <%--</li>--%>
                <%--<li>--%>
                    <%--<a href="javascript:;">价格降序</a>--%>
                <%--</li>--%>
            <%--</ul>--%>
        <%--</div>--%>

    </div>
    <div class="administer-head">
        <input id="searchText"  type="text" placeholder="请输入产品名称">
        <span class="head-remove"></span>
        <a href="javascript:;" id="search" onclick="serach()" class="head-serach">搜索</a>
    </div>
    <form style="padding-bottom : 500px">
    <input  type="hidden" name="companyId" value="${companyId}" id="companyId">
    <div id="wrapper" class="inferiors-cont adminuster-wed">
        <div class="administer wrapper-product" id="scroller">

            <ul class="optional-product" id="product-list">

            </ul>
            <div id="pullUp">
                <span class="pullUpLabel">上拉加载更多...</span>
            </div>
            <p id="ert"></p>

        </div>
    </div>
    </form>
</div>

<c:if test="${not empty newType}">
    <div class="pro-steps">
        <div class="steps">
            <button class="xia"  onclick="tijiao()">下一步</button>
            <button onclick="fanhui(0)">上一步</button>
        </div>
    </div>
</c:if>

<c:if test="${ empty newType}">
    <div class="pro-steps">
        <div class="steps">
            <button class="xia"  onclick="tijiao()">确认选择</button>
            <button onclick="fanhui(1)">返回</button>
        </div>
    </div>
</c:if>

<!--白色蒙版-->
<div class="white-mask"></div>

<script src="${ctxwxsta}/js/jquery-1.8.3.min.js"></script>

<script type="text/javascript" src="${ctxwxsta}/js/iscroll.js"></script>
<script type="text/javascript" src="${ctxwxsta}/js/products.js"></script>
<script type="text/javascript" src="${ctxwxsta}/js/basicOne.js"></script>
<script>
    var baseUrl = '${pageContext.request.contextPath }';
    $(document).ready(function(){
        getData(0);
    });

     function tijiao() {
         var newType='${newType}';
         var parentName="";
         $(".select-wed.on").each(function () {
             parentName=parentName+$(this).attr('name')+",";
         })
         if(parentName!=""){
             parentName= parentName.substring(0,parentName.length-1);
         }
         if(parentName==""){
             layer.open({content:"请选择产品！",btn: '我知道了'});
             return ;
         }
         var companyId =$("#companyId").val();
         layer.open({type: 2});
         $.ajax({
             type: 'POST',
             url: "/weixin/product/saveProductRelation",
             data:{productIds:parentName,companyId:companyId,type:1},
             dataType:"json",
             async: false,
             success: function(data){
                 console.log(JSON.stringify(data));
                 if(data.success){
                     if(newType){
                         window.location.href="/weixin/product/distributionList/"+companyId+"?newType=1";
                     }else{
                         window.location.href="/weixin/product/distributionList/"+companyId;
                     }
                 }else{
                     layer.open({content:"操作失败！",btn: '我知道了'});
                 }
             }
         });
     }

     function fanhui(type){

         var companyId =$("#companyId").val();
         if(type==0){
             window.location.href="/weixin/partner/updPartner/"+companyId+"?newType=1";
         }
         if(type==1){
             window.location.href="/weixin/product/distributionList/"+companyId;
         }

    }
    function assighed(obj) {
        $('.proportion-wind').show();
        $('.block-mask-more').show();

    }

    function serach() {
        $("#product-list").html("");
        getData(0);
    }
</script>
<script>
    $('.bai-head i.she').click(function () {
        if($('.bai-head .she-content').hasClass('active')){
            $('.bai-head .she-content').removeClass('active');
            $('.white-mask').hide();
        }else{
            $('.bai-head .she-content').addClass('active');
            $('.white-mask').show();
        }
    });
    $('.white-mask').click(function () {
        $('.bai-head .she-content').removeClass('active');
        $('.white-mask').hide();
    });
    $('.assigned-steps .steps button').click(function () {
        $('.bai-head .she-content').removeClass('active');
        $('.white-mask').hide();
    });
    $('.assigned-steps .steps button.xia').click(function () {
        $('.empty_booth').show();
        $('.mask_block').show();
    });

    $('.empty_booth span.cancel').click(function () {
        $('.empty_booth').hide();
        $('.mask_block').hide();
    });
    $('.empty_booth span.sure').click(function () {
        $('.empty_booth').hide();
        $('.mask_block').hide();
    });
</script>
<script>
    $(function () {
        var u = navigator.userAgent, app = navigator.appVersion;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
        if (isAndroid) {
            //这个是安卓操作系统
            var oHeight = $(document).height(); //浏览器当前的高度

            $(window).resize(function(){

                if($(document).height() < oHeight){
                    $('body').css({"min-height":oHeight});
                    $(".pro-steps").css("position","static");
                }else{
                    $('body').css({"min-height":oHeight});
                    $(".pro-steps").css("position","absolute");
                }
            });
        }
    })
</script>
</body>
</html>