| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\admin\controller;
- use think\Validate;
- use think\Lang;
- class Homeinfo extends AdminControl
- {
- public function _initialize()
- {
- parent::_initialize();
- Lang::load(APP_PATH . 'admin/lang/' . config('default_lang') . '/member.lang.php');
- }
- /**
- * 用户列表
- * @return mixed
- */
- public function index()
- {
- /*$a='sadsffdsfds';
- echo substr($a,0,20);die;*/
- $getHomeInformation = model('homeinformation')->getHomeInformation();
- $this->assign('information', $getHomeInformation);
- $this->setAdminCurItem('index');
- return $this->fetch();
- }
- public function edit()
- {
- $homeinformation_id = input('param.homeinformation_id');
- if (!request()->isPost()) {
- $getHomeInformation = model('homeinformation')->findHomeInformation($homeinformation_id);
- $this->assign('information', $getHomeInformation);
- $this->setAdminCurItem('edit');
- return $this->fetch('form');
- } else {
- $updateData = array(
- 'homeinformation_name' => input('post.homeinformation_name'),
- 'homeinformation_content' => input('post.homeinformation_content'),
- 'homeinformation_en' => input('post.homeinformation_en'),
- 'homeinformation_bgcolor' => input('post.homeinformation_bgcolor'),
- );
- $files = request()->file('homeinformation_bgImg');
- if($files){
- $imgurl = DS_THEME_STYLE_URL . 'images';
- $begin = strrpos(input('post.bgImgName'), '/');
- $end = strrpos(input('post.bgImgName'), '.');
- $oldFileName = substr(input('post.bgImgName'), $begin + 1, $end - $begin - 1);
- $oldFile = $imgurl . "\\" . substr(input('post.bgImgName'),$begin + 1);
- if(file_exists($oldFile)){
- unlink($oldFile);
- };
- $files = $files->setSaveName($oldFileName);//设置保存文件名
- $imgt = $files->move($imgurl, $savename = $oldFileName, $replace = true);
- if($imgt){
- $img = 1;
- }
- }
- $result = model('homeinformation')->updateHomeInformation($homeinformation_id, $updateData);
- if ($result || $img) {
- dsLayerOpenSuccess("编辑成功");
- } else {
- $this->error("操作失败");
- }
- }
- }
- }
|