store_joinin.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. /**
  3. * 店铺开店
  4. *
  5. *
  6. *
  7. ***/
  8. defined('InShopNC') or exit('Access Invalid!');
  9. class store_joininControl extends SystemControl{
  10. public function __construct(){
  11. parent::__construct();
  12. Language::read('setting');
  13. }
  14. /**
  15. * 前台头部图片传
  16. */
  17. public function edit_infoOp() {
  18. $size = 3;//上传显示图片总数
  19. $i = 1;
  20. $info['pic'] = array();
  21. $info['show_txt'] = '';
  22. $model_setting = Model('setting');
  23. $code_info = $model_setting->getRowSetting('store_joinin_pic');
  24. if(!empty($code_info['value'])) {
  25. $info = unserialize($code_info['value']);
  26. }
  27. if (chksubmit()) {
  28. $info['show_txt'] = $_POST['show_txt'];
  29. for ($i;$i <= $size;$i++) {
  30. $file = 'pic'.$i;
  31. $info['pic'][$i] = $_POST['show_pic'.$i];
  32. if (!empty($_FILES[$file]['name'])) {//上传图片
  33. $filename_tmparr = explode('.', $_FILES[$file]['name']);
  34. $ext = end($filename_tmparr);
  35. $file_name = 'store_joinin_'.$i.'.'.$ext;
  36. $upload = new UploadFile();
  37. $upload->set('default_dir',ATTACH_COMMON);
  38. $upload->set('file_name',$file_name);
  39. $result = $upload->upfile($file);
  40. if ($result) {
  41. $info['pic'][$i] = $file_name;
  42. }
  43. }
  44. }
  45. $code_info = serialize($info);
  46. $update_array = array();
  47. $update_array['store_joinin_pic'] = $code_info;
  48. $result = $model_setting->updateSetting($update_array);
  49. showMessage(Language::get('nc_common_save_succ'),'index.php?act=store_joinin&op=edit_info');
  50. }
  51. Tpl::output('size',$size);
  52. Tpl::output('pic',$info['pic']);
  53. Tpl::output('show_txt',$info['show_txt']);
  54. Tpl::showpage('store_joinin_pic');
  55. }
  56. /**
  57. * 入驻指南
  58. *
  59. */
  60. public function help_listOp() {
  61. $model_help = Model('help');
  62. $condition = array();
  63. $condition['type_id'] = '1';
  64. $help_list = $model_help->getStoreHelpList($condition);
  65. Tpl::output('help_list',$help_list);
  66. Tpl::showpage('store_joinin_help');
  67. }
  68. /**
  69. * 编辑入驻指南
  70. *
  71. */
  72. public function edit_helpOp() {
  73. $model_help = Model('help');
  74. $condition = array();
  75. $help_id = intval($_GET['help_id']);
  76. $condition['help_id'] = $help_id;
  77. $help_list = $model_help->getStoreHelpList($condition);
  78. $help = $help_list[0];
  79. Tpl::output('help',$help);
  80. if (chksubmit()) {
  81. $help_array = array();
  82. $help_array['help_title'] = $_POST['help_title'];
  83. $help_array['help_info'] = $_POST['content'];
  84. $help_array['help_sort'] = intval($_POST['help_sort']);
  85. $help_array['update_time'] = time();
  86. $state = $model_help->editHelp($condition, $help_array);
  87. if ($state) {
  88. $this->log('编辑店铺入驻指南,编号'.$help_id);
  89. showMessage(Language::get('nc_common_save_succ'),'index.php?act=store_joinin&op=help_list');
  90. } else {
  91. showMessage(Language::get('nc_common_save_fail'));
  92. }
  93. }
  94. $condition = array();
  95. $condition['item_id'] = $help_id;
  96. $pic_list = $model_help->getHelpPicList($condition);
  97. Tpl::output('pic_list',$pic_list);
  98. Tpl::showpage('store_joinin_help.edit');
  99. }
  100. /**
  101. * 上传图片
  102. */
  103. public function upload_picOp() {
  104. $data = array();
  105. if (!empty($_FILES['fileupload']['name'])) {//上传图片
  106. $fprefix = 'help_store';
  107. $upload = new UploadFile();
  108. $upload->set('default_dir',ATTACH_ARTICLE);
  109. $upload->set('fprefix',$fprefix);
  110. $upload->upfile('fileupload');
  111. $model_upload = Model('upload');
  112. $file_name = $upload->file_name;
  113. $insert_array = array();
  114. $insert_array['file_name'] = $file_name;
  115. $insert_array['file_size'] = $_FILES['fileupload']['size'];
  116. $insert_array['upload_time'] = time();
  117. $insert_array['item_id'] = intval($_GET['item_id']);
  118. $insert_array['upload_type'] = '2';
  119. $result = $model_upload->add($insert_array);
  120. if ($result) {
  121. $data['file_id'] = $result;
  122. $data['file_name'] = $file_name;
  123. }
  124. }
  125. echo json_encode($data);exit;
  126. }
  127. /**
  128. * 删除图片
  129. */
  130. public function del_picOp() {
  131. $condition = array();
  132. $condition['upload_id'] = intval($_GET['file_id']);
  133. $model_help = Model('help');
  134. $state = $model_help->delHelpPic($condition);
  135. if ($state) {
  136. echo 'true';exit;
  137. } else {
  138. echo 'false';exit;
  139. }
  140. }
  141. }