|
@@ -2,11 +2,37 @@
|
|
|
|
|
|
namespace app\api\controller\qiyu;
|
|
|
use app\common\controller\Api;
|
|
|
+use think\Cache;
|
|
|
|
|
|
/**
|
|
|
* 会员接口
|
|
|
*/
|
|
|
class User extends Api
|
|
|
{
|
|
|
+ public function get_token(){
|
|
|
+ $config=config('qiyu');
|
|
|
+ $this->_validate([
|
|
|
+ 'appid'=>['required',"in:{$config['appid']}"],
|
|
|
+ 'appsecret'=>['required',"in:{$config['appSecret']}"],
|
|
|
+ ]);
|
|
|
+ $cacheName="qiyu_crm_token";
|
|
|
+ $expire=$config['expire']??7200;
|
|
|
+ $token=Cache::remember($cacheName,function (){
|
|
|
+ return session_create_id();
|
|
|
+ },$expire);
|
|
|
+ $this->success('',[
|
|
|
+ 'token'=>$token,
|
|
|
+ 'expires'=>$expire,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
|
|
|
+ protected function success($msg = '', $data = [], $code = 1, $type = null, array $header = [])
|
|
|
+ {
|
|
|
+ $info=[
|
|
|
+ 'rlt'=>$code?0:1,
|
|
|
+ ];
|
|
|
+ $info=array_merge($info,$data);
|
|
|
+ json($info)->send();
|
|
|
+ exit;
|
|
|
+ }
|
|
|
}
|