Storejoin.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. namespace app\admin\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 Storejoin extends AdminControl {
  18. public function initialize() {
  19. parent::initialize(); // TODO: Change the autogenerated stub
  20. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/storejoin.lang.php');
  21. }
  22. /**
  23. * 前台头部图片传
  24. */
  25. public function index() {
  26. $size = 3; //上传显示图片总数
  27. $i = 1;
  28. $info['pic'] = array();
  29. $info['show_txt'] = '';
  30. $config_model = model('config');
  31. $list_config = rkcache('config', true);
  32. $code_info = $list_config['store_joinin_pic'];
  33. if (!empty($code_info)) {
  34. $info = unserialize($code_info);
  35. }
  36. $post = input('post.'); #获取POST 数据
  37. if (request()->isPost()) {
  38. $store_joinin_open = input('post.store_joinin_open');
  39. if (!in_array($store_joinin_open, array(0, 1, 2, 3))) {
  40. $this->error(lang('param_error'));
  41. }
  42. $info['show_txt'] = input('post.show_txt');
  43. for ($i; $i <= $size; $i++) {
  44. $file = 'pic' . $i;
  45. $info['pic'][$i] = $post['show_pic' . $i];
  46. if (!empty($_FILES[$file]['name'])) {//上传图片
  47. $filename_tmparr = explode('.', $_FILES[$file]['name']);
  48. $ext = end($filename_tmparr);
  49. $file_name = 'store_joinin_' . $i . '.' . $ext;
  50. $res = ds_upload_pic('admin/Storejion', $file, $file_name);
  51. if ($res['code']) {
  52. $file_name = $res['data']['file_name'];
  53. $info['pic'][$i] = $file_name;
  54. } else {
  55. $this->error($res['msg']);
  56. }
  57. }
  58. }
  59. $code_info = serialize($info);
  60. $update_array = array();
  61. $update_array['store_joinin_pic'] = $code_info;
  62. $update_array['store_joinin_open'] = $store_joinin_open;
  63. $config_model->editConfig($update_array);
  64. $this->success(lang('ds_common_save_succ'), 'Storejoin/index');
  65. }
  66. View::assign('store_joinin_open', $list_config['store_joinin_open']);
  67. View::assign('size', $size);
  68. View::assign('pic', $info['pic']);
  69. View::assign('show_txt', $info['show_txt']);
  70. $this->setAdminCurItem('index');
  71. return View::fetch();
  72. }
  73. /**
  74. * 入驻指南
  75. *
  76. */
  77. public function help_list() {
  78. $help_model = model('help');
  79. $condition = array();
  80. $condition[] = array('helptype_id', '=', '1');
  81. $help_list = $help_model->getStoreHelpList($condition);
  82. View::assign('help_list', $help_list);
  83. $this->setAdminCurItem('help_list');
  84. return View::fetch();
  85. }
  86. /**
  87. * 编辑入驻指南
  88. *
  89. */
  90. public function edit_help() {
  91. $help_model = model('help');
  92. $condition = array();
  93. $help_id = intval(input('param.help_id'));
  94. $condition[] = array('help_id', '=', $help_id);
  95. $help_list = $help_model->getStoreHelpList($condition);
  96. $help = $help_list[0];
  97. $help['help_info'] = str_replace("\r\n", "", $help['help_info']);
  98. View::assign('help', $help);
  99. if (request()->isPost()) {
  100. $help_array = array();
  101. $help_array['help_title'] = input('post.help_title');
  102. $help_array['help_info'] = input('post.help_info');
  103. $help_array['help_sort'] = intval(input('post.help_sort'));
  104. $help_array['help_updatetime'] = TIMESTAMP;
  105. $state = $help_model->editHelp($condition, $help_array);
  106. if ($state) {
  107. $this->log('编辑店铺入驻指南,编号' . $help_id);
  108. $this->success(lang('ds_common_save_succ'), 'storejoin/help_list');
  109. } else {
  110. $this->error(lang('ds_common_save_fail'));
  111. }
  112. }
  113. $condition = array();
  114. $condition[] = array('item_id', '=', $help_id);
  115. $pic_list = $help_model->getHelpPicList($condition);
  116. View::assign('pic_list', $pic_list);
  117. $this->setAdminCurItem('edit');
  118. return View::fetch();
  119. }
  120. /**
  121. * 上传图片
  122. */
  123. public function upload_pic() {
  124. $data = array();
  125. if (!empty($_FILES['fileupload']['name'])) {//上传图片
  126. $fprefix = 'admin/storehelp';
  127. $res = ds_upload_pic($fprefix, 'fileupload');
  128. if ($res['code']) {
  129. $file_name = $res['data']['file_name'];
  130. } else {
  131. echo json_encode($data);
  132. exit;
  133. }
  134. $upload_model = model('upload');
  135. $insert_array = array();
  136. $insert_array['file_name'] = $file_name;
  137. $insert_array['file_size'] = $_FILES['fileupload']['size'];
  138. $insert_array['upload_time'] = TIMESTAMP;
  139. $insert_array['item_id'] = intval(input('param.item_id'));
  140. $insert_array['upload_type'] = '2';
  141. $result = $upload_model->addUpload($insert_array);
  142. if ($result) {
  143. $data['file_id'] = $result;
  144. $data['file_name'] = $file_name;
  145. $data['file_path'] = ds_get_pic( $fprefix , $file_name);
  146. }
  147. }
  148. echo json_encode($data);
  149. exit;
  150. }
  151. /**
  152. * 删除图片
  153. */
  154. public function del_pic() {
  155. $condition = array();
  156. $condition[] = array('upload_id', '=', intval(input('param.file_id')));
  157. $help_model = model('help');
  158. $state = $help_model->delHelpPic($condition);
  159. if ($state) {
  160. echo 'true';
  161. exit;
  162. } else {
  163. echo 'false';
  164. exit;
  165. }
  166. }
  167. protected function getAdminItemList() {
  168. $menu_array = array(
  169. array(
  170. 'name' => 'index', 'text' => lang('image_and_notice'), 'url' => (string) url('Storejoin/index')
  171. ), array(
  172. 'name' => 'help_list', 'text' => lang('joinin_guide'), 'url' => (string) url('Storejoin/help_list')
  173. )
  174. );
  175. if (request()->action() == 'edit_help') {
  176. $menu_array[] = array('name' => 'edit', 'text' => lang('edit_content'), 'url' => 'javascript:void(0)');
  177. }
  178. return $menu_array;
  179. }
  180. }