This commit is contained in:
lisong 2021-12-27 23:24:56 +08:00
parent 19ff7673f8
commit 9be6c14a19
4 changed files with 18 additions and 9 deletions

View File

@ -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();

View File

@ -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');

View File

@ -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']):'';

View File

@ -11,7 +11,6 @@
// [ 应用入口文件 ]
namespace think;
phpinfo();
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象