Config.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Lang;
  4. use think\File;
  5. class Config extends AdminControl {
  6. public function _initialize() {
  7. parent::_initialize();
  8. Lang::load(APP_PATH . 'admin/lang/' . config('default_lang') . '/config.lang.php');
  9. }
  10. /**
  11. * 网站配置
  12. * @return mixed
  13. */
  14. public function index() {
  15. // var_dump(BASE_UPLOAD_PATH);
  16. $model_config = model('config');
  17. $allpower = $this->qxhans();
  18. $this->assign('allpower',$allpower);
  19. if (!request()->isPost()) {
  20. $list_config = $model_config->getListConfig();
  21. $this->assign('list_config', $list_config);
  22. $this->setAdminCurItem('index');
  23. return $this->fetch();
  24. } else {
  25. $update_array = array();
  26. $update_array['site_state'] = isset($_POST['site_state']) ? '1' : '';
  27. $update_array['site_name'] = $_POST['site_name'];
  28. $update_array['icp_number'] = $_POST['icp_number'];
  29. $update_array['site_phone'] = $_POST['site_phone'];
  30. $update_array['flow_static_code'] = $_POST['flow_static_code'];
  31. $update_array['fax'] = $_POST['fax'];
  32. $imgurl = BASE_UPLOAD_PATH;
  33. $file = request()->file('site_logo');
  34. $imgname = "logo";//官网logo
  35. $file->setSaveName($imgname);//设置保存文件名
  36. $imgo = $file->move($imgurl,false,false);
  37. if($imgo){
  38. $update_array['site_logo'] = $imgurl . '/' .$imgname.'.jpg';
  39. }
  40. $files = request()->file('site_logowx');
  41. $wximgname = "code";//微信二维码
  42. $files->setSaveName($wximgname);//设置保存文件名
  43. $imgt = $files->move($imgurl,false,false);
  44. if($imgt){
  45. $update_array['site_logowx'] = $imgurl . '/' .$wximgname.'.png';
  46. }
  47. $result = $model_config->updateConfig($update_array);
  48. if ($result === true) {
  49. $this->log(lang('ds_edit') . lang('dis_dump'), 1);
  50. $this->success('修改成功', 'Config/index');
  51. } else {
  52. $this->log(lang('ds_edit') . lang('dis_dump'), 0);
  53. $this->error(lang('修改失败'));
  54. }
  55. }
  56. }
  57. /**
  58. * 获取卖家栏目列表,针对控制器下的栏目
  59. */
  60. protected function getAdminItemList() {
  61. $menu_array = array(
  62. array(
  63. 'name' => 'base',
  64. 'text' => lang('site_set'),
  65. 'url' => url('Admin/Config/index')
  66. ),
  67. );
  68. return $menu_array;
  69. }
  70. }