Goodsalbum.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /*
  3. * 空间管理
  4. */
  5. namespace app\admin\controller;
  6. use think\facade\View;
  7. use think\facade\Lang;
  8. /**
  9. * ============================================================================
  10. *
  11. * ============================================================================
  12. *
  13. * ----------------------------------------------------------------------------
  14. *
  15. * ============================================================================
  16. * 控制器
  17. */
  18. class Goodsalbum extends AdminControl {
  19. public function initialize() {
  20. parent::initialize();
  21. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/goodsalbum.lang.php');
  22. }
  23. /**
  24. * 相册列表
  25. */
  26. public function index() {
  27. $condition = array();
  28. $store_name = '';
  29. if (is_numeric(input('param.keyword'))) {
  30. $store_id = intval(input('param.keyword'));
  31. $condition[] = array('s.store_id','=',$store_id);
  32. $store_name = ds_getvalue_byname('store', 'store_id', $store_id, 'store_name');
  33. } elseif (!empty(input('param.keyword'))) {
  34. $store_name = input('param.keyword');
  35. $store_id = ds_getvalue_byname('store', 'store_name', $store_name, 'store_id');
  36. if (is_numeric($store_id)) {
  37. $condition[] = array('s.store_id','=',$store_id);
  38. } else {
  39. $condition[] = array('s.store_id','=',0);
  40. }
  41. }
  42. $goodsalbum_model = model('album');
  43. $albumclass_list = $goodsalbum_model->getGoodsalbumList($condition,10,'a.*,s.store_name');
  44. View::assign('show_page', $goodsalbum_model->page_info->render());
  45. if (is_array($albumclass_list) && !empty($albumclass_list)) {
  46. foreach ($albumclass_list as $v) {
  47. $class[] = $v['aclass_id'];
  48. }
  49. $where=array();
  50. $where[]=array('aclass_id','in',$class);
  51. } else {
  52. $where = '1=1';
  53. }
  54. $count = $goodsalbum_model->getAlbumpicCountlist($where,'aclass_id,count(*) as pcount','aclass_id');
  55. $pic_count = array();
  56. if (is_array($count)) {
  57. foreach ($count as $v) {
  58. $pic_count[$v['aclass_id']] = $v['pcount'];
  59. }
  60. }
  61. View::assign('pic_count', $pic_count);
  62. View::assign('albumclass_list', $albumclass_list);
  63. View::assign('store_name', $store_name);
  64. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  65. $this->setAdminCurItem('index');
  66. return View::fetch();
  67. }
  68. /**
  69. * 图片列表
  70. */
  71. public function pic_list() {
  72. $condition = array();
  73. $store_name = '';
  74. if (is_numeric(input('param.keyword'))) {
  75. $store_id = intval(input('param.keyword'));
  76. $condition[] = array('store_id','=',$store_id);
  77. $store_name = ds_getvalue_byname('store','store_id',$store_id,'store_name');
  78. } elseif ((input('param.keyword'))) {
  79. $store_name = input('param.keyword');
  80. $store_id = ds_getvalue_byname('store','store_name',$store_name,'store_id');
  81. if (is_numeric($store_id)) {
  82. $condition[] = array('store_id','=',$store_id);
  83. } else {
  84. $condition[] = array('store_id','=',0);
  85. }
  86. } elseif (is_numeric(input('param.aclass_id'))) {
  87. $condition[] = array('aclass_id','=',input('param.aclass_id'));
  88. }
  89. $albumpic_model = model('album');
  90. $albumpic_list = $albumpic_model->getAlbumpicList($condition,34,'','apic_id desc');
  91. //halt($albumpic_list);
  92. $show_page = $albumpic_model->page_info->render();
  93. View::assign('show_page', $show_page);
  94. View::assign('albumpic_list', $albumpic_list);
  95. View::assign('store_name', $store_name);
  96. $this->setAdminCurItem('pic_list');
  97. return View::fetch();
  98. }
  99. /**
  100. * 删除相册
  101. */
  102. public function aclass_del() {
  103. $aclass_id = input('param.aclass_id');
  104. $aclass_id_array = ds_delete_param($aclass_id);
  105. if ($aclass_id_array == FALSE) {
  106. ds_json_encode('10001', lang('param_error'));
  107. }
  108. $condition=array();
  109. $condition[]=array('aclass_id','in',$aclass_id_array);
  110. $albumpic_model = model('album');
  111. //批量删除相册图片
  112. $albumpic_model->delAlbumpic($condition);
  113. $albumpic_model->delAlbumclass($condition);
  114. $this->log(lang('ds_del') . lang('g_album_one') . '[ID:' . intval(input('param.aclass_id')) . ']', 1);
  115. ds_json_encode('10000', lang('ds_common_del_succ'));
  116. }
  117. /**
  118. * 删除一张图片及其对应记录
  119. *
  120. */
  121. public function del_album_pic() {
  122. $apic_id = input('param.apic_id');
  123. $apic_id_array = ds_delete_param($apic_id);
  124. if ($apic_id_array === FALSE) {
  125. ds_json_encode('10001', lang('param_error'));
  126. }
  127. $condition=array();
  128. $condition[]=array('apic_id','in',$apic_id_array);
  129. $albumpic_model = model('album');
  130. //批量删除相册图片
  131. $albumpic_model->delAlbumpic($condition);
  132. $this->log(lang('ds_del') . lang('g_album_pic_one') . '[ID:' . $apic_id . ']', 1);
  133. ds_json_encode('10000', lang('ds_common_op_succ'));
  134. }
  135. protected function getAdminItemList() {
  136. $menu_array = array(
  137. array(
  138. 'name' => 'index',
  139. 'text' => lang('g_album_list'),
  140. 'url' => (string)url('Goodsalbum/index')
  141. ),
  142. array(
  143. 'name' => 'pic_list',
  144. 'text' => lang('g_album_pic_list'),
  145. 'url' => (string)url('Goodsalbum/pic_list')
  146. ),
  147. );
  148. return $menu_array;
  149. }
  150. }