index.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. /**
  3. * FecShop file.
  4. *
  5. * @link http://www.fecshop.com/
  6. * @copyright Copyright (c) 2016 FecShop Software LLC
  7. * @license http://www.fecshop.com/license/
  8. */
  9. ?>
  10. <div class="content">
  11. <div class="content-block">
  12. <?= Yii::$service->page->widget->render('breadcrumbs',$this); ?>
  13. <div class="category_page">
  14. <div class="category_img">
  15. <a href="#">
  16. <?= $image ? '<img style="width:100%;" src="'.$image.'"/>' : '';?>
  17. <a>
  18. </div>
  19. <div class="category_description" >
  20. <h1><?= $name ?></h1>
  21. <?= $description ?>
  22. </div>
  23. <div class="sort_filter">
  24. <a href="#" class="category-open open-filter">Filter &nbsp;<span class="icon icon-caret"></span></a>
  25. <div class="clear"></div>
  26. </div>
  27. <div >
  28. <!-- 添加 class infinite-scroll 和 data-distance 向下无限滚动可不加infinite-scroll-bottom类,这里加上是为了和下面的向上无限滚动区分-->
  29. <div class=" infinite-scroll infinite-scroll-bottom" data-distance="10">
  30. <div class="list-block">
  31. <div class="list-container">
  32. <?php if(is_array($products) && !empty($products)): ?>
  33. <?php
  34. $parentThis['products'] = $products;
  35. $config = [
  36. 'view' => 'cms/home/index/product.php',
  37. ];
  38. echo Yii::$service->page->widget->renderContent('category_product_price',$config,$parentThis);
  39. ?>
  40. <?php else: ?>
  41. <?= Yii::$service->page->translate->__('Search results for \'{searchText}\' returns no results',['searchText' => $searchText]); ?>
  42. <?php endif; ?>
  43. </div>
  44. <!-- 加载提示符 -->
  45. <div class="infinite-scroll-preloader">
  46. <div class="preloader"></div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="popup popup-filter">
  55. <div class="content-block">
  56. <div class="close_popup">
  57. <a href="#" class="close-popup">×</a></p>
  58. </div>
  59. <?php
  60. # Refind By
  61. $parentThis = [
  62. 'refine_by_info' => $refine_by_info,
  63. ];
  64. $config = [
  65. 'view' => 'catalog/category/index/filter/refineby.php',
  66. ];
  67. echo Yii::$service->page->widget->renderContent('category_product_filter_refine_by',$config,$parentThis);
  68. ?>
  69. <?php
  70. # Category Left Filter subCategory
  71. $parentThis = [
  72. 'filter_category' => $filter_category,
  73. 'current_category'=> $name,
  74. ];
  75. $config = [
  76. 'view' => 'catalog/category/index/filter/subcategory.php',
  77. ];
  78. echo Yii::$service->page->widget->renderContent('category_product_filter_sub_category',$config,$parentThis);
  79. ?>
  80. <?php
  81. # Category Left Filter Product Attributes
  82. $parentThis = [
  83. 'filters' => $filter_info,
  84. ];
  85. $config = [
  86. 'view' => 'catalog/category/index/filter/attr.php',
  87. ];
  88. echo Yii::$service->page->widget->renderContent('category_product_filter_attr',$config,$parentThis);
  89. ?>
  90. <?php
  91. # Category Left Filter Product Price
  92. $parentThis = [
  93. 'filter_price' => $filter_price,
  94. ];
  95. $config = [
  96. 'view' => 'catalog/category/index/filter/price.php',
  97. ];
  98. echo Yii::$service->page->widget->renderContent('category_product_filter_price',$config,$parentThis);
  99. ?>
  100. </div>
  101. </div>
  102. <script>
  103. <?php $this->beginBlock('category_product_filter') ?>
  104. $(document).ready(function(){
  105. $(".product_sort").change(function(){
  106. url = $(this).find('option').not(function() {return !this.selected}).attr('url');
  107. window.location.href = url;
  108. });
  109. $(".product_num_per_page").change(function(){
  110. //url = $(this).find("option:selected").attr('url');
  111. url = $(this).find('option').not(function() {return !this.selected}).attr('url');
  112. window.location.href = url;
  113. });
  114. $(".filter_attr_info a").click(function(){
  115. if($(this).hasClass("checked")){
  116. $(this).removeClass("checked");
  117. }else{
  118. $(this).parent().find("a.checked").removeClass("checked");
  119. $(this).addClass("checked");
  120. }
  121. });
  122. $("img.lazy").each(function(){
  123. src = $(this).attr("data-src");
  124. $(this).attr("src",src);
  125. });
  126. });
  127. $(document).on('click','.open-filter', function () {
  128. $.popup('.popup-filter');
  129. });
  130. $(document).on('click','.open-sort', function () {
  131. $.popup('.popup-sort');
  132. });
  133. $(document).on("pageInit", "#page-infinite-scroll-bottom", function(e, id, page) {
  134. var loading = false;
  135. var pageNum = 1;
  136. var maxPage = <?= $page_count ? $page_count : 1 ?>;
  137. if(maxPage <= pageNum){
  138. $('.infinite-scroll-preloader').remove();
  139. }
  140. function addItems() {
  141. //alert(pageNum);
  142. pageNum++;
  143. var html = '';
  144. url = window.location.href;
  145. $.ajax({
  146. async:true,
  147. timeout: 60000,
  148. dataType: 'json',
  149. type:'get',
  150. data: {
  151. 'p':pageNum
  152. },
  153. url: url,
  154. success:function(data, textStatus){
  155. //alert(data);
  156. html = data.html;
  157. //alert(html);
  158. $('.infinite-scroll .list-container').append(html);
  159. $("img.lazy").each(function(){
  160. src = $(this).attr("data-src");
  161. $(this).attr("src",src);
  162. });
  163. },
  164. error:function (XMLHttpRequest, textStatus, errorThrown){}
  165. });
  166. }
  167. $(page).on('infinite', function() {
  168. //alert(222);
  169. if (loading) return;
  170. loading = true;
  171. if (pageNum >= maxPage) {
  172. $.detachInfiniteScroll($('.infinite-scroll'));
  173. $('.infinite-scroll-preloader').remove();
  174. return;
  175. }
  176. addItems();
  177. //alert(pageNum);
  178. loading = false;
  179. $.refreshScroller();
  180. });
  181. });
  182. $.init();
  183. <?php $this->endBlock(); ?>
  184. </script>
  185. <?php $this->registerJs($this->blocks['category_product_filter'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
  186. <?= Yii::$service->page->trace->getTraceSearchJsCode($traceSearchData) ?>