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 (
+

*当前页面所有统计单位均为钻石

-

可提现钻石

+

可提现钻石

- {39900} - + {data.withdraw_diamonds} + {/* 前往提现 - + */}
-
+

今日收益

-

{9900}

+

{data.today_income}

-

待结算

-

{1500}

+

待结算收益

+

{data.wait_deal_income}

近一周收益

-

{15200}

+

{data.weekIncom}

-
-

数据看板

-
-
-
-

收益来源

-
+ +
+

*以下所有数据均为次日00:10更新

+ { + data.week_dashboard && +
+

数据看板

+
+
+ } + { + data.income_from_dashboard && +
+

收益来源

+
+
+ }
); diff --git a/package-lock.json b/package-lock.json index 69d10ab..9eb4d81 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5777,6 +5777,126 @@ "version": "2.3.0", "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz", "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.0.2.tgz", + "integrity": "sha512-i+jQY0fOb8L5gvGvojWyZMfQoQtDVB2kYe7fufOEiST6sicvzI2W5/EXo4lX5bLUjapHKe+nFxuVv7BA+Pd7LQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.0.2.tgz", + "integrity": "sha512-tSJmiaon8YaKsVhi7GgRizZoV0N1Sx5+i+hFTrCKKQN7s3tuqW0Rov+RYdPhAv/pJl4qiG+XfSX4eJXqpNg3dA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.0.2.tgz", + "integrity": "sha512-dXJLMSEOwqJKcag1BeX1C+ekdPPJ9yXbWIt3nAadhbLx5CjACoB2NQj9Xcqu2tmdr5L6m34fR+fjGPs+ZVPLzA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.0.2.tgz", + "integrity": "sha512-WC9KAPSowj6as76P3vf1J3mf2QTm3Wv3FBzQi7UJ+dxWjK3MhHVWsWUo24AnmHx9qDcEtHM58okgZkXVqeLB+Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.0.2.tgz", + "integrity": "sha512-KSSAwvUcjtdZY4zJFa2f5VNJIwuEVnOSlqYqbQIawREJA+gUI6egeiRu290pXioQXnQHYYdXmnVNZ4M+VMB7KQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.0.2.tgz", + "integrity": "sha512-2/O0F1SqJ0bD3zqNuYge0ok7OEWCQwk55RPheDYD0va5ij7kYwrFkq5ycCRN0TLjLfxSF6xI5NM6nC5ux7svEQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.0.2.tgz", + "integrity": "sha512-vJI/x70Id0oN4Bq/R6byBqV1/NS5Dl31zC+lowO8SDu1fHmUxoAdILZR5X/sKbiJpuvKcCrwbYgJU8FF/Gh50Q==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.0.2.tgz", + "integrity": "sha512-Ut4LXIUvC5m8pHTe2j0vq/YDnTEyq6RSR9vHYPqnELrDapPhLNz9Od/L5Ow3J8RNDWpEnfCiQXuVdfjlNEJ7ug==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } }