Flea.php 9.7 KB

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