function _xt_widget_grid_tuan($args, $instance) { extract($args); $title = !isset($instance['title']) || empty($instance['title']) ? '' : $instance['title']; $size = isset($instance['size']) ? $instance['size'] : ''; $page_no = isset($instance['page']) ? intval($instance['page']) : 1; $page_size = isset($instance['row']) ? intval($instance['row']) * xt_size($layout, $size) : (isset($instance['pagesize']) ? intval($instance['pagesize']) : 10); $tuan = $instance['tuan']; $tuan_keyword = $tuan['keyword']; $tuan_category_id = intval($tuan['catid']); $tuan_city_id = intval($tuan['city_id']); $tuan_price = $tuan['price']; $tuan_order = $tuan['orderby']; $tuan_display = isset($tuan['display']) ? $tuan['display'] : array('title', 'price', 'volume', 'seller'); $params = array('page_no' => $page_no, 'page_size' => $page_size, 'keyword' => $tuan_keyword, 'catid' => $tuan_category_id, 'city_id' => $tuan_city_id, 'price' => $tuan_price, 'orderby' => $tuan_order); $_items = xt_yiqifa_api_tuan_search($params); if ($layout == 'span3' && $size == 'small') { echo str_replace('clearfix', ' xt-widget-recommend-side clearfix', $before_widget); } else { echo $before_widget; } if (is_wp_error($_items)) { xt_api_error($_items); } else { $__params = array('total' => $_items['total'], 'size' => $size, 'count' => $page_size, 'title' => $title, 'items' => $_items['tuan_list']['tuan'], 'type' => 'tuan', 'display' => $tuan_display, 'params' => $params, 'urlType' => isset($instance['urlType']) ? $instance['urlType'] : 'direct'); if ($layout == 'span3' && $size == 'small') { xt_widget_template_grid_sidesmall($__params); } else { xt_widget_template_grid($__params); } } echo $after_widget; }
function widget($args, $instance) { extract($args); global $wp_query, $xt; if ($xt->is_shops) { echo $before_widget; $xt_shops_param = $wp_query->query_vars['xt_param']; $xt_shops_param['page_size'] = absint($instance['count']); $results = xt_taobaoke_shops_search($xt_shops_param); if (is_wp_error($results)) { xt_api_error($results); } else { $shops = $results['shops']; $total = $results['total']; $filterType = 0; if ($xt_shops_param['only_mall']) { $filterType = 1; } elseif ($xt_shops_param['start_credit'] == 16 && $xt_shops_param['end_credit'] == 20) { $filterType = 2; } elseif ($xt_shops_param['start_credit'] == 11 && $xt_shops_param['end_credit'] == 15) { $filterType = 3; } $page = $xt_shops_param['page_no']; $prev_url = $next_url = ''; if ($page > 1) { $prev_url = xt_get_shop_search_url(array_merge($xt_shops_param, array('page_no' => $page - 1))); } if ($page < $total) { $next_url = xt_get_shop_search_url(array_merge($xt_shops_param, array('page_no' => $page + 1))); } $base = xt_get_shop_search_url(array_merge($xt_shops_param, array('page_no' => '%#%'))); $pager_top = xt_search_pager_top($prev_url, $next_url, $page, $xt_shops_param['page_size'], $total); $pager_bottom = xt_search_pager_bottom($base, $page, $xt_shops_param['page_size'], $total); echo '<div class="hd">'; xt_output_breadcrumbs(true, array('name' => $total . '个店铺', 'url' => ''), false, $pager_top); echo '</div>'; $isFanxian = xt_is_fanxian(); $urlType = isset($instance['urlType']) ? $instance['urlType'] : 'direct'; ?> <div class="bd" style="padding-top: 10px;"> <div class="xt-filter-box xt-shop-filter form-inline"> <label>关键词:</label> <input id="X_Shop-Filter-Keyword" type="text" class="input-small" value="<?php echo esc_attr($xt_shops_param['keyword']); ?> "> <select id="X_Shop-Filter-Start-Credit" style="width:80px"> <option value="">等级</option> <option value="1">一心</option> <option value="2">两心</option> <option value="3">三心</option> <option value="4">四心</option> <option value="5">五心</option> <option value="6">一钻</option> <option value="7">两钻</option> <option value="8">三钻</option> <option value="9">四钻</option> <option value="10">五钻</option> <option value="11">一皇冠</option> <option value="12">两皇冠</option> <option value="13">三皇冠</option> <option value="14">四皇冠</option> <option value="15">五皇冠</option> <option value="16">一金冠</option> <option value="17">两金冠</option> <option value="18">三金冠</option> <option value="19">四金冠</option> <option value="20">五金冠</option> </select> -- <select id="X_Shop-Filter-End-Credit" style="width:80px"> <option value="">等级</option> <option value="1">一心</option> <option value="2">两心</option> <option value="3">三心</option> <option value="4">四心</option> <option value="5">五心</option> <option value="6">一钻</option> <option value="7">两钻</option> <option value="8">三钻</option> <option value="9">四钻</option> <option value="10">五钻</option> <option value="11">一皇冠</option> <option value="12">两皇冠</option> <option value="13">三皇冠</option> <option value="14">四皇冠</option> <option value="15">五皇冠</option> <option value="16">一金冠</option> <option value="17">两金冠</option> <option value="18">三金冠</option> <option value="19">四金冠</option> <option value="20">五金冠</option> </select> <button id="X_Shop-Filter-Btn" class="btn btn-small btn-primary" data-url="<?php echo xt_get_shop_search_url(array('keyword' => 'SEARCH', 'start_credit' => 'START', 'end_credit' => 'END')); ?> " data-loading-text="搜索中...">搜索</button> </div> <div class="xt-filter-tab clearfix"> <ul> <li class="<?php echo $filterType == 0 ? 'active' : ''; ?> "><a href="<?php echo xt_get_shop_search_url(); ?> ">所有店铺</a></li> <li class="<?php echo $filterType == 1 ? 'active' : ''; ?> "><a href="<?php echo xt_get_shop_search_url(array('cid' => $xt_shops_param['cid'], 'only_mall' => 1, 'keyword' => $xt_shops_param['keyword'])); ?> ">天猫商城</a></li> <li class="<?php echo $filterType == 2 ? 'active' : ''; ?> "><a href="<?php echo xt_get_shop_search_url(array('cid' => $xt_shops_param['cid'], 'start_credit' => 16, 'end_credit' => 20, 'keyword' => $xt_shops_param['keyword'])); ?> ">至尊店铺</a></li> <li class="xt-last <?php echo $filterType == 3 ? 'active' : ''; ?> "><a href="<?php echo xt_get_shop_search_url(array('cid' => $xt_shops_param['cid'], 'start_credit' => 11, 'end_credit' => 15, 'keyword' => $xt_shops_param['keyword'])); ?> ">皇冠店铺</a></li> </ul> </div> <div class="row-fluid clearfix"> <?php foreach ($shops as $shop) { $click_url = $shop->click_url; if ($urlType == 'jump') { $click_url = xt_jump_url(array('title' => $shop->shop_title, 'url' => $click_url)); } ?> <div class="span6"> <div class="media"> <div class="pull-left"> <a rel="nofollow" data-type="1" data-sellerid="<?php echo $shop->user_id; ?> " data-rd="1" data-style="2" data-tmpl="140x190"></a> </div> <div class="media-body"> <h5 class="media-heading"><a rel="nofollow" href="<?php echo $click_url; ?> " target="_blank"><?php echo $shop->shop_title; ?> </a></h5> <ul class="unstyled"> <li>店铺掌柜:<?php echo $shop->seller_nick; ?> </li> <li>信用等级:<i class="rank seller-rank-<?php echo $shop->seller_credit; ?> "></i></li> <li>累计销量:<?php echo $shop->total_auction; ?> </li> <li>宝贝数量:<?php echo $shop->auction_count; ?> </li> <?php if ($isFanxian) { ?> <li>平均返现:<strong class="text-default"><?php echo $shop->commission_rate; ?> %</strong></li><?php } ?> </ul> </div> </div> </div> <?php } ?> </div> <?php if (!empty($pager_bottom)) { echo '<div id="X_Pagination-Bottom" class="clearfix">'; echo '<div class="pagination pagination-large xt-pagination-links">'; echo $pager_bottom; echo '</div>'; echo '</div>'; } echo '</div>'; } echo $after_widget; ?> <script> jQuery(function($){ $('#X_Shop-Filter-Start-Credit').val(<?php echo $xt_shops_param['start_credit']; ?> ); $('#X_Shop-Filter-End-Credit').val(<?php echo $xt_shops_param['end_credit']; ?> ) $('.xt-widget-system-shops .span6').hover(function(){ $(this).addClass('hover').siblings().removeClass('hover'); },function(){ $(this).removeClass('hover'); }); $('#X_Shop-Filter-Btn').click(function(){ var url = ($(this).attr('data-url')); var self=$(this); if(url){ try{ var keyword = $('#X_Shop-Filter-Keyword').val(); var start_credit = $('#X_Shop-Filter-Start-Credit').val(); var end_credit = $('#X_Shop-Filter-End-Credit').val(); if(start_credit&&end_credit){ if(parseInt(end_credit)<parseInt(start_credit)){ alert('结束信用等级不能小于开始信用等级'); return false; } } self.button('loading'); url = url.replace('SEARCH',encodeURIComponent(keyword)).replace('START',start_credit).replace('END',end_credit); document.location.href = url; }catch(e){ $(this).button('reset'); } } }); }) </script> <?php } }