From 9be6c14a199cc86509b2ad4d3a9575ef4419b908 Mon Sep 17 00:00:00 2001 From: lisong <377344020@qq.com> Date: Mon, 27 Dec 2021 23:24:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Controller.php | 11 +++++++++-- application/api/controller/GoodsController.php | 5 ++++- application/api/controller/IndexController.php | 10 +++++----- public/index.php | 1 - 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/application/api/controller/Controller.php b/application/api/controller/Controller.php index c97cf6e..440bf57 100755 --- a/application/api/controller/Controller.php +++ b/application/api/controller/Controller.php @@ -38,11 +38,18 @@ class Controller public function __construct(Request $request) { + header('Access-Control-Allow-Origin:*'); + header("Access-Control-Allow-Headers:token, Origin, X-Requested-With, Content-Type, Accept, Authorization"); + header('Access-Control-Allow-Methods:POST,GET,PUT,DELETE'); + header("Access-Control-Max-Age:1728000"); + if (request()->isOptions()) { //浏览器的option试探请求,要exit掉,不然你的业务会被执行两次 + exit(); + } $this->request = $request; //jwt验证 - $this->jtwInit(); - $this->checkToken(); + //$this->jtwInit(); + //$this->checkToken(); //初始化基本数据 $this->param = $request->param(); diff --git a/application/api/controller/GoodsController.php b/application/api/controller/GoodsController.php index 4da5d47..f172040 100755 --- a/application/api/controller/GoodsController.php +++ b/application/api/controller/GoodsController.php @@ -150,7 +150,10 @@ class GoodsController extends Controller //商品筛选 public function category_list(Request $request,GoodsCategory $gcmodel,GoodsBrand $gbmodel) { - $brand_list=$gbmodel->field('name,initial')->where(array('is_show'=>1))->select(); + $brand_list=$gbmodel->field('name,initial,img')->where(array('is_show'=>1))->select(); + foreach ($brand_list as $k1 => $v1) { + $brand_list[$k1]['img'] =$this->img_url.$v1['img']; + } $category_list=$gcmodel->field('name,id as cid,parent_id')->select(); $category=getSubs($category_list,0); $size_list=ShopConfig::get('website', 'size'); diff --git a/application/api/controller/IndexController.php b/application/api/controller/IndexController.php index 2a0ed1c..67450f9 100755 --- a/application/api/controller/IndexController.php +++ b/application/api/controller/IndexController.php @@ -5,7 +5,7 @@ */ namespace app\api\controller; -use app\common\model\Goodsindex; +use app\common\model\GoodsIndex; use app\common\model\Goods; use app\common\model\GoodsBrand; use app\common\model\GoodsItem; @@ -22,10 +22,10 @@ class IndexController extends Controller 'home','pattern_goods' ]; - public function home(Request $request,Goods $gmodel,Goodsindex $gimodel) + public function home(Request $request,Goods $gmodel,GoodsIndex $gimodel) { - echo Crypt::encrypt(1).'|'; - echo $this->getToken(1); + // echo Crypt::encrypt(1).'|'; + // echo $this->getToken(1); $param = $request->param(); //首页轮播 $carousel = get_ad('carousel',6); @@ -57,7 +57,7 @@ class IndexController extends Controller } //模式商品 - public function pattern_goods(Request $request,Goods $model,Goodsindex $gimodel) + public function pattern_goods(Request $request,Goods $model,GoodsIndex $gimodel) { $param = $request->param(); $id = $param['id']?Crypt::decrypt($param['id']):''; diff --git a/public/index.php b/public/index.php index 6588d16..65b63c1 100755 --- a/public/index.php +++ b/public/index.php @@ -11,7 +11,6 @@ // [ 应用入口文件 ] namespace think; -phpinfo(); // 加载基础文件 require __DIR__ . '/../thinkphp/base.php'; // 支持事先使用静态方法设置Request对象和Config对象