|
@@ -5,16 +5,28 @@ use app\common\controller\Api;
|
|
|
use think\Cache;
|
|
|
|
|
|
/**
|
|
|
- * 会员接口
|
|
|
+ * 七鱼接口
|
|
|
*/
|
|
|
class User extends Api
|
|
|
{
|
|
|
+ protected $noNeedLogin='*';
|
|
|
+ /**
|
|
|
+ * 获取token
|
|
|
+ * @param string appid
|
|
|
+ * @param string appsecret
|
|
|
+ */
|
|
|
public function get_token(){
|
|
|
$config=config('qiyu');
|
|
|
- $this->_validate([
|
|
|
- 'appid'=>['required',"in:{$config['appid']}"],
|
|
|
- 'appsecret'=>['required',"in:{$config['appSecret']}"],
|
|
|
+ $data=$this->_validate([
|
|
|
+ 'appid'=>['require'],
|
|
|
+ 'appsecret'=>['require'],
|
|
|
]);
|
|
|
+ if($data['appid']!=$config['appid']){
|
|
|
+ $this->error('appid有误');
|
|
|
+ }
|
|
|
+ if($data['appsecret']!=$config['appSecret']){
|
|
|
+ $this->error('appsecret有误');
|
|
|
+ }
|
|
|
$cacheName="qiyu_crm_token";
|
|
|
$expire=$config['expire']??7200;
|
|
|
$token=Cache::remember($cacheName,function (){
|
|
@@ -30,9 +42,14 @@ class User extends Api
|
|
|
{
|
|
|
$info=[
|
|
|
'rlt'=>$code?0:1,
|
|
|
+ 'msg'=>$msg,
|
|
|
];
|
|
|
$info=array_merge($info,$data);
|
|
|
json($info)->send();
|
|
|
exit;
|
|
|
}
|
|
|
+ protected function error($msg = '', $data = [], $code = 0, $type = null, array $header = [])
|
|
|
+ {
|
|
|
+ $this->success($msg,$data,0);
|
|
|
+ }
|
|
|
}
|