|
@@ -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 { useAjax } from "@/Hook/useAjax"
|
|
|
import { history, useModel } from "@umijs/max"
|
|
|
-import { Button } from "antd"
|
|
|
+import { Button, message } from "antd"
|
|
|
import { PlusCircleOutlined } from "@ant-design/icons"
|
|
|
-import { listOfPage } from "@/services/miniApp/extend"
|
|
|
import { authSuccess, getMpAccount, preAuth } from "@/services/miniApp/emsCnpl"
|
|
|
-import { useEffect } from "react"
|
|
|
+import { useEffect, useRef } from "react"
|
|
|
import { searchToObj } from "@/utils"
|
|
|
|
|
|
const Page: React.FC = () => {
|
|
|
let { initialState } = useModel("@@initialState")
|
|
|
+ const actionRef = useRef<ActionType>();
|
|
|
let getList = useAjax((params) => getMpAccount(params), { type: 'table' })
|
|
|
let PreAuth = useAjax((params) => preAuth(params)) //授权地址
|
|
|
let AuthSuccess = useAjax((params) => authSuccess(params)) //授权
|
|
|
- useEffect(()=>{
|
|
|
- if(history.location.search){
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ // 授权回调
|
|
|
+ if (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)
|
|
|
- },[])
|
|
|
+ }, [])
|
|
|
// 授权
|
|
|
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) {
|
|
|
window.open(res?.data)
|
|
|
}
|
|
@@ -38,6 +47,7 @@ const Page: React.FC = () => {
|
|
|
return <PageContainer title={false}
|
|
|
>
|
|
|
<ProTable<any, any>
|
|
|
+ actionRef={actionRef}
|
|
|
scroll={{ x: true }}
|
|
|
toolBarRender={() => {
|
|
|
return [
|