猜你喜欢

<!--猜你喜欢 S-->
<div class="depreciate-tit font28"><h2 class="font28 color-blue"><i class="h2-bo"></i>猜你喜欢
    <a class="font24 color-gray fr change" data-id="1"><i class="change-icon"></i>换一换</a></h2>
</div>
<div class="tj-buy-car">

</div>
<script id="reduce-tem" type="text/html">
    <%for(var i=1;i<=3;i++) {%>
    <div class="list_<%=i%> reduce_info" style="display:<%if(i>1){%> none <%}%>;">
        <ul class="clearfix">
            <%for(var j in data.reduce) {%>
            <%if(j>=(i-1)*4 && j<=(i*4)-1){%>
            <li>
                <a href="<?=Url::to(['choose-car/view'])?>?id=<%=data.reduce[j].model.id%>"
                   class="car">
                    <img src="<%='<?=$imageHost?>'+data.reduce[j].model.logo%>" class="img-responsive"/>
                    <strong class="font28 color-black"><%=data.reduce[j].name ? data.reduce[j].name :
                        data.reduce[j].model.name%></strong>

                    <p class="font24"><em class="color-red "><%=data.reduce[j].model.priceWanYuanMin%>-<%=data.reduce[j].model.priceWanYuanMax%>万</em><span
                            class="x-jt color-blue"><i
                            class="promotion-icon decline-icon"></i><%=data.reduce[j].reduce%>万</span></p>
                </a>
                <a class="font24 color-yellow btn-ask"
                   href="<?=Url::to(['choose-car/inquiry'])?>?id=<%=data.reduce[j].model.id%>">
                    询底价
                </a>
            </li>
            <%}%>
            <%}%>
        </ul>
    </div>
    <%}%>
</script>
<script>
    $(function () {
    var url = '/rest-api/get-home-elements';
    $.ajax({
        type: 'get',
        url: url,
        dataType: 'json',
        success: function (res) {
             var reduce_html = template('reduce-tem', res);
             $('.tj-buy-car').html(reduce_html);
             
             $('.change').click(function () {
                var id = $(this).attr('data-id');
                var show_id = parseInt(id) + 1;
                $(this).attr('data-id', show_id);
                if (show_id > 3) {
                    show_id = 1;
                    $(this).attr('data-id', show_id);
                }
                $('.reduce_info').hide();
                $('.list_' + show_id).show();
            });
        }
   });
});
</script>

 

posted @ 2018-01-05 13:03  邹柯  阅读(332)  评论(0编辑  收藏  举报