技术标签: VUE vue.js javascript
<template>
<div id="app">
<div id="login_container"></div>
</div>
</template>
<script>
import axios from 'axios'
export default {
name: 'App',
components: {},
data() {
return {
appid: '<钉钉应用APPID>',
redirectUrl: '<扫码跳转URL(使用当前URL,我们会处理跳转后回调URL的CODE)>',
apiUrl: '<用户信息接口,把redirectUrl回调获取的CODE给后端用于获取扫码用户信息>',
dingCodeConfig: {
id: 'login_container',
style: "border:none;background-color:#FFFFFF;",
width: "365",
height: "400"
}
}
},
computed: {
getRedirectUrl() {
return encodeURIComponent(this.redirectUrl)
},
getAuthUrl() {
return `https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=${this.appid}&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=${this.getRedirectUrl}`
},
getGoto() {
return encodeURIComponent(this.getAuthUrl)
},
getDingCodeConfig() {
return {...this.dingCodeConfig, goto: this.getGoto}
}
},
created() {
this.initDingJs()
},
mounted() {
this.addDingListener()
this.initDingLogin()
this.getUser()
},
methods: {
initDingJs() {
!function (window, document) {
function d(a) {
var e, c = document.createElement("iframe"),
d = "https://login.dingtalk.com/login/qrcode.htm?goto=" + a.goto;
d += a.style ? "&style=" + encodeURIComponent(a.style) : "",
d += a.href ? "&href=" + a.href : "",
c.src = d,
c.frameBorder = "0",
c.allowTransparency = "true",
c.scrolling = "no",
c.width = a.width ? a.width + 'px' : "365px",
c.height = a.height ? a.height + 'px' : "400px",
e = document.getElementById(a.id),
e.innerHTML = "",
e.appendChild(c)
}
window.DDLogin = d
}(window, document);
},
addDingListener() {
let self = this
let handleLoginTmpCode = function (loginTmpCode) {
window.location.href = self.getAuthUrl + `&loginTmpCode=${loginTmpCode}`
}
let handleMessage = function (event) {
if (event.origin == "https://login.dingtalk.com") {
handleLoginTmpCode(event.data)
}
}
if (typeof window.addEventListener != 'undefined') {
window.addEventListener('message', handleMessage, false)
} else if (typeof window.attachEvent != 'undefined') {
window.attachEvent('onmessage', handleMessage)
}
},
initDingLogin() {
window.DDLogin(this.getDingCodeConfig);
},
getUser() {
let getQueryString = function (name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
var r = window.location.search.substr(1).match(reg)
if (r != null) {
return unescape(r[2])
}
return null
}
let code = getQueryString('code')
if (code !== null) {
axios
.get(`${this.apiUrl}?code=${code}`)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
}
}
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
文章浏览阅读694次。如果服务成功启动,状态应显示为 “active”。现在,您的服务将在系统启动时自动启动编写启动脚本。创建一个服务文件:使用文本编辑器创建一个以。验证服务状态:使用以下命令检查服务的状态。启用服务:使用以下命令启用服务。启动服务:使用以下命令启动服务。结尾的服务文件,例如。_ubuntu systemctl设置开机运行脚本
文章浏览阅读2.5k次。Everything是一款基于名称快速定位文件和文件夹的window上的搜索软件。_everything 文件内容
文章浏览阅读1.6k次。在含有电阻、电感和电容的交流电路中,电路两端电压与其电流一般是不同相的,若调节电路参数或电源频率使电流与电源电压同相,电路呈电阻性,称这时电路的工作状态为谐振。谐振现象是正弦交流电路的一种特定现象,它在电子和通讯工程中得到广泛应用,但在电力系统中,发生谐振有可能破坏系统的正常工作。谐振一般分串联谐振和并联谐振。顾名思义,串联谐振就是在串联电路中发生的谐振。并联谐振就是在并联电路中发生的谐振。串联谐..._并联谐振 电流计算
文章浏览阅读5.7k次,点赞4次,收藏19次。如何使用Windows server 2022 创建ad域与加入_windows server 2022配置域控
文章浏览阅读7.1k次。魔兽世界怀旧服10月已经到来,目前怀旧服由于位面的逐渐取消,导致现在排队严重,让很多玩家还想知道现在各大服务器的人口普查数据,下面就来为大家详细的介绍一下最新10月份的人口普查阵营比例。12月19日更新:【魔兽世界怀旧服12月最新转服前人口普查 联盟部落阵营比例数据】魔兽世界怀旧服人口普查插件已经被修复,所以这个就是最终版,此外还有附带一些目前新服务器的情况。大家也就凑合着看看之前记录的最新数据,...
文章浏览阅读855次。目录Base64编码SSL 与 OpenSSLmacOS 下 RSA 证书生成过程Base64编码Base64编码简介一般情况下,如果用记事本直接打开 .exe、.jpg、.pdf、… 等格式的文件时,会看到一大堆乱码,因为二进制文件包含很多无法显示和打印的字符。所以,如果要让像记事本这样的文本处理软件能处理和显示二进制数据,就需要一个二进制数据到字符串的转换方法。Base64 就是一种最常见的二进制编码方法。Base64 是一种用 64 个字符来表示任意二进制数据的方法。Base64 是一种__airths的博客-csdn博客.pdf
文章浏览阅读1.2k次。文件名大小更新时间ROSTCM6.exedict/1.datdict/2.datdict/3.datdict/4.datdict/5.datdict/6.datdict/8.datdict/9.datdict/F.datdict/new.datdict/s.datdict/SSCItitle.txtdict/Z.datsample/模拟群(437343630).txtuser/Feature.tx..._rostcm6.exe
文章浏览阅读1.8w次,点赞46次,收藏371次。前后端参数传递总结(@RequestParam @RequestBody@PathVariable @RequestHeader )@RequestParam@RequestBody合理的创建标题,有助于目录的生成如何改变文本的样式@RequestParam@RequestParam 常用来处理简单类型的绑定,通过Request.getParameter() 获取的String可直接转换为简单类型的情况( String–> 简单类型的转换操作由ConversionService配置的转换器来完成_pathvariable前端传参
文章浏览阅读2.9w次,点赞29次,收藏113次。C语言 strstr函数的用法及模拟实现strstr函数一、strstr函数的用法二、模拟实现strstr函数的功能一、strstr函数的用法1.strstr函数原型:char* strstr(const char* str1,const char* str2)2.功能:strstr()是一个参数为两个字符指针类型,返回值是char*类型的函数,它用于找到子串(str2)在一个字符串(str1)中第一次出现的位置。这里因为传进来的地址指向的内容不会在发生改变,所以我们在两个形参(char*)前加上c_strstr
文章浏览阅读293次。--_使用page标准动作可以实现动态包含
文章浏览阅读742次,点赞5次,收藏8次。ROS打包错误: /usr/bin/ld: cannot find -lpthreads 的解决_performing test cmake_have_libc_pthread - failed
文章浏览阅读1.7k次。“本文介绍的论文全面概述了深度神经网络的压缩方法,主要可分为参数修剪与共享、低秩分解、迁移/压缩卷积滤波器和知识精炼,本论文对每一类方法的性能、相关应用、优势和缺陷等进行独到的分析。” 大型神经网络具有大量的层级与结点,因此考虑如何减少它们所需要的内存与计算量就显得极为重要,特别是对于在线学习和增量学习等实时应用。此外,近来智能可穿戴设备的流行也为研究员提供了在资源(内存、CPU、能..._深度网络模型压缩