shenwu 6 månader sedan
förälder
incheckning
2638320f8d
2 ändrade filer med 34 tillägg och 19 borttagningar
  1. 26 17
      src/pages/MiniApp/AdBack/index.tsx
  2. 8 2
      src/services/miniApp/adBack/index.ts

+ 26 - 17
src/pages/MiniApp/AdBack/index.tsx

@@ -1,38 +1,47 @@
 import { useAjax } from "@/Hook/useAjax"
-import { tencentAdAccountDoAuth, tencentAdAccountToAuth } from "@/services/miniApp/adBack"
+import { getAppAccountConfig, tencentAdAccountDoAuth, tencentAdAccountToAuth } from "@/services/miniApp/adBack"
 import { PageContainer, ProCard, ProForm, ProFormRadio, ProFormSelect, ProFormText } from "@ant-design/pro-components"
+import { history, useModel } from "@umijs/max"
 import { Button, Divider, Space } from "antd"
 import { useEffect, useRef, useState } from "react"
 
 function Auth() {
+    let {getEnum} = useModel('global')
+    let {initialState} = useModel("@@initialState")
     let [key, setKey] = useState<any>()
     let [isEdit, setIsEdit] = useState(false)
     let formRef = useRef()
     let TencentAdAccountToAuth = useAjax((params) => tencentAdAccountToAuth(params))//获取授权地址
     let TencentAdAccountDoAuth = useAjax((params) => tencentAdAccountDoAuth(params))//开始授权
+    let GetAppAccountConfig = useAjax((params) => getAppAccountConfig(params))//获取回传配置
     // 获取广告回传列表
     useEffect(() => {
-
-    }, [key])
+        console.log("history.location.search",history.location.search)
+        getConfig()
+    }, [])
+    //获取回传配置
+    const getConfig =()=>{
+        GetAppAccountConfig.run({appType:initialState?.selectApp?.appType,appId:initialState?.selectApp?.id})
+    }
     // 授权
     const auth = () => {
-        console.log("授权")
+        // TencentAdAccountToAuth.run({
+
+        // })
+        console.log("授权",{
+            appType:initialState?.selectApp?.appType,
+            appId:initialState?.selectApp?.id,
+            advertisingChannel:key,
+            callbackPage:"https://testdistribution.zanxiangnet.com/#/miniApp/adBack"
+        })
     }
     return <PageContainer
-        tabList={[
-            {
-                tab: '基本信息',
-                key: 'base',
-            },
-            {
-                tab: '详细信息',
-                key: 'info',
-            },
-            {
-                tab: '详细信息',
-                key: 'info1',
+        tabList={getEnum("ADVERTISING_CHANNEL","arr")?.map((item: { label: any; key: any },index:number)=>{
+            if(index === 0 && !key){
+                setKey(item.key)
             }
-        ]}
+            return {tab:item.label,key:item.key}
+        })}
         tabProps={{
             type: 'card',
             hideAdd: true,

+ 8 - 2
src/services/miniApp/adBack/index.ts

@@ -8,7 +8,7 @@ type ToAuthData = {
     "callbackPage": string//回调地址
 }
 /**获取授权地址*/
-export async function tencentAdAccountToAuth(data:ToAuthData ) {
+export async function tencentAdAccountToAuth(data: ToAuthData) {
     return request(api + '/admin/tencentAdAccount/toAuth', {
         method: 'POST',
         data
@@ -20,9 +20,15 @@ type DoAuthData = {
     "callbackPage": string//回调地址
 }
 /**广告账号授权*/
-export async function tencentAdAccountDoAuth(data:DoAuthData ) {
+export async function tencentAdAccountDoAuth(data: DoAuthData) {
     return request(api + '/admin/tencentAdAccount/doAuth', {
         method: 'POST',
         data
     });
+}
+/**广告账号授权*/
+export async function getAppAccountConfig({ appType, appId }: any) {
+    return request(api + `/admin/tencentAdAccount/getAppAccountConfig/${appType}/${appId}`, {
+        method: 'GET',
+    });
 }