|  | @@ -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}
 | 
	
		
			
				|  |  |          />
 | 
	
		
			
				|  |  |          {/* 阅读小说 */}
 |