增加钉钉自动登录

This commit is contained in:
LawyZHENG
2021-03-19 10:33:59 +08:00
parent 3ca09b7cbf
commit a01cb91cbd
5 changed files with 191 additions and 10 deletions

View File

@@ -87,26 +87,42 @@
<script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/layer/layer.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/js/dingtalk-jsapi.js"}}" type="text/javascript"></script>
<!-- <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.10.3/dingtalk.open.js"></script> -->
<script type="text/javascript">
if (dd.env.platform !== "notInDingTalk"){
dd.ready(function() {
dd.runtime.permission.requestAuthCode({
corpId: "dingd55b04400e53d11cbc961a6cb783455b", // id
corpId: {{ .corpID }} , // id
onSuccess: function (info) {
$.post("http://192.168.0.51/token?action=AuthCorpUser", {"code": info.code}, function(rdata){
if (rdata.status == 0) {
$(window).attr('location', rdata.data.url)
}else{
alert(rdata.msg)
}
var index = layer.load(1, {
shade: [0.1, '#fff'] // 0.1
})
var formData = $("form").serializeArray()
formData.push({"name": "code", "value": info.code})
$.ajax({
url: "{{urlfor "AccountController.DingTalkLogin"}} ",
data: formData,
dataType: "json",
type: "POST",
complete: function(){
layer.close(index)
},
success: function (res) {
if (res.errcode !== 0) {
layer.msg(res.message)
} else {
window.location = "/"
}
},
// error: function () {
// }
})
// alert(info.code) //
}
});
});
}
</script>
<script type="text/javascript">
$(function () {