Homeinfo.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Validate;
  4. use think\Lang;
  5. class Homeinfo extends AdminControl
  6. {
  7. public function _initialize()
  8. {
  9. parent::_initialize();
  10. Lang::load(APP_PATH . 'admin/lang/' . config('default_lang') . '/member.lang.php');
  11. }
  12. /**
  13. * 用户列表
  14. * @return mixed
  15. */
  16. public function index()
  17. {
  18. /*$a='sadsffdsfds';
  19. echo substr($a,0,20);die;*/
  20. $getHomeInformation = model('homeinformation')->getHomeInformation();
  21. $this->assign('information', $getHomeInformation);
  22. $this->setAdminCurItem('index');
  23. return $this->fetch();
  24. }
  25. public function edit()
  26. {
  27. $homeinformation_id = input('param.homeinformation_id');
  28. if (!request()->isPost()) {
  29. $getHomeInformation = model('homeinformation')->findHomeInformation($homeinformation_id);
  30. $this->assign('information', $getHomeInformation);
  31. $this->setAdminCurItem('edit');
  32. return $this->fetch('form');
  33. } else {
  34. $updateData = array(
  35. 'homeinformation_name' => input('post.homeinformation_name'),
  36. 'homeinformation_content' => input('post.homeinformation_content'),
  37. 'homeinformation_en' => input('post.homeinformation_en'),
  38. 'homeinformation_bgcolor' => input('post.homeinformation_bgcolor'),
  39. );
  40. $files = request()->file('homeinformation_bgImg');
  41. if($files){
  42. $imgurl = DS_THEME_STYLE_URL . 'images';
  43. $begin = strrpos(input('post.bgImgName'), '/');
  44. $end = strrpos(input('post.bgImgName'), '.');
  45. $oldFileName = substr(input('post.bgImgName'), $begin + 1, $end - $begin - 1);
  46. $oldFile = $imgurl . substr(input('post.bgImgName'),strrpos(input('post.bgImgName'), '/'));
  47. if(file_exists($oldFile)){
  48. unlink($oldFile);
  49. };
  50. $files = $files->setSaveName($oldFileName);//设置保存文件名
  51. $imgt = $files->move($imgurl, $savename = $oldFileName, $replace = true);
  52. if($imgt){
  53. $update_array['site_logowx'] = $oldFileName.'.png';
  54. }
  55. }
  56. $result = model('homeinformation')->findHomeInformation($homeinformation_id);
  57. if ($result) {
  58. dsLayerOpenSuccess(lang('member_edit_succ'));
  59. } else {
  60. $this->error(lang('member_edit_fail'));
  61. }
  62. }
  63. }
  64. }