Flea.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Flea extends BaseFlea {
  17. public function initialize() {
  18. parent::initialize(); // TODO: Change the autogenerated stub
  19. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/flea.lang.php');
  20. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/fleacommon.lang.php');
  21. }
  22. /**
  23. * 闲置市场首页
  24. */
  25. public function index() {
  26. /**
  27. * 地区
  28. */
  29. $fleaarea_model = model('fleaarea');
  30. $area_array = $fleaarea_model->fleaarea_show();
  31. View::assign('area_one_level', $area_array['area_one_level']);
  32. View::assign('area_two_level', $area_array['area_two_level']);
  33. /**
  34. * 分类
  35. */
  36. $fleaclass_model = model('fleaclass');
  37. $goods_class = $fleaclass_model->getTreeClassList(3, array('fleaclass_show' => 1));
  38. if (is_array($goods_class) and !empty($goods_class)) {
  39. $show_goods_class = array();
  40. $arr = array();
  41. foreach ($goods_class as $val) {
  42. if ($val['fleaclass_parent_id'] == 0) {
  43. $show_goods_class[$val['fleaclass_id']]['class_name'] = $val['fleaclass_name'];
  44. $show_goods_class[$val['fleaclass_id']]['class_id'] = $val['fleaclass_id'];
  45. $show_goods_class[$val['fleaclass_id']]['fleaclass_index_show'] = $val['fleaclass_index_show'];
  46. $arr[$val['fleaclass_id']]['class_name'] = $val['fleaclass_name'];
  47. $arr[$val['fleaclass_id']]['class_id'] = $val['fleaclass_id'];
  48. if (!isset($arr[$val['fleaclass_id']]['fleaclass_id_str'])) {
  49. $arr[$val['fleaclass_id']]['fleaclass_id_str'] = '';
  50. }
  51. $arr[$val['fleaclass_id']]['fleaclass_id_str'] .= ',' . $val['fleaclass_id'];
  52. } else {
  53. if (isset($show_goods_class[$val['fleaclass_parent_id']])) {
  54. $show_goods_class[$val['fleaclass_parent_id']]['sub_class'][$val['fleaclass_id']]['class_name'] = $val['fleaclass_name'];
  55. $show_goods_class[$val['fleaclass_parent_id']]['sub_class'][$val['fleaclass_id']]['class_id'] = $val['fleaclass_id'];
  56. $show_goods_class[$val['fleaclass_parent_id']]['sub_class'][$val['fleaclass_id']]['fleaclass_parent_id'] = $val['fleaclass_parent_id'];
  57. $show_goods_class[$val['fleaclass_parent_id']]['sub_class'][$val['fleaclass_id']]['fleaclass_index_show'] = $val['fleaclass_index_show'];
  58. $arr[$val['fleaclass_parent_id']]['sub_class'][$val['fleaclass_id']]['class_name'] = $val['fleaclass_name'];
  59. $arr[$val['fleaclass_parent_id']]['sub_class'][$val['fleaclass_id']]['class_id'] = $val['fleaclass_id'];
  60. $arr[$val['fleaclass_parent_id']]['fleaclass_id_str'] .= ',' . $val['fleaclass_id'];
  61. } else {
  62. foreach ($show_goods_class as $v) {
  63. if (isset($v['sub_class'][$val['fleaclass_parent_id']])) {
  64. $show_goods_class[$v['sub_class'][$val['fleaclass_parent_id']]['fleaclass_parent_id']]['sub_class'][$val['fleaclass_parent_id']]['sub_class'][$val['fleaclass_id']]['class_name'] = $val['fleaclass_name'];
  65. $show_goods_class[$v['sub_class'][$val['fleaclass_parent_id']]['fleaclass_parent_id']]['sub_class'][$val['fleaclass_parent_id']]['sub_class'][$val['fleaclass_id']]['class_id'] = $val['fleaclass_id'];
  66. $arr[$v['sub_class'][$val['fleaclass_parent_id']]['fleaclass_parent_id']]['fleaclass_id_str'] .= ',' . $val['fleaclass_id'];
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
  73. $new_arr = array();
  74. $flea_model = model('flea');
  75. $condition = array();
  76. $condition[]=array('flea.goods_image','<>','');
  77. if (isset($arr) && !empty($arr)) {
  78. foreach ($arr as $key => $value) {
  79. if (isset($new_arr[4]) && is_array($new_arr[4]) && !empty($new_arr[4]))
  80. break; //只取前5条分类下有的商品
  81. $condition[]=array('flea.fleaclass_id','in',$value['fleaclass_id_str']);
  82. $arr[$key]['goods'] = $flea_model->getFleaByClass($condition,'goods_id,goods_name,goods_store_price,flea_quality,member_id,goods_image','goods_id desc',14);
  83. if (is_array($arr[$key]['goods']) && !empty($arr[$key]['goods']))
  84. $new_arr[] = $arr[$key];
  85. }
  86. }
  87. View::assign('show_flea_goods_class_list', $new_arr);
  88. /**
  89. * js滑动参数
  90. */
  91. $str = '';
  92. $str1 = '';
  93. for ($j = 1; $j <= count($new_arr); $j++) {
  94. $str .= '"m0' . $j . '"' . ',';
  95. $str1 .= '"c0' . $j . '"' . ',';
  96. }
  97. $str = rtrim($str, ",");
  98. $str1 = rtrim($str1, ",");
  99. View::assign('mstr', $str);
  100. View::assign('cstr', $str1);
  101. /**
  102. * 新鲜货
  103. */
  104. $condition = array();
  105. $condition[]=array('goods_image','<>','');
  106. $condition[]=array('goods_body','<>','');
  107. $new_flea_goods = $flea_model->getOneFlea($condition);
  108. View::assign('new_flea_goods', $new_flea_goods);
  109. /**
  110. * 收藏第一
  111. */
  112. $condition = array();
  113. $condition[]=array('goods_image','<>','');
  114. $col_flea_goods = $flea_model->getOneFlea($condition);
  115. View::assign('col_flea_goods', $col_flea_goods);
  116. /**
  117. * 热门搜
  118. */
  119. $new_flea_goods2 = $flea_model->getFleaList(array('pic_input' => '2'),'','*','goods_click desc',14);
  120. View::assign('new_flea_goods2', $new_flea_goods2);
  121. /**
  122. * 闲置围观区
  123. */
  124. $new_flea_goods3 = $flea_model->getFleaList(array('pic_input' => '2'),'','*','goods_id desc',14);
  125. View::assign('new_flea_goods3', $new_flea_goods3);
  126. /**
  127. * 导航标识
  128. */
  129. View::assign('index_sign', 'flea');
  130. // 首页幻灯
  131. $loginpic = unserialize(config('ds_config.flea_loginpic'));
  132. View::assign('loginpic', $loginpic);
  133. /**
  134. * 广告图
  135. */
  136. $result = false;
  137. $condition = array();
  138. $condition_1 = array();
  139. $condition_2 = array();
  140. $condition_3 = array();
  141. $condition_4 = array();
  142. $condition_5 = array();
  143. $condition_1[] = ['ap_id', '=', 16];
  144. $condition_2[] = ['ap_id', '=', 17];
  145. $condition_3[] = ['ap_id', '=', 18];
  146. $condition_4[] = ['ap_id', '=', 19];
  147. $condition_5[] = ['ap_id', '=', 20];
  148. $condition[] = ['adv_enabled', '=', 1];
  149. $condition[] = ['adv_startdate', '<', strtotime(date('Y-m-d H:00:00'))];
  150. $condition[] = ['adv_enddate', '>', strtotime(date('Y-m-d H:00:00'))];
  151. $adv_list = model('adv')->getAdvList(array_merge($condition,$condition_1), '', 10, 'adv_sort asc,adv_id asc');
  152. if (!empty($adv_list)) {
  153. $result = $adv_list;
  154. }
  155. $adv_four=array();
  156. $adv_list = model('adv')->getAdvList(array_merge($condition,$condition_2), '', 1, 'adv_sort asc,adv_id asc');
  157. if (!empty($adv_list)) {
  158. $adv_four[] = $adv_list[0];
  159. }
  160. $adv_list = model('adv')->getAdvList(array_merge($condition,$condition_3), '', 1, 'adv_sort asc,adv_id asc');
  161. if (!empty($adv_list)) {
  162. $adv_four[] = $adv_list[0];
  163. }
  164. $adv_list = model('adv')->getAdvList(array_merge($condition,$condition_4), '', 1, 'adv_sort asc,adv_id asc');
  165. if (!empty($adv_list)) {
  166. $adv_four[] = $adv_list[0];
  167. }
  168. $adv_list = model('adv')->getAdvList(array_merge($condition,$condition_5), '', 1, 'adv_sort asc,adv_id asc');
  169. if (!empty($adv_list)) {
  170. $adv_four[] = $adv_list[0];
  171. }
  172. View::assign('adv_slide', $result);
  173. View::assign('adv_four', $adv_four);
  174. /**
  175. * 获取设置信息
  176. */
  177. $fleaclass_model = model('fleaclass');
  178. $fc_index = $fleaclass_model->getFleaclassindex(array());
  179. if (!empty($fc_index) && is_array($fc_index)) {
  180. foreach ($fc_index as $value) {
  181. View::assign($value['fcindex_code'], $value);
  182. }
  183. }
  184. //SEO 设置
  185. $seo = array(
  186. 'html_title'=>config('ds_config.flea_site_title'),
  187. 'seo_keywords'=>config('ds_config.flea_site_keywords'),
  188. 'seo_description'=>config('ds_config.flea_site_description'),
  189. );
  190. $this->_assign_seo($seo);
  191. return View::fetch($this->template_dir . 'flea_index');
  192. }
  193. }