Flea.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. *
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * 控制器
  11. */
  12. class Flea extends AdminControl
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize(); // TODO: Change the autogenerated stub
  17. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/flea.lang.php');
  18. if (config('ds_config.flea_isuse') != 1) {
  19. $this->error(lang('flea_index_unable'), 'dashboard/welcome');
  20. }
  21. }
  22. /**
  23. * 商品管理
  24. */
  25. public function flea()
  26. {
  27. $flea_model = model('flea');
  28. /**
  29. * 排序
  30. */
  31. $special_condition = array();
  32. $keyword = trim(input('param.search_goods_name'));
  33. if ($keyword) {
  34. $special_condition['keyword'] = $keyword;
  35. }
  36. $like_member_name = trim(input('param.search_store_name'));
  37. if ($like_member_name) {
  38. $special_condition['like_member_name'] = $like_member_name; //店铺名称
  39. }
  40. $search_brand_id = intval(input('param.search_brand_id'));
  41. if ($search_brand_id) {
  42. $special_condition['brand_id'] = $search_brand_id;
  43. }
  44. $cate_id = intval(input('param.cate_id'));
  45. if ($cate_id) {
  46. $special_condition['fleaclass_id'] = $cate_id;
  47. }
  48. /**
  49. * 分页
  50. */
  51. $goods_list = $flea_model->getFleaList($special_condition, 10);
  52. if (is_array($goods_list) and !empty($goods_list)) {
  53. foreach ($goods_list as $key => $val) {
  54. $goods_list[$key]['goods_image'] = $goods_list[$key]['goods_image'] == '' ? '' : ds_get_pic(ATTACH_MFLEA . '/' . $val['member_id'], str_replace('_1024', '_240', $val['goods_image']));
  55. }
  56. }
  57. /**
  58. * 商品类别
  59. */
  60. /**
  61. * 商品分类
  62. */
  63. $fleaclass_model = model('fleaclass');
  64. $goods_class = $fleaclass_model->getTreeClassList(1);
  65. View::assign('goods_class', $goods_class);
  66. View::assign('goods_list', $goods_list);
  67. View::assign('show_page', $flea_model->page_info->render());
  68. View::assign('filtered', $special_condition ? 1 : 0); //是否有查询条件
  69. $this->setAdminCurItem('index');
  70. return View::fetch('index');
  71. }
  72. /**
  73. * 闲置商品删除
  74. */
  75. public function del()
  76. {
  77. $del_id = input('param.del_id');
  78. $del_id_array = ds_delete_param($del_id);
  79. if ($del_id_array == FALSE) {
  80. ds_json_encode('10001', lang('goods_index_argument_invalid'));
  81. }
  82. $flea_model = model('flea');
  83. $result = $flea_model->delFlea($del_id_array);
  84. if ($result) {
  85. ds_json_encode('10000', lang('goods_index_del_succ'));
  86. } else {
  87. ds_json_encode('10001', lang('goods_index_choose_del'));
  88. }
  89. }
  90. /**
  91. * ajax操作
  92. */
  93. public function ajax()
  94. {
  95. $branch = input('get.branch');
  96. $column = input('get.column');
  97. $value = trim(input('get.value'));
  98. $id = intval(input('get.id'));
  99. switch ($branch) {
  100. /**
  101. * 商品名称
  102. */
  103. case 'goods_name':
  104. $flea_model = model('flea');
  105. $update_array = array();
  106. $update_array[$column] = $value;
  107. $flea_model->editFlea($update_array, array('goods_id' => $id));
  108. echo 'true';
  109. exit;
  110. break;
  111. }
  112. }
  113. protected function getAdminItemList()
  114. {
  115. $menu_array = array(
  116. array(
  117. 'name' => 'index', 'text' => lang('flea_all_ldle'), 'url' => (string)url('Flea/flea')
  118. ),
  119. );
  120. return $menu_array;
  121. }
  122. }