Merge branch 'master' of http://app.git.1nww.com:8188/gitlab-instance-db4ab2e7/cxhxy
This commit is contained in:
commit
5648becd68
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace app;
|
||||
|
||||
use think\App;
|
||||
@ -37,11 +38,11 @@ abstract class BaseController
|
||||
/**
|
||||
* 构造方法
|
||||
* @access public
|
||||
* @param App $app 应用对象
|
||||
* @param App $app 应用对象
|
||||
*/
|
||||
public function __construct(App $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->app = $app;
|
||||
$this->request = $this->app->request;
|
||||
|
||||
// 控制器初始化
|
||||
@ -50,15 +51,23 @@ abstract class BaseController
|
||||
|
||||
// 初始化
|
||||
protected function initialize()
|
||||
{}
|
||||
{
|
||||
$allowOrigin = Request::header('origin');
|
||||
$allowHeaders = 'X-Requested-With, Content-Type, Authorization';
|
||||
$allowMethods = 'GET, POST, PUT, DELETE, PATCH, OPTIONS';
|
||||
|
||||
header("Access-Control-Allow-Origin: " . $allowOrigin);
|
||||
header("Access-Control-Allow-Headers: " . $allowHeaders);
|
||||
header("Access-Control-Allow-Methods: " . $allowMethods);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证数据
|
||||
* @access protected
|
||||
* @param array $data 数据
|
||||
* @param string|array $validate 验证器名或者验证规则数组
|
||||
* @param array $message 提示信息
|
||||
* @param bool $batch 是否批量验证
|
||||
* @param array $data 数据
|
||||
* @param string|array $validate 验证器名或者验证规则数组
|
||||
* @param array $message 提示信息
|
||||
* @param bool $batch 是否批量验证
|
||||
* @return array|string|true
|
||||
* @throws ValidateException
|
||||
*/
|
||||
@ -73,7 +82,7 @@ abstract class BaseController
|
||||
[$validate, $scene] = explode('.', $validate);
|
||||
}
|
||||
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
|
||||
$v = new $class();
|
||||
$v = new $class();
|
||||
if (!empty($scene)) {
|
||||
$v->scene($scene);
|
||||
}
|
||||
|
||||
@ -174,7 +174,12 @@ class User extends Controller
|
||||
public function wxCode()
|
||||
{
|
||||
$appid = 'wx89c12dd426a55a2e';
|
||||
|
||||
|
||||
$redirect_uri = $this->request->host() . 'api/food.user/wxLogin';
|
||||
|
||||
|
||||
|
||||
$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
|
||||
return $this->renderSuccess($url, '成功');
|
||||
}
|
||||
|
||||
@ -1819,7 +1819,7 @@ class Driver
|
||||
$result = json_decode(Http::get($url), true);
|
||||
if (isset($result['access_token'])) {
|
||||
$access_token = $result['access_token'];
|
||||
Cache::set($key, $access_token, 3600);
|
||||
Cache::set($key, $access_token, 7200);
|
||||
return $access_token;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user