|
@@ -11,6 +11,7 @@ let api= "http://47.99.157.216:8023"
|
|
|
function QQAuth(props: { qqVisible: boolean, callBack: () => void }) {
|
|
|
const { qqVisible, callBack } = props
|
|
|
let [visible, setVisible] = useState(false)
|
|
|
+ let [loading,setLoading]=useState(false)
|
|
|
let [codeUrl, setCodeUrl] = useState('')
|
|
|
let [err, setErr] = useState({})
|
|
|
let [data, setData] = useState({
|
|
@@ -28,6 +29,7 @@ function QQAuth(props: { qqVisible: boolean, callBack: () => void }) {
|
|
|
message.error('账号请使用数字!!!!!!')
|
|
|
return
|
|
|
}
|
|
|
+ setLoading(true)
|
|
|
fetch(api+'/qq/auth', {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
@@ -38,19 +40,32 @@ function QQAuth(props: { qqVisible: boolean, callBack: () => void }) {
|
|
|
if (r?.data?.codeImgUrl) {
|
|
|
setCodeUrl(r?.data?.codeImgUrl)
|
|
|
setVisible(true)
|
|
|
+ let n=0
|
|
|
time = setInterval(() => {
|
|
|
- fetch(`${api}/qq/isOk?userId=${localStorage.getItem('userId')}`, {
|
|
|
- method: 'GET'
|
|
|
- }).then(res => res.json()).then(r => {
|
|
|
- if (r.data) {
|
|
|
- setVisible(false)
|
|
|
- setCodeUrl("")
|
|
|
- clearInterval(time)
|
|
|
- }
|
|
|
- })
|
|
|
+ if(n< 60){
|
|
|
+ n+=1
|
|
|
+ fetch(`${api}/qq/isOk?userId=${localStorage.getItem('userId')}`, {
|
|
|
+ method: 'GET'
|
|
|
+ }).then(res => res.json()).then(r => {
|
|
|
+ if (r.data) {
|
|
|
+ setVisible(false)
|
|
|
+ setCodeUrl("")
|
|
|
+ clearInterval(time)
|
|
|
+ setLoading(false)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ message.error('扫码超时请重新扫码!')
|
|
|
+ setVisible(false)
|
|
|
+ setCodeUrl("")
|
|
|
+ clearInterval(time)
|
|
|
+ setLoading(false)
|
|
|
+ }
|
|
|
+
|
|
|
}, 1000)
|
|
|
} else {
|
|
|
message.success('已经开始授权,稍后自行查看结果!')
|
|
|
+ setLoading(false)
|
|
|
}
|
|
|
console.log(r)
|
|
|
})
|
|
@@ -106,8 +121,8 @@ function QQAuth(props: { qqVisible: boolean, callBack: () => void }) {
|
|
|
</Row>
|
|
|
<Row style={{ display: 'flex', justifyContent: 'center', marginTop: 20 }}>
|
|
|
<Space>
|
|
|
- <Button type='primary' onClick={submit}>提交</Button>
|
|
|
- <Button type='default' onClick={query}>查询授权失败账号</Button>
|
|
|
+ <Button type='primary' onClick={submit} loading={loading}>提交</Button>
|
|
|
+ <Button type='default' onClick={query} >查询授权失败账号</Button>
|
|
|
<Popconfirm title={'清除账号状态将清除所有失败记录,并清空上一次扫码授权状态!'} onConfirm={del} >
|
|
|
<Button type='primary' danger >清除账号状态</Button>
|
|
|
</Popconfirm>
|