shenwu 2 年 前
コミット
334dc4d633

+ 6 - 3
src/pages/launchSystemNew/account/index.tsx

@@ -1,6 +1,6 @@
 
 import HocError from '@/Hoc/HocError'
-import { Col, Modal, Row, Input, message, Space } from 'antd'
+import { Col, Modal, Row, Input, message, Space, Button } from 'antd'
 import React, { useCallback, useEffect, useState } from 'react'
 import { columnsMp } from './tableConfig'
 import { useModel } from 'umi'
@@ -9,10 +9,11 @@ import { getAdAccountListApi, putAdAccountApi } from '@/services/launchAdq/adAut
 import style from './index.less'
 import TableData from '../components/TableData'
 import GroupLeft from './groupLeft'
+import QQAuth from './qqAuto'
 
 /** 投放管理 */
 const AdAuthorize: React.FC = () => {
-
+    let [visible, setVisible] = useState(false)
     /*************************/
     const { getAdAccount } = useModel('useLaunchAdq.useAdAuthorize')
     const [tableData, setTableData] = useState<any[]>([])
@@ -73,11 +74,13 @@ const AdAuthorize: React.FC = () => {
                             }
                         }} />
                         {/* <Button onClick={getList} type='primary'>搜索</Button> */}
+                        <Button type='primary' onClick={()=>setVisible(true)}>广告账号授权</Button>
                     </Space>}
                 />
             </div>
         {/* </div> */}
-
+        {/* 授权 */}
+        {visible && <QQAuth qqVisible={visible} callBack={()=>setVisible(false)}/>}
         {remarkData.visible && <Modal
             visible={remarkData.visible}
             title='编辑账户'

+ 144 - 0
src/pages/launchSystemNew/account/qqAuto.tsx

@@ -0,0 +1,144 @@
+import { useCallback, useState } from "react"
+import React from 'react'
+import { Col, Row, Radio, Input, Button, message, Space, Image, Modal, Popconfirm } from "antd";
+let name = {
+    0: '小说账号失败列表:',
+    1: '游戏账号失败列表:',
+}
+var time: any = null
+// let api= "http://47.99.157.216:8023"
+let api= "http://127.0.0.1:8023"
+function QQAuth(props: { qqVisible: boolean, callBack: () => void }) {
+    const { qqVisible, callBack } = props
+    let [visible, setVisible] = useState(false)
+    let [codeUrl, setCodeUrl] = useState('')
+    let [err, setErr] = useState({})
+    let [data, setData] = useState({
+        userId: localStorage.getItem('userId'),
+        adAppType: 0,
+        users: [],
+        callbackPage: 'http%3A%2F%2Ferp.zanxiangnet.com%2FadCode',
+        authorization: `Bearer ${sessionStorage.getItem('Admin-Token')}`
+    })
+    let adAppIdonChange = useCallback((checkedValue) => {
+        setData({ ...data, adAppType: checkedValue })
+    }, [data])
+    let submit = useCallback(() => {
+        if (data.users.some(user => isNaN(user))) {
+            message.error('账号请使用数字!!!!!!')
+            return
+        }
+        fetch(api+'/qq/auth', {
+            method: 'POST',
+            headers: {
+                "content-type": "application/json",
+            },
+            body: JSON.stringify(data)
+        }).then(res => res.json()).then(r => {
+            if (r?.data?.codeImgUrl) {
+                setCodeUrl(r?.data?.codeImgUrl)
+                setVisible(true)
+                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)
+                        }
+                    })
+                }, 1000)
+            } else {
+                message.success('已经开始授权,稍后自行查看结果!')
+            }
+            console.log(r)
+        })
+    }, [data])
+    let query = () => {
+        fetch(`${api}/qq/queryErr?userId=${localStorage.getItem('userId')}`, {
+            method: 'GET'
+        }).then(res => res.json()).then(r => {
+            console.log(r)
+            setErr(r.data)
+        })
+    }
+    let del = () => {
+        fetch(`${api}/qq/delCookie?userId=${localStorage.getItem('userId')}`, {
+            method: 'GET'
+        }).then(res => res.json()).then(r => {
+            console.log(r)
+            message.success('清理成功!!!!请重新扫码授权登录!!!')
+        })
+    }
+    let userIdChange = useCallback((e) => {
+        let value = e.target.value
+        let arr = value.split(/,|,/)
+        let newArr = arr?.map((str: string) => Number(str.replace(/\s/ig, '')))
+        setData({ ...data, users: newArr })
+    }, [data])
+    return <Modal
+        visible={qqVisible}
+        footer={null}
+        width={800}
+        onCancel={callBack}
+        maskClosable={false}
+    >
+        <div>
+            <Row>
+                <Col span='24'>
+                    <Row>
+                        <Col span={3}><h3>平台选择:</h3></Col>
+                        <Col span={20}>
+                            <Radio.Group style={{ width: '100%' }} onChange={adAppIdonChange} defaultValue={data.adAppType}>
+                                <Radio value={0}>小说</Radio>
+                                <Radio value={1}>游戏</Radio>
+                            </Radio.Group>
+                        </Col>
+                    </Row>
+                </Col>
+                <Col span='24'>
+                    <Row>
+                        <Col span={3}><h3>账号ID:</h3></Col>
+                        <Col span={20}> <Input.TextArea placeholder='多个账号请以,号隔开例:123456,222333,444444' rows={5} onChange={userIdChange} allowClear></Input.TextArea></Col>
+                    </Row>
+                </Col>
+            </Row>
+            <Row style={{ display: 'flex', justifyContent: 'center', marginTop: 20 }}>
+                <Space>
+                    <Button type='primary' onClick={submit}>提交</Button>
+                    <Button type='default' onClick={query}>查询授权失败账号</Button>
+                    <Popconfirm title={'清除账号状态将清除所有失败记录,并清空上一次扫码授权状态!'} onConfirm={del} >
+                        <Button type='primary' danger >清除账号状态</Button>
+                    </Popconfirm>
+
+                </Space>
+            </Row>
+            <Row>
+                {
+                    Object.keys(err).map((key, i) => {
+                        return <Col key={i} span={24}>
+                            <div>
+                                <h4>{name[key]}</h4>
+                                <p>{err[key]?.join()}</p>
+                            </div>
+                        </Col>
+                    })
+                }
+            </Row>
+            <Modal
+                visible={visible}
+                footer={null}
+                width={200}
+                onCancel={() => setVisible(false)}
+                maskClosable={false}
+            >
+                <Image
+                    style={{ width: 150 }}
+                    src={codeUrl} />
+            </Modal>
+        </div>
+    </Modal>
+
+}
+export default QQAuth

+ 3 - 1
src/pages/launchSystemNew/adq/ad/index.tsx

@@ -88,8 +88,8 @@ const Ad: React.FC<Props> = (props) => {
     }) => {
         if (!params.adgroupName || params.adgroupName !== listAjax?.params[0]?.adgroupName) {
             !params.adgroupName && delete params.adgroupName
-            listAjax.run({ ...params, userId })
         }
+        listAjax.run({ ...params, userId })
     }, [userId, listAjax])
     // 同步 
     const sync = useCallback(() => {
@@ -527,6 +527,8 @@ const Ad: React.FC<Props> = (props) => {
             onChange={(props: any) => {
                 let { sortData, pagination } = props
                 let { current, pageSize } = pagination
+                console.log(pagination)
+                console.log({...queryFrom, pageNum: current, pageSize })
                 set_queryFrom({...queryFrom,pageNum:current,pageSize})
                 getList({...queryFrom, pageNum: current, pageSize })
             }}