|
@@ -3,7 +3,6 @@
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
-use app\common\library\WXBizDataCrypt;
|
|
|
use app\common\model\Config;
|
|
|
use app\common\model\User;
|
|
|
use app\common\controller\Api;
|
|
@@ -13,24 +12,24 @@ use think\facade\Validate;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @title 登录注册
|
|
|
+ * @title 登录
|
|
|
* @controller Login
|
|
|
*/
|
|
|
class Login extends Api
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
- * @title 微信授权登录
|
|
|
- * @desc 微信授权登录
|
|
|
- * @url /api/Login/wechat_login
|
|
|
+ * @title 账号登录
|
|
|
+ * @desc 账号登录
|
|
|
+ * @url /api/Login/login
|
|
|
* @method POST
|
|
|
* @tag 基础
|
|
|
* @header
|
|
|
- * @param name:code type:string require:1 desc:code
|
|
|
- * @param name:rawData type:json require:1 desc:用户信息
|
|
|
+ * @param name:account type:string require:1 desc:账号
|
|
|
+ * @param name:password type:string require:1 desc:密码
|
|
|
*
|
|
|
*/
|
|
|
- public function wechat_login(){
|
|
|
+ public function login(){
|
|
|
$code = input('code');
|
|
|
if (!$code) $this->error('code为空');
|
|
|
$rawData = input('rawData'); //用户信息
|
|
@@ -43,50 +42,6 @@ class Login extends Api
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * @title 授权手机号
|
|
|
- * @desc 授权手机号
|
|
|
- * @url /api/Login/bind_phone
|
|
|
- * @method POST
|
|
|
- * @tag 基础
|
|
|
- * @header
|
|
|
- * @param name:code type:string require:1 desc:code
|
|
|
- * @param name:iv type:string require:1 desc:iv
|
|
|
- * @param name:encryptedData type:string require:1 desc:encryptedData
|
|
|
- *
|
|
|
- */
|
|
|
- public function bind_phone(){
|
|
|
- $user_id = $this->check_login();
|
|
|
- $code = input('code');
|
|
|
- $appid = Config::get_values('wechat_appid');
|
|
|
- $secret = Config::get_values('wechat_appsecret');
|
|
|
- //$session_key = input('session_key');
|
|
|
- $iv = input('iv');
|
|
|
- $encryptedData = input('encryptedData');
|
|
|
-
|
|
|
- $url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $secret . "&js_code=" . $code . "&grant_type=authorization_code";
|
|
|
- $session_key = Common::curlRequest($url);
|
|
|
- if (!empty($session_key['session_key'])) {
|
|
|
- $pc = new WXBizDataCrypt($appid, $session_key['session_key']);
|
|
|
- $errCode =$pc->decryptData($encryptedData, $iv, $data );
|
|
|
- if ($errCode!=0){
|
|
|
- $this->error('授权失败');
|
|
|
- }
|
|
|
- $array=json_decode($data, true);
|
|
|
-
|
|
|
- $result = User::bindPhone($user_id,$array);
|
|
|
- if ($result['code']){
|
|
|
- $this->success($result['msg']);
|
|
|
- }else{
|
|
|
- $this->error($result['msg']);
|
|
|
- }
|
|
|
- }else{
|
|
|
- return Common::return_error('获取session_key失败!');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
|
|
|
}
|