diff --git a/app/bill/[type]/income_querry/page.jsx b/app/bill/[type]/income_querry/page.jsx index f634cbf..6757ec2 100644 --- a/app/bill/[type]/income_querry/page.jsx +++ b/app/bill/[type]/income_querry/page.jsx @@ -2,16 +2,49 @@ import Link from "next/link"; import * as echarts from "echarts"; -import { useEffect, useRef } from "react"; +import { useEffect, useRef, useState } from "react"; +import webviewBaseRequest from "@/utils/webviewBaseRequest"; +import { generateSignature } from "@/utils/crypto"; export default function IncomeQuerry({ children }) { var databoard = useRef(); var incomeOrgin = useRef(); + const [data, setData] = useState({ + withdraw_diamonds: 0, + today_income: 0, + wait_deal_income: 0, + weekIncom: 0, + }); useEffect(() => { - createDataBoard(); - createIncomeOrgin(); + getData(); }, []); - - const createDataBoard = () => { + const getData = async () => { + const base = webviewBaseRequest(); + const signature = generateSignature({ + ...base, + }); + try { + const response = await fetch( + `/api/vas/income_page?signature=${signature}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + ...base, + }), + } + ); + const { data } = await response.json(); + const weekIncom = data.week_dashboard.reduce((total, item) => { + return total + item.income; + }, 0); + data && setData({ ...data, weekIncom }); + createDataBoard(data.week_dashboard); + createIncomeOrgin(data.income_from_dashboard); + } catch (error) {} + }; + const createDataBoard = (data) => { if (databoard.current) { var myChart = echarts.init(databoard.current, "dark"); var option; @@ -32,16 +65,24 @@ export default function IncomeQuerry({ children }) { }, ], }, + // tooltip: { + // trigger: 'axis' + // }, + tooltip: { + trigger: 'axis', + formatter: '{b} : {c}' + }, xAxis: { type: "category", - data: getDateStr(), + boundaryGap: false, + data: getDateStr(data), }, yAxis: { splitLine: { // show: false, lineStyle: { type: "dashed", - color: '#ffffff30' + color: "#ffffff30", // ... }, }, @@ -56,23 +97,26 @@ export default function IncomeQuerry({ children }) { }, series: [ { - data: [150, 230, 224, 218, 135, 147, 260], + name: '', + symbolSize: 10, + data:data.map(item=>item.income), type: "line", + stack: 'Total', lineStyle: { - color: '#ffffff' - // ... - }, - itemStyle: { - color:"#fff", - backgroundColor:"#fff" - } + color: "#ffffff", + // ... + }, + itemStyle: { + color: "#fff", + backgroundColor: "#fff", + }, }, ], }; option && myChart.setOption(option); } }; - const createIncomeOrgin = () => { + const createIncomeOrgin = (data) => { if (incomeOrgin.current) { var myChart = echarts.init(incomeOrgin.current, "dark"); var option; @@ -100,14 +144,14 @@ export default function IncomeQuerry({ children }) { type: "scroll", orient: "vertical", right: 10, - top: 20, + top: 32, bottom: 20, color: "#fff", // data: data.legendData }, series: [ { - name: "Access From", + name: "", type: "pie", radius: ["40%", "70%"], center: ["30%", "50%"], @@ -122,7 +166,7 @@ export default function IncomeQuerry({ children }) { }, emphasis: { label: { - show: true, + show: false, fontSize: 40, fontWeight: "bold", }, @@ -130,13 +174,7 @@ export default function IncomeQuerry({ children }) { labelLine: { show: false, }, - data: [ - { value: 1048, name: "空间解锁" }, - { value: 735, name: "付费贴" }, - { value: 580, name: "超粉解锁" }, - { value: 484, name: "个人微信" }, - { value: 300, name: "其他分成" }, - ], + data: data.map(item=>({value:item.income,name:item.desc})), }, ], }; @@ -144,47 +182,58 @@ export default function IncomeQuerry({ children }) { } }; - const getDateStr = () => { - const currentDay = new Date(); - return Array(7).fill(null).map((it,index)=>{ - const days = (6-index) - return (currentDay.getMonth()+1)+"."+(currentDay.getDate()-days) - }) - } + const getDateStr = (data) => { + return data.map(item=>{ + let newTimeStr = `${item.date.slice(0,4)}-${item.date.slice(4,6)}-${item.date.slice(6,8)}` + return (new Date(newTimeStr).getMonth() + 1)+"."+(new Date(newTimeStr).getDate()) + }) + + }; return (
*当前页面所有统计单位均为钻石
可提现钻石
+可提现钻石
今日收益
-{9900}
+{data.today_income}
待结算
-{1500}
+待结算收益
+{data.wait_deal_income}
近一周收益
-{15200}
+{data.weekIncom}
数据看板
- -收益来源
- + +*以下所有数据均为次日00:10更新
+ { + data.week_dashboard && +数据看板
+ +收益来源
+ +