This commit is contained in:
2018-07-19 18:48:36 +08:00
parent 837f6285f8
commit e329401a0a
5 changed files with 28 additions and 11 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ class Account extends Base
*/
public function login($code)
{
return http::get('https://api.weixin.qq.com/sns/jscode2session', [
return Http::get('sns/jscode2session', [
'appid' => $this->app_id,
'secret' => $this->app_secret,
'js_code' => $code,
+24 -7
View File
@@ -105,20 +105,37 @@ abstract class Base
*/
public $key = '';
/** @var static */
protected static $base;
/**
* Base constructor.
* @param $method
* @param $configPath
* @param mixed ...$params
* @return mixed
* @throws \Exception
*/
public function __construct($configPath)
public static function call($method, $configPath, ...$params)
{
$this->init($configPath);
if (!static::$base instanceof Base) {
static::$base = new static();
}
$class = static::$base;
$class->loadConfig($configPath);
if (!method_exists($class, $method)) {
throw new \Exception('未知的执行方法!');
}
return call_user_func([$class, $method], ...$params);
}
/**
*
*/
public function init($configPath)
public function loadConfig($configPath)
{
$config = require $configPath;
$config = require realpath($configPath);
if (empty($config)) {
return;
}
@@ -138,7 +155,7 @@ abstract class Base
*/
public function push($url, $data = [], callable $callback = NULL)
{
return http::post($url, $data, $callback);
return Http::post($url, $data, $callback);
}
/**
@@ -229,7 +246,7 @@ abstract class Base
*/
protected function getAccessToken()
{
$data = http::get('https://api.weixin.qq.com/cgi-bin/token', [
$data = Http::get('https://api.weixin.qq.com/cgi-bin/token', [
'grant_type' => 'client_credential',
'appid' => $this->app_id,
'secret' => $this->app_secret,
+1 -1
View File
@@ -33,7 +33,7 @@ class Recharge extends Base
$this->money = $money;
$this->orderNo = $orderNo;
$this->data['openid'] = $openId;
return http::post($this->createPayUrl(), $this->builder(),
return Http::post($this->createPayUrl(), $this->builder(),
function ($result, $body) use ($_this) {
$data = $_this->toArray($result);
if(isset($data['sign'])){
+1 -1
View File
@@ -77,7 +77,7 @@ class Result
* @param $key
* @param $data
* @return $this
* @throws Exception
* @throws \Exception
*/
public function setAttr($key, $data)
{
+1 -1
View File
@@ -24,7 +24,7 @@ class Template extends Base
{
$url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=' . $access;
$postBody = json_encode($postBody);
return http::post($url, $postBody, NULL, ['content-type' => 'application/json'])
return Http::post($url, $postBody, NULL, ['content-type' => 'application/json'])
->append('postBody', $postBody);
}
}