|
|
|
@ -2,6 +2,7 @@ import { Result, Spin, Flex, Typography } from 'antd'
|
|
|
|
|
import React, { useEffect, useState } from 'react'
|
|
|
|
|
import { useNavigate } from 'react-router-dom'
|
|
|
|
|
import useAuthStore from '@/stores/AuthStore'
|
|
|
|
|
import { fetchJSON } from '@/utils/request'
|
|
|
|
|
|
|
|
|
|
const { Title } = Typography
|
|
|
|
|
|
|
|
|
@ -10,9 +11,16 @@ const { Title } = Typography
|
|
|
|
|
function DingdingQRCode() {
|
|
|
|
|
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
// const { loginUser } = useAuthContext()
|
|
|
|
|
|
|
|
|
|
const { loginStatus, fetchUser } = useAuthStore()
|
|
|
|
|
|
|
|
|
|
useEffect (() => {
|
|
|
|
|
if (location.search === '?out') {
|
|
|
|
|
window.sessionStorage.clear()
|
|
|
|
|
navigate('/p/dingding/qrcode')
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
import('https://g.alicdn.com/dingding/h5-dingtalk-login/0.21.0/ddlogin.js').then(() => {
|
|
|
|
|
window.DTFrameLogin(
|
|
|
|
@ -32,8 +40,28 @@ function DingdingQRCode() {
|
|
|
|
|
(loginResult) => {
|
|
|
|
|
const { authCode } = loginResult
|
|
|
|
|
fetchUser(authCode)
|
|
|
|
|
// setLoginStatus(200)
|
|
|
|
|
|
|
|
|
|
// fetchJSON(`https://p9axztuwd7x8a7.mycht.cn/dingtalk/dingtalkwork/WhatsAppAuth`, { authCode })
|
|
|
|
|
// .then(json => {
|
|
|
|
|
// if (json.errcode === 0) {
|
|
|
|
|
// loginUser.userId = json.result.opisn
|
|
|
|
|
// loginUser.accountName = json.result.opicode
|
|
|
|
|
// loginUser.username = json.result.nick
|
|
|
|
|
// loginUser.avatarUrl = json.result.avatarUrl
|
|
|
|
|
// loginUser.mobile = '+' + json.result.stateCode + '-' + json.result.mobile
|
|
|
|
|
// loginUser.email = json.result.email
|
|
|
|
|
// loginUser.openId = json.result.openId
|
|
|
|
|
// loginUser.accountList = json.result.accountlist
|
|
|
|
|
// window.sessionStorage.setItem('GLOBAL_SALES_LOGIN_USER', JSON.stringify(loginUser))
|
|
|
|
|
// setLoginStatus(302)
|
|
|
|
|
// } else {
|
|
|
|
|
// setLoginStatus(403)
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
},
|
|
|
|
|
(errorMsg) => {
|
|
|
|
|
// setLoginStatus(403)
|
|
|
|
|
console.error(`Login Error: ${errorMsg}`)
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|