添加base获取方式

This commit is contained in:
al 2024-07-23 18:06:31 +08:00
parent 45da9dcfe3
commit 52ef5f73d7
4 changed files with 79 additions and 21 deletions

View File

@ -1,14 +1,32 @@
"use client"; "use client";
import React, { useState, useEffect } from "react"; import React, { useState, useEffect, useMemo } from "react";
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import { generateSignature } from "@/utils/crypto"; import { generateSignature } from "@/utils/crypto";
import webviewBaseRequest from "@/utils/webviewBaseRequest"; import webviewBaseRequest from "@/utils/webviewBaseRequest";
import { useSearchParams } from "next/navigation";
import Link from "next/link"; import Link from "next/link";
export default function BillDetail({ params }) { export default function BillDetail({ params }) {
const [data, setData] = useState([]); const [data, setData] = useState([]);
const [isFetching, setIsFetching] = useState(true); const [isFetching, setIsFetching] = useState(true);
const searchParams = useSearchParams();
const base = useMemo(()=>{
let searchParamsObj=null; b
if(searchParams.get("b_mid")){
searchParamsObj={};
searchParamsObj.b_mid=searchParams.get("b_mid");
searchParamsObj.b_did=searchParams.get("b_did");
searchParamsObj.b_ver=searchParams.get("b_ver");
searchParamsObj.b_dt=searchParams.get("b_dt");
searchParamsObj.b_model=searchParams.get("b_model");
searchParamsObj.b_nt=searchParams.get("b_nt");
searchParamsObj.b_token=searchParams.get("b_token");
searchParamsObj.b_ch=searchParams.get("b_ch");
searchParamsObj.b_ts=searchParams.get("b_ts");
}
return searchParamsObj || webviewBaseRequest();
},[searchParams]);
useEffect(() => { useEffect(() => {
const getData = async () => { const getData = async () => {
let type; let type;
@ -29,7 +47,6 @@ export default function BillDetail({ params }) {
break; break;
} }
try { try {
const base = webviewBaseRequest();
const signature = generateSignature({ const signature = generateSignature({
type: type, type: type,
offset: 0, offset: 0,

View File

@ -1,7 +1,7 @@
"use client"; "use client";
import React, { useState, useEffect } from "react"; import React, { useState, useEffect,useMemo } from "react";
import { useRouter } from "next/navigation"; import { useRouter, useSearchParams } from "next/navigation";
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import { generateSignature } from "@/utils/crypto"; import { generateSignature } from "@/utils/crypto";
import webviewBaseRequest from "@/utils/webviewBaseRequest"; import webviewBaseRequest from "@/utils/webviewBaseRequest";
@ -9,9 +9,8 @@ import Link from "next/link";
export default function Pay() { export default function Pay() {
const router = useRouter(); const router = useRouter();
const searchParams = useSearchParams();
const alipayBlock = () => { const alipayBlock = () => {
const base = webviewBaseRequest();
if (base?.b_mid === 161) { if (base?.b_mid === 161) {
createOrder("alipay_h5"); createOrder("alipay_h5");
return; return;
@ -45,9 +44,25 @@ export default function Pay() {
// //
const [isFetching, setIsFetching] = useState(true); const [isFetching, setIsFetching] = useState(true);
const base = useMemo(()=>{
let searchParamsObj=null; b
if(searchParams.get("b_mid")){
searchParamsObj={};
searchParamsObj.b_mid=searchParams.get("b_mid");
searchParamsObj.b_did=searchParams.get("b_did");
searchParamsObj.b_ver=searchParams.get("b_ver");
searchParamsObj.b_dt=searchParams.get("b_dt");
searchParamsObj.b_model=searchParams.get("b_model");
searchParamsObj.b_nt=searchParams.get("b_nt");
searchParamsObj.b_token=searchParams.get("b_token");
searchParamsObj.b_ch=searchParams.get("b_ch");
searchParamsObj.b_ts=searchParams.get("b_ts");
}
return searchParamsObj || webviewBaseRequest();
},[searchParams]);
useEffect(() => { useEffect(() => {
const getData = async () => { const getData = async () => {
const base = webviewBaseRequest();
const body = { ...base }; const body = { ...base };
const signature = generateSignature(body); const signature = generateSignature(body);
try { try {
@ -93,7 +108,7 @@ export default function Pay() {
return; return;
} }
const base = webviewBaseRequest();
const body = { const body = {
...base, ...base,
product_id: customCoin.selected ? "h5_custom_coin" : selectedPrice.id, product_id: customCoin.selected ? "h5_custom_coin" : selectedPrice.id,

View File

@ -1,17 +1,15 @@
"use client"; "use client";
import React, { useState, useEffect } from "react"; import React, { useState, useEffect, useMemo } from "react";
import { generateSignature } from "@/utils/crypto"; import { generateSignature } from "@/utils/crypto";
import webviewBaseRequest from "@/utils/webviewBaseRequest"; import webviewBaseRequest from "@/utils/webviewBaseRequest";
import Link from "next/link"; import Link from "next/link";
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import { useRouter } from "next/navigation"; import { useRouter, useSearchParams } from "next/navigation";
export default function Vip() { export default function Vip() {
const router = useRouter(); const router = useRouter();
const searchParams = useSearchParams();
const alipayBlock = () => { const alipayBlock = () => {
const base = webviewBaseRequest();
if (base?.b_mid === 161) { if (base?.b_mid === 161) {
createOrder("alipay_h5"); createOrder("alipay_h5");
return; return;
@ -25,9 +23,24 @@ export default function Vip() {
const [isVip, setIsVip] = useState(false); const [isVip, setIsVip] = useState(false);
const [name, setName] = useState(""); const [name, setName] = useState("");
const [isFetching, setIsFetching] = useState(true); const [isFetching, setIsFetching] = useState(true);
const base = useMemo(()=>{
let searchParamsObj=null; b
if(searchParams.get("b_mid")){
searchParamsObj={};
searchParamsObj.b_mid=searchParams.get("b_mid");
searchParamsObj.b_did=searchParams.get("b_did");
searchParamsObj.b_ver=searchParams.get("b_ver");
searchParamsObj.b_dt=searchParams.get("b_dt");
searchParamsObj.b_model=searchParams.get("b_model");
searchParamsObj.b_nt=searchParams.get("b_nt");
searchParamsObj.b_token=searchParams.get("b_token");
searchParamsObj.b_ch=searchParams.get("b_ch");
searchParamsObj.b_ts=searchParams.get("b_ts");
}
return searchParamsObj || webviewBaseRequest();
},[searchParams]);
const getUserData = async () => { const getUserData = async () => {
try { try {
const base = webviewBaseRequest();
const signature = generateSignature({ const signature = generateSignature({
...base, ...base,
mid: base.b_mid, mid: base.b_mid,
@ -73,7 +86,6 @@ export default function Vip() {
// //
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const createOrder = async (type = "alipay_h5") => { const createOrder = async (type = "alipay_h5") => {
const base = webviewBaseRequest();
const body = { const body = {
...base, ...base,
product_id: "membership", product_id: "membership",

View File

@ -1,26 +1,40 @@
"use client"; "use client";
import React, { useState, useEffect } from "react"; import React, { useState, useEffect, useMemo } from "react";
import Divider from "@/components/Divider"; import Divider from "@/components/Divider";
import Link from "next/link"; import Link from "next/link";
import { Toast, Switch } from "antd-mobile"; import { Toast, Switch } from "antd-mobile";
import { generateSignature } from "@/utils/crypto"; import { generateSignature } from "@/utils/crypto";
import webviewBaseRequest from "@/utils/webviewBaseRequest"; import webviewBaseRequest from "@/utils/webviewBaseRequest";
import { useRouter } from "next/navigation"; import { useRouter,useSearchParams } from "next/navigation";
export default function Pay({ params }) { export default function Pay({ params }) {
const router = useRouter(); const router = useRouter();
const searchParams = useSearchParams();
// //
const [data, setData] = useState({}); const [data, setData] = useState({});
// //
const [superfanshipData, setSuperfanshipData] = useState(); const [superfanshipData, setSuperfanshipData] = useState();
const [isFetching, setIsFetching] = useState(true); const [isFetching, setIsFetching] = useState(true);
const base = useMemo(()=>{
let searchParamsObj=null; b
if(searchParams.get("b_mid")){
searchParamsObj={};
searchParamsObj.b_mid=searchParams.get("b_mid");
searchParamsObj.b_did=searchParams.get("b_did");
searchParamsObj.b_ver=searchParams.get("b_ver");
searchParamsObj.b_dt=searchParams.get("b_dt");
searchParamsObj.b_model=searchParams.get("b_model");
searchParamsObj.b_nt=searchParams.get("b_nt");
searchParamsObj.b_token=searchParams.get("b_token");
searchParamsObj.b_ch=searchParams.get("b_ch");
searchParamsObj.b_ts=searchParams.get("b_ts");
}
return searchParamsObj || webviewBaseRequest();
},[searchParams]);
// //
const getData = async () => { const getData = async () => {
try { try {
const base = webviewBaseRequest();
const body = { const body = {
zid: parseInt(params.zid), zid: parseInt(params.zid),
moment_id: parseInt(params.moment_id), moment_id: parseInt(params.moment_id),