123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\admin\controller\product;
- use app\common\controller\Backend;
- use think\Exception;
- use think\exception\DbException;
- use think\response\Json;
- /**
- * 产品-pro
- *
- * @icon fa fa-circle-o
- */
- class Pro extends Backend
- {
- /**
- * ProductPro模型对象
- * @var \app\common\model\ProductPro
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\common\model\ProductPro;
- }
- /**
- * 查看
- *
- * @return string|Json
- * @throws \think\Exception
- * @throws DbException
- */
- public function index()
- {
- if ($this->request->isPost()) {
- $row = $this->request->post("row/a");
- if(count($row) == 2){
- $alteration = ['name','image'];
- }else{
- $alteration = ['name','image','content'];
- }
- $res = array_combine($alteration,$row);
- try {
- $this->model->save($res,['name'=>$res['name']]);
- } catch (Exception $e) {
- $this->error($e->getMessage());
- }
- $this->success("提交成功", null, ['data' => json_encode($this->request->post("row/a"), JSON_UNESCAPED_UNICODE)]);
- }else{
- if (false === $this->request->isAjax()) {
- $this->assign('iantern_slide',$this->model->get(['name'=>'幻灯片']));
- $this->assign('product_framework',$this->model->get(['name'=>'产品框架']));
- $this->assign('product_fram_image',$this->model->get(['name'=>'产品优势']));
- $this->assign('product_features',$this->model->where(['name'=>'产品亮点'])->field(['name','image','content as product_features_content'])->find());
- $this->assign('product_function',$this->model->where(['name'=>'产品功能'])->field(['name','image','content as product_function_content'])->find());
- $this->assign('product_case_show',$this->model->get(['name'=>'案例展示']));
- $this->assign('advanced',$this->model->where(['name'=>'采用最前沿的技术框架'])->field(['name','image','content as advanced_content'])->find());
- $this->assign('product_study',$this->model->where(['name'=>'学习'])->field(['name','image','content as study_content'])->find());
- return $this->view->fetch();
- }
- }
- }
- }
|