Forráskód Böngészése

upp-pc和后台管理修改一波

shaogen1995 2 éve
szülő
commit
d0b26a907c

+ 1 - 7
houtai/src/pages/A1Hot/HotMap/index.module.scss

@@ -35,13 +35,7 @@
     }
 
 
-    .leftNumBox {
-      z-index: 10;
-      position: absolute;
-      bottom: 20px;
-      left: 30px;
-      font-size: 14px;
-    }
+
 
     // .hot0{
     //   pointer-events: none;

+ 1 - 13
houtai/src/pages/A1Hot/HotMap/index.tsx

@@ -1,7 +1,7 @@
 import React, { useCallback, useEffect, useMemo, useState } from "react";
 import styles from "./index.module.scss";
 import classNames from "classnames";
-import { getHotMapInfoAPI, getHotMapInfoNumAPI } from "@/store/action/A1Hot";
+import { getHotMapInfoAPI } from "@/store/action/A1Hot";
 import { HotMaoType } from "@/types";
 function HotMap() {
   // 城市名字id
@@ -13,9 +13,6 @@ function HotMap() {
   // 整个数据
   const [arr, setArr] = useState<HotMaoType[]>([]);
 
-  // 国内外访客
-  const [numNation, setNumNation] = useState([{ pcs: 0 }, { pcs: 0 }]);
-
   const getMapInfo = useCallback(async () => {
     const res = await getHotMapInfoAPI();
     if (res.code === 0) {
@@ -29,10 +26,6 @@ function HotMap() {
 
       setMaxNum(maxNumRes);
     }
-
-    // 获取国内国外访客数量
-    const res2 = await getHotMapInfoNumAPI();
-    if (res2.code === 0) setNumNation(res2.data);
   }, []);
 
   useEffect(() => {
@@ -105,11 +98,6 @@ function HotMap() {
           ) : null}
         </div>
       )}
-      {/* 左下角的数据 */}
-      <div className="leftNumBox">
-        <div>国内访客合计:{numNation[0] ? numNation[0].pcs : 0}</div>
-        <div>国外访客合计:{numNation[1] ? numNation[1].pcs : 0}</div>
-      </div>
 
       <svg
         xmlns="http://www.w3.org/2000/svg"

+ 8 - 10
houtai/src/pages/A1Hot/index.module.scss

@@ -50,6 +50,12 @@
           height: 22px;
           background-color: var(--themeColor2);
         }
+        .hotTitSelectTxt{
+          height: 32px;
+          line-height: 32px;
+          font-weight: 400;
+          font-size: 16px;
+        }
       }
 
       .hotTime {
@@ -86,7 +92,7 @@
             &>div {
               border-radius: 10px;
               background-color: #fff;
-              width: calc(50% - 4px);
+              width: 100%;
               height: 245px;
               padding: 10px 15px 0;
             }
@@ -96,14 +102,6 @@
               height: 180px;
             }
 
-            #echarts3 {
-              width: 100%;
-              height: 180px;
-            }
-
-            .topBoxL2L {
-              margin-right: 8px;
-            }
           }
         }
 
@@ -178,7 +176,7 @@
                 .echarts4BoxTxt {
                   position: absolute;
                   z-index: 10;
-                  top: 30%;
+                  top: 25%;
                   left: 45%;
                   text-align: center;
                   min-width: 34px;

+ 31 - 53
houtai/src/pages/A1Hot/index.tsx

@@ -27,6 +27,7 @@ import {
   HotGoodsType,
   HotInfo1Type,
   HotInfo3Type,
+  HotInfo3TypegroupKey,
   HotInfo4Type,
 } from "@/types";
 import { hotChangeObj } from "@/utils/changeData";
@@ -43,17 +44,15 @@ echarts.use([
 ]);
 
 function Hot() {
-  // 5个echart的Ref
+  // 4个echart的Ref
   const echartRef1 = useRef<HTMLDivElement>(null);
   const echartRef2 = useRef<HTMLDivElement>(null);
-  const echartRef3 = useRef<HTMLDivElement>(null);
   const echartRef4 = useRef<HTMLDivElement>(null);
   const echartRef7 = useRef<HTMLDivElement>(null);
 
   // 数量总计
   const [allNum1, setAllNum1] = useState(0);
   const [allNum2, setAllNum2] = useState(0);
-  const [allNum3, setAllNum3] = useState(0);
   const [allNum4, setAllNum4] = useState(0);
   const [allNum5, setAllNum5] = useState(0);
 
@@ -61,8 +60,7 @@ function Hot() {
   const [select1, setSelect1] = useState<1 | 7 | 30 | "">(7);
   // 馆藏排行下拉框
   const [select2, setSelect2] = useState("visit");
-  // 场景排行下拉框
-  const [select3, setSelect3] = useState("visit");
+
   // 馆藏统计下拉框
   const [select4, setSelect4] = useState("texture");
 
@@ -79,7 +77,7 @@ function Hot() {
       data2: number[],
       color: string[]
     ) => {
-      const myChart1 = echarts.init(dom);
+      const myChart1 = echarts.getInstanceByDom(dom) || echarts.init(dom);
       const option1 = {
         color: color,
         grid: {
@@ -135,8 +133,7 @@ function Hot() {
       data: { value: number; name: string }[],
       obj: any
     ) => {
-      let myChart2 = echarts.getInstanceByDom(dom);
-      if (!myChart2) myChart2 = echarts.init(dom);
+      const myChart2 = echarts.getInstanceByDom(dom) || echarts.init(dom);
       let option2 = {
         color: ["#11A480", "#00BBF6", "#F97C7C", "#93876D", "#ECDFBF"],
         tooltip: {
@@ -192,13 +189,27 @@ function Hot() {
     []
   );
 
-  // 第一个饼图--浏览总数
+  // 第一个饼图--浏览板块
   const echartsB1 = useCallback(async () => {
     const res3 = await getHotInfo3API(select1);
     if (res3.code === 0) {
       const data3: HotInfo3Type[] = res3.data;
       let allNum4 = 0;
       const data4: any = [];
+
+      // 不够5个,手动匹配
+      if (data3.length < 5) {
+        const arrTemp: any = data3.map((v) => v.groupKey);
+        for (const key in hotChangeObj) {
+          if (!arrTemp.includes(key)) {
+            data3.push({
+              pcs: 0,
+              groupKey: key as HotInfo3TypegroupKey,
+            });
+          }
+        }
+      }
+
       data3.forEach((v) => {
         data4.push({
           icon: "circle",
@@ -211,8 +222,8 @@ function Hot() {
 
       // 左边饼图配置文件
       const data4Obj = {
-        legend: { left: "center", bottom: 20 },
-        series: { center: ["50%", "35%"], radius: ["50%", "70%"] },
+        legend: { left: "center", bottom: 10 },
+        series: { center: ["50%", "30%"], radius: ["40%", "60%"] },
       };
       echartsFu2(echartRef4.current!, data4, data4Obj);
     }
@@ -229,12 +240,12 @@ function Hot() {
 
   // 场景排行
   const getlikeData2Fu = useCallback(async () => {
-    const res = await getHotInfo5API(select1, select3);
+    const res = await getHotInfo5API(select1, "visit");
     if (res.code === 0) {
       const data: HotInfo4Type[] = res.data;
       setLikeData2(data);
     }
-  }, [select1, select3]);
+  }, [select1]);
 
   // 馆藏统计---第二个饼图
   // 把全部的第二个饼图的数据存起来
@@ -316,7 +327,7 @@ function Hot() {
 
   const getInfoFu = useCallback(async () => {
     // 第一个折线 echarts----------------------------
-    const res1 = await getHotInfo1API();
+    const res1 = await getHotInfo1API(13);
     if (res1.code === 0) {
       const data1: HotInfo1Type[] = res1.data.reverse();
       let allNum1 = 0;
@@ -331,8 +342,8 @@ function Hot() {
       echartsFu1(echartRef1.current!, data1_1, data1_2, ["#11A480"]);
     }
 
-    // 第二、三个折线 echarts----------------------------
-    const res2 = await getHotInfo2API();
+    // 第二个折线 echarts----------------------------
+    const res2 = await getHotInfo2API(13);
 
     if (res2.code === 0) {
       const data2: HotInfo1Type[] = res2.data.reverse();
@@ -340,24 +351,14 @@ function Hot() {
       const data2_1: string[] = [];
       const data2_2: number[] = [];
 
-      let allNum3 = 0;
-      const data3_1: string[] = [];
-      const data3_2: number[] = [];
-
       data2.forEach((v) => {
         data2_1.push(v.today);
         data2_2.push(v.pcsWall);
         allNum2 += v.pcsWall;
-
-        data3_1.push(v.today);
-        data3_2.push(v.pcsWearable);
-        allNum3 += v.pcsWearable;
       });
       setAllNum2(allNum2);
-      setAllNum3(allNum3);
 
       echartsFu1(echartRef2.current!, data2_1, data2_2, ["#00BBF6"]);
-      echartsFu1(echartRef3.current!, data3_1, data3_2, ["#F97C7C"]);
     }
   }, [echartsFu1]);
 
@@ -402,22 +403,7 @@ function Hot() {
                 </div>
                 {/* 第二个echarts盒子 */}
                 <div id="echarts2" ref={echartRef2}></div>
-                <div className="hotTime">近七天数据</div>
-              </div>
-              {/* 穿戴设备热度盒子 */}
-              <div className="topBoxL2R">
-                <div className="hotTit">
-                  穿戴设备热度&nbsp;&nbsp;
-                  <span style={{ color: "#F97C7C" }}>{allNum3}</span>
-                  <Tooltip title="穿戴设备每次启动,记为1点热度">
-                    <div className="inco">
-                      <ExclamationCircleFilled />
-                    </div>
-                  </Tooltip>
-                </div>
-                {/* 第三个echarts盒子 */}
-                <div id="echarts3" ref={echartRef3}></div>
-                <div className="hotTime">近七天数据</div>
+                <div className="hotTime">近十四天数据</div>
               </div>
             </div>
           </div>
@@ -453,14 +439,14 @@ function Hot() {
                 ]}
               />
               <div className="downBoxLTopTit">
-                可对浏览总数、馆藏排行、场景排行进行日期区间的筛选
+                可对浏览板块、馆藏排行、场景排行进行日期区间的筛选
               </div>
             </div>
             <div className="downBoxLMain">
               <div className="downBoxLMain2">
                 <div className="downBoxLMain2EchBox">
                   <div className="hotTit">
-                    浏览总数
+                    浏览板块
                     <Tooltip title="在所选时间段内,每查看一次对应内容记为1">
                       <div className="inco">
                         <ExclamationCircleFilled />
@@ -526,15 +512,7 @@ function Hot() {
                 <div className="downBoxLMain2R">
                   <div className="hotTitSelect">
                     <div>场景排行</div>
-                    <Select
-                      value={select3}
-                      style={{ width: 100 }}
-                      onChange={(e) => setSelect3(e)}
-                      options={[
-                        { value: "visit", label: "按浏览" },
-                        { value: "star", label: "按点赞" },
-                      ]}
-                    />
+                    <div className="hotTitSelectTxt"></div>
                   </div>
 
                   {likeData2.length ? (

+ 3 - 0
houtai/src/pages/B1Scene/index.tsx

@@ -9,6 +9,8 @@ import { removeTokenInfo } from "@/utils/storage";
 import history from "@/utils/history";
 import { baseURL } from "@/utils/http";
 
+
+// 待完善
 const isTokenFlagFu = (val: boolean, url: string) => {
   if (val) {
     // token 有效
@@ -35,6 +37,7 @@ function Scene() {
       },
       { id: 5, sceneCode: "1194", name: "海战博物馆D厅", img: demoImg },
       { id: 6, sceneCode: "1194", name: "虎门故事展厅", img: demoImg },
+      { id: 7, sceneCode: "1194", name: "虎门故事展厅777", img: demoImg },
     ];
   }, []);
 

+ 1 - 3
houtai/src/pages/B3Wall/WallTable/index.tsx

@@ -1,13 +1,11 @@
-import { Button, Popconfirm, Switch, Table, Tooltip } from "antd";
+import { Button, Popconfirm, Switch, Table } from "antd";
 import React, {
   useCallback,
   useEffect,
-  useImperativeHandle,
   useMemo,
   useRef,
   useState,
 } from "react";
-import { ExclamationCircleFilled } from "@ant-design/icons";
 import styles from "./index.module.scss";
 
 // 表格拖动排序-----------------

+ 2 - 2
houtai/src/pages/B3Wall/index.tsx

@@ -31,7 +31,7 @@ function Wall() {
     const res = await getWallCategoryoApi();
     if (res.code === 0) {
       const data = JSON.parse(res.data.content);
-      console.log(data);
+      // console.log(data);
       setValueType(data.isAuto);
       setTimeType0(data.startTime + "," + data.endTime);
       setTypeDisplay(data.type)
@@ -43,7 +43,7 @@ function Wall() {
   const getWallCategoryListApiFu = useCallback(async () => {
     const res = await getWallCategoryoListApi();
     if (res.code === 0) {
-      console.log(res);
+      // console.log(res);
       setTypes(res.data);
     }
   }, []);

+ 62 - 3
houtai/src/pages/B7Poster/index.module.scss

@@ -1,5 +1,64 @@
-.B7Poster{
-  :global{
-    
+.B7Poster {
+  :global {
+    .B7main {
+      width: 100%;
+      height: 100%;
+      display: flex;
+      justify-content: space-between;
+
+      &>div {
+        background-color: #fff;
+        border-radius: 10px;
+        width: calc(50% - 10px);
+        padding: 20px;
+        position: relative;
+
+        .B7tit {
+          padding-left: 15px;
+          position: relative;
+          font-weight: 700;
+          font-size: 16px;
+
+          &>span {
+            font-size: 12px;
+            color: #666;
+          }
+
+          &::before {
+            content: '';
+            position: absolute;
+            left: 0;
+            top: 0;
+            width: 5px;
+            height: 22px;
+            background-color: var(--themeColor2);
+          }
+        }
+
+        .B7tableBox {
+          overflow: hidden;
+          margin-top: 20px;
+          height: calc(100% - 25px);
+
+          .ant-table-body {
+            height: 700px;
+            overflow-y: auto !important;
+            // overflow-y: overlay !important;
+
+            .ant-table-row {
+              .ant-table-cell {
+                padding: 10px;
+              }
+            }
+          }
+        }
+
+        .B7addBtn {
+          position: absolute;
+          top: 15px;
+          right: 20px;
+        }
+      }
+    }
   }
 }

+ 238 - 5
houtai/src/pages/B7Poster/index.tsx

@@ -1,12 +1,245 @@
-import React from "react";
+import React, { useCallback, useEffect, useMemo, useRef } from "react";
 import styles from "./index.module.scss";
- function B7Poster() {
-  
+import { Button, Popconfirm, Table } from "antd";
+import { MessageFu } from "@/utils/message";
+import {
+  B7_APIadd,
+  B7_APIdel,
+  B7_APIsetCover,
+  B7_APIupImg,
+  B7_getList,
+} from "@/store/action/B7Poster";
+import { fileDomInitialFu } from "@/utils/domShow";
+import { useDispatch, useSelector } from "react-redux";
+import { RootState } from "@/store";
+import { B7TableType } from "@/types";
+import ImageLazy from "@/components/ImageLazy";
+import { baseURL } from "@/utils/http";
+function B7Poster() {
+  const dispatch = useDispatch();
+
+  // 获取 pc 端表格数据
+  const getListPcFu = useCallback(() => {
+    dispatch(B7_getList("pc"));
+  }, [dispatch]);
+
+  // 获取 app 端表格数据
+  const getListAppFu = useCallback(() => {
+    dispatch(B7_getList("app"));
+  }, [dispatch]);
+
+  useEffect(() => {
+    getListPcFu();
+    getListAppFu();
+  }, [getListAppFu, getListPcFu]);
+
+  // 从仓库获取表格数据
+  const { tableList1, tableList2 } = useSelector(
+    (state: RootState) => state.B7Poster
+  );
+
+  const typeRef = useRef<"pc" | "app">("pc");
+
+  const myInput = useRef<HTMLInputElement>(null);
+
+  // 上传封面图
+  const handeUpPhoto = useCallback(
+    async (e: React.ChangeEvent<HTMLInputElement>) => {
+      if (e.target.files) {
+        // 拿到files信息
+        const filesInfo = e.target.files[0];
+        // 校验格式
+        const type = ["image/jpeg", "image/png"];
+        if (!type.includes(filesInfo.type)) {
+          e.target.value = "";
+          return MessageFu.warning("只支持jpg、png格式!");
+        }
+        // 校验大小
+        if (filesInfo.size > 2 * 1024 * 1024) {
+          e.target.value = "";
+          return MessageFu.warning("最大支持2M!");
+        }
+        // 创建FormData对象
+        const fd = new FormData();
+        // 把files添加进FormData对象(‘photo’为后端需要的字段)
+        fd.append("type", "thumb");
+        fd.append("dirCode", "B7Cover");
+        fd.append("file", filesInfo);
+
+        e.target.value = "";
+
+        try {
+          const res = await B7_APIupImg(fd);
+          if (res.code === 0) {
+            const url = res.data.filePath;
+
+            const res2 = await B7_APIadd({ thumb: url, type: typeRef.current });
+
+            if (res2.code === 0) {
+              MessageFu.success("上传成功!");
+              typeRef.current === "pc" ? getListPcFu() : getListAppFu();
+            }
+          }
+          fileDomInitialFu();
+        } catch (error) {
+          fileDomInitialFu();
+        }
+      }
+    },
+    [getListAppFu, getListPcFu]
+  );
+
+  // 点击新增
+  const addClickFu = useCallback(
+    (type: "pc" | "app") => {
+      if (type === "pc" && tableList1.length >= 5)
+        return MessageFu.warning("最多上传5张图片!");
+
+      if (type === "app" && tableList2.length >= 5)
+        return MessageFu.warning("最多上传5张图片!");
+
+      typeRef.current = type;
+      myInput.current?.click();
+    },
+    [tableList1.length, tableList2.length]
+  );
+
+  // 点击删除
+  const B7_APIdelFu = useCallback(
+    async (type: "pc" | "app", id: number) => {
+      const res = await B7_APIdel(id);
+      if (res.code === 0) {
+        MessageFu.success("删除成功!");
+        type === "pc" ? getListPcFu() : getListAppFu();
+      }
+    },
+    [getListAppFu, getListPcFu]
+  );
+
+  // 点击设置为海报
+  const B7_APIsetCoverFu = useCallback(
+    async (type: "pc" | "app", id: number) => {
+      const res = await B7_APIsetCover(type, id);
+      if (res.code === 0) {
+        MessageFu.success("设置成功!");
+        type === "pc" ? getListPcFu() : getListAppFu();
+      }
+    },
+    [getListAppFu, getListPcFu]
+  );
+
+  const columns = useMemo(() => {
+    return [
+      {
+        title: "图片",
+        render: (item: B7TableType) => (
+          <div className="tableImgAuto">
+            <ImageLazy width={60} height={60} src={item.thumb} />
+          </div>
+        ),
+      },
+      {
+        title: "操作",
+        render: (item: B7TableType) => (
+          <>
+            <Button
+              size="small"
+              type="text"
+              onClick={() => B7_APIsetCoverFu(item.type, item.id)}
+              disabled={item.isIndex === 1}
+            >
+              {item.isIndex === 1 ? "已" : ""}设为海报
+            </Button>
+
+            <a
+              href={baseURL + item.thumb}
+              download
+              target="_blank"
+              className="upSuccTxt"
+              rel="noreferrer"
+            >
+              下载
+            </a>
+
+            {item.isIndex === 1 ? null : (
+              <Popconfirm
+                title="删除后无法恢复,是否删除?"
+                okText="删除"
+                cancelText="取消"
+                onConfirm={() => B7_APIdelFu(item.type, item.id)}
+              >
+                <Button size="small" type="text" danger>
+                  删除
+                </Button>
+              </Popconfirm>
+            )}
+          </>
+        ),
+      },
+    ];
+  }, [B7_APIdelFu, B7_APIsetCoverFu]);
+
   return (
     <div className={styles.B7Poster}>
-      <h1>B7Poster</h1>
+      <input
+        id="upInput"
+        type="file"
+        accept=".png,.jpg,.jpeg"
+        ref={myInput}
+        onChange={(e) => handeUpPhoto(e)}
+      />
+
+      <div className="pageTitlt">开屏海报</div>
+      <div className="B7main">
+        <div className="B7box">
+          <div className="B7tit">
+            pc端 &emsp;<span>建议尺寸:1920 x 930</span>&emsp;
+            <span>图片大小&lt;=2M,只支持jpg、png格式</span>
+          </div>
+
+          <div className="B7tableBox">
+            <Table
+              scroll={{ y: 700 }}
+              dataSource={tableList1}
+              columns={columns}
+              rowKey="id"
+              pagination={false}
+            />
+          </div>
+
+          {/* 新增按钮 */}
+          <div className="B7addBtn">
+            <Button type="primary" onClick={() => addClickFu("pc")}>
+              新增
+            </Button>
+          </div>
+        </div>
+        <div className="B7box">
+          <div className="B7tit">
+            移动端 &emsp;<span>建议尺寸:375 x 667 、 414 x 736</span>&emsp;
+            <span>图片大小&lt;=2M,只支持jpg、png格式</span>
+          </div>
+
+          <div className="B7tableBox">
+            <Table
+              scroll={{ y: 700 }}
+              dataSource={tableList2}
+              columns={columns}
+              rowKey="id"
+              pagination={false}
+            />
+          </div>
+
+          {/* 新增按钮 */}
+          <div className="B7addBtn">
+            <Button type="primary" onClick={() => addClickFu("app")}>
+              新增
+            </Button>
+          </div>
+        </div>
+      </div>
     </div>
-  )
+  );
 }
 
 const MemoB7Poster = React.memo(B7Poster);

+ 7 - 14
houtai/src/store/action/A1Hot.ts

@@ -3,22 +3,22 @@ import http from "@/utils/http";
 /**
  * 线上访客
  */
-export const getHotInfo1API = () => {
-  return http.get("cms/report/getUserHot");
+export const getHotInfo1API = (day: number) => {
+  return http.get(`cms/report/getUserHot/${day}`);
 };
 
 /**
  * 热度
  */
-export const getHotInfo2API = () => {
-  return http.get("cms/report/getHot");
+export const getHotInfo2API = (day: number) => {
+  return http.get(`cms/report/getHot/${day}`);
 };
 
 /**
  * 浏览总数
  */
 export const getHotInfo3API = (dayScope: 1 | 7 | 30 | "") => {
-  return http.get(`cms/report/getVisitTotal?dayScope=${dayScope}`);
+  return http.get(`cms/report/getModule/${dayScope ? dayScope : 1000}`);
 };
 
 /**
@@ -43,19 +43,12 @@ export const getHotInfo5API = (dayScope: 1 | 7 | 30 | "", type: string) => {
  * 馆藏统计
  */
 export const getHotInfo6API = () => {
-  return http.get('cms/report/getGoodsTotal');
+  return http.get("cms/report/getGoodsTotal");
 };
 
 /**
  * 访客来源
  */
 export const getHotMapInfoAPI = () => {
-  return http.get('cms/report/getIpHot');
-};
-
-/**
- * 访客-国内/国外
- */
-export const getHotMapInfoNumAPI = () => {
-  return http.get('cms/report/getIpTotalByType');
+  return http.get("cms/report/getIpHot");
 };

+ 64 - 0
houtai/src/store/action/B7Poster.ts

@@ -0,0 +1,64 @@
+import { domShowFu, progressDomFu } from "@/utils/domShow";
+import http from "@/utils/http";
+import axios from "axios";
+import store, { AppDispatch } from "..";
+
+const CancelToken = axios.CancelToken;
+/**
+ * 上传图片
+ */
+export const B7_APIupImg = (data: any) => {
+  domShowFu("#UpAsyncLoding", true);
+
+  return http.post("cms/poster/upload", data, {
+    timeout: 0,
+    // 显示进度条
+    onUploadProgress: (e: any) => {
+      const complete = (e.loaded / e.total) * 100 || 0;
+      progressDomFu(complete + "%");
+    },
+    // 取消上传
+    cancelToken: new CancelToken(function executor(c) {
+      store.dispatch({
+        type: "login/closeUpFile",
+        payload: { fu: c, state: true },
+      });
+    }),
+  });
+};
+
+/**
+ * 新增
+ */
+export const B7_APIadd = (data: any) => {
+  return http.post("cms/poster/save", data);
+};
+
+/**
+ * 获取表格列表
+ */
+export const B7_getList = (type: "pc" | "app") => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.get(`cms/poster/getList/${type}`);
+    if (res.code === 0) {
+      dispatch({
+        type: type === "pc" ? "B7/pcList" : "B7/appList",
+        payload: res.data,
+      });
+    }
+  };
+};
+
+/**
+ * 删除
+ */
+export const B7_APIdel = (id: number) => {
+  return http.get(`cms/poster/remove/${id}`);
+};
+
+/**
+ * 设为海报
+ */
+export const B7_APIsetCover = (type: "pc" | "app", id: number) => {
+  return http.get(`cms/poster/index/${type}/${id}`);
+};

+ 29 - 0
houtai/src/store/reducer/B7Poster.ts

@@ -0,0 +1,29 @@
+import { B7TableType } from "@/types";
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  tableList1: [] as B7TableType[],
+  tableList2: [] as B7TableType[],
+};
+
+// 定义 action 类型
+type SmartActionType =
+  | { type: "B7/pcList"; payload: B7TableType[] }
+  | { type: "B7/appList"; payload: B7TableType[] };
+
+// 频道 reducer
+export default function smartReducer(
+  state = initState,
+  action: SmartActionType
+) {
+  switch (action.type) {
+    // 获取列表数据
+    case "B7/pcList":
+      return { ...state, tableList1: action.payload };
+    case "B7/appList":
+      return { ...state, tableList2: action.payload };
+    default:
+      return state;
+  }
+}

+ 22 - 20
houtai/src/store/reducer/index.ts

@@ -1,29 +1,31 @@
 // 导入合并reducer的依赖
-import { combineReducers } from 'redux'
-import goodsReducer from './B2Goods'
-import wallReducer from './B3Wall'
-import barrageReducer from './B4Barrage'
-import topicReducer from './B5Topic'
-import smartReducer from './B6Smart'
-import userReducer from './C1User'
-import RoleReducer from './C2Role'
-import logReducer from './C3log'
+import { combineReducers } from "redux";
+import goodsReducer from "./B2Goods";
+import wallReducer from "./B3Wall";
+import barrageReducer from "./B4Barrage";
+import topicReducer from "./B5Topic";
+import smartReducer from "./B6Smart";
+import B7Poster from "./B7Poster";
+import userReducer from "./C1User";
+import RoleReducer from "./C2Role";
+import logReducer from "./C3log";
 
 // 导入 登录 模块的 reducer
-import loginReducer from './login'
+import loginReducer from "./login";
 
 // 合并 reducer
 const rootReducer = combineReducers({
   loginStore: loginReducer,
-  logReducer:logReducer,
-  goodsReducer:goodsReducer,
-  wallReducer:wallReducer,
-  barrageReducer:barrageReducer,
-  smartReducer:smartReducer,
-  topicReducer:topicReducer,
-  userReducer:userReducer,
-  RoleReducer:RoleReducer
-})
+  logReducer: logReducer,
+  goodsReducer: goodsReducer,
+  wallReducer: wallReducer,
+  barrageReducer: barrageReducer,
+  smartReducer: smartReducer,
+  B7Poster,
+  topicReducer: topicReducer,
+  userReducer: userReducer,
+  RoleReducer: RoleReducer,
+});
 
 // 默认导出
-export default rootReducer
+export default rootReducer;

+ 10 - 0
houtai/src/types/api/B7Poster.d.ts

@@ -0,0 +1,10 @@
+export type B7TableType= {
+	createTime: string;
+	creatorId: number;
+	creatorName: string;
+	id: number;
+	isIndex: number;
+	thumb: string;
+	type: 'pc'|'app';
+	updateTime: string;
+}

+ 3 - 1
houtai/src/types/api/hot.d.ts

@@ -10,8 +10,10 @@ export type HotInfo1Type = {
   updateTime: string;
 };
 
+export type HotInfo3TypegroupKey ="exhibition" | "site" | "goods" | "knowledge" | "video";
+
 export type HotInfo3Type = {
-  groupKey: "goods" | "scene" | "video";
+  groupKey: HotInfo3TypegroupKey
   pcs: number;
 };
 

+ 1 - 0
houtai/src/types/index.d.ts

@@ -6,5 +6,6 @@ export * from './api/goods'
 export * from './api/barrage'
 export * from './api/smart'
 export * from './api/topic'
+export * from './api/B7Poster'
 export * from './api/user'
 export * from './api/role'

+ 4 - 2
houtai/src/utils/changeData.ts

@@ -6,8 +6,10 @@ export const typeChangeObj = {
 };
 
 export const hotChangeObj = {
-  goods: "馆藏",
-  scene: "VR场景",
+  exhibition:'展陈',
+  site:'旧址',
+  goods: "文物",
+  knowledge: "知识",
   video: "视频",
 };
 

+ 0 - 17
pc/public/index.html

@@ -26,23 +26,6 @@
   <title>鸦片战争博物馆</title>
 </head>
 
-<script>
-  // 移动端和pc端的切换
-  if (
-    window.navigator.userAgent.match(
-      /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
-    )
-  ) {
-    // 移动端
-    if (window.location.href.includes("web")) {
-      window.location.href = window.location.href.replace("web", "webM");
-      setTimeout(() => {
-        location.reload(true);
-      }, 200);
-    }
-  }
-</script>
-
 <body>
   <noscript>You need to enable JavaScript to run this app.</noscript>
   <div id="root"></div>

+ 3 - 2
pc/public/knowInfo.html

@@ -55,8 +55,9 @@
 
   const id = window.location.href.split('?sId=')[1]
 
-  // https://ypbwg.4dage.com
-  fetch(`/api/show/knowledge/cms/detail/${id}`)
+  const fetchUrl = window.location.href.includes('localhost:') ? 'https://ypbwg.4dage.com' : ''
+
+  fetch(`${fetchUrl}/api/show/knowledge/cms/detail/${id}`)
     .then(response => response.json())
     .then(data => {
       const dataRes = data.data

+ 8 - 3
pc/src/pages/A1Home/index.module.scss

@@ -1,4 +1,5 @@
 .A1Home{
+  cursor: pointer;
   position: relative;
   :global{
     .HomeBac{
@@ -6,12 +7,16 @@
       height: 100%;
       object-fit: cover;
     }
-    .btn{
+
+    .A1tit{
       position: absolute;
+      bottom: 15px;
+      font-size: 12px;
+      color: #fff;
       left: 50%;
-      bottom: 100px;
-      cursor: pointer;
       transform: translateX(-50%);
+      text-shadow: 1px 1px 1px black;
     }
+
   }
 }

+ 34 - 12
pc/src/pages/A1Home/index.tsx

@@ -1,25 +1,47 @@
-import React from "react";
+import React, { useCallback, useEffect, useState } from "react";
 import styles from "./index.module.scss";
 import history from "@/utils/history";
-import { envUrl } from "@/utils/env";
 import ImgLoding from "@/components/ImgLoding";
 import { imgLodingFu } from "../A0Map/data";
+import { addVisitFu } from "@/utils/storage";
+import { A1_APIgetCover } from "@/store/action/A1Home";
+import { baseURL } from "@/utils/http";
+
 function A1Home() {
+  const [cover, setCover] = useState("");
+
+  const A1_APIgetCoverFu = useCallback(async () => {
+    const res = await A1_APIgetCover("pc");
+    if (res.code === 0) {
+      const urlObj = res.data.find((v: any) => v.isIndex === 1);
+      setCover(urlObj.thumb || res.data[0].thumb);
+    }
+  }, []);
+
+  useEffect(() => {
+    A1_APIgetCoverFu();
+  }, [A1_APIgetCoverFu]);
+
+  useEffect(() => {
+    // 进来页面 线上访客  访问量+1(23小时内)
+    addVisitFu();
+  }, []);
+
   return (
-    <div className={styles.A1Home}>
+    <div className={styles.A1Home} onClick={() => history.push("/main")}>
       {/* 大图片加载中 */}
       <ImgLoding id={-1} />
 
-      <img
-        className="HomeBac"
-        onLoad={() => imgLodingFu(-1)}
-        src={`${envUrl}/home/homeBg.jpg`}
-        alt=""
-      />
+      {cover ? (
+        <img
+          className="HomeBac"
+          onLoad={() => imgLodingFu(-1)}
+          src={baseURL + cover}
+          alt=""
+        />
+      ) : null}
 
-      <div className="btn" onClick={() => history.push("/main")}>
-        <img src={`${envUrl}/home/homeBtn.png`} alt="" />
-      </div>
+      <div className="A1tit">点击任意处开始探索</div>
     </div>
   );
 }

+ 2 - 1
pc/src/pages/A2Main/Tab5Info/index.tsx

@@ -5,6 +5,7 @@ import { A2_APItab5Info } from "@/store/action/A2Main";
 import classNames from "classnames";
 import { Spin } from "antd";
 import { LeftOutlined } from "@ant-design/icons";
+import { isEnvFlag } from "@/utils/env";
 
 type ListType = {
   id: string;
@@ -150,7 +151,7 @@ function Tab5Info({ sId, closeFu, isOpen, title }: Props) {
           <iframe
             onLoad={() => setIsLoding(false)}
             key={acId}
-            src={`/pc/knowInfo.html?sId=${acId}`}
+            src={`${isEnvFlag ? "" : "/pc"}/knowInfo.html?sId=${acId}`}
             frameBorder="0"
           ></iframe>
         ) : null}

+ 17 - 2
pc/src/pages/A2Main/index.tsx

@@ -1,4 +1,3 @@
-/* eslint-disable jsx-a11y/iframe-has-title */
 import React, { useCallback, useState } from "react";
 import styles from "./index.module.scss";
 import classNames from "classnames";
@@ -8,6 +7,16 @@ import { envData, envDataSonType, envDataType, envUrl } from "@/utils/env";
 import Tab1 from "./Tab1";
 import Tab4 from "./Tab4";
 import Tab5 from "./Tab5";
+import { A2_APIsaveModulesVisit } from "@/store/action/A2Main";
+
+// goods:文物 | knowledge:知识 | exhibition:展陈 | site:旧址 | video:视频
+const aIdObj = {
+  2: "exhibition",
+  3: "site",
+  4: "goods",
+  5: "knowledge",
+  1: "video",
+};
 
 function A2Main() {
   // 传给历史
@@ -15,9 +24,15 @@ function A2Main() {
 
   // 右侧选中的状态
   const [type, setType] = useState(0);
-  const typeChangeFu = useCallback((item: envDataType) => {
+  const typeChangeFu = useCallback(async (item: envDataType) => {
     setSwData(item.data);
     setType(item.id);
+    // 保存访问量
+    const aId = item.id;
+    if (aId) {
+      const key = Reflect.get(aIdObj, aId);
+      await A2_APIsaveModulesVisit(key);
+    }
   }, []);
 
   return (

+ 8 - 0
pc/src/store/action/A1Home.ts

@@ -0,0 +1,8 @@
+import http from "@/utils/http";
+
+/**
+ * 获取 主页 海报
+ */
+export const A1_APIgetCover = (type:'pc'|'app') => {
+  return http.get(`show/poster/getList/${type}`);
+};

+ 7 - 0
pc/src/store/action/A2Main.ts

@@ -175,3 +175,10 @@ export const A2_APIgetRandCode = () => {
 export const A2_APIsaveBarrage = (data: A2R_fSaveType) => {
   return http.post("show/goods/saveBarrage", data);
 };
+
+/**
+ * 保存浏览板块访问量
+ */
+export const A2_APIsaveModulesVisit = (key:string) => {
+  return http.get(`show/cv/add/${key}`);
+};

+ 4 - 1
pc/src/utils/env.ts

@@ -14,4 +14,7 @@ export type envDataType = {
 export const envData = staticData as envDataType[];
 
 //@ts-ignore
-export const envUrl =staticUrl
+export const envUrl = staticUrl;
+
+// 为true 为 开发环境 、false为 服务器 正式环境
+export const isEnvFlag = process.env.NODE_ENV === "development";

+ 43 - 0
pc/src/utils/storage.ts

@@ -0,0 +1,43 @@
+import http from "@/utils/http";
+
+// 线上访客  访问量+1(23小时内)
+const TIME_KEY = "YPZZBWG_PC_VISIT";
+
+/**
+ * 从本地缓存中获取 时间戳
+ */
+const getTimeInfoFu = (): number => {
+  return Number(localStorage.getItem(TIME_KEY) || "0");
+};
+
+/**
+ * 将 时间戳 信息存入缓存
+ */
+const setTimeInfoFu = (time: number): void => {
+  localStorage.setItem(TIME_KEY, time + "");
+};
+
+/**
+ * 线上访客+1
+ */
+const A0_APIaddVisit = () => {
+  const nowTime = Date.now();
+  setTimeInfoFu(nowTime);
+  return http.get(`show/addHotUser`);
+};
+
+export const addVisitFu = async () => {
+  const time = getTimeInfoFu();
+  if (time) {
+    const nowTime = Date.now();
+
+    const timeBad = nowTime - time;
+
+    const numBad = 1000 * 60 * 60 * 23;
+
+    if (timeBad >= numBad) {
+      // 超过了23小时
+      A0_APIaddVisit();
+    }
+  } else A0_APIaddVisit();
+};

BIN
staticData/home/homeBg.jpg


BIN
staticData/home/homeBtn.png


BIN
staticData/swData/1/1.jpg


BIN
staticData/swData/1/1.mp4


BIN
staticData/swData/1/2.jpg


BIN
staticData/swData/1/2.mp4


BIN
staticData/swData/1/3.jpg