accelerate "dingtalk h5 auto login" speed

This commit is contained in:
LawyZHENG 2021-03-25 16:54:53 +08:00
parent 5404db07eb
commit ec5ce5c705

View File

@ -99,43 +99,41 @@
<script src="{{cdnjs "/static/js/dingtalk-ddlogin.js"}}" type="text/javascript"></script> <script src="{{cdnjs "/static/js/dingtalk-ddlogin.js"}}" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function () { if (dd.env.platform !== "notInDingTalk"){
if (dd.env.platform !== "notInDingTalk"){ dd.ready(function() {
dd.ready(function() { dd.runtime.permission.requestAuthCode({
dd.runtime.permission.requestAuthCode({ corpId: {{ .corpID }} , // 企业id
corpId: {{ .corpID }} , // 企业id onSuccess: function (info) {
onSuccess: function (info) { var index = layer.load(1, {
var index = layer.load(1, { shade: [0.1, '#fff'] // 0.1 透明度的白色背景
shade: [0.1, '#fff'] // 0.1 透明度的白色背景 })
})
var formData = $("form").serializeArray() var formData = $("form").serializeArray()
formData.push({"name": "dingtalk_code", "value": info.code}) formData.push({"name": "dingtalk_code", "value": info.code})
$.ajax({ $.ajax({
url: "{{urlfor "AccountController.DingTalkLogin"}} ", url: "{{urlfor "AccountController.DingTalkLogin"}} ",
data: formData, data: formData,
dataType: "json", dataType: "json",
type: "POST", type: "POST",
complete: function(){ complete: function(){
layer.close(index) layer.close(index)
}, },
success: function (res) { success: function (res) {
if (res.errcode !== 0) { if (res.errcode !== 0) {
layer.msg(res.message) layer.msg(res.message)
} else { } else {
window.location = "{{ urlfor "HomeController.Index" }}" window.location = "{{ urlfor "HomeController.Index" }}"
}
},
error: function (res) {
layer.msg("发生异常")
} }
}) },
} error: function (res) {
}); layer.msg("发生异常")
}
})
}
}); });
} });
}) }
</script> </script>