|
@@ -4,11 +4,11 @@ import { Col, Modal, Row, Input, message, Space, Tabs, Button, Select } from 'an
|
|
|
import React, { useCallback, useEffect, useState } from 'react'
|
|
|
import { columnsMp } from './tableConfig'
|
|
|
import { useAjax } from '@/Hook/useAjax'
|
|
|
-import { getAdAccountListApi, GetAdAccountParams, putAdAccountApi } from '@/services/launchAdq/adAuthorize'
|
|
|
+import { getAdAccountListApi, GetAdAccountParams, getAuthInfoApi, putAdAccountApi, setAuthSuccessApi } from '@/services/launchAdq/adAuthorize'
|
|
|
import style from './index.less'
|
|
|
import TableData from '@/pages/launchSystemNew/components/TableData'
|
|
|
import GroupLeft from './groupLeft'
|
|
|
-import { MenuFoldOutlined, MenuUnfoldOutlined, PlusOutlined, SwapOutlined } from '@ant-design/icons'
|
|
|
+import { ExclamationCircleOutlined, MenuFoldOutlined, MenuUnfoldOutlined, PlusOutlined, SafetyOutlined, SwapOutlined } from '@ant-design/icons'
|
|
|
import { getAdAccountAllOfMember, getErpUserAll, getServiceProviderAll, putConfigServiceProvider, putRefreshTokenApi } from '@/services/launchAdq/adq'
|
|
|
import AddAccountToGroup from './addAccountToGroup'
|
|
|
import { delAccountToGroupApi } from '@/services/launchAdq/subgroup'
|
|
@@ -17,9 +17,10 @@ import ChangeRecord from './changeRecord'
|
|
|
import CheckAccount from './checkAccount'
|
|
|
import AppointPut from './appointPut'
|
|
|
import SetEarlyWarningsAccount from '@/components/EarlyWarning/setEarlyWarningsAccount'
|
|
|
-import { AdUnitType_Enum } from './const'
|
|
|
import TeamMembers from '@/pages/launchSystemNew/components/teamMembers'
|
|
|
import QQAuth from '@/pages/launchSystemNew/account/components/qqAuto'
|
|
|
+import { history } from 'umi';
|
|
|
+import moment from 'moment'
|
|
|
|
|
|
/** 投放管理 */
|
|
|
const AdAuthorize: React.FC = () => {
|
|
@@ -58,10 +59,14 @@ const AdAuthorize: React.FC = () => {
|
|
|
const [selectAccData, setSelectAccData] = useState<any[]>([])
|
|
|
const [puShow, setPuShow] = useState<boolean>(false)
|
|
|
const [puData, setPuData] = useState<any[]>([])
|
|
|
+ const [expireTime, setExpireTime] = useState<string>()
|
|
|
+ const [tokenStatus, setTokenStatus] = useState<string>('normal')
|
|
|
const [switchType, setSwitchType] = useState<'account' | 'putUser' | 'setServer' | 'refreshToken'>('account')
|
|
|
const putRemark = useAjax((adAccountId: any, remark: any) => putAdAccountApi(adAccountId, remark))
|
|
|
const delAccountToGroup = useAjax((params) => delAccountToGroupApi(params))
|
|
|
const getAdAccountList = useAjax((params) => getAdAccountListApi(params), { formatResult: true })
|
|
|
+ const setAuthSuccess = useAjax((params) => setAuthSuccessApi(params), { formatResult: true })
|
|
|
+ const getAuthInfo = useAjax(() => getAuthInfoApi(), { formatResult: true })
|
|
|
const allOfMember = useAjax(() => getAdAccountAllOfMember(), { formatResult: true })
|
|
|
const erpUserALL = useAjax(() => getErpUserAll(), { formatResult: true })
|
|
|
const api_getServiceProviderAll = useAjax(() => getServiceProviderAll(), { formatResult: true })
|
|
@@ -69,8 +74,39 @@ const AdAuthorize: React.FC = () => {
|
|
|
const putRefreshToken = useAjax((params) => putRefreshTokenApi(params), { formatResult: true })
|
|
|
/*************************/
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ const query = history.location.query
|
|
|
+ if (query?.user_token && query?.user_status && query?.wx_id) {
|
|
|
+ setAuthSuccess.run({
|
|
|
+ userStatus: query.user_status, userToken: query.user_token, expireTime: query.expire_time, wxId: query.wx_id, state: query?.state
|
|
|
+ }).then(() => {
|
|
|
+ message.success('授权成功', () => {
|
|
|
+ location.href = window.location.href.split('?')[0]
|
|
|
+ location.reload()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ message.error('授权失败')
|
|
|
+ }
|
|
|
+ }, [])
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
groupListInit()
|
|
|
+ getAuthInfo.run().then(res => {
|
|
|
+ if (res?.data?.expireTime && moment(res?.data?.expireTime) > moment()) {
|
|
|
+ setExpireTime(res?.data?.expireTime)
|
|
|
+ setTokenStatus(res?.data?.tokenStatus)
|
|
|
+ } else {
|
|
|
+ Modal.confirm({
|
|
|
+ title: '授权',
|
|
|
+ icon: <ExclamationCircleOutlined />,
|
|
|
+ content: '授权已过期,请重新授权!',
|
|
|
+ onOk() {
|
|
|
+ window.open(`https://ad.qq.com/account-center/single/user-authorize?redirect_uri=${encodeURIComponent(location.href)}&state=${encodeURIComponent(1)}`, '_blank')
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
!erpUserALL.data && erpUserALL.run()
|
|
|
!api_getServiceProviderAll.data && api_getServiceProviderAll.run()
|
|
|
}, [])
|
|
@@ -164,9 +200,19 @@ const AdAuthorize: React.FC = () => {
|
|
|
activeKey={activeKey}
|
|
|
type="card"
|
|
|
// tabBarExtraContent={<Button type='primary' onClick={()=>setVisible(true)}><PlusOutlined />广告账号授权</Button>}
|
|
|
+ tabBarExtraContent={<Button
|
|
|
+ type='primary'
|
|
|
+ loading={getAuthInfo.loading}
|
|
|
+ style={['expire', 'no', 'will_expire'].includes(tokenStatus) ? {
|
|
|
+ backgroundColor: ['expire', 'no'].includes(tokenStatus) ? '#ff4d4f' : '#faad14',
|
|
|
+ borderColor: ['expire', 'no'].includes(tokenStatus) ? '#ff4d4f' : '#faad14'
|
|
|
+ } : {}}
|
|
|
+ icon={<SafetyOutlined />}
|
|
|
+ onClick={() => window.open(`https://ad.qq.com/account-center/single/user-authorize?redirect_uri=${encodeURIComponent(location.href)}&state=${encodeURIComponent(1)}`, '_blank')}
|
|
|
+ >投放人员授权{expireTime ? `,到期时间:${expireTime}` : ''}</Button>}
|
|
|
onChange={(activeKey) => {
|
|
|
if (activeKey !== 'contract') {
|
|
|
- let newQueryForm = JSON.parse(JSON.stringify(queryForm))
|
|
|
+ const newQueryForm = JSON.parse(JSON.stringify(queryForm))
|
|
|
delete newQueryForm?.groupId
|
|
|
delete newQueryForm?.putUserId
|
|
|
setQueryForm(newQueryForm)
|