ajax for in eval()知识点的应用

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>团体交通意外险-国内旅游保险-中国平安官方直销网站</title>
    <link rel="stylesheet" href="http://pcss1.4008000000.com/app_css/4008000000/v20/base.css" />
    <link rel="stylesheet" href="http://pcss1.4008000000.com/app_css/4008000000/v20/public.css" />
    <link rel="stylesheet" href="http://pcss1.4008000000.com/app_css/4008000000/v20/zaixiangoumai/baoxian/prolist.css" />
    <style>
    .prolist_cont,.prolist_cont_item {margin:0!important;padding:0!important;}
    </style>
</head>
<body>
<ul class="prolist_cont">
    <!--0928 团体交通意外险-->
    <li class="prolist_cont_item">
        <div class="default_box">
            <div class="default_box_Img"><img src="http://pimg1.4008000000.com/app_images/4008000000/v20/zaixiangoumai/baoxian/productList/tuantijiaotongyiwai.jpg" alt="团体交通意外险"></div>
            <span class="default_box_name">团体交通意外险</span>
            <p class="default_box_text">飞机、火车、旅游大巴、私家车全都保<br />多人、团队折扣高。</p>
        </div>
        <div class="current_box">
            <div class="current_box_name c">
                <a href="/zaixiangoumai/baoxian/tuantijiaotongyiwai.shtml" otitle="团体交通意外险" otype="button" target="_blank" class="current_box_name_link">团体交通意外险</a>
                <a href="/zaixiangoumai/baoxian/tuantijiaotongyiwai.shtml" otitle="团体交通意外险-查看详情" otype="button" target="_blank" class="current_box_more">查看详情 &gt;</a>
            </div>
            <div class="current_box_list">
                <ul class="c">
                    <li><p class="f_c_f63">50-800万元</p>· 飞机意外</li>
                    <li><p class="f_c_f63">10-100万元</p>· 火车意外</li>
                    <li><p class="f_c_f63">10-100万元</p>· 轮船意外</li>
                    <li><p class="f_c_f63" style="width: 80px;">10-30万元</p>· 汽车(客车、私家车、旅游大巴)意外</li>
                </ul>
            </div>
            <a href="http://www.pingan.com/pa18shopnst/productCenterNew/wrap.shtml?productCode=PAT0050" otitle="团体交通意外险-立即报价" otype="button" target="_blank" class="current_box_btn" onClick="hrefChangeByMediaSource(this);">立即报价</a>
        </div>
        <div class="resident_box c">
            <ul class="ul_four">
                <li>电子保单</li>
                <li>全国通赔</li>
            </ul>
            <div class="resident_box_price">
                <p><span class="resident_box_price_num"0.20</span>/人起</p>
                <a href="/zaixiangoumai/baoxian/tuantijiaotongyiwai.shtml?type=guestui#product-detail" otitle="团体交通意外险-评论" otype="button" target="_blank" id="ttjtywx" class="resident_box_price_pinjia"><span class="f_c_f63"></span>人评价</a>
            </div>
        </div>
    </li>
    <!--0928 团体交通意外险 end-->
</ul>
<div style="display:none;" id="proCodeJson">{'PAT0050':'ttjtywx'}</div>
<script src="http://pscript1.4008000000.com/app_js/paui/1.1.0/build/pa.ui.min.js"></script>

<script>
    $(".prolist_cont_item").hover(function(){
    $(this).addClass("hover");
    },function(){
    $(this).removeClass("hover");
    });
</script>
<script type="text/javascript">
    // ebusiness 服务器地址
    // code -> 保险产品code  ;  aId 界面上 [已有XXX人评论] 的<a>元素ID
    function request_product_comment(code, aId){
        //var url = '/ebusiness/payment/user/showOtherCommont.ajax?prePageSize=1&toPageNumber=1&productCode=' + code;
        /*
            http://www.4008000000.com/member/do/commont/other/1/1/PAT0050  输出如下数据
            { "resultCode":"success", "status":"success", "msg":"", "data":{ "currentPage":"1", "pages":"1", "fullSize":"1", "datas":[ { "commendLevel":"10", "commontContent":"为好朋友买了十一期间的交通意外,产品购买比较方便,多人投保优惠比较大,比较好的解决了类似十一之类的假期出行安全问题,支付也超级方便,很不错,下次旅行还买这个。 一个小小的建议,能不能出一个3天的方案,有时候周末或者小假期能够用到哦。", "commontDateStr":"2015-09-29 11:00:22", "courseComentLevel":"0", "licenceNo":"", "priceComentLevel":"0", "userName":"王**", "responseContent":"", "responseDate":"", "commontId":"20150000000000397472", "serviceAttitudeLevel":"0", "commontLevel":"10" } ] } }
        */
        var url = 'http://www.4008000000.com/member/do/commont/other/1/1/' + code;
        $.ajax({type: "GET",dataType: "json",url: url,
            success: function(data){
                show_product_comment(code, aId, data);
            }
        });
    }
    // 请求到评论数后,根据<a>的ID,显示数据
    function show_product_comment(code, aId, comment){
        if (!comment.data || !comment.data.datas || comment.data.datas.length === 0){
            $('#'+aId).hide();
        }else{
            $('#'+aId).show();
            $('#'+aId).attr('title','已有'+comment.data.fullSize+'人评论');
            $('#'+aId).attr('otitle','已有'+comment.data.fullSize+'人评论');
            $('#'+aId).find('span').html(comment.data.fullSize);
        }
    }

    $(document).ready(function(){

        var objText = $("#proCodeJson").text();
        var obj=eval("["+objText+"]")[0];
        for(var o in obj){
            request_product_comment(o, obj[o]);
        }
    });
</script>
</body>
</html>

 

posted @ 2015-12-19 23:54  iicoo  阅读(327)  评论(0编辑  收藏  举报