Information.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 = DS_THEME_USER_URL . '/images/';
  44. $file = request()->file('inc_logo');
  45. if($file){
  46. $oldFile = $imgurl . "backlogo.png";
  47. if(file_exists($oldFile)){
  48. unlink($oldFile);
  49. };
  50. $imgname = "backlogo.png";//官网logo
  51. $file = $file->setSaveName($imgname);//设置保存文件名
  52. $imgo = $file->move($imgurl, $savename = $imgname, $replace = true);
  53. if($imgo){
  54. $img = 1;
  55. }
  56. }
  57. $result = IncInfoModel::updateIncInfo($update_array);
  58. if ($result || $img) {
  59. $this->log(lang('ds_edit') . lang('dis_dump'), 1);
  60. $this->success('修改成功', 'Information/index');
  61. } else {
  62. $this->log(lang('ds_edit') . lang('dis_dump'), 0);
  63. $this->error(lang('修改失败'));
  64. }
  65. }
  66. }
  67. public function contact() {
  68. $getHomecontact = model('Homecontact')->getHomecontact();
  69. $this->assign('homecontact', $getHomecontact);
  70. $this->setAdminCurItem('index');
  71. return $this->fetch();
  72. }
  73. public function edit()
  74. {
  75. $homecontact_id = input('param.homecontact_id');
  76. if (!request()->isPost()) {
  77. $findHomecontact = model('Homecontact')->findHomecontact($homecontact_id);
  78. $this->assign('homecontact', $findHomecontact);
  79. $this->setAdminCurItem('edit');
  80. return $this->fetch('form');
  81. } else {
  82. $updateData = array(
  83. 'homecontact_name' => input('post.homecontact_name'),
  84. 'homecontact_content1' => input('post.homecontact_content1'),
  85. 'homecontact_content2' => input('post.homecontact_content2'),
  86. 'homecontact_content3' => input('post.homecontact_content3'),
  87. );
  88. $result = model('Homecontact')->updateHomecontact($homecontact_id, $updateData);
  89. if ($result) {
  90. dsLayerOpenSuccess("编辑成功");
  91. } else {
  92. $this->error("操作失败");
  93. }
  94. }
  95. }
  96. }