shenwu před 8 měsíci
rodič
revize
faaf536051

+ 54 - 3
src/pages/MiniApp/MiniAppUser/WeChat/index.tsx

@@ -1,6 +1,57 @@
+import { ActionType, PageContainer, ProTable } from "@ant-design/pro-components"
+import { columns } from "./tableConfig"
+import { useAjax } from "@/Hook/useAjax"
+import { useModel } from "@umijs/max"
+import { wechatMiniappUserDel, wechatMiniappUserListOfPage, wechatMiniappUserUpdateEnabled } from "@/services/miniApp/miniAppUser/weChat"
+import { useCallback, useRef } from "react"
+import { message } from "antd"
 
-function Page(){
-    return <>微信小程序用户管理</>
-}
+const Page: React.FC = () => {
+    let { initialState } = useModel("@@initialState")
+    const actionRef = useRef<ActionType>();
+    let { enumList } = useModel("global", (model) => ({
+        enumList: model.state.enumList
+    }))
+    let getList = useAjax((params) => wechatMiniappUserListOfPage(params), { type: 'table' })
+    let delApi = useAjax((id) => wechatMiniappUserDel(id))
+    let upDateApi = useAjax((params) => wechatMiniappUserUpdateEnabled(params))
+
+    const upDate = useCallback((params: { id: any, enabled: boolean }) => {
+        upDateApi.run(params).then(res => {
+            if (res.code === 200) {
+                message.success("修改状态成功!")
+                actionRef.current?.reload()//刷新
+            }
+        })
+    }, [])
+    const del = useCallback((id: any) => {
+        delApi.run(id).then(res => {
+            if (res.code === 200) {
+                message.success("删除成功!")
+                actionRef.current?.reload()//刷新
+            }
+        })
+    }, [])
+    return <PageContainer title={false}
+    >
+        <ProTable<any, any>
+            actionRef={actionRef}
+            scroll={{ x: true }}
+            params={{
+                appId: initialState?.selectApp?.id || "",
+            }}
+            headerTitle={"微信小程序用户列表"}
+            rowKey={(r) => r.id}
+            search={{
+                labelWidth: 120,
+            }}
+            request={async (params) => {
+                return await getList.run(params)
+            }}
+            columns={columns({ enumList: enumList || [], del, upDate })}
+        // bordered
+        />
+    </PageContainer>
 
+}
 export default Page

+ 124 - 0
src/pages/MiniApp/MiniAppUser/WeChat/tableConfig.tsx

@@ -0,0 +1,124 @@
+import { ProColumns } from "@ant-design/pro-components";
+import { Badge, Popconfirm, Switch } from "antd";
+
+export const columns = (params: { enumList: { [key: string]: any }, del: (id: any) => void, upDate: (params: { id: any, enabled: boolean }) => void }): ProColumns<any>[] => {
+    let { enumList, del, upDate } = params
+    return [
+        {
+            title: "openId",
+            dataIndex: 'openId',
+            key: "openId",
+            align: "center",
+            // hideInSearch: true,
+        },
+        {
+            title: "unionId",
+            dataIndex: 'unionId',
+            key: "unionId",
+            align: "center",
+        },
+        {
+            title: "用户昵称",
+            dataIndex: 'nickname',
+            key: "nickname",
+            align: "center",
+            hideInSearch: true,
+        },
+        {
+            title: "手机号",
+            dataIndex: 'phoneNum',
+            key: "phoneNum",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "用户身份",
+            dataIndex: 'userStanding',
+            key: "userStanding",
+            valueType: 'select',
+            valueEnum: new Map(enumList?.USER_STANDING?.values?.map(({ value, description }: any) => [value, description])),
+            align: "center",
+            render: (a: any, b: any) => {
+                let arr: any = new Map(enumList?.USER_STANDING?.values?.map(({ value, description }: any) => [value, description]))
+                return arr.get(b?.userStanding) || '-'
+            }
+        },
+        {
+            title: "书币余额",
+            dataIndex: 'coinNumMin',
+            key: "coinNumMin",
+            valueType: 'digit',
+            align: "center",
+            render:(a,b)=>{
+                return b?.coinNum
+            }
+        },
+        {
+            title: "最近登录IP",
+            dataIndex: 'lastLoginIp',
+            key: "lastLoginIp",
+            align: "center",
+            hideInSearch: true,
+        },
+        {
+            title: "最近登录时间",
+            dataIndex: 'lastLoginTime',
+            key: "lastLoginTime",
+            align: "center",
+            hideInSearch: true,
+        },
+        {
+            title: "注册时间",
+            dataIndex: 'createTime',
+            key: "createTime",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "更新时间",
+            dataIndex: 'updateTime',
+            key: "updateTime",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "状态",
+            dataIndex: 'enabled',
+            key: "enabled",
+            align: "center",
+            valueType: 'select',
+            valueEnum: { true: "正常", false: "禁用" },
+            render: (a, b) => {
+                return <Switch checked={b.enabled} size="default" checkedChildren="正常" unCheckedChildren="禁用" onChange={(enabled) => { upDate({ id: b.id, enabled }) }} />
+            }
+        },
+        {
+            title: '操作',
+            dataIndex: 'cz',
+            key: 'cz',
+            width: 90,
+            ellipsis: true,
+            align: 'center',
+            hideInSearch: true,
+            render: (a: any, b: any) => {
+                return <Popconfirm title="确定要删除此用户?" onConfirm={() => { del(b?.id) }}>
+                    <a style={{ color: 'red' }}>删除</a>
+                </Popconfirm>
+            }
+        },
+        // 搜索条件
+        {
+            title: "最早登录时间",
+            dataIndex: 'lastLoginTimeMin',
+            valueType: 'date',
+            hideInTable: true
+        },
+        {
+            title: "最晚登录时间",
+            dataIndex: 'lastLoginTimeMax',
+            valueType: 'date',
+            hideInTable: true
+        },
+
+    ];
+}

+ 1 - 1
src/pages/MiniApp/ModuleConfig/template.tsx

@@ -10,7 +10,7 @@ export function Template(params: { data: any, enmuList: any }) {
     let { firstRecharge, rechargeConfigList } = data
     const useStyles = createStyles((props) => {
         let { token } = props
-        let navTheme = localStorage.getItem("navTheme")//2亮 3黑
+        let navTheme = localStorage.getItem("navTheme")//全局 2亮 3黑
         return {
             cardBox: {
                 position: 'relative'

+ 0 - 0
src/services/miniApp/miniAppUser/douYin.tsx


+ 42 - 0
src/services/miniApp/miniAppUser/weChat.tsx

@@ -0,0 +1,42 @@
+import { api } from '@/services/api';
+import { request } from '@umijs/max';
+type Page = {
+    pageSize: number | string,
+    pageNum: number | string
+}
+interface PublicParams {
+    appId: string,//微信小程序组件ID
+  }
+export interface Params extends Page,PublicParams {
+    openId?:string,//小程序用户标识
+    unionId?:string,//联合ID
+    userStanding?:string,//用户身份(NONE:普通用户、VIP:vip用户)
+    coinNumMin?:string,//用户书币数量
+    lastLoginTimeMin?:string,//最小登录时间
+    lastLoginTimeMax?:string,//最大登录时间
+    enabled?:boolean,//状态
+}
+/**微信小程序用户状态更新 */
+export async function wechatMiniappUserUpdateEnabled(params: {
+    id: string,
+    enabled: boolean,//状态
+}) {
+    let { id, enabled } = params
+    return request(api + `/admin/wechatMiniappUser/updateEnabled/${id}`, {
+        method: 'PUT',
+        data: { enabled }
+    });
+}
+/**微信小程序用户列表 */
+export async function wechatMiniappUserListOfPage(params: Params) {
+    return request(api + '/admin/wechatMiniappUser/listOfPage', {
+        method: 'GET',
+        params
+    })
+}
+/**删除微信小程序用户 */
+export async function wechatMiniappUserDel(id: string) {
+    return request(api +`/admin/wechatMiniappUser/delById/${id}`, {
+        method: 'DELETE',
+    })
+}