shenwu 7 ماه پیش
والد
کامیت
4aaf86e5fe

+ 14 - 10
src/components/bookSelect/drawer.less

@@ -1,28 +1,32 @@
-.addBtn{
+.addBtn {
     width: calc(100vw / 30);
     height: calc(100vw / 22.4);
     display: flex;
     align-items: center;
     justify-content: center;
 }
-.book{
+
+.book {
     margin-top: calc(100vw / 170);
-    // display: flex;
 
-    img {
-        width: calc(100vw / 30);
-        height: calc(100vw / 22.4);
-        background: #D8D8D8;
-        border-radius: calc(100vw / 500);
-        margin-right: calc(100vw / 170);
+    // display: flex;
+    >span {
+        position: relative;
         float: left;
+        img {
+            width: calc(100vw / 30);
+            height: calc(100vw / 22.4);
+            background: #D8D8D8;
+            border-radius: calc(100vw / 500);
+            margin-right: calc(100vw / 170);
+        }
     }
-
     >div {
         float: left;
         display: flex;
         flex-flow: column;
         width: calc(100vw / 10);
+
         strong {
             height: calc(100vw / 100);
             font-family: PingFangSC, PingFang SC;

+ 8 - 2
src/components/bookSelect/drawer.tsx

@@ -6,6 +6,7 @@ import styles from './drawer.less'
 import { useAjax } from "@/Hook/useAjax"
 import useApi from "@/Hook/useApi"
 import { useModel } from "@umijs/max"
+import { MyIcon } from "@/global"
 function BookSelectDrawer(props: { value?: any, onChange?: (v: any) => void }) {
     let [open, setOpen] = useState(false)
     let { initialState } = useModel("@@initialState")
@@ -21,7 +22,7 @@ function BookSelectDrawer(props: { value?: any, onChange?: (v: any) => void }) {
                 bookId: props?.value
             }).then(res => {
                 if (res?.data?.total > 0) {
-                    props.onChange?.(res.data.records[0]?.shortBookInfoVO ? { ...res.data.records[0], ...res.data.records[0]?.shortBookInfoVO } : { ...res.data.records[0], ...res.data.records[0]?.longBookInfo })
+                    props.onChange?.(res.data.records[0]?.shortBookInfoVO ? { ...res.data.records[0]?.shortBookInfoVO, ...res.data.records[0] } : { ...res.data.records[0]?.longBookInfo, ...res.data.records[0] })
                 }
             })
         }
@@ -32,7 +33,12 @@ function BookSelectDrawer(props: { value?: any, onChange?: (v: any) => void }) {
                 <PlusOutlined style={{ fontSize: 20 }} />
             </Button> :
                 <div onClick={() => { setOpen(true) }} className={styles.book}>
-                    <img className={styles.addBtn} src={props?.value?.picUrl} />
+                    <span>
+                        {props?.value?.vipFree && <MyIcon type="icon-vipmianfei" style={{ fontSize: 35, position: 'absolute', zIndex: 1 }} />}
+                        <img className={styles.addBtn} src={props?.value?.picUrl} onError={(e: any) => {
+                            e.target.src = localStorage.getItem("nocover")
+                        }} />
+                    </span>
                     <div>
                         <strong>{props?.value?.bookName || "书名"}</strong>
                         <span>{props?.value?.bookDesc || "描述"}</span>

+ 36 - 5
src/pages/MiniApp/BookManage/Long/index.tsx

@@ -29,14 +29,20 @@ type DataItem = {
 type Props = {
     value?: any,
     onChange?: (v: any) => void
+    closeDrawer?: (v: any) => void
 }
+/**
+ * 关于props的值和bookId的操作都是为了在被当做组件选择书籍使用时的逻辑处理
+ * */
 const Page: React.FC = (props: Props) => {
     let { initialState } = useModel("@@initialState")
     let { state, getLabelAndClassList } = useModel('global')
+    let { tabs } = useModel("appPageConifg", modal => ({ tabs: modal.state.tabs }))
     let [open, setOpen] = useState<any>(null)//付费配置
     let [editValues, setEditValues] = useState<any>({})
     let paymentType = useState(0)
     let paymentCategory = useState(0)//收费货币
+    let [bookId, setBookId] = useState<any>(props?.value?.bookId || props?.value)//当组件选择时使用
     let [isGlobalConfig, setIsGlobalConfig] = useState(false)//
     let [workDirection, setWorkDirection] = useState<any>(null)
     const [openBook, setOpneBook] = useState<any>(null)//阅读小说
@@ -56,12 +62,16 @@ const Page: React.FC = (props: Props) => {
     }, [workDirection])
     // 接口公共参数
     let publicData = useMemo(() => {
-        return {
+        let pramas = {
             appId: initialState?.selectApp?.id || "",
-            distributorId: initialState?.currentUser?.distributorId,
             appType: initialState?.selectApp?.appType || ""
         }
-    }, [initialState?.selectApp, initialState?.currentUser?.distributorId])
+        return bookId ? {
+            appId: initialState?.selectApp?.id || "",
+            appType: initialState?.selectApp?.appType || "",
+            bookId
+        } : pramas
+    }, [initialState?.selectApp, bookId])
     //获取全局收费配置
     const getGlobalInfo = useCallback(() => {
         globaleConfig.run(publicData).then(res => {
@@ -143,7 +153,7 @@ const Page: React.FC = (props: Props) => {
         tabProps={{ type: 'card' }}
     >
         <ProTable<any, any>
-            params={publicData}
+            // params={publicData}
             actionRef={actionRef}
             headerTitle={"小说列表"}
             rowKey={(r) => r.bookId}
@@ -169,6 +179,23 @@ const Page: React.FC = (props: Props) => {
                 labelWidth: 90,
                 searchGutter: [10, 15],
             }}
+            //多选
+            rowSelection={!!props?.onChange ? {
+                hideSelectAll: true,
+                type: 'radio',
+                selectedRowKeys: [props?.value?.bookId || props?.value],
+                onSelect: (record, selected) => {
+                    props?.onChange?.({ ...record?.longBookInfo, ...record })
+                    props?.closeDrawer?.(false)
+                },
+            } : false}
+            // 点击行
+            onRow={(record) => ({
+                onClick: () => {
+                    props?.onChange?.({ ...record?.longBookInfo, ...record })
+                    props?.closeDrawer?.(false)
+                }
+            })}
             loading={getChapterAllList?.loading || configInfo?.loading || getList.loading}
             // ghost={true}//去除表格的背景一些配置改变ui
             beforeSearchSubmit={(params) => {//处理搜索数据
@@ -188,10 +215,14 @@ const Page: React.FC = (props: Props) => {
                 return newParams
             }}
             request={async (params) => {
-                return await getList.run(params)
+                return await getList.run({ ...params, ...publicData }).then(res => {
+                    setBookId(null)
+                    return res
+                })
             }}
             columns={columns({ authList: state?.authList, labelList: state.labelList, categoryList: state.categoryList, enumList: state?.enumList, lookBook: lookBookList, closeForm, setWorkDirection, isModal: !!props?.onChange })}
         />
+
         {/* 付费配置 */}
         <BetaSchemaForm<DataItem>
             title={(isGlobalConfig ? "全局" : "《" + editValues?.bookName + "》") + "付费配置"}

+ 1 - 1
src/pages/MiniApp/BookManage/Short/index.tsx

@@ -41,7 +41,7 @@ const Page: React.FC = (props: Props) => {
     let [editValues, setEditValues] = useState<any>({})
     let paymentType = useState(0)//付费方式
     let paymentCategory = useState(0)//收费货币
-    let [bookId, setBookId] = useState<any>(props?.value?.bookId || props?.value)//付费配置
+    let [bookId, setBookId] = useState<any>(props?.value?.bookId || props?.value)//当组件选择时使用,用于初始请求搜索已选择的书
     let [isGlobalConfig, setIsGlobalConfig] = useState(false)//
     let [workDirection, setWorkDirection] = useState<any>(null)
     const [openBook, setOpneBook] = useState<any>(null)//阅读小说

+ 14 - 7
src/pages/MiniApp/CompConfig/components/hot_books.tsx

@@ -5,6 +5,7 @@ import { Empty, Tag } from "antd";
 import { useModel } from "@umijs/max";
 import { ReactElement, JSXElementConstructor, ReactNode, ReactPortal, Key } from "react";
 import { Config } from "@/models/appPageConifg";
+import { MyIcon } from "@/global";
 // 热门书
 export function HotBooks(props: {
     data: {
@@ -23,9 +24,12 @@ export function HotBooks(props: {
         <Header title={componentName || "今日热书"} showBtn={showRightButton} />
         {configs?.[0]?.bookInfo ? <>
             <div className={styles.top}>
-                <img src={configs?.[0]?.bookInfo?.picUrl} onError={(e: any) => {
-                    e.target.src = localStorage.getItem("nocover")
-                }} />
+                <span>
+                    {configs?.[0]?.bookInfo?.vipFree && <MyIcon type="icon-vipmianfei" style={{ fontSize: 35, position: 'absolute', zIndex: 1 }} />}
+                    <img src={configs?.[0]?.bookInfo?.picUrl} onError={(e: any) => {
+                        e.target.src = localStorage.getItem("nocover")
+                    }} />
+                </span>
                 <div>
                     <strong>{configs?.[0]?.bookInfo?.bookName || "书名"}</strong>
                     <span>{configs?.[0]?.bookInfo?.bookDesc || "描述"}</span>
@@ -37,11 +41,14 @@ export function HotBooks(props: {
             </div>
             <div className={styles.list}>
                 {
-                    configs?.filter((i: any, eq: number) => eq != 0)?.map((item: { bookInfo: { picUrl: string | undefined; bookName: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; }; }, index: Key | null | undefined) => {
+                    configs?.filter((i: any, eq: number) => eq != 0)?.map((item: { bookInfo: { vipFree: any, picUrl: string | undefined; bookName: string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined; }; }, index: Key | null | undefined) => {
                         return <div key={index} className={styles.box}>
-                            <img src={item?.bookInfo?.picUrl} onError={(e: any) => {
-                                e.target.src = localStorage.getItem("nocover")
-                            }} />
+                            <div>
+                                {item?.bookInfo?.vipFree && <MyIcon type="icon-vipmianfei" style={{ fontSize: 35, position: 'absolute', zIndex: 1 }} />}
+                                <img src={item?.bookInfo?.picUrl} onError={(e: any) => {
+                                    e.target.src = localStorage.getItem("nocover")
+                                }} />
+                            </div>
                             <span>{item?.bookInfo?.bookName}</span>
                         </div>
                     })

+ 13 - 6
src/pages/MiniApp/CompConfig/components/hot_category.tsx

@@ -8,6 +8,7 @@ import { useAjax } from "@/Hook/useAjax";
 import useApi from "@/Hook/useApi";
 import { Empty, Spin } from "antd";
 import usePrevious from "@/Hook/usePrevious";
+import { MyIcon } from "@/global";
 // 热门书
 export function HotCategory(props: {
     data: {
@@ -84,16 +85,22 @@ export function HotCategory(props: {
                 {
                     configs?.find(i => i.categoryId == tag)?.bookIds ? configs?.find(i => i.categoryId == tag)?.bookInfos?.map((item: any, index: any) => {
                         return <div key={item.id || index} className={styles.box}>
-                            <img src={item?.picUrl} onError={(e: any) => {
-                                e.target.src = localStorage.getItem("nocover")
-                            }} />
+                            <div>
+                                {item?.vipFree && <MyIcon type="icon-vipmianfei" style={{ fontSize: 35, position: 'absolute', zIndex: 1 }} />}
+                                <img src={item?.picUrl} onError={(e: any) => {
+                                    e.target.src = localStorage.getItem("nocover")
+                                }} />
+                            </div>
                             <span>{item?.bookName}</span>
                         </div>
                     }) : bookData?.length > 0 ? bookData?.map((item: any, index) => {
                         return <div key={item.bookId || index} className={styles.box}>
-                            <img src={item?.longBookInfo?.picUrl || item?.shortBookInfoVO?.picUrl} onError={(e: any) => {
-                                e.target.src = localStorage.getItem("nocover")
-                            }} />
+                            <div>
+                                {(item?.vipFree) && <MyIcon type="icon-vipmianfei" style={{ fontSize: 35, position: 'absolute', zIndex: 1 }} />}
+                                <img src={item?.longBookInfo?.picUrl || item?.shortBookInfoVO?.picUrl} onError={(e: any) => {
+                                    e.target.src = localStorage.getItem("nocover")
+                                }} />
+                            </div>
                             <span>{item?.longBookInfo?.bookName || item?.shortBookInfoVO?.bookName}</span>
                         </div>
                     }) : <div style={{ justifyContent: 'center', display: 'flex', width: '100%' }}><Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无数据请选中后设置" /></div>

+ 30 - 20
src/pages/MiniApp/CompConfig/components/index.less

@@ -43,13 +43,17 @@
         margin-top: calc(100vw / 170);
         display: flex;
 
-        img {
-            width: calc(100vw / 30);
-            height: calc(100vw / 22.4);
-            background: #D8D8D8;
-            border-radius: calc(100vw / 500);
-            margin-right: calc(100vw / 170);
+        >span {
             float: left;
+            position: relative;
+
+            img {
+                width: calc(100vw / 30);
+                height: calc(100vw / 22.4);
+                background: #D8D8D8;
+                border-radius: calc(100vw / 500);
+                margin-right: calc(100vw / 170);
+            }
         }
 
         >div {
@@ -126,16 +130,17 @@
         .box {
             display: flex;
             flex-flow: column;
-
-            img {
-                width: calc(100vw / 30);
-                height: calc(100vw / 22.4);
-                background: #D8D8D8;
-                border-radius: calc(100vw / 500);
-                margin-right: calc(100vw / 170);
-                margin-bottom: calc(100vw / 420);
+            >div {
+                position: relative;
+                img {
+                    width: calc(100vw / 30);
+                    height: calc(100vw / 22.4);
+                    background: #D8D8D8;
+                    border-radius: calc(100vw / 500);
+                    margin-right: calc(100vw / 170);
+                    margin-bottom: calc(100vw / 420);
+                }
             }
-
             span {
                 width: calc(100vw / 30);
                 height: calc(100vw / 60);
@@ -172,23 +177,28 @@
         overflow-y: hidden;
         flex-flow: row nowrap;
         margin: calc(100vw / 150) 0;
+
         .tag {
             height: calc(100vw / 75);
             background: #e8e7e7;
-            border-radius:  calc(100vw / 128);;
+            border-radius: calc(100vw / 128);
+            ;
             font-size: calc(100vw / 160);
             float: left;
-            margin-right:  calc(100vw / 213);
+            margin-right: calc(100vw / 213);
             padding: calc(100vw / 155) calc(100vw / 155);
             display: flex;
             align-items: center;
             justify-content: center;
         }
-        .tag_ac{
+
+        .tag_ac {
             background: #E5EBFA;
         }
-        &::-webkit-scrollbar{
-            display: none;  /* 隐藏滚动条 */
+
+        &::-webkit-scrollbar {
+            display: none;
+            /* 隐藏滚动条 */
         }
     }