|
@@ -2,11 +2,22 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
import dd from 'gdt-jsapi'
|
|
import dd from 'gdt-jsapi'
|
|
import styles from './index.module.scss'
|
|
import styles from './index.module.scss'
|
|
import { MessageFu } from '@/utils/message'
|
|
import { MessageFu } from '@/utils/message'
|
|
-import { API_ddLogin } from '@/store/action/layout'
|
|
|
|
|
|
+import { API_ddLogin, API_LoginGetCode } from '@/store/action/layout'
|
|
import { Button } from 'antd'
|
|
import { Button } from 'antd'
|
|
import { setTokenInfo } from '@/utils/storage'
|
|
import { setTokenInfo } from '@/utils/storage'
|
|
import history from '@/utils/history'
|
|
import history from '@/utils/history'
|
|
function DingLogin() {
|
|
function DingLogin() {
|
|
|
|
+ // 获取验证码
|
|
|
|
+ const LoginGetCodeFu = useCallback(async () => {
|
|
|
|
+ const res: any = await API_LoginGetCode()
|
|
|
|
+
|
|
|
|
+ console.log('pppp', res)
|
|
|
|
+ }, [])
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if (isMyAlert) LoginGetCodeFu()
|
|
|
|
+ }, [LoginGetCodeFu])
|
|
|
|
+
|
|
const DDloginFu = useCallback(() => {
|
|
const DDloginFu = useCallback(() => {
|
|
dd.ready(function () {
|
|
dd.ready(function () {
|
|
dd.getAuthCode({
|
|
dd.getAuthCode({
|
|
@@ -14,7 +25,13 @@ function DingLogin() {
|
|
})
|
|
})
|
|
.then(async res1 => {
|
|
.then(async res1 => {
|
|
const code = res1.auth_code
|
|
const code = res1.auth_code
|
|
|
|
+
|
|
|
|
+ // if (isMyAlert) alert(`code:${code}`)
|
|
|
|
+
|
|
const res = await API_ddLogin(code!)
|
|
const res = await API_ddLogin(code!)
|
|
|
|
+
|
|
|
|
+ // if (isMyAlert) alert(JSON.stringify(res))
|
|
|
|
+
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
MessageFu.success('登录成功')
|
|
MessageFu.success('登录成功')
|
|
// 用户信息存到本地
|
|
// 用户信息存到本地
|
|
@@ -28,6 +45,8 @@ function DingLogin() {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
.catch(err => {
|
|
.catch(err => {
|
|
|
|
+ // if (isMyAlert) alert(JSON.stringify(err))
|
|
|
|
+
|
|
MessageFu.error(err)
|
|
MessageFu.error(err)
|
|
})
|
|
})
|
|
})
|
|
})
|
|
@@ -60,7 +79,7 @@ function DingLogin() {
|
|
<div className={styles.DingLogin}>
|
|
<div className={styles.DingLogin}>
|
|
<div className='DingLoginBox'>
|
|
<div className='DingLoginBox'>
|
|
<Button type='primary' size='large' onClick={() => setNum(0)}>
|
|
<Button type='primary' size='large' onClick={() => setNum(0)}>
|
|
- 钉钉授权登录
|
|
|
|
|
|
+ 浙政钉授权登录
|
|
</Button>
|
|
</Button>
|
|
<h3 style={{ opacity: num <= 0 ? '0' : '1' }}>
|
|
<h3 style={{ opacity: num <= 0 ? '0' : '1' }}>
|
|
<span>{num}</span>秒之后自动登录
|
|
<span>{num}</span>秒之后自动登录
|