Commit b682c964 authored by zhoujun's avatar zhoujun

'初始版本'

parent 68dd36da
Pipeline #540 failed with stages
......@@ -31,8 +31,10 @@ class UserController extends BaseController
*/
public function getLogin(Request $request)
{
$data['key'] = env('DD_APP_KEY');
return view('login.index',$data);
$key = env('dingoap7dwt39svqfxlnkx');
$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
*/
public function getReturnLogin(Request $request)
{
$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('参数异常');
}
$Input = $request->all();
$accessKey = env('DD_APP_SECRET');
$timestamp = $this->getmTime();
$signature = $this->getsignature($timestamp,$accessKey);
$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);
$res = json_decode($userInfo, true);
print_r($res);die();
......
<!doctype html>
<html lang="en" class="fixed">
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>apk管理</title>
<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>
......@@ -14,34 +12,36 @@
<body>
<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>
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)
alert(goto);
var obj = DDLogin({
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({
id:"login_container",
goto: goto,
style: "border:none;background-color:#FFFFFF;",
width : "322",
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 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;
alert(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
}
console.log("loginTmpCode", loginTmpCode);
// }
};
if (typeof window.addEventListener != 'undefined') {
window.addEventListener('message', handleMessage, false);
window.addEventListener('message', handleMessage);
} else if (typeof window.attachEvent != 'undefined') {
window.attachEvent('onmessage', handleMessage);
}
</script>
</body>
</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