From 3d3af31c6153ae66d4ebeb4107d195d8962d43a2 Mon Sep 17 00:00:00 2001 From: al Date: Wed, 24 Jul 2024 17:12:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=B6=E7=9B=8A=E6=98=8E?= =?UTF-8?q?=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/bill/[type]/income_querry/page.jsx | 162 ++++++++++++------ app/bill/[type]/page.jsx | 117 ++++++------- app/bill/layout.jsx | 23 ++- app/bill/page.js | 33 ---- app/my/wallet/page.js | 33 ++-- app/space/[id]/page.js | 2 +- .../person_space_introduce/[mid]/page.js | 2 +- components/PaySpacePost/index.js | 2 +- components/Photos/index.js | 2 +- 9 files changed, 204 insertions(+), 172 deletions(-) delete mode 100644 app/bill/page.js diff --git a/app/bill/[type]/income_querry/page.jsx b/app/bill/[type]/income_querry/page.jsx index f634cbf..a3fea0e 100644 --- a/app/bill/[type]/income_querry/page.jsx +++ b/app/bill/[type]/income_querry/page.jsx @@ -1,18 +1,59 @@ "use client"; -import Link from "next/link"; import * as echarts from "echarts"; -import { useEffect, useRef } from "react"; -export default function IncomeQuerry({ children }) { +import { useEffect, useRef, useState } from "react"; +import webviewBaseRequest from "@/utils/webviewBaseRequest"; +import { generateSignature } from "@/utils/crypto"; +export default function IncomeQuerry() { 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(); }, []); + useEffect(() => { + if(databoard.current&&data.week_dashboard){ + createDataBoard(data.week_dashboard); + } + }, [databoard.current,data]); + useEffect(() => { + if(incomeOrgin.current && data.income_from_dashboard){ + createIncomeOrgin(data.income_from_dashboard); + } + }, [incomeOrgin.current,data]); + 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 }); + + } catch (error) {} + }; - const createDataBoard = () => { - if (databoard.current) { + const createDataBoard = (data) => { var myChart = echarts.init(databoard.current, "dark"); var option; option = { @@ -32,16 +73,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,24 +105,25 @@ 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 = () => { - if (incomeOrgin.current) { + const createIncomeOrgin = (data) => { var myChart = echarts.init(incomeOrgin.current, "dark"); var option; option = { @@ -100,14 +150,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 +172,7 @@ export default function IncomeQuerry({ children }) { }, emphasis: { label: { - show: true, + show: false, fontSize: 40, fontWeight: "bold", }, @@ -130,61 +180,65 @@ 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})), }, ], }; option && myChart.setOption(option); - } }; - 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}

-
-

数据看板

-
-
-
-

收益来源

-
+ +
+ {(data.week_dashboard || data.income_from_dashboard) &&

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

} + { + data.week_dashboard && +
+

数据看板

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

收益来源

+
+
+ }
); diff --git a/app/bill/[type]/page.jsx b/app/bill/[type]/page.jsx index 422cdf7..a0b60dd 100644 --- a/app/bill/[type]/page.jsx +++ b/app/bill/[type]/page.jsx @@ -1,71 +1,58 @@ "use client"; import React, { useState, useEffect } from "react"; -import Link from "next/link"; - +import {useRouter} from "next/navigation"; +import requireAPI from "@/utils/requireAPI"; export default function BillDetail({ params }) { const [data, setData] = useState([]); const [isFetching, setIsFetching] = useState(true); + const router = useRouter(); useEffect(() => { - // const getData = async () => { - // let type; - // switch (params.type) { - // case "cost": - // type = 1; - // break; - // case "recharge": - // type = 2; - // break; - // case "income": - // type = 3; - // break; - // case "withdrawal": - // type = 4; - // break; - // default: - // break; - // } - // try { - // const base = webviewBaseRequest(); - // const signature = generateSignature({ - // type: type, - // offset: 0, - // limit: 99, - // ...base, - // }); - // const response = await fetch( - // `/api/vas/get_ch_list?signature=${signature}`, - // { - // method: "POST", - // headers: { - // "Content-Type": "application/json", - // }, - // body: JSON.stringify({ - // type: type, - // offset: 0, - // limit: 99, - // ...base, - // }), - // } - // ); - // const temData = await response.json(); - // if (temData.ret === -1) { - // Toast.show({ - // content: temData.msg, - // }); - // return; - // } - // setData(temData.data.list); - // setIsFetching(false); - // } catch (error) { - // console.error(error); - // } - // }; - // setTimeout(() => { - // getData(); - // }, 500); + + setTimeout(() => { + getData(); + }, 500); }, []); - + const getData = async () => { + let type; + switch (params.type) { + case "cost": + type = 1; + break; + case "recharge": + type = 2; + break; + case "income": + type = 3; + break; + case "withdrawal": + type = 4; + break; + default: + break; + } + try { + const _data = await requireAPI( + "POST", + "/api/vas/get_ch_list", + {body: { + type: type, + offset: 0, + limit: 99, + }} + ); + if (_data.ret === -1) { + Toast.show({ + content: _data.msg, + }); + return; + } + setData(_data.data.list); + setIsFetching(false); + } catch (error) { + console.error(error); + } + }; const RenderItem = ({ item }) => { return (
@@ -94,9 +81,9 @@ export default function BillDetail({ params }) { return (
{params.type == "income" && ( - +
router.push("income/income_querry")}>

查看近一周收益情况

- +
)} {data.length === 0 && (
@@ -130,9 +117,11 @@ export default function BillDetail({ params }) {

暂无数据

)} - {/* {data.map((item, index) => ( +
+ {data.map((item, index) => ( - ))} */} + ))} +
); } diff --git a/app/bill/layout.jsx b/app/bill/layout.jsx index 398069b..36e46ab 100644 --- a/app/bill/layout.jsx +++ b/app/bill/layout.jsx @@ -3,13 +3,16 @@ import { usePathname } from "next/navigation"; import Link from "next/link"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { - faAngleLeft, -} from "@fortawesome/free-solid-svg-icons"; +import { faAngleLeft } from "@fortawesome/free-solid-svg-icons"; import { useRouter } from "next/navigation"; +import { useEffect, useState } from "react"; export default function BillLayout({ children }) { const pathname = usePathname(); const router = useRouter(); + const [scrollHeight, setScrollHeight] = useState(0); + useEffect(() => { + setScrollHeight(window.innerHeight - 44); + }, []); return (
@@ -18,15 +21,20 @@ export default function BillLayout({ children }) { icon={faAngleLeft} size="xl" onClick={() => { - router.push("/my/wallet"); + pathname.split("/").length < 4? + router.push("/my/wallet"): + router.back(); }} />

收支明细

{pathname.split("/").length < 4 && ( -
-
+
+
+
{children}
)} -
{children}
+ {pathname.split("/").length >3 &&
{children}
} ); } diff --git a/app/bill/page.js b/app/bill/page.js deleted file mode 100644 index f30fcba..0000000 --- a/app/bill/page.js +++ /dev/null @@ -1,33 +0,0 @@ -"use client"; - -import React, { useEffect, useState } from "react"; -import { useRouter } from "next/navigation"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { - faAngleLeft, -} from "@fortawesome/free-solid-svg-icons"; -export default function Recharge() { - const router = useRouter(); - // 获取屏幕高度 - // const scrollHeight = 600; - useEffect(() => {}, []); - return ( -
-
-
- { - router.push("/my/wallet"); - }} - /> -
-

收支明细

-
- {/* 内容 */} -
-
-
- ); -} diff --git a/app/my/wallet/page.js b/app/my/wallet/page.js index efc03c9..09b13fd 100644 --- a/app/my/wallet/page.js +++ b/app/my/wallet/page.js @@ -24,13 +24,17 @@ export default function Wallet() { // 获取屏幕高度 // const scrollHeight = 600; useEffect(() => { - getData() + getData(); }, []); const getData = async () => { try { //获取账号基本信息 - const _data = - await requireAPI("POST", "/api/account/list_by_mid", null, true); + const _data = await requireAPI( + "POST", + "/api/account/list_by_mid", + null, + true + ); if (_data.ret === -1) { Toast.show({ icon: "fail", @@ -69,7 +73,9 @@ export default function Wallet() { width={48} height={48} /> -

{data?.gold_num || 0}

+

+ {data?.gold_num || 0} +

金币

-

{data?.diamond_num || 0}

+

+ {data?.diamond_num || 0} +

钻石

@@ -95,10 +103,14 @@ export default function Wallet() { // title: "充值中心", // uri: process.env.EXPO_PUBLIC_WEB_URL + "/pay", // }) - {console.log("base,base",base); - router.push( - `/webView/${encodeURIComponent(`pay?base=${encodeURIComponent(JSON.stringify(base))}`)}` - )} + { + console.log("base,base", base); + router.push( + `/webView/${encodeURIComponent( + `pay?base=${encodeURIComponent(JSON.stringify(base))}` + )}` + ); + } } className="flex justify-between items-center py-4 w-full" > @@ -143,7 +155,8 @@ export default function Wallet() {
- window && window.open( + window && + window.open( `${process.env.NEXT_PUBLIC_WEB_URL}/withdrawal?mid=${data?.mid}&mobile_phone=${mobilePhone}&token=${temToken}` ) } diff --git a/app/space/[id]/page.js b/app/space/[id]/page.js index a92d4b9..3db32ef 100644 --- a/app/space/[id]/page.js +++ b/app/space/[id]/page.js @@ -316,7 +316,7 @@ export default function PersonSpace() { data?.id + "/h5_zone_superfanship/0" + "?base=" + - encodeURIComponent(base) + encodeURIComponent(JSON.stringify(base)) ) ); }} diff --git a/app/space/person_space_introduce/[mid]/page.js b/app/space/person_space_introduce/[mid]/page.js index bb51772..6a5ee2a 100644 --- a/app/space/person_space_introduce/[mid]/page.js +++ b/app/space/person_space_introduce/[mid]/page.js @@ -302,7 +302,7 @@ export default function PersonSpaceIntroduce() { data?.id + "/h5_zone_admission/0" + "?base=" + - encodeURIComponent(base) + encodeURIComponent(JSON.stringify(base)) ) ); } diff --git a/components/PaySpacePost/index.js b/components/PaySpacePost/index.js index bd64028..be71cf5 100644 --- a/components/PaySpacePost/index.js +++ b/components/PaySpacePost/index.js @@ -103,7 +103,7 @@ export default function PaySpacePost({ "/zone/pay/" + data?.id + "/h5_zone_moment/" + - data?.id+"?base="+encodeURIComponent(base) + data?.id+"?base="+encodeURIComponent(JSON.stringify(base)) ) ) } diff --git a/components/Photos/index.js b/components/Photos/index.js index aaa2822..45b953a 100644 --- a/components/Photos/index.js +++ b/components/Photos/index.js @@ -141,7 +141,7 @@ export default function Photos({ isUnlocked, mediaAmount, media, type, data }) { "/h5_zone_moment/" + data?.id + "?base=" + - encodeURIComponent(base) + encodeURIComponent(JSON.stringify(base)) ) ); }}