123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <?php
- namespace app\admin\controller;
- use think\facade\View;
- use think\facade\Lang;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 控制器
- */
- class Storejoin extends AdminControl
- {
- public function initialize()
- {
- parent::initialize(); // TODO: Change the autogenerated stub
- Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/storejoin.lang.php');
- }
- /**
- * 前台头部图片传
- */
- public function index()
- {
- $size = 3; //上传显示图片总数
- $i = 1;
- $info['pic'] = array();
- $info['show_txt'] = '';
- $config_model = model('config');
- $list_config = rkcache('config', true);
- $code_info = $list_config['store_joinin_pic'];
- if (!empty($code_info)) {
- $info = unserialize($code_info);
- }
- $post = input('post.'); #获取POST 数据
- if (request()->isPost()) {
- $store_joinin_open = input('post.store_joinin_open');
- if (!in_array($store_joinin_open, array(0, 1, 2, 3))) {
- $this->error(lang('param_error'));
- }
- $info['show_txt'] = input('post.show_txt');
- for ($i; $i <= $size; $i++) {
- $file = 'pic' . $i;
- $info['pic'][$i] = $post['show_pic' . $i];
- if (!empty($_FILES[$file]['name'])) { //上传图片
- $filename_tmparr = explode('.', $_FILES[$file]['name']);
- $ext = end($filename_tmparr);
- $file_name = 'store_joinin_' . $i . '.' . $ext;
- $res = ds_upload_pic('admin/Storejion', $file, $file_name);
- if ($res['code']) {
- $file_name = $res['data']['file_name'];
- $info['pic'][$i] = $file_name;
- } else {
- $this->error($res['msg']);
- }
- }
- }
- $code_info = serialize($info);
- $update_array = array();
- $update_array['store_joinin_pic'] = $code_info;
- $update_array['store_joinin_open'] = $store_joinin_open;
- $config_model->editConfig($update_array);
- $this->success(lang('ds_common_save_succ'), 'Storejoin/index');
- }
- View::assign('store_joinin_open', $list_config['store_joinin_open']);
- View::assign('size', $size);
- View::assign('pic', $info['pic']);
- View::assign('show_txt', $info['show_txt']);
- $this->setAdminCurItem('index');
- return View::fetch();
- }
- /**
- * 入驻指南
- *
- */
- public function help_list()
- {
- $help_model = model('help');
- $condition = array();
- $condition[] = array('helptype_id', '=', '1');
- $help_list = $help_model->getStoreHelpList($condition);
- View::assign('help_list', $help_list);
- $this->setAdminCurItem('help_list');
- return View::fetch();
- }
- /**
- * 编辑入驻指南
- *
- */
- public function edit_help()
- {
- $help_model = model('help');
- $condition = array();
- $help_id = intval(input('param.help_id'));
- $condition[] = array('help_id', '=', $help_id);
- $help_list = $help_model->getStoreHelpList($condition);
- $help = $help_list[0];
- $help['help_info'] = str_replace("\r\n", "", $help['help_info']);
- View::assign('help', $help);
- if (request()->isPost()) {
- $help_array = array();
- $help_array['help_title'] = input('post.help_title');
- $help_array['help_info'] = input('post.help_info');
- $help_array['help_sort'] = intval(input('post.help_sort'));
- $help_array['help_updatetime'] = TIMESTAMP;
- $state = $help_model->editHelp($condition, $help_array);
- if ($state) {
- $this->log('编辑店铺入驻指南,编号' . $help_id);
- $this->success(lang('ds_common_save_succ'), 'storejoin/help_list');
- } else {
- $this->error(lang('ds_common_save_fail'));
- }
- }
- $condition = array();
- $condition[] = array('item_id', '=', $help_id);
- $pic_list = $help_model->getHelpPicList($condition);
- View::assign('pic_list', $pic_list);
- $this->setAdminCurItem('edit');
- return View::fetch();
- }
- /**
- * 上传图片
- */
- public function upload_pic()
- {
- $data = array();
- if (!empty($_FILES['fileupload']['name'])) { //上传图片
- $fprefix = 'admin/storehelp';
- $res = ds_upload_pic($fprefix, 'fileupload');
- if ($res['code']) {
- $file_name = $res['data']['file_name'];
- } else {
- echo json_encode($data);
- exit;
- }
- $upload_model = model('upload');
- $insert_array = array();
- $insert_array['file_name'] = $file_name;
- $insert_array['file_size'] = $_FILES['fileupload']['size'];
- $insert_array['upload_time'] = TIMESTAMP;
- $insert_array['item_id'] = intval(input('param.item_id'));
- $insert_array['upload_type'] = '2';
- $result = $upload_model->addUpload($insert_array);
- if ($result) {
- $data['file_id'] = $result;
- $data['file_name'] = $file_name;
- $data['file_path'] = ds_get_pic($fprefix, $file_name);
- }
- }
- echo json_encode($data);
- exit;
- }
- /**
- * 删除图片
- */
- public function del_pic()
- {
- $condition = array();
- $condition[] = array('upload_id', '=', intval(input('param.file_id')));
- $help_model = model('help');
- $state = $help_model->delHelpPic($condition);
- if ($state) {
- echo 'true';
- exit;
- } else {
- echo 'false';
- exit;
- }
- }
- protected function getAdminItemList()
- {
- $menu_array = array(
- array(
- 'name' => 'index', 'text' => lang('image_and_notice'), 'url' => (string) url('Storejoin/index')
- ), array(
- 'name' => 'help_list', 'text' => lang('joinin_guide'), 'url' => (string) url('Storejoin/help_list')
- )
- );
- if (request()->action() == 'edit_help') {
- $menu_array[] = array('name' => 'edit', 'text' => lang('edit_content'), 'url' => 'javascript:void(0)');
- }
- return $menu_array;
- }
- }
|