shenwu 6 ay önce
ebeveyn
işleme
a630edcbc1
1 değiştirilmiş dosya ile 18 ekleme ve 2 silme
  1. 18 2
      src/pages/MiniApp/AdBack/index.tsx

+ 18 - 2
src/pages/MiniApp/AdBack/index.tsx

@@ -2,9 +2,10 @@ import { useAjax } from "@/Hook/useAjax"
 import { getAppAccountConfig, tencentAdAccountDoAuth, tencentAdAccountToAuth } from "@/services/miniApp/adBack"
 import { BetaSchemaForm, PageContainer, ProCard, ProForm, ProFormRadio, ProFormSelect, ProFormText } from "@ant-design/pro-components"
 import { history, useModel } from "@umijs/max"
-import { Button, Divider, Space } from "antd"
+import { Button, Divider, message, Space } from "antd"
 import { useEffect, useRef, useState } from "react"
 import formConfig from "./formConfig"
+import { searchToObj } from "@/utils"
 
 function Auth() {
     let { getEnum } = useModel('global')
@@ -17,7 +18,22 @@ function Auth() {
     let GetAppAccountConfig = useAjax((params) => getAppAccountConfig(params))//获取回传配置
     // 获取广告回传列表
     useEffect(() => {
-        console.log("history.location.search", history.location.search)
+         // 授权回调
+         if (history.location.search) {
+            let obj = searchToObj(history.location.search)
+            if (obj?.state && obj?.authorization_code) {
+                TencentAdAccountDoAuth.run({
+                    "state": obj.state,
+                    "authorizationCode": obj.authorization_code,
+                    "callbackPage": "https://testdistribution.zanxiangwl.com/miniApp/adBack"
+                }).then(res => {
+                    if (res.code === 200) {
+                        message.success("授权成功")
+                        history.push("/miniApp/adBack")
+                    }
+                })
+            }
+        }
         getConfig()
     }, [])
     //获取回传配置