IndexController.php 2.1 KB
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;

use app\portal\model\AskModel;
use cmf\controller\HomeBaseController;
use EasyWeChat\Foundation\Application;
use think\Loader;

class IndexController extends HomeBaseController
{
    public function index()
    {
        header("Content-type: text/html; charset=utf-8");
        $final['kuang1'] = 'Https://'.$_SERVER['HTTP_HOST'].'/themes/simpleboot3/public/assets/images/kuang1@2x.png';
        $final['logo'] = 'Https://'.$_SERVER['HTTP_HOST'].'/themes/simpleboot3/public/assets/images/logo@2x.png';
        $final['fanhui'] = 'Https://'.$_SERVER['HTTP_HOST'].'/themes/simpleboot3/public/assets/images/fanhui@2x.png';
        $final['top'] = 'Https://'.$_SERVER['HTTP_HOST'].'/themes/simpleboot3/public/assets/images/top@2x.png';
        $final['bottom'] = 'Https://'.$_SERVER['HTTP_HOST'].'/themes/simpleboot3/public/assets/images/bottom@2x.png';
        $this->apiResponse('1','成功',$final);
    }
    public function submit()
    {
        return $this->fetch('bingo/index');
    }
    public function insert()
    {
        $data = $this->request->param();
        $validate = Loader::validate('Ask');
        if(!$validate->scene('edit')->check($data)){
            $mes = $validate->getError();
            $this->apiResponse('0',$mes);
        }
        $model = new AskModel();
        $isSet = $model->where($data)->find();
        if($isSet){
            $this->apiResponse('0','请勿重复提交');
        }
        $res = $model->save($data);
        if($res){
            $this->apiResponse('1','提交成功');
        }else{
            $this->apiResponse('0','提交失败');
        }

    }
}