shenwu 6 months ago
parent
commit
87c7b14fb7
1 changed files with 24 additions and 14 deletions
  1. 24 14
      src/pages/MiniApp/EmsCnpl/Auth/index.tsx

+ 24 - 14
src/pages/MiniApp/EmsCnpl/Auth/index.tsx

@@ -1,35 +1,44 @@
-import { PageContainer, ProTable } from "@ant-design/pro-components"
+import { ActionType, PageContainer, ProTable } from "@ant-design/pro-components"
 import { columns } from "./tableConfig"
 import { columns } from "./tableConfig"
 import { useAjax } from "@/Hook/useAjax"
 import { useAjax } from "@/Hook/useAjax"
 import { history, useModel } from "@umijs/max"
 import { history, useModel } from "@umijs/max"
-import { Button } from "antd"
+import { Button, message } from "antd"
 import { PlusCircleOutlined } from "@ant-design/icons"
 import { PlusCircleOutlined } from "@ant-design/icons"
-import { listOfPage } from "@/services/miniApp/extend"
 import { authSuccess, getMpAccount, preAuth } from "@/services/miniApp/emsCnpl"
 import { authSuccess, getMpAccount, preAuth } from "@/services/miniApp/emsCnpl"
-import { useEffect } from "react"
+import { useEffect, useRef } from "react"
 import { searchToObj } from "@/utils"
 import { searchToObj } from "@/utils"
 
 
 const Page: React.FC = () => {
 const Page: React.FC = () => {
     let { initialState } = useModel("@@initialState")
     let { initialState } = useModel("@@initialState")
+    const actionRef = useRef<ActionType>();
     let getList = useAjax((params) => getMpAccount(params), { type: 'table' })
     let getList = useAjax((params) => getMpAccount(params), { type: 'table' })
     let PreAuth = useAjax((params) => preAuth(params)) //授权地址
     let PreAuth = useAjax((params) => preAuth(params)) //授权地址
     let AuthSuccess = useAjax((params) => authSuccess(params)) //授权
     let AuthSuccess = useAjax((params) => authSuccess(params)) //授权
-    useEffect(()=>{
-        if(history.location.search){
+    
+    useEffect(() => {
+        // 授权回调
+        if (history.location.search) {
             let obj = searchToObj(history.location.search)
             let obj = searchToObj(history.location.search)
-            if(obj?.auth_code){
-                console.log(obj,initialState?.selectApp)
-                // AuthSuccess.run({
-                //     appType: initialState?.selectApp?.appType,
-                //     appId: initialState?.selectApp?.id,
-                // })
+            if (obj?.auth_code && obj?.uuid) {
+                console.log(obj, initialState?.selectApp)
+                AuthSuccess.run({
+                    appType: initialState?.selectApp?.appType,
+                    appId: initialState?.selectApp?.id,
+                    uuid: obj.uuid,
+                    authCode: obj.auth_code
+                }).then(res => {
+                    if (res.code === 200) {
+                        message.success("授权成功")
+                        actionRef?.current?.reload()
+                    }
+                })
             }
             }
         }
         }
         console.log("history.location.search", history.location.search)
         console.log("history.location.search", history.location.search)
-    },[])
+    }, [])
     // 授权
     // 授权
     const auth = () => {
     const auth = () => {
-        PreAuth.run({ callbackPage: "https://testdistribution.zanxiangwl.com/#/miniApp/emsCnpl/auth" }).then(res => {
+        PreAuth.run({ callbackPage: "https://testdistribution.zanxiangwl.com/#/miniApp/emsCnpl/auth?uuid=UUID" }).then(res => {
             if (res.code === 200) {
             if (res.code === 200) {
                 window.open(res?.data)
                 window.open(res?.data)
             }
             }
@@ -38,6 +47,7 @@ const Page: React.FC = () => {
     return <PageContainer title={false}
     return <PageContainer title={false}
     >
     >
         <ProTable<any, any>
         <ProTable<any, any>
+            actionRef={actionRef}
             scroll={{ x: true }}
             scroll={{ x: true }}
             toolBarRender={() => {
             toolBarRender={() => {
                 return [
                 return [