|  | @@ -1,8 +1,8 @@
 | 
	
		
			
				|  |  |  import { useAjax } from "@/Hook/useAjax"
 | 
	
		
			
				|  |  | -import { appAccountConfig, getAppAccountConfig, tencentAdAccountDoAuth, tencentAdAccountToAuth } from "@/services/miniApp/adBack"
 | 
	
		
			
				|  |  | +import { appAccountConfig, doAuthOfBUnit, getAppAccountConfig, tencentAdAccountDoAuth, tencentAdAccountToAuth } from "@/services/miniApp/adBack"
 | 
	
		
			
				|  |  |  import { BetaSchemaForm, PageContainer, ProCard, ProForm, ProFormInstance, ProFormRadio, ProFormSelect, ProFormText } from "@ant-design/pro-components"
 | 
	
		
			
				|  |  |  import { history, useModel } from "@umijs/max"
 | 
	
		
			
				|  |  | -import { Button, Divider, message, Space } from "antd"
 | 
	
		
			
				|  |  | +import { Button, Divider, List, message, Modal, Radio, Space } from "antd"
 | 
	
		
			
				|  |  |  import { useEffect, useRef, useState } from "react"
 | 
	
		
			
				|  |  |  import formConfig from "./formConfig"
 | 
	
		
			
				|  |  |  import { searchToObj } from "@/utils"
 | 
	
	
		
			
				|  | @@ -14,10 +14,13 @@ function Auth() {
 | 
	
		
			
				|  |  |      let [isEdit, setIsEdit] = useState(false)
 | 
	
		
			
				|  |  |      const [readonly, setReadonly] = useState(false);
 | 
	
		
			
				|  |  |      const formRef = useRef<ProFormInstance>();
 | 
	
		
			
				|  |  | +    const [accountData, setAccountData] = useState<any>(null)
 | 
	
		
			
				|  |  | +    const [accountId, setAccountId] = useState(null)
 | 
	
		
			
				|  |  |      let TencentAdAccountToAuth = useAjax((params) => tencentAdAccountToAuth(params))//获取授权地址
 | 
	
		
			
				|  |  |      let TencentAdAccountDoAuth = useAjax((params) => tencentAdAccountDoAuth(params))//开始授权
 | 
	
		
			
				|  |  |      let GetAppAccountConfig = useAjax((params) => getAppAccountConfig(params))//获取回传配置
 | 
	
		
			
				|  |  |      let AppAccountConfig = useAjax((params) => appAccountConfig(params))//设置配置
 | 
	
		
			
				|  |  | +    let DoAuthOfBUnit = useAjax((params) => doAuthOfBUnit(params))//广告业务单元授权
 | 
	
		
			
				|  |  |      // 获取广告回传列表
 | 
	
		
			
				|  |  |      useEffect(() => {
 | 
	
		
			
				|  |  |          // 授权回调
 | 
	
	
		
			
				|  | @@ -30,11 +33,20 @@ function Auth() {
 | 
	
		
			
				|  |  |                      "callbackPage": "https://testdistribution.zanxiangwl.com/miniApp/adBack"
 | 
	
		
			
				|  |  |                  }).then(res => {
 | 
	
		
			
				|  |  |                      if (res.code === 200) {
 | 
	
		
			
				|  |  | -                        message.success("授权成功")
 | 
	
		
			
				|  |  | +                        // 授权失败
 | 
	
		
			
				|  |  | +                        if (res.data.authorizationStatus == 1) {
 | 
	
		
			
				|  |  | +                            setAccountData(res.data)
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            message.success("授权成功")
 | 
	
		
			
				|  |  | +                            setTimeout(() => {
 | 
	
		
			
				|  |  | +                                history.push("/miniApp/adBack")
 | 
	
		
			
				|  |  | +                            }, 1000)
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        setTimeout(() => {
 | 
	
		
			
				|  |  | +                            history.push("/miniApp/adBack")
 | 
	
		
			
				|  |  | +                        }, 1000)
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                   setTimeout(()=>{
 | 
	
		
			
				|  |  | -                    history.push("/miniApp/adBack")
 | 
	
		
			
				|  |  | -                   },1000)
 | 
	
		
			
				|  |  |                  })
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -109,6 +121,19 @@ function Auth() {
 | 
	
		
			
				|  |  |              }, 100)
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    // 广告单元授权
 | 
	
		
			
				|  |  | +    const ad = () => {
 | 
	
		
			
				|  |  | +        doAuthOfBUnit({ state: accountData?.state, accountId }).then(res => {
 | 
	
		
			
				|  |  | +            if (res.code === 200) {
 | 
	
		
			
				|  |  | +                message.success("授权成功")
 | 
	
		
			
				|  |  | +                setAccountData(null)
 | 
	
		
			
				|  |  | +                setAccountId(null)
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            setTimeout(() => {
 | 
	
		
			
				|  |  | +                history.push("/miniApp/adBack")
 | 
	
		
			
				|  |  | +            }, 1000)
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      return <PageContainer
 | 
	
		
			
				|  |  |          tabList={getEnum("ADVERTISING_CHANNEL", "arr")?.map((item: { label: any; key: any }, index: number) => {
 | 
	
		
			
				|  |  |              if (index === 0 && !key) {
 | 
	
	
		
			
				|  | @@ -212,6 +237,26 @@ function Auth() {
 | 
	
		
			
				|  |  |                  destroyOnClose: true
 | 
	
		
			
				|  |  |              }}
 | 
	
		
			
				|  |  |          />
 | 
	
		
			
				|  |  | +        {/* 业务单元授权 */}
 | 
	
		
			
				|  |  | +        <Modal
 | 
	
		
			
				|  |  | +            open={!!accountData}
 | 
	
		
			
				|  |  | +            title={"选择广告账号"}
 | 
	
		
			
				|  |  | +            footer={false}
 | 
	
		
			
				|  |  | +            destroyOnClose
 | 
	
		
			
				|  |  | +            onCancel={() => { setAccountData(null); setAccountId(null) }}
 | 
	
		
			
				|  |  | +            onOk={ad}
 | 
	
		
			
				|  |  | +        >
 | 
	
		
			
				|  |  | +            <Radio.Group onChange={(e) => {
 | 
	
		
			
				|  |  | +                let value = e.target.value
 | 
	
		
			
				|  |  | +                setAccountId(value)
 | 
	
		
			
				|  |  | +            }} value={accountId} >
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    accountData?.accountIdList?.map((id: any) => {
 | 
	
		
			
				|  |  | +                        return <Radio key={id} value={id}>{id}</Radio>
 | 
	
		
			
				|  |  | +                    })
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            </Radio.Group>
 | 
	
		
			
				|  |  | +        </Modal>
 | 
	
		
			
				|  |  |      </PageContainer>
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 |