Flea.php 4.3 KB

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