Commit b682c964 authored by zhoujun's avatar zhoujun

'初始版本'

parent 68dd36da
Pipeline #540 failed with stages
...@@ -31,8 +31,10 @@ class UserController extends BaseController ...@@ -31,8 +31,10 @@ class UserController extends BaseController
*/ */
public function getLogin(Request $request) public function getLogin(Request $request)
{ {
$data['key'] = env('DD_APP_KEY'); $key = env('dingoap7dwt39svqfxlnkx');
return view('login.index',$data); $redirectUri = env('dingoap7dwt39svqfxlnkx');
$url = 'https://oapi.dingtalk.com/connect/qrconnect?appid='.$key.'&response_type=code&scope=snsapi_login&state=STATE&redirect_uri='.$redirectUri;
return redirect($url);
} }
/** /**
...@@ -43,22 +45,12 @@ class UserController extends BaseController ...@@ -43,22 +45,12 @@ class UserController extends BaseController
*/ */
public function getReturnLogin(Request $request) public function getReturnLogin(Request $request)
{ {
$input = $request->all(); $Input = $request->all();
print_r($input);die();
$code = $input('get.code');
$state = $input('get.state');
if(!$code or !$state) {
$this->error('参数缺失');
}
if($state > time()) {
$this->error('参数异常');
}
$accessKey = env('DD_APP_SECRET'); $accessKey = env('DD_APP_SECRET');
$timestamp = $this->getmTime(); $timestamp = $this->getmTime();
$signature = $this->getsignature($timestamp,$accessKey); $signature = $this->getsignature($timestamp,$accessKey);
$url = 'https://oapi.dingtalk.com/sns/getuserinfo_bycode?accessKey=' . $accessKey . '&timestamp=' . $timestamp . '&signature=' . $signature; $url = 'https://oapi.dingtalk.com/sns/getuserinfo_bycode?accessKey=' . $accessKey . '&timestamp=' . $timestamp . '&signature=' . $signature;
$data = [ 'tmp_auth_code' => $code ]; $data = [ 'tmp_auth_code' => $Input['code'] ];
$userInfo = $this->curl_json($url, $data); $userInfo = $this->curl_json($url, $data);
$res = json_decode($userInfo, true); $res = json_decode($userInfo, true);
print_r($res);die(); print_r($res);die();
......
<!doctype html> <html lang="en">
<html lang="en" class="fixed">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>apk管理</title> <title>apk管理</title>
<link rel="icon" type="image/png" sizes="192x192" href=""> <link rel="icon" type="image/png" sizes="192x192" href="">
<link rel="stylesheet" href="/html/vendor/bootstrap/css/bootstrap.css">
<script src="https://g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script>
<style type="text/css"> <style type="text/css">
</style> </style>
...@@ -14,34 +12,36 @@ ...@@ -14,34 +12,36 @@
<body> <body>
<div id="login_container" style="width: 400px; margin:200px auto;"></div> <div id="login_container" style="width: 400px; margin:200px auto;"></div>
<script src="https://g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script>
<script> <script>
var url = encodeURIComponent('http://upload-apk.srccwl.com/return/login'); var url = encodeURIComponent('http://upload-apk.srccwl.com/return/login');
alert(url); var goto = encodeURIComponent('https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoap7dwt39svqfxlnkx &response_type=code&scope=snsapi_login&state=STATE&redirect_uri='+url);
var goto = encodeURIComponent('https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoap7dwt39svqfxlnkx &response_type=code&scope=snsapi_login&state=STATE&redirect_uri='+url) DDLogin({
alert(goto);
var obj = DDLogin({
id:"login_container", id:"login_container",
goto: goto, goto: goto,
style: "border:none;background-color:#FFFFFF;", style: "border:none;background-color:#FFFFFF;",
width : "322", width : "322",
height: "320" height: "320"
}); });
window.location.href="https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoap7dwt39svqfxlnkx&response_type=code&scope=snsapi_login&state=STATE&redirect_uri="+url+"&loginTmpCode="+loginTmpCode
var handleMessage = function (event) { var handleMessage = function (event) {
var origin = event.origin; var origin = event.origin;
if( origin == "https://login.dingtalk.com" ) { console.log("origin", event.origin);
//if( origin == "https://login.dingtalk.com" ) { //判断是否来自ddLogin扫码事件。
var loginTmpCode = event.data; var loginTmpCode = event.data;
alert(loginTmpCode); console.log("loginTmpCode", loginTmpCode);
alert(url);
window.location.href='https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoap7dwt39svqfxlnkx &response_type=code&scope=snsapi_login&state=STATE&redirect_uri='+url+'&loginTmpCode='+loginTmpCode // }
}
}; };
if (typeof window.addEventListener != 'undefined') { if (typeof window.addEventListener != 'undefined') {
window.addEventListener('message', handleMessage, false); window.addEventListener('message', handleMessage);
} else if (typeof window.attachEvent != 'undefined') { } else if (typeof window.attachEvent != 'undefined') {
window.attachEvent('onmessage', handleMessage); window.attachEvent('onmessage', handleMessage);
} }
</script> </script>
</body> </body>
</html> </html>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment