dever 7 years ago
parent
commit
26a1969ed7
2 changed files with 37 additions and 0 deletions
  1. 21 0
      component/config/component/applet.php
  2. 16 0
      component/src/Auth.php

+ 21 - 0
component/config/component/applet.php

@@ -3,6 +3,27 @@
 
 $domain = '{domain}';
 
+# 登录
+$config['applet_login'] = array
+(
+	'name' => '登录',
+	'method' => 'get',
+	'json' => false,
+	'url' => 'https://api.weixin.qq.com/sns/component/jscode2session?',
+	'param' => array
+	(
+		'appid' => 'appid',
+		'js_code' => 'js_code',
+		'grant_type' => 'authorization_code',
+		'component_appid' => 'component_appid',
+		'component_access_token' => 'component_token',
+	),
+	'response' => array
+	(
+		'errmsg' => 'errmsg',
+	),
+);
+
 # 设置服务域名
 $config['applet_domain'] = array
 (

+ 16 - 0
component/src/Auth.php

@@ -42,6 +42,22 @@ class Auth
 		$this->wechat = new Wechat();
 	}
 
+	/**
+     * 小程序登录login
+     * 
+     * @return mixed
+     */
+	public function applet_login_api()
+	{
+		$param['js_code'] = Dever::input('code');
+		$param['appid'] = Dever::input('appid');
+		$param['component_access_token'] = $this->wechat->token();
+		$param['component_appid'] = $this->wechat->project['id'];
+		$data = $this->wechat->curl('applet_login', $param);
+
+		echo $data;die;
+	}
+
 	/**
      * 获取component token 一般为系统token
      *