Information.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jun.peng
  5. * Date: 2019/6/19
  6. * Time: 9:28
  7. */
  8. namespace app\admin\controller;
  9. use map\Map;
  10. use think\Lang;
  11. use app\admin\model\IncInfo as IncInfoModel;
  12. /**
  13. * Class Information
  14. * @package app\admin\controller
  15. * 企业信息管理
  16. */
  17. class Information extends AdminControl
  18. {
  19. public function _initialize()
  20. {
  21. parent::_initialize();
  22. Lang::load(APP_PATH . 'admin/lang/' . config('default_lang') . '/inc_info.lang.php');
  23. }
  24. public function index() {
  25. $allpower = $this->qxhans();
  26. $this->assign('allpower',$allpower);
  27. if (!request()->isPost()) {
  28. $incData = IncInfoModel::get(1);
  29. $this->assign('IncData', $incData);
  30. $this->setAdminCurItem('index');
  31. return $this->fetch();
  32. } else {
  33. $update_array = array();
  34. $update_array['inc_name'] = $_POST['inc_name'];
  35. $update_array['inc_phone'] = $_POST['inc_phone'];
  36. $update_array['inc_email'] = $_POST['inc_email'];
  37. $update_array['inc_weixin'] = $_POST['inc_weixin'];
  38. $update_array['inc_qq'] = $_POST['inc_qq'];
  39. $update_array['inc_address'] = $_POST['inc_address'];
  40. //获取地址经纬度
  41. $map = Map::getLngLat($_POST['inc_address']);
  42. $update_array['inc_location'] = json_encode($map['location']);
  43. $imgurl = USER_SITE_ROOT . '/images/';
  44. $file = request()->file('inc_logo');
  45. if($file){
  46. $imgname = "logo";//官网logo
  47. $file = $file->setSaveName($imgname);//设置保存文件名
  48. $imgo = $file->move($imgurl, $savename = false, $replace = true);
  49. if($imgo){
  50. $update_array['inc_logo'] = $imgname.'.png';
  51. }
  52. }
  53. $result = IncInfoModel::updateIncInfo($update_array);
  54. if ($result === true) {
  55. $this->log(lang('ds_edit') . lang('dis_dump'), 1);
  56. $this->success('修改成功', 'Information/index');
  57. } else {
  58. $this->log(lang('ds_edit') . lang('dis_dump'), 0);
  59. $this->error(lang('修改失败'));
  60. }
  61. }
  62. }
  63. }