index.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { PageContainer, ProTable } from "@ant-design/pro-components"
  2. import { columns } from "./tableConfig"
  3. import { useAjax } from "@/Hook/useAjax"
  4. import { history, useModel } from "@umijs/max"
  5. import { Button } from "antd"
  6. import { PlusCircleOutlined } from "@ant-design/icons"
  7. import { listOfPage } from "@/services/miniApp/extend"
  8. import { authSuccess, getMpAccount, preAuth } from "@/services/miniApp/emsCnpl"
  9. import { useEffect } from "react"
  10. const Page: React.FC = () => {
  11. let { initialState } = useModel("@@initialState")
  12. let getList = useAjax((params) => getMpAccount(params), { type: 'table' })
  13. let PreAuth = useAjax((params) => preAuth(params)) //授权地址
  14. let AuthSuccess = useAjax((params) => authSuccess(params)) //授权
  15. useEffect(()=>{
  16. console.log("history.location.search", history.location.search)
  17. },[])
  18. // 授权
  19. const auth = () => {
  20. PreAuth.run({ callbackPage: "https://testdistribution.zanxiangwl.com/#/miniApp/emsCnpl/auth" }).then(res => {
  21. if (res.code === 200) {
  22. window.open(res?.data?.data)
  23. }
  24. })
  25. }
  26. return <PageContainer title={false}
  27. >
  28. <ProTable<any, any>
  29. scroll={{ x: true }}
  30. toolBarRender={() => {
  31. return [
  32. <Button
  33. type="primary"
  34. onClick={auth}
  35. >
  36. <PlusCircleOutlined />
  37. 授权
  38. </Button>,
  39. ];
  40. }}
  41. params={{
  42. appId: initialState?.selectApp?.id || "",
  43. appType: initialState?.selectApp?.appType || "",
  44. linkType: 1,
  45. }}
  46. headerTitle={"已授权公众号列表"}
  47. rowKey={(r) => r.linkId}
  48. search={{
  49. labelWidth: 90,
  50. span: 4
  51. }}
  52. request={async (params) => {
  53. return await getList.run(params)
  54. }}
  55. columns={columns(initialState?.selectApp?.appCategory || 1)}
  56. // bordered
  57. />
  58. </PageContainer>
  59. }
  60. export default Page