www_fpvone_cn/application/index/controller/Zhinan.php

95 lines
3.6 KiB
PHP

<?php
namespace app\index\controller;
use think\Request;
use think\Config;
use app\admin\model\cms\Archives;
use app\admin\model\Addonnews;
//装机指南
class Zhinan
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
protected $layout = '';
public function search(){
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
header('Access-Control-Expose-Headers: *'); //服务器 headers 白名单,可以让客户端进行访问
header('Access-Control-Allow-Headers: *');
$request = Request::instance();
$params = $request->param();
$archives = new Archives();
if(empty($params['str']) || empty($params['limit']) || !is_numeric($params['limit']) || empty($params['page']) || !is_numeric($params['page'])){
$message = [
'code' => 0,
'message' => '请求异常',
];
return json($message);
}
$data = [];
$res = $archives->where('channel_id',59)->where('status','normal')->where('title','like','%'.$params['str'].'%')->select();
$res1 = $archives->where('channel_id',59)->where('status','normal')->where('title','like','%'.$params['str'].'%')->page($params['page'],$params['limit'])->select();
$data['code'] = 1;
$data['total'] = count($res);
$data['data'] = $res1;
return json($data);
}
public function list(){
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
header('Access-Control-Expose-Headers: *'); //服务器 headers 白名单,可以让客户端进行访问
header('Access-Control-Allow-Headers: *');
$archives = new Archives();
$request = Request::instance();
$params = $request->param();
if(empty($params['limit']) || !is_numeric($params['limit']) || empty($params['page']) || !is_numeric($params['page'])){
$message = [
'code' => 0,
'message' => '请求异常',
];
return json($message);
}
$data = [];
$res = $archives->where('channel_id',59)->where('status','normal')->select();
$res1 = $archives->where('channel_id',59)->where('status','normal')->page($params['page'],$params['limit'])->select();
$data['code'] = 1;
$data['total'] = count($res);
$data['data'] = $res1;
return json($data);
// var_dump($res);exit;
}
public function detail(){
// $user = auth_user();
// var_dump($user);exit;
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
header('Access-Control-Expose-Headers: *'); //服务器 headers 白名单,可以让客户端进行访问
header('Access-Control-Allow-Headers: *');
$request = Request::instance();
$params = $request->param();
if(empty($params['id'])){
$message = [
'code' => 0,
'message' => '请求异常',
];
return json($message);
}
$archives = new Archives();
$addonnews = new Addonnews();
$res = $addonnews->where('id',$params['id'])->find();
$res2 = $archives->where('id',$params['id'])->find();
$res['title'] = $res2['title'];
$data['code'] = 1;
$data['data'] = $res;
return json($data);
}
}