|
|
@@ -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">
|
|
|
- 穿戴设备热度
|
|
|
- <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 ? (
|