function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        $websites = xt_yiqifa_hotactivity_website();
        $activities = xt_yiqifa_hotactivity();
        ?>
        <ul class="nav nav-pills">
            <?php 
        if (!empty($websites)) {
            foreach ($websites as $website) {
                ?>
                    <li><a href="javascript:;" data-value="<?php 
                echo $website['web_id'];
                ?>
"><?php 
                echo $website['web_name'];
                ?>
</a></li>
                    <?php 
            }
        }
        ?>

        </ul>
        <?php 
        if (!empty($activities)) {
            foreach ($activities as $key => $acts) {
                if (!empty($acts)) {
                    echo '<ul class="thumbnails hide" data-value="' . $key . '" style="text-align:center;">';
                    foreach ($acts as $act) {
                        ?>
                        <li class="span6">
                            <a href="<?php 
                        echo $act['hot_o_url'];
                        ?>
" target="_blank" class="thumbnail text-gray">
                                <img src="<?php 
                        echo $act['pic_url'];
                        ?>
" alt="<?php 
                        echo $act['hot_name'];
                        ?>
">
                                <h4>
                                    <?php 
                        if (!empty($act['discount'])) {
                            echo '<span class="text-default">' . str_replace('折', '', $act['discount']) . '折</span>&nbsp;&nbsp;&nbsp;';
                        }
                        echo $act['hot_name'];
                        ?>
                                </h4>
                                <p>
                                    <?php 
                        if (!empty($act['begin_date']) && !empty($act['end_date'])) {
                            echo $act['begin_date'] . '&nbsp;&nbsp;-&nbsp;&nbsp;' . $act['end_date'];
                        } elseif (!empty($act['begin_date']) && empty($act['end_date'])) {
                            echo $act['begin_date'] . '开始';
                        } elseif (empty($act['begin_date']) && !empty($act['end_date'])) {
                            echo $act['end_date'] . '结束';
                        }
                        ?>
                                </p>
                            </a>
                        </li>
                        <?php 
                    }
                    echo '</ul>';
                }
            }
        }
        echo $after_widget;
        ?>
        <script>
            jQuery(function($){
                $('#<?php 
        echo $widget_id;
        ?>
').find('.nav a').click(function(){
                    var id = $(this).attr('data-value');
                    $(this).parent().addClass('active').siblings().removeClass('active');
                    $('#<?php 
        echo $widget_id;
        ?>
 .thumbnails').each(function(){
                        if($(this).attr('data-value')==id){
                            $(this).removeClass('hide');
                        }else{
                            $(this).addClass('hide');
                        }
                    });
                });
                $('#<?php 
        echo $widget_id;
        ?>
').find('.nav a:first').click();
            })
        </script>
        <?php 
    }
Example #2
0
function xt_cron_yiqifa_hotactivity()
{
    xt_yiqifa_hotactivity_website(true);
    xt_yiqifa_hotactivity(true);
}