shaogen1995 hai 1 ano
pai
achega
4bcae63048

+ 48 - 24
src/pages/A2integral/A2edit.tsx

@@ -6,6 +6,12 @@ import MyPopconfirm from "@/components/MyPopconfirm";
 import { MessageFu } from "@/utils/message";
 import { A2_APIsave } from "@/store/action/A2integral";
 
+const titleObj = {
+  user: "用户活跃",
+  game: "爱心林场",
+  other: "其他小游戏",
+};
+
 type Props = {
   editInfo: A2editInfoType;
   closeFu: () => void;
@@ -13,19 +19,19 @@ type Props = {
 };
 
 function A2edit({ editInfo, closeFu, upTableFu }: Props) {
-  const [day, setDay] = useState(0);
+  const [cycle, setCycle] = useState(0);
   const [score, setScore] = useState(0);
 
   useEffect(() => {
-    setDay(editInfo.day || 1);
+    setCycle(editInfo.cycle || 1);
     setScore(editInfo.score);
-  }, [editInfo.day, editInfo.score]);
+  }, [editInfo.cycle, editInfo.score]);
 
   // 点击确定
   const btnOkFu = useCallback(async () => {
     const obj = {
       id: editInfo.id,
-      cycle: day,
+      cycle,
       score,
     };
 
@@ -36,27 +42,26 @@ function A2edit({ editInfo, closeFu, upTableFu }: Props) {
       upTableFu();
       closeFu();
     }
-  }, [closeFu, day, editInfo.id, score, upTableFu]);
+  }, [closeFu, cycle, editInfo.id, score, upTableFu]);
 
   // 禁用按钮
   const inputNumRes = useMemo(() => {
     let flag = false;
-    if (!day) flag = true;
+    if (!cycle) flag = true;
     if (!score) flag = true;
     return flag;
-  }, [day, score]);
+  }, [cycle, score]);
 
   const inputChange = useCallback(
-    (val: React.ChangeEvent<HTMLInputElement>, type: "day" | "score") => {
+    (
+      val: React.ChangeEvent<HTMLInputElement>,
+      type: "cycle" | "score",
+      oneNum: number
+    ) => {
       let txt = val.target.value.replace(/^(0+)|[^\d]+/g, "");
       let txtNum = Number(txt);
-      if (type === "day") {
-        txtNum = txtNum > 99 ? 99 : txtNum;
-        setDay(txtNum);
-      } else {
-        txtNum = txtNum > 9999 ? 9999 : txtNum;
-        setScore(txtNum);
-      }
+      txtNum = txtNum > oneNum ? oneNum : txtNum;
+      type === "cycle" ? setCycle(txtNum) : setScore(txtNum);
     },
     []
   );
@@ -65,7 +70,7 @@ function A2edit({ editInfo, closeFu, upTableFu }: Props) {
     <Modal
       wrapClassName={styles.A2edit}
       open={true}
-      title={`${editInfo.type === "user" ? "用户活跃" : "爱心林场"} - 编辑`}
+      title={`${Reflect.get(titleObj, editInfo.type)} - 编辑`}
       footer={
         [] // 设置footer为空,去掉 取消 确定默认按钮
       }
@@ -73,22 +78,31 @@ function A2edit({ editInfo, closeFu, upTableFu }: Props) {
       <div className="A2eMain">
         <div className="A2eRow">
           <div className="A2eRow1 A2eRow3">
-            {editInfo.type === "user" ? "行为:" : "动植物:"}
+            {editInfo.type === "user"
+              ? "行为:"
+              : editInfo.type === "game"
+              ? "动植物:"
+              : "游戏名称:"}
           </div>
           <div className="A2eRow2">{editInfo.name}</div>
         </div>
 
-        {editInfo.type === "game" ? (
+        {editInfo.type !== "user" ? (
           <div className="A2eRow">
             <div className="A2eRow1">
-              <span>* </span>成熟周期(天):
+              <span>* </span>
+              {editInfo.type === "game" ? "成熟周期(天)" : "时限(秒)"}:
             </div>
             <div className="A2eRow2">
               <Input
                 style={{ width: 160 }}
-                placeholder="请输入1~99整数"
-                value={day}
-                onChange={(e) => inputChange(e, "day")}
+                placeholder={`请输入1~${
+                  editInfo.type === "game" ? "99" : "300"
+                }整数`}
+                value={cycle}
+                onChange={(e) =>
+                  inputChange(e, "cycle", editInfo.type === "game" ? 99 : 300)
+                }
               />
             </div>
           </div>
@@ -101,13 +115,23 @@ function A2edit({ editInfo, closeFu, upTableFu }: Props) {
           <div className="A2eRow2">
             <Input
               style={{ width: 160 }}
-              placeholder="请输入1~9999整数"
+              placeholder="请输入1~99999整数"
               value={score}
-              onChange={(e) => inputChange(e, "score")}
+              onChange={(e) => inputChange(e, "score", 99999)}
             />
           </div>
         </div>
 
+        {editInfo.type === "other" ? (
+          <div className="A2eRow">
+            <div className="A2eRow1 A2eRow3">
+              <span> </span>
+              奖励说明:
+            </div>
+            <div className="A2eRow2">{editInfo.description}</div>
+          </div>
+        ) : null}
+
         <div className="A2eBtn">
           <Button type="primary" onClick={btnOkFu} disabled={inputNumRes}>
             提交

+ 14 - 3
src/pages/A2integral/index.tsx

@@ -4,7 +4,7 @@ import { useDispatch, useSelector } from "react-redux";
 import { A2_APIgetList } from "@/store/action/A2integral";
 import MyTable from "@/components/MyTable";
 import { RootState } from "@/store";
-import { A2tableC1, A2tableC2 } from "@/utils/tableData";
+import { A2tableC1, A2tableC2, A2tableC3 } from "@/utils/tableData";
 import { A2editInfoType, A2tableType } from "@/types";
 import { Button } from "antd";
 import A2edit from "./A2edit";
@@ -24,7 +24,7 @@ function A2integral() {
     (state: RootState) => state.A2integral.tableInfo
   );
 
-  const tableLastBtn = useCallback((type: "user" | "game") => {
+  const tableLastBtn = useCallback((type: "user" | "game" | "other") => {
     return [
       {
         title: "操作",
@@ -37,8 +37,9 @@ function A2integral() {
                 id: item.id,
                 type,
                 name: item.name,
-                day: item.day,
+                cycle: item.cycle,
                 score: item.score,
+                description: item.description,
               })
             }
           >
@@ -75,6 +76,16 @@ function A2integral() {
         />
       </div>
 
+      <div className="A2tit">其他小游戏</div>
+      <div className="A1tableBox">
+        <MyTable
+          list={tableInfo.list3}
+          columnsTemp={A2tableC3}
+          lastBtn={tableLastBtn("other")}
+          pagingInfo={false}
+        />
+      </div>
+
       {editInfo.id ? (
         <A2edit
           editInfo={editInfo}

+ 7 - 0
src/pages/A9board/index.module.scss

@@ -0,0 +1,7 @@
+.A9board{
+  :global{
+    .aa{
+      color: red;
+    }
+  }
+}

+ 14 - 0
src/pages/A9board/index.tsx

@@ -0,0 +1,14 @@
+import React from "react";
+import styles from "./index.module.scss";
+function A9board() {
+  return (
+    <div className={styles.A9board}>
+      <div className="pageTitle">数据看板</div>
+      <h1>等待开发</h1>
+    </div>
+  );
+}
+
+const MemoA9board = React.memo(A9board);
+
+export default MemoA9board;

+ 7 - 7
src/pages/Layout/data.ts

@@ -56,13 +56,13 @@ const tabLeftArr: RouterType = [
       //   Com: React.lazy(() => import("../A4store")),
       //
       // },
-      // {
-      //   id: 900,
-      //   name: "数据看板",
-      //   path: "/store",
-      //   Com: React.lazy(() => import("../A4store")),
-      //
-      // },
+      {
+        id: 900,
+        name: "数据看板",
+        path: "/board",
+        Com: React.lazy(() => import("../A9board")),
+      
+      },
     ],
   },
   {

+ 3 - 2
src/store/action/A2integral.ts

@@ -12,6 +12,7 @@ export const A2_APIgetList = () => {
       const obj = {
         list1: list.filter((v) => v.type === "user"),
         list2: list.filter((v) => v.type === "game"),
+        list3: list.filter((v) => v.type === "other"),
       };
       dispatch({ type: "A2/getList", payload: obj });
     }
@@ -21,6 +22,6 @@ export const A2_APIgetList = () => {
 /**
  * 编辑爱心币和天数
  */
-export const A2_APIsave = (data:any) => {
-  return http.post('cms/rule/save',data);
+export const A2_APIsave = (data: any) => {
+  return http.post("cms/rule/save", data);
 };

+ 2 - 1
src/store/reducer/A2integral.ts

@@ -6,13 +6,14 @@ const initState = {
   tableInfo: {
     list1: [] as A2tableType[],
     list2: [] as A2tableType[],
+    list3: [] as A2tableType[],
   },
 };
 
 // 定义 action 类型
 type Props = {
   type: "A2/getList";
-  payload: { list1: A2tableType[]; list2: A2tableType[] };
+  payload: { list1: A2tableType[]; list2: A2tableType[]; list3: A2tableType[] };
 };
 
 //  reducer

+ 6 - 4
src/types/api/A2integral.d.ts

@@ -1,20 +1,22 @@
 export type A2tableType = {
   createTime: string;
   creatorName: string;
-  day: number;
+  cycle: number;
   description: string;
   id: number;
   name: string;
   rtf: string;
+  description:string
   score: number;
-  type: "user" | "game";
+  type: "user" | "game"|'other';
   updateTime: string;
 }
 
 export type A2editInfoType = {
   id: number;
-  type: "user" | "game";
+  type: "user" | "game"|'other';
   name:string
-  day: number;
+  description:string
+  cycle: number;
   score: number;
 };

+ 8 - 0
src/utils/tableData.ts

@@ -43,6 +43,14 @@ export const A2tableC2 = [
   ["txt", "说明", "description"],
 ];
 
+export const A2tableC3 = [
+  ["txt", "游戏名称", "name"],
+  ["txt", "时限(秒)", "cycle"],
+  ["txt", "奖励爱心币", "score"],
+  ["txt", "单日奖励上限", "dayLimit"],
+  ["txt", "奖励说明", "description"],
+];
+
 export const A3tableC = [
   ["txt", "时间", "createTime"],
   ["txt", "用户名", "creatorName"],