You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/application/third_party/dingding_auth/views/welcome.php

83 lines
3.1 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>钉钉授权</title>
<script type="text/javascript" src="https://g.alicdn.com/dingding/open-develop/1.6.9/dingtalk.js"></script>
<script type="text/javascript" src="https://g.alicdn.com/dingding/dingtalk-pc-api/2.7.0/index.js"></script>
<script src="/js/jquery.min.js"></script>
<script type="text/javascript">
var _config = <?php echo $auth_config; ?>;
var DingTalk = DingTalk || {};
(function (dt) {
var self = dt;
var ding;
dt.init = function () {
dt.isMobileClient = self.util.isMobileClient();
ding = self.isMobileClient ? dd : DingTalkPC;
};
dt.auth = function () {
ding.config({
agentId: _config.agentId,
corpId: _config.corpId,
timeStamp: _config.timeStamp,
nonceStr: _config.nonceStr,
signature: _config.signature,
jsApiList: [
'runtime.permission.requestAuthCode',
'device.notification.alert',
'device.notification.confirm',
'biz.contact.choose',
'device.notification.prompt',
'biz.ding.post'
] // 必填需要使用的jsapi列表
});
ding.userid = 0;
ding.ready(function (res) {
ding.runtime.permission.requestAuthCode({
corpId: _config.corpId, //企业ID
onSuccess: function (info) {
console.log('auth success ');
window.location.href = "/info.php/apps/dingding_auth/index/authOnSuccess/" +_config.agentId+'/'+_config.accessToken+'/'+ info.code;
},
onFail: function (err) {
console.log(JSON.stringify(err));
}
});
});
ding.error(function (error) {
console.log('dd error: ' + JSON.stringify(error));
});
};
dt.util = {
isMobileClient: function () {
return /(iPhone|iPod|Android|ios|iOS|iPad|Backerry|WebOS|Symbian|Windows Phone|Phone)/i.test(navigator.userAgent);
}
};
window.DingTalk = dt;
})(DingTalk);
DingTalk.init();
DingTalk.auth();
</script>
</head>
<body>
<div>
<p class="text-center">授权登录中,请稍候...</p>
</div>
</body>
</html>