<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!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="/static/weChat/css/public.css">
    <link rel="stylesheet" href="/static/weChat/css/bai_basic.css">
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script src="/static/weChat/js/flexible.js"></script>
    <title>产品列表</title>
    <style>
        #mask{
            position: fixed;
            display: none;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            background: rgba(0,0,0,.5);
            z-index: 99;
        }
        #p_tishi{
            position: fixed;
            display: none;
            width: 80%;
            height: 7.78rem;
            background: rgb(255,255,255);
            border-radius: 5px;
            top: 50%;
            left: 10%;
            margin-top: -3.89rem;
            z-index: 109;
        }
        #text_message {
            display: inline-block;
            padding: 0.32rem;
            text-indent: 2em;
            font-size: 14px;
            color: #333;
            line-height: 0.56rem; }
        [data-dpr="2"]  #text_message{
            font-size: 28px; }
        [data-dpr="3"]  #text_message {
            font-size: 42px; }
        #p_tishi h2{
            height: 1.17333rem;
            width: 100%;
            background: linear-gradient(90deg, #ff8b00, #ff6600);
            font-size: 16px;
            color: #fff;
            line-height:  1.17333rem;
            text-align: center;
        }
        [data-dpr="2"]  #p_tishi h2{
            font-size: 32px;
        }
        [data-dpr="3"]  #p_tishi h2{
            font-size: 48px;
        }

        #message_confirm{
            display: block;
            width: 2.5rem;
            height: 0.95rem;
            background: linear-gradient(90deg, #ff8b00, #ff6600);
            margin: 0.15rem auto 0 auto;
            border-radius: 0.08rem;
            font-size: 16px;
            color: #fff;
            line-height: 0.95rem;
            text-align: center;
        }
        [data-dpr="2"]  #message_confirm{
            font-size: 32px;
        }
        [data-dpr="3"]  #message_confirm{
            font-size: 48px;
        }
        #p_tishi.wedf{
            height: auto!important;
            padding-bottom: 0.3rem;
        }
    </style>
</head>
<body id="container">
<%--<c:if test="${not empty type}">
    <div style="width:100%; height:100%;">
        <img src="/static/weChat/images/weixin_cover.png" style="
    background-size: cover;
    position: fixed;
    width:100%; height:100%; opacity: 0.7;
    z-index: 999;" />
    </div>
</c:if>--%>

<div class="list-head">
    <div class="head">
        <input id="product_search" type="text" placeholder="请输入关键词搜索">
    </div>
    <div class="head-remove">
        <img src="/static/weChat/images/remove-error.png" />
    </div>
</div>

<div id="wrapper" class="product-wrapper">
    <div class="administer" id="scroller">
        <div class="insurance-list">
            <ul id="product">
                <%-- <li>
                     <a href="javascript:;">
                         <div class="insur-head">
                             <div class="head-img"></div>
                             <div class="head-right">
                                 <h2>众安展会综合责任保险计划一</h2>
                                 <p>保障期限：1年</p>
                                 <span>灰色空间带饭还是看大家水灰色空间带饭还是看大家水灰色空间带饭还是看大家水电费灰色空间返回抗生素东方航空收到反馈生死看淡交话费考试</span>
                             </div>
                         </div>
                         <div class="insur-cont">
                             <p>
                                 <span>展会场馆方财产损失责任</span>
                                 <i>50万元</i>
                             </p>
                             <p>
                                 <span>第三者人身损害责任</span>
                                 <i>100万元</i>
                             </p>
                             <p>
                                 <span>雇主责任</span>
                                 <i>150万</i>
                             </p>
                         </div>
                         <p class="head-money">
                             ￥450.00
                             <i>起</i>
                         </p>
                     </a>
                 </li>
                --%>
            </ul>
        </div>
        <div id="pullUp">
            <span class="pullUpLabel">上拉加载更多...</span>
        </div>
        <p id="ert"></p>
    </div>
</div>

<div class="bottom-list">
    <div class="list-cont">
        <div class="list product_list active">
            <a href="/weixin/product/win/list">
                <img src="/static/weChat/images/product-q1-more.png" />
                <span>产品</span>
            </a>
        </div>
        <div class="list order_list">
            <a href="/weixin/order/order_list">
                <img src="/static/weChat/images/order-q2.png" />
                <span>订单</span>
            </a>
        </div>
        <div class="list mine_list ">
            <a href="/weixin/usercenter/index">
                <img src="/static/weChat/images/user-q3.png" />
                <span>我</span>
            </a>
        </div>
    </div>
</div>

<div id="p_tishi" class="wedf">
    <h2>温馨提示</h2>
    <p id="text_message"></p>
    <span id="message_confirm" onclick="javascript:$('#p_tishi').hide();$('#mask').hide();">确定</span>
</div>
<div id="mask"></div>

</body>
<script src="/static/weChat/js/jquery-1.8.3.min.js"></script>
<script src="/static/weChat/common/layer_mobile/layer.js"></script>
<link rel="stylesheet" href="/static/weChat/common/layer_mobile/need/right.css">
<script src="/static/weChat/js/weixin_g.js"></script>
<script src="/static/weChat/js/basic.js"></script>
<script src="/static/weChat/js/iscroll.js"></script>
<script src="/static/weChat/js/product.js"></script>
<script>
    $("#product_search").click(function(){
        location.href = "/weixin/product/win/search"
    });

    var p = { limit: 5, offset: 0 };
    <%--var gurl = '${url}';--%>
    <%--var recommendCode = '${recommendCode}';--%>

    //搜索功能
    //    $("#search").click(function(){
    //        $("#assigned-list").html("");
    //        p = { limit: 5, offset: 0 };
    //        p.search  = $("#searchText").val().trim();
    //        getData();
    //        myScroll.refresh();
    //    });

    function chgMoney(money){
        if(money>=10000){
            return (money/10000)+"万";
        }else{
            return money;
        }
    }

    function getData(){
        g_ajax("/weixin/product/query",p ,function(json){
            var el, li, i;
            var rows = json.rows;
            var total = json.total;
            el = document.getElementById('product');
            if( rows==undefined || rows.length==0 ) { //长度为空，或者小于limit条数，说明是已经到最后了
                $("#pullUp").hide();
                $("#ert").text('数据已经加载完了！').show();
                return;
            }else{
                p.offset += p.limit;
            }
            for(var i in rows){
                li = document.createElement('li');
                var responses = "";
                var res = rows[i].responsesList;
                if(res!=""){
                    for( var idx in res ){
                        var money ="- -";
                        if(res[idx].insurance_amount_max!=undefined && res[idx].insurance_amount_max!="") money = chgMoney(res[idx].insurance_amount_max)+'元';
                        responses += '<p><span>'+res[idx].show_name+'</span><i>'+money+'</i></p>';
                    }
                }
                li.innerHTML =
                    '<a href="/weixin/product/win/detail/'+rows[i].pro_primary_id+'">'
                    +'<div class="insur-head">'
                    +'<div class="head-img" style="background:url('+rows[i].company_logo+') no-repeat center center;background-size: 100% auto;"></div>'
                    +'<div class="head-right">'
                    +'<h2>'+ rows[i].insurance_name +'</h2>'
                    +'<p>保障期限：最多15天</p>'
                    +'<span>'+rows[i].intro+'</span>'
                    +'</div>'
                    +'</div>'
                    +'<div class="insur-cont">'
                    + responses
                    +'</div>'
                    +'<p class="head-money">'
                    + '￥'+rows[i].fixed_premium
                    //                    +'<i> 起</i>'
                    +'</p>'
                    +'</a>';
                el.appendChild(li, el.childNodes[0]);
            }
        },false);
    }
    function pullUpAction () {
        getData();
        myScroll.refresh();		// 数据加载完成后，调用界面更新方法 Remember to refresh when contents are loaded (ie: on ajax completion)
    }

    $(document).ready(function(){;
        getData(); //初始化加载
        if('${type}' == '0'){
            var zg_html = '<div style="width:100%; height:100%;"><img src="/static/weChat/images/weixin_cover.png" style="background-size: cover;position: fixed;width:100%; height:100%; opacity: 0.7;z-index: 999;" /></div>';
            $('#container').children().first().before(zg_html);
        }
        if('${notOpen}' != '1'&&'${type}' != '0'){
            openShow();
        }
    });
    function openShow(){
        var name = '${ywzc_activity_info.name}';
        if(name != ''){
            var detail = '为维护和保障 <strong>'+name+'</strong> 展参与各方利益，做好展会的安全管理，进一步完善安全管理体制，促进展会持续健康发展，本次 <strong>'+name+'</strong> 会要求参展商购买《展会综合责任保险》后，方能办理报馆手续，入场布展。参展商可通过在线购买《展会综合责任保险》，确保保额充足真实有效，保障全面。';
            $('#text_message').html(detail);
            $('#mask').show();
            $('#p_tishi').show();
        }
    }
    $(function(){
        var url = location.href.split('#').toString();//url不能写死
        $.ajax({
            type : "get",
            url : "/weixin/token/wechatParam",
            dataType : "json",
            async : false,
            data:{hostUrl:url},
            success : function(data) {
                wx.config({
                    debug: false,////生产环境需要关闭debug模式
                    appId: data.appid,//appId通过微信服务号后台查看
                    timestamp: data.timestamp,//生成签名的时间戳
                    nonceStr: data.nonceStr,//生成签名的随机字符串
                    signature: data.signature,//签名
                    jsApiList: [//需要调用的JS接口列表
                        'checkJsApi',//判断当前客户端版本是否支持指定JS接口
                        'onMenuShareTimeline',//分享给好友
                        'onMenuShareAppMessage'//分享到朋友圈
                    ]
                });
                wx.ready(function () {
                    getPengyou();
                });

            },
            error: function(xhr, status, error) {
                console.log("error:"+error);
                //alert(status);
                //alert(xhr.responseText);
            }
        })
    });

    function getPengyou(){

        var url = location.href.split('#').toString();//url不能写死
        wx.onMenuShareAppMessage({
            title: '${ywzc_activity_info.name}', // 分享标题
            desc: '科学转移参展风险.', // 分享描述
            link: url, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
            imgUrl: url.split('/weixin')[0]+'/images/logo.png', // 自定义图标
            type: 'link', // 分享类型,music、video或link，不填默认为link
            dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
            success: function () {
                // 用户确认分享后执行的回调函数
                //alert("666");
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });
        wx.error(function (res) {
            //alert(res.errMsg);
        });

    }

</script>
</html>