shenwu 8 mesi fa
parent
commit
05c92650a3

+ 1 - 1
src/pages/Distributor/DyMiniApp/index.tsx

@@ -27,7 +27,7 @@ const Page: React.FC = () => {
                 expandedRowRender: (record) => {
                     return <Table
                         columns={childrenColumns}
-                        dataSource={record.wxAppCarrierVOList}
+                        dataSource={record.appCarrierList}
                         rowKey={(r) => r.id}
                         pagination={false}
                         size='small'

+ 1 - 1
src/pages/Distributor/WxMiniApp/index.tsx

@@ -27,7 +27,7 @@ const Page: React.FC = () => {
                 expandedRowRender: (record) => {
                     return <Table
                         columns={childrenColumns}
-                        dataSource={record.wxAppCarrierVOList}
+                        dataSource={record.appCarrierList}
                         rowKey={(r) => r.id}
                         pagination={false}
                         size='small'

+ 54 - 10
src/pages/MiniApp/BookManage/Long/formConfig.tsx

@@ -1,11 +1,10 @@
 import { ProFormColumnsType } from "@ant-design/pro-components";
 
-function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]: any }, paymentType: any }): ProFormColumnsType<{
+function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]: any }, paymentType: any, paymentCategory: any, isGlobalConfig: boolean }): ProFormColumnsType<{
     name: string;
     state: string;
 }>[] {
-    let { paragraphList, enumList, paymentType } = props
-    console.log(paymentType)
+    let { paragraphList, enumList, paymentType, paymentCategory, isGlobalConfig } = props
     return [
         {
             title: '付费方式',
@@ -18,7 +17,7 @@ function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]:
                 }
             },
             formItemProps: {
-                style: { marginBottom: 0 },
+                style: { marginBottom: 10 },
                 rules: [
                     {
                         required: true,
@@ -44,14 +43,39 @@ function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]:
                     },
                 ],
             },
-            hideInForm:paymentType[0] != 2,
+            hideInForm: paymentType[0] != 2,
             valueEnum: () => {
                 let arr = enumList?.PAYMENT_OPTION?.values
                 return new Map(arr?.map(({ value, description }: any) => [value, description]))
             }
         },
         {
-            title: '开始付费段落',
+            title: '收费货币',
+            dataIndex: 'paymentCategory',
+            valueType: 'radio',
+            fieldProps: {
+                onChange: (e) => {
+                    let value = e.target.value
+                    paymentCategory[1](value)
+                }
+            },
+            formItemProps: {
+                style: { marginBottom: 10 },
+                rules: [
+                    {
+                        required: true,
+                        message: '此项为必填项',
+                    },
+                ],
+            },
+            hideInForm: paymentType[0] == 0,
+            valueEnum: () => {
+                let arr = [{ value: 0, description: "现金" }, { value: 1, description: "书币" }]
+                return new Map(arr?.map(({ value, description }: any) => [value, description]))
+            }
+        },
+        {//单本
+            title: '付费起始段落',
             dataIndex: 'beginPayParagraphNo',
             valueType: 'select',
             fieldProps: {
@@ -66,11 +90,30 @@ function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]:
                     },
                 ],
             },
-            hideInForm:paymentType[0] != 2,
+            hideInForm: paymentType[0] != 2 || isGlobalConfig,//单本书
             valueEnum: () => {
                 return new Map(paragraphList?.map(item => [item.paragraphNo, item.content]))
             }
         },
+        {//全局
+            title: '付费起始段落',
+            dataIndex: 'beginPayNo',
+            valueType: 'digit',
+            fieldProps: {
+                placeholder: '请输入收费段落'
+            },
+            width: 200,
+            formItemProps: {
+                style: { marginBottom: 15 },
+                rules: [
+                    {
+                        required: true,
+                        message: '此项为必填项',
+                    },
+                ],
+            },
+            hideInForm: paymentType[0] != 2 || !isGlobalConfig,//单本书
+        },
         {
             title: 'VIP阅读',
             dataIndex: 'vipFree',
@@ -84,7 +127,7 @@ function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]:
                     },
                 ],
             },
-            hideInForm:paymentType[0] == 0,
+            hideInForm: paymentType[0] == 0 || isGlobalConfig,
             valueEnum: () => {
                 let arr = enumList?.VIP_FREE?.values
                 return new Map(arr?.map(({ value, description }: any) => [value, description]))
@@ -94,7 +137,7 @@ function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]:
             title: '收费金额',
             dataIndex: 'paymentAmount',
             valueType: 'money',
-            hideInForm: paymentType[0] != 1,
+            hideInForm: paymentCategory[0] == 1,
             formItemProps: {
                 style: { marginBottom: 15 },
                 rules: [
@@ -109,7 +152,7 @@ function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]:
             title: '收费书币',
             dataIndex: 'paymentCoin',
             valueType: 'digit',
-            hideInForm: paymentType[0] != 2,
+            hideInForm: paymentCategory[0] == 0,
             formItemProps: {
                 style: { marginBottom: 15 },
                 rules: [
@@ -124,6 +167,7 @@ function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]:
             title: '备注',
             dataIndex: 'remark',
             valueType: 'textarea',
+            hideInForm: isGlobalConfig,
             formItemProps: {
                 style: { marginBottom: 15 },
             },

+ 51 - 11
src/pages/MiniApp/BookManage/Long/index.tsx

@@ -2,12 +2,13 @@ import { ActionType, BetaSchemaForm, PageContainer, ProFormInstance, ProTable }
 import { columns } from "./tableConfig"
 import { useAjax } from "@/Hook/useAjax"
 import { useModel } from "@umijs/max"
-import { longBookInfoList, longBookInfoChapterContent, longBookInfoBookConfig, longBookInfoConfig, longBookInfoChapterAllList } from "@/services/miniApp/bookManage"
-import { useEffect, useMemo, useRef, useState } from "react"
-import { Drawer, message } from "antd"
+import { longBookInfoList, longBookInfoChapterContent, longBookInfoBookConfig, longBookInfoConfig, longBookInfoChapterAllList, sysRechargeGetInfo, sysRechargeAddOrEdit } from "@/services/miniApp/bookManage"
+import { useCallback, useEffect, useMemo, useRef, useState } from "react"
+import { Drawer, message, Space, Tag } from "antd"
 import ReadText from "../components/readText"
 import formConfig from "./formConfig"
 import ReadBook from "../components/readBook"
+import { EditFilled } from "@ant-design/icons"
 const wordCountRanges: any = {
     "": { start: null, end: null }, // 全部
     "0-2": { start: 0, end: 2 * 10000 },
@@ -31,6 +32,8 @@ const Page: React.FC = () => {
     let [open, setOpen] = useState<any>(null)//付费配置
     let [editValues, setEditValues] = useState<any>({})
     let paymentType = useState(0)
+    let paymentCategory = useState(0)//收费货币
+    let [isGlobalConfig, setIsGlobalConfig] = useState(false)//
     let [workDirection, setWorkDirection] = useState<any>(null)
     const [openBook, setOpneBook] = useState<any>(null)//阅读小说
     let getList = useAjax((params) => longBookInfoList(params), { type: 'table' })//获取书列表
@@ -38,11 +41,14 @@ const Page: React.FC = () => {
     let getChapterAllList = useAjax((params) => longBookInfoChapterAllList(params))//获取全部章节
     let add = useAjax((params) => longBookInfoBookConfig(params))//新增配置
     let configInfo = useAjax((params) => longBookInfoConfig(params))//获取配置信息
+    let globaleConfig = useAjax((params) => sysRechargeGetInfo(params))//获取全局配置信息
+    let globaleAddOrEdit = useAjax((params) => sysRechargeAddOrEdit(params))//全局配置信息修改
     const formRef = useRef<ProFormInstance>();
     const actionRef = useRef<ActionType>();
     // 获取标签和分类
     useEffect(() => {
         getLabelAndClassList({ workDirection })
+        getGlobalInfo()
     }, [workDirection])
     // 接口公共参数
     let publicData = useMemo(() => {
@@ -52,7 +58,12 @@ const Page: React.FC = () => {
             appType: initialState?.selectApp?.appType || ""
         }
     }, [initialState?.selectApp, initialState?.currentUser?.distributorId])
-
+    //获取全局收费配置
+    const getGlobalInfo = useCallback(() => {
+        globaleConfig.run(publicData).then(res => {
+            console.log(res)
+        })
+    }, [publicData])
     // 看小说列表
     const lookBookList = (params: any) => {
         let { id, pageNum, pageSize } = params
@@ -74,7 +85,7 @@ const Page: React.FC = () => {
         if (editValues?.bookId) {
             values.bookId = editValues?.bookId
         }
-        if(values.paymentType === 0){//假如免费,设置vip也免费
+        if (values.paymentType === 0) {//假如免费,设置vip也免费
             values.vipFree = true
         }
         add.run({ ...values, ...publicData }).then(res => {
@@ -85,6 +96,18 @@ const Page: React.FC = () => {
             }
         })
     }
+    // 全局配置弹窗
+    const closeGlobalForm = () => {
+        setIsGlobalConfig(true)
+        setOpen(true)//弹窗开启
+        let data = globaleConfig?.data?.data
+        setEditValues({ ...data })
+        paymentType[1](data?.paymentType || 0)
+        paymentCategory[1](data?.paymentCategory || 0)
+        setTimeout(() => {
+            formRef?.current?.setFieldsValue({ ...data })
+        }, 100)
+    }
     // 关闭表单弹窗和重置表单内容
     const closeForm = (b: boolean, values?: any) => {
         if (!b) {
@@ -104,7 +127,7 @@ const Page: React.FC = () => {
                                 let data = { ...res.data }
                                 setEditValues(data)
                                 paymentType[1](data?.paymentType || 0)
-                                formRef?.current?.setFieldsValue({ ...data, paymentType:data?.paymentType || 0,vipFree:data?.vipFree === null ? true : data?.vipFree})
+                                formRef?.current?.setFieldsValue({ ...data, paymentType: data?.paymentType || 0, vipFree: data?.vipFree === null ? true : data?.vipFree })
                             }
                         })
                     }
@@ -118,9 +141,26 @@ const Page: React.FC = () => {
         <ProTable<any, any>
             params={publicData}
             actionRef={actionRef}
-            headerTitle={"长篇篇小说列表"}
+            headerTitle={"小说列表"}
             rowKey={(r) => r.bookId}
-            scroll={{x:true,y:500}}
+            scroll={{ x: true, y: 500 }}
+            tableAlertRender={() => {
+                let { paymentType, paymentOption, paymentCategory, paymentAmount, paymentCoin, beginPayNo } = globaleConfig?.data?.data || {}
+                let enumList: any = state?.enumList
+                let PAYMENT_TYPE_Map: Map<any, any> = new Map(enumList?.PAYMENT_TYPE?.values?.map(({ value, description }: any) => [value, description]))
+                let PAYMENT_OPTION_Map: Map<any, any> = new Map(enumList?.PAYMENT_OPTION?.values?.map(({ value, description }: any) => [value, description]))
+                return <Tag bordered={false} style={{ cursor: 'pointer' }} onClick={closeGlobalForm}>
+                    <Space>
+                        <Tag bordered={false} color="processing" style={{ cursor: 'pointer' }}>收费类型:<span style={{ color: '#f64747' }}>{PAYMENT_TYPE_Map?.get(paymentType)}</span></Tag>
+                        <Tag bordered={false} color="processing" style={{ cursor: 'pointer' }}>付费起始段落/章节:<span style={{ color: "#f64747" }}>{beginPayNo}</span></Tag>
+                        {paymentType === 2 && <Tag bordered={false} color="processing" style={{ cursor: 'pointer' }}>段落/章节收费类型:<span style={{ color: '#f64747' }}>{PAYMENT_OPTION_Map?.get(paymentOption)}</span></Tag>}
+                        <Tag bordered={false} color="processing" style={{ cursor: 'pointer' }}>付费价格:
+                            <span style={{ color: "#f64747" }}>{paymentCategory === 0 && '¥'}{paymentCategory === 0 ? paymentAmount : paymentCoin}</span>
+                            {paymentCategory === 1 && '书币'}</Tag>
+                    </Space>
+                    <EditFilled />
+                </Tag>
+            }}
             search={{
                 labelWidth: 90,
                 searchGutter: [10, 15],
@@ -146,11 +186,11 @@ const Page: React.FC = () => {
             request={async (params) => {
                 return await getList.run(params)
             }}
-            columns={columns({ authList: state?.authList, labelList: state.labelList, categoryList: state.categoryList, enumList: state?.enumList, lookBook:lookBookList, closeForm, setWorkDirection })}
+            columns={columns({ authList: state?.authList, labelList: state.labelList, categoryList: state.categoryList, enumList: state?.enumList, lookBook: lookBookList, closeForm, setWorkDirection })}
         />
         {/* 付费配置 */}
         <BetaSchemaForm<DataItem>
-            title={"付费配置"}
+           title={(isGlobalConfig ? "全局" : "《" + editValues?.bookName + "》") + "付费配置"}
             formRef={formRef}
             open={open}
             onOpenChange={(b) => { !b && closeForm(b) }}
@@ -160,7 +200,7 @@ const Page: React.FC = () => {
             // grid={true}
             layout='horizontal'
             onFinish={submit}
-            columns={formConfig({ enumList: state?.enumList, paymentType, paragraphList: getChapterAllList?.data?.data?.map((item: { chapterInfo: any }) => item.chapterInfo) })}
+            columns={formConfig({ isGlobalConfig, enumList: state?.enumList, paymentType, paymentCategory, paragraphList: getChapterAllList?.data?.data?.map((item: { chapterInfo: any }) => item.chapterInfo) })}
             loading={add?.loading}
         />
         {/* 阅读小说 */}

+ 306 - 54
src/pages/MiniApp/ModuleConfig/formConfig.tsx

@@ -1,29 +1,21 @@
 import { convertEnumArr } from "@/utils";
 import { ProFormColumnsType } from "@ant-design/pro-components";
 
-function formConfig(enumList?:any): ProFormColumnsType<{
+function formConfig(enumList?: any): ProFormColumnsType<{
     name: string;
     state: string;
 }>[] {
     let templateTypeEnum = enumList?.TEMPLATE_TYPE?.values || []
+    let ORDER_TYPEEnum = enumList?.ORDER_TYPE?.values || []
+    let COLOREnum = enumList?.COLOR?.values || []
+    let VIP_DAYSEnum = enumList?.VIP_DAYS?.values || []
     return [
         {
             title: '模板名称',
             dataIndex: 'templateName',
-            formItemProps: {
-                rules: [
-                    {
-                        required: true,
-                        message: '此项为必填项',
-                    },
-                ],
-            }
-        },
-        {
-            title: '充值模板类型',
-            dataIndex: 'templateType',
-            valueType: 'select',
-            valueEnum:  convertEnumArr(templateTypeEnum),
+            colProps:{
+                span:24
+            },
             formItemProps: {
                 rules: [
                     {
@@ -44,15 +36,15 @@ function formConfig(enumList?:any): ProFormColumnsType<{
             valueType: 'textarea',
         },
         {
-            title: '充档位配置',
+            title: '充档位',
             dataIndex: 'rechargeConfigList',
             valueType: 'formList',
             fieldProps: {
-                // min:4,
-                // max:4,
+                min: 4,
+                max: 6,
                 creatorButtonProps: {
-                    creatorButtonText:"添加一个配置"
-                }
+                    creatorButtonText: "添加一个首充档位配置",
+                },
             },
             colProps: {
                 span: 24
@@ -63,41 +55,301 @@ function formConfig(enumList?:any): ProFormColumnsType<{
                     colProps: {
                         span: 24
                     },
-                    columns: [{
-                        title: '价格',
-                        dataIndex: 'price',
-                        valueType: 'money',
-                        width: "100%",
-                        colProps: {
-                            span: 6
-                        }
-                    },
-                    {
-                        title: '赠送',
-                        dataIndex: 'gift',
-                        valueType: 'digit',
-                        width: "100%",
-                        colProps: {
-                            span: 6
-                        }
-                    },
-                    {
-                        title: '额外赠送',
-                        dataIndex: 'extra',
-                        valueType: 'digit',
-                        width: "100%",
-                        colProps: {
-                            span: 6
-                        }
+                    columns: [
+                        {
+                            title: '类型',
+                            dataIndex: 'gearType',
+                            valueType: 'select',
+                            width: "100%",
+                            initialValue:1,
+                            fieldProps: { placeholder: "请选择档位类型" },
+                            colProps: {
+                                span: 4
+                            },
+                            formItemProps: {
+                                rules: [
+                                    {
+                                        required: true,
+                                        message: '此项为必填项',
+                                    },
+                                ],
+                            },
+                            valueEnum: new Map(ORDER_TYPEEnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
+                        },
+                        {
+                            valueType: 'dependency',
+                            name: ['gearType'],
+                            columns: ({ gearType }) => {
+                                return [
+                                    {
+                                        title: '价格',
+                                        dataIndex: 'price',
+                                        valueType: 'money',
+                                        width: "100%",
+                                        hideInForm: gearType === 3,
+                                        fieldProps: { placeholder: "输入价格" },
+                                        colProps: {
+                                            span: 5
+                                        },
+                                        formItemProps: {
+                                            rules: [
+                                                {
+                                                    required: true,
+                                                    message: '此项为必填项',
+                                                },
+                                            ],
+                                        }
+                                    },
+                                    {
+                                        title: '赠送',
+                                        dataIndex: 'gift',
+                                        valueType: 'digit',
+                                        width: "100%",
+                                        hideInForm: gearType !== 1,
+                                        fieldProps: { placeholder: "输入赠送书币数" },
+                                        colProps: {
+                                            span: 5
+                                        },
+                                        formItemProps: {
+                                            rules: [
+                                                {
+                                                    required: true,
+                                                    message: '此项为必填项',
+                                                },
+                                            ],
+                                        }
+                                    },
+                                    {
+                                        title: 'vip天数',
+                                        dataIndex: 'vipDays',
+                                        valueType: 'select',
+                                        width: "100%",
+                                        hideInForm: gearType !== 2,
+                                        fieldProps: { placeholder: "选择VIP天数" },
+                                        colProps: {
+                                            span: 4
+                                        },
+                                        formItemProps: {
+                                            rules: [
+                                                {
+                                                    required: true,
+                                                    message: '此项为必填项',
+                                                },
+                                            ],
+                                        },
+                                        valueEnum: new Map(VIP_DAYSEnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
+                                    },
+                                    {
+                                        title: '价格',
+                                        width: "100%",
+                                        fieldProps: { placeholder: "价格在小说管理设置", disabled: true },
+                                        hideInForm: gearType !== 3,
+                                        colProps: {
+                                            span: 5
+                                        }
+                                    },
+                                    {
+                                        title: '文案',
+                                        dataIndex: 'description',
+                                        width: "100%",
+                                        fieldProps: { placeholder: "输入展示文案" },
+                                        hideInForm: gearType !== 3,
+                                        colProps: {
+                                            span: 5
+                                        },
+                                        formItemProps: {
+                                            rules: [
+                                                {
+                                                    required: true,
+                                                    message: '此项为必填项',
+                                                },
+                                            ],
+                                        }
+                                    },
+                                    {
+                                        title: '角标',
+                                        dataIndex: 'subscript',
+                                        width: "100%",
+                                        fieldProps: { placeholder: "右上角角标文案" },
+                                        colProps: {
+                                            span: 5
+                                        }
+                                    },
+                                    {
+                                        title: '底色',
+                                        dataIndex: "color",
+                                        valueType: "radioButton",
+                                        width: "100%",
+                                        initialValue: false,
+                                        colProps: {
+                                            span: 4
+                                        },
+                                        valueEnum: new Map(COLOREnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
+                                    }
+                                ]
+                            }
+
+                        },
+                    ]
+                }
+            ]
+        },
+        {
+            title: '非首充档位',
+            dataIndex: 'rechargeConfigList1',
+            valueType: 'formList',
+            fieldProps: {
+                min: 4,
+                max: 6,
+                creatorButtonProps: {
+                    creatorButtonText: "添加一个非首充档位配置",
+                },
+            },
+            colProps: {
+                span: 24
+            },
+            columns: [
+                {
+                    valueType: 'group',
+                    colProps: {
+                        span: 24
                     },
-                    {
-                        title: '额外描述',
-                        dataIndex: 'description',
-                        width: "100%",
-                        colProps: {
-                            span: 6
-                        }
-                    },]
+                    columns: [
+                        {
+                            title: '类型',
+                            dataIndex: 'gearType',
+                            valueType: 'select',
+                            width: "100%",
+                            initialValue:1,
+                            fieldProps: { placeholder: "请选择档位类型" },
+                            colProps: {
+                                span: 4
+                            },
+                            formItemProps: {
+                                rules: [
+                                    {
+                                        required: true,
+                                        message: '此项为必填项',
+                                    },
+                                ],
+                            },
+                            valueEnum: new Map(ORDER_TYPEEnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
+                        },
+                        {
+                            valueType: 'dependency',
+                            name: ['gearType'],
+                            columns: ({ gearType }) => {
+                                return [
+                                    {
+                                        title: '价格',
+                                        dataIndex: 'price',
+                                        valueType: 'money',
+                                        width: "100%",
+                                        hideInForm: gearType === 3,
+                                        fieldProps: { placeholder: "输入价格" },
+                                        colProps: {
+                                            span: 5
+                                        },
+                                        formItemProps: {
+                                            rules: [
+                                                {
+                                                    required: true,
+                                                    message: '此项为必填项',
+                                                },
+                                            ],
+                                        }
+                                    },
+                                    {
+                                        title: '赠送',
+                                        dataIndex: 'gift',
+                                        valueType: 'digit',
+                                        width: "100%",
+                                        hideInForm: gearType !== 1,
+                                        fieldProps: { placeholder: "输入赠送书币数" },
+                                        colProps: {
+                                            span: 5
+                                        },
+                                        formItemProps: {
+                                            rules: [
+                                                {
+                                                    required: true,
+                                                    message: '此项为必填项',
+                                                },
+                                            ],
+                                        }
+                                    },
+                                    {
+                                        title: 'vip天数',
+                                        dataIndex: 'vipDays',
+                                        valueType: 'select',
+                                        width: "100%",
+                                        hideInForm: gearType !== 2,
+                                        fieldProps: { placeholder: "选择VIP天数" },
+                                        colProps: {
+                                            span: 4
+                                        },
+                                        formItemProps: {
+                                            rules: [
+                                                {
+                                                    required: true,
+                                                    message: '此项为必填项',
+                                                },
+                                            ],
+                                        },
+                                        valueEnum: new Map(VIP_DAYSEnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
+                                    },
+                                    {
+                                        title: '价格',
+                                        width: "100%",
+                                        fieldProps: { placeholder: "价格在小说管理设置", disabled: true },
+                                        hideInForm: gearType !== 3,
+                                        colProps: {
+                                            span: 5
+                                        }
+                                    },
+                                    {
+                                        title: '文案',
+                                        dataIndex: 'description',
+                                        width: "100%",
+                                        fieldProps: { placeholder: "输入展示文案" },
+                                        hideInForm: gearType !== 3,
+                                        colProps: {
+                                            span: 5
+                                        },
+                                        formItemProps: {
+                                            rules: [
+                                                {
+                                                    required: true,
+                                                    message: '此项为必填项',
+                                                },
+                                            ],
+                                        }
+                                    },
+                                    {
+                                        title: '角标',
+                                        dataIndex: 'subscript',
+                                        width: "100%",
+                                        fieldProps: { placeholder: "右上角角标文案" },
+                                        colProps: {
+                                            span: 5
+                                        }
+                                    },
+                                    {
+                                        title: '底色',
+                                        dataIndex: "color",
+                                        valueType: "radioButton",
+                                        width: "100%",
+                                        initialValue: false,
+                                        colProps: {
+                                            span: 4
+                                        },
+                                        valueEnum: new Map(COLOREnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
+                                    }
+                                ]
+                            }
+
+                        },
+                    ]
                 }
             ]
         },

+ 37 - 27
src/pages/MiniApp/ModuleConfig/index.tsx

@@ -1,7 +1,7 @@
 import { BetaSchemaForm, PageContainer, ProFormInstance, useToken } from "@ant-design/pro-components"
 import { useAjax } from "@/Hook/useAjax"
 import { useModel } from "@umijs/max"
-import { JSXElementConstructor, Key, ReactElement, ReactNode, ReactPortal, useEffect, useMemo, useRef, useState } from "react"
+import React, { JSXElementConstructor, Key, ReactElement, ReactNode, ReactPortal, useEffect, useMemo, useRef, useState } from "react"
 import { appRechargeTemplateList, appRechargeTemplateSave, appRechargeTemplateSwitch, appRechargeTemplateRemove, appRechargeTemplateUpdate, appRechargeTemplateInfo } from "@/services/miniApp/moduleConfig"
 import { Button, Card, Col, Empty, message, Modal, Row, Space } from "antd"
 import { DeleteOutlined, EditOutlined, ExclamationCircleFilled, PlusOutlined } from "@ant-design/icons"
@@ -75,6 +75,24 @@ const Page: React.FC = () => {
         if (editValues?.id) {
             values.id = editValues?.id
         }
+        values.rechargeConfigs = []
+        if (values.rechargeConfigList?.length > 0) {//首充
+            values.rechargeConfigs.push({
+                firstRecharge: true,//是否首充档位;true:首充 false:非首充
+                rechargeConfigList: values.rechargeConfigList,
+            })
+        }
+        if (values.rechargeConfigList1?.length > 0) {//非首充
+            values.rechargeConfigs.push(
+                {
+                    firstRecharge: false,//是否首充档位;true:首充 false:非首充
+                    rechargeConfigList: values.rechargeConfigList1,
+                }
+            )
+        }
+        delete values.rechargeConfigList
+        delete values.rechargeConfigList1
+        console.log(values)
         api.run({ ...values, ...publicData }).then(res => {
             if (res.code === 200) {
                 getList.refresh()
@@ -94,7 +112,15 @@ const Page: React.FC = () => {
             if (values) {
                 infoT.run(values.id).then(res => {
                     if (res.code === 200) {
-                        let data = { ...res.data, templateType: values.templateType + "" }
+                        console.log(res.data)
+                        let data = res.data
+                        for (let item of data.rechargeConfigs) {
+                            if (item.firstRecharge) {
+                                data.rechargeConfigList = item.rechargeConfigList
+                            } else {
+                                data.rechargeConfigList1 = item.rechargeConfigList
+                            }
+                        }
                         setEditValues(data)
                         formRef?.current?.setFieldsValue(data)
                     }
@@ -139,40 +165,23 @@ const Page: React.FC = () => {
             }
         });
     }
-    // 获取模板详情
-    const getTemplateInfo = (id: any) => {
-
-    }
-    // 模板编辑
-    const editTemplate = (values: any) => {
-        console.log(values)
-
-        // Modal.confirm({
-        //     title: '切换充值模板',
-        //     content: '是否要切换为当前充值模板?',
-        //     icon: <ExclamationCircleFilled />,
-        //     onOk: () => {
-        //         delT.run(id).then(res => {
-        //             if (res.code === 200) {
-        //                 getList.refresh()
-        //                 message.success("删除成功")
-        //             }
-        //         })
-        //     }
-        // });
-    }
-
     return <PageContainer
         extra={getList?.data?.data?.length > 0 && <Button type="primary" onClick={() => { closeForm(true) }}><PlusOutlined />新增模板</Button>}
     >
         {/* 模板列表 */}
         <Row gutter={[20, 20]}>
             {
-                getList?.data?.data?.map((item: { id: Key | null | undefined; templateName: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; rechargeConfigList: any[]; templateType: any; templateDescription: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined }) => {
+                getList?.data?.data?.map((item: { id: Key | null | undefined; templateName: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; rechargeConfigs: any[]; templateType: number; templateDescription: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined }) => {
                     return <Col key={item.id} style={{ cursor: 'pointer' }} onClick={() => { switchTemplate(item.id) }}>
                         <Card className={activeT === item.id ? styles.active : ""} style={{ background: activeT === item.id ? token.colorPrimaryBgHover : token.colorFillAlter }} hoverable>
                             <h3 style={{ fontSize: 16, fontWeight: 500, color: token.colorText, fontFamily: 'PingFang SC' }}>{item.templateName}</h3>
-                            <Template list={item.rechargeConfigList} isVip={item.templateType === 2} />
+                            {
+                                item.rechargeConfigs?.map((config, index) => {
+                                    return <React.Fragment key={index}>
+                                        <Template data={config} enmuList={enumList} />
+                                    </React.Fragment>
+                                })
+                            }
                             <p style={{ marginTop: 20, color: token.colorTextSecondary, fontSize: 12 }}>{item.templateDescription}</p>
                             <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'end' }}>
                                 <Space>
@@ -201,6 +210,7 @@ const Page: React.FC = () => {
             colProps={{
                 span: 12,
             }}
+            width={1000}
             grid={true}
             onFinish={submit}
             columns={formConfig(enumList)}

+ 104 - 34
src/pages/MiniApp/ModuleConfig/template.tsx

@@ -5,65 +5,135 @@ import top from '../../../../public//top-r1.png';
 import { createStyles } from "antd-style";
 
 
-export function Template(params: { list: any[], isVip: boolean }) {
-    let { list, isVip } = params
+export function Template(params: { data: any, enmuList: any }) {
+    let { data, enmuList } = params
+    let { firstRecharge, rechargeConfigList } = data
     const useStyles = createStyles((props) => {
         let { token } = props
         return {
             cardBox: {
                 position: 'relative'
             },
-            isOne: {
-                backgroundImage: isVip ? "linear-gradient(180deg, #fff1dc 60%, #fffdfa 100%)" : 'linear-gradient(180deg, #ffeced 60%, #fffafa 100%)',
+            bgVip: {
+                backgroundImage: "linear-gradient(180deg, #fff1dc 60%, #fffdfa 100%)",
+            },
+            bg: {
+                backgroundImage: 'linear-gradient(180deg, #ffeced 60%, #fffafa 100%)'
             },
             topRight: {
                 lineHeight: '20px',
-                background: isVip ? "#ffd89d" : "#ff2441",
+                background: "#ff2441",
                 position: 'absolute',
                 top: 0,
                 right: 0,
                 fontSize: 12,
-                borderRadius: isVip ? '0 8px 0 8px' : "8px 8px 0 8px",
-                padding: isVip ? '0 5px' : 0,
+                borderRadius: "0px 8px 0 8px",
+            },
+            topRightVip: {
+                background: "#ffd89d !important",
             },
+            // 
             topRightSpan1: { display: 'inline-block', background: `url(${top}) no-repeat`, minWidth: 40, height: 20, padding: "0 10px 0 6px", backgroundSize: "100% 100%", color: "#fff" },
-            topRightSpan2: { color: "#fff", display: 'inline-block', transform: 'translateX(-4px)' },
+            topRightSpan2: { color: "#fff", display: 'inline-block', padding: "0 5px" },
             del: { fontSize: 14, textDecoration: 'line-through', marginLeft: 7, color: token.colorTextTertiary, fontWeight: "500" }
         }
     });
-    let { styles } = useStyles(isVip)
+    let { styles } = useStyles()
 
     return <Card bordered={false} style={{ width: 420 }}>
         <Row gutter={[0, 15]}>
             {
-                list?.map((item, index) => {
-                    let isOne = index === 0
-                    return <Col key={index} span={11} offset={index % 2 === 0 ? 0 : 1} >
-                        <Card className={`${styles.cardBox} ${isOne ? styles.isOne : ""}`} styles={{ body: { maxHeight: 90, padding: '20px 15px' } }}>
-                            <div className={styles.topRight}>
-                                {
-                                    isVip ? <> <span>{item.description}</span></> : <>
-                                        <span className={styles.topRightSpan1}>{isOne ? "首充" : "超值"}</span>
-                                        <span className={styles.topRightSpan2}>{item.description}</span>
-                                    </>
-                                }
-                            </div>
-                            <div style={{ display: 'flex', flexFlow: 'column' }}>
-                                <strong >
-                                    <span style={{ fontSize: '20px', marginRight: 3 }}>¥</span>
-                                    <span style={{ fontSize: 22, fontFamily: 'Yuewen Font' }}>{item.price}</span>
-                                    {isVip && item.gift && <span className={styles.del}>¥{item.gift}</span>}
-                                </strong>
-                                {isVip ?
+                rechargeConfigList?.map((item: any, index: any) => {
+                    let {
+                        color,//背景色
+                        description,//整数购买文案
+                        extra,//右上角描述值
+                        gearType,//充值类型
+                        gift,//赠送
+                        obtain,//获得书币/vip每天价格
+                        price,//价格
+                        subscript,//右上角文案 首充|超值等
+                        vipDays,//vip天数
+                    } = item
+                    switch (gearType) {
+                        case 1://充值
+                            return <Col key={index} span={11} offset={index % 2 === 0 ? 0 : 1} >
+                                <Card className={`${styles.cardBox} ${color && styles.bg}`} styles={{ body: { maxHeight: 90, padding: '20px 15px' } }}>
+                                    {/* 右上角 */}
+                                    <div className={`${styles.topRight}`} style={subscript ?{borderRadius: "8px 8px 0 8px",}:{}} >
+                                        {
+                                            <>
+                                                {subscript && <span className={styles.topRightSpan1}>{subscript}</span>}
+                                                <span className={styles.topRightSpan2} style={subscript ? { transform: 'translateX(-4px)' } : {}}>多送{extra}元</span>
+                                            </>
+                                        }
+                                    </div>
+                                    <div style={{ display: 'flex', flexFlow: 'column' }}>
+                                        <strong >
+                                            <span style={{ fontSize: '20px', marginRight: 3 }} >¥</span>
+                                            <span style={{ fontSize: 22, fontFamily: 'Yuewen Font' }}>{price}</span>
+                                        </strong>
+                                        <span style={{ fontSize: 12, marginTop: 2, color: "#777", display: 'block' }}>{obtain}书币 送{gift}书券</span>
+                                    </div>
+                                    {color && <img src={jb} style={{ position: 'absolute', right: 0, bottom: 0, width: 50 }} />}
+                                </Card>
+                            </Col>
+                        case 2://vip
+                            let vipEnum = enmuList?.VIP_DAYS?.values;
+                            let vipStr = vipEnum?.find((i: { value: any; }) => i.value === vipDays)?.description || ""
+                            return <Col key={index} span={11} offset={index % 2 === 0 ? 0 : 1} >
+                                <Card className={`${styles.cardBox} ${color && styles.bgVip}`} styles={{ body: { maxHeight: 90, padding: '20px 15px' } }}>
+                                    {/* 右上角 */}
+                                    <div className={`${styles.topRight} ${styles.topRightVip}`} style={subscript ?{borderRadius: "8px 8px 0 8px",}:{}}>
+                                        {
+                                            <>
+                                                {subscript && <span className={styles.topRightSpan1}>{subscript}</span>}
+                                                <span className={styles.topRightSpan2}>{vipStr}</span>
+                                            </>
+                                        }
+                                    </div>
+                                    <div style={{ display: 'flex', flexFlow: 'column' }}>
+                                        <strong >
+                                            <span style={{ fontSize: '20px', marginRight: 3 }} >¥</span>
+                                            <span style={{ fontSize: 22, fontFamily: 'Yuewen Font' }}>{price}</span>
+                                        </strong>
+                                        <span style={{ fontSize: 12, marginTop: 2, color: "#777", display: 'block' }}>¥{obtain}元/天</span>
+                                    </div>
+                                    {color && <img src={vip} style={{ position: 'absolute', right: 0, bottom: 0, width: 30 }} />}
+                                </Card>
+                            </Col>
+                        case 3://整本
+                            return <Col key={index} span={11} offset={index % 2 === 0 ? 0 : 1} >
+                                <Card className={`${styles.cardBox} `} styles={{ body: { maxHeight: 90, padding: '20px 15px' } }}>
+                                    {/* 右上角 */}
+                                    <div className={styles.topRight}>
+                                        {
+                                            subscript ? <> <span>{item.description}</span></> : <>
+                                                <span className={styles.topRightSpan1}>{subscript}</span>
+                                                <span className={styles.topRightSpan2}>{item.description}</span>
+                                            </>
+                                        }
+                                    </div>
+                                    <div style={{ display: 'flex', flexFlow: 'column' }}>
+                                        <strong >
+                                            <span style={{ fontSize: '20px', marginRight: 3 }} >¥</span>
+                                            <span style={{ fontSize: 22, fontFamily: 'Yuewen Font' }}>{price}</span>
+                                            {/* {isVip && item.gift && <span className={styles.del}>¥{item.gift}</span>} */}
+                                        </strong>
+                                        {/* {isVip ?
                                     <span style={{ fontSize: 12, marginTop: 2, color: "#777", display: 'block' }}>{isOne ? "仅" : "¥"}{item.extra}元/天</span>
                                     :
-                                    <span style={{ fontSize: 12, marginTop: 2, color: "#777", display: 'block' }}>{item.gift}书币 送{item.extra}书券</span>}
-                            </div>
-                            {isOne && <img src={isVip ? vip : jb} style={{ position: 'absolute', right: 0, bottom: 0, width: isVip ? 30 : 50 }} />}
-                        </Card>
-                    </Col>
+                                    <span style={{ fontSize: 12, marginTop: 2, color: "#777", display: 'block' }}>{item.gift}书币 送{item.extra}书券</span>} */}
+                                    </div>
+                                    {/* {isOne && <img src={isVip ? vip : jb} style={{ position: 'absolute', right: 0, bottom: 0, width: isVip ? 30 : 50 }} />} */}
+                                </Card>
+                            </Col>
+                        default:
+                            break;
+                    }
+
                 })
             }
         </Row>
-    </Card>
+    </Card >
 }