Goodsalbum.php 6.0 KB

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