钉钉H5微应用
公司新项目要用到Vue+钉钉H5,在此记录一下免密登录:
引入插件:
import * as dd from 'dingtalk-jsapi'
import { login as loginUrl } from '../api/login'
新建方法:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
export function login() { return new Promise((resolve, reject) => { dd.ready(function () { dd.runtime.permission.requestAuthCode({ corpId: 'dingdbcd84596436b4d535c2f4657eb6378f', onSuccess: function (result) { /* { code: 'hYLK98jkf0m' //string authCode } */ // console.log(result) loginUrl(result.code).then(val => { if (val.code === 200) { resolve(val.data) } }) }, onFail: function (_err) { resolve('164636245023643942') } }) }) }) }
注意:引入钉钉是一定要加“dd.ready”,不然会有报错