添加base获取方式
This commit is contained in:
parent
45da9dcfe3
commit
52ef5f73d7
|
@ -1,14 +1,32 @@
|
|||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState, useEffect, useMemo } from "react";
|
||||
import { Toast } from "antd-mobile";
|
||||
import { generateSignature } from "@/utils/crypto";
|
||||
import webviewBaseRequest from "@/utils/webviewBaseRequest";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
|
||||
export default function BillDetail({ params }) {
|
||||
const [data, setData] = useState([]);
|
||||
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(() => {
|
||||
const getData = async () => {
|
||||
let type;
|
||||
|
@ -29,7 +47,6 @@ export default function BillDetail({ params }) {
|
|||
break;
|
||||
}
|
||||
try {
|
||||
const base = webviewBaseRequest();
|
||||
const signature = generateSignature({
|
||||
type: type,
|
||||
offset: 0,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import React, { useState, useEffect,useMemo } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { Toast } from "antd-mobile";
|
||||
import { generateSignature } from "@/utils/crypto";
|
||||
import webviewBaseRequest from "@/utils/webviewBaseRequest";
|
||||
|
@ -9,9 +9,8 @@ import Link from "next/link";
|
|||
|
||||
export default function Pay() {
|
||||
const router = useRouter();
|
||||
|
||||
const searchParams = useSearchParams();
|
||||
const alipayBlock = () => {
|
||||
const base = webviewBaseRequest();
|
||||
if (base?.b_mid === 161) {
|
||||
createOrder("alipay_h5");
|
||||
return;
|
||||
|
@ -45,9 +44,25 @@ export default function Pay() {
|
|||
|
||||
//获取当前充值档位
|
||||
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(() => {
|
||||
const getData = async () => {
|
||||
const base = webviewBaseRequest();
|
||||
|
||||
const body = { ...base };
|
||||
const signature = generateSignature(body);
|
||||
try {
|
||||
|
@ -93,7 +108,7 @@ export default function Pay() {
|
|||
return;
|
||||
}
|
||||
|
||||
const base = webviewBaseRequest();
|
||||
|
||||
const body = {
|
||||
...base,
|
||||
product_id: customCoin.selected ? "h5_custom_coin" : selectedPrice.id,
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState, useEffect, useMemo } from "react";
|
||||
import { generateSignature } from "@/utils/crypto";
|
||||
import webviewBaseRequest from "@/utils/webviewBaseRequest";
|
||||
import Link from "next/link";
|
||||
import { Toast } from "antd-mobile";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
export default function Vip() {
|
||||
const router = useRouter();
|
||||
|
||||
const searchParams = useSearchParams();
|
||||
const alipayBlock = () => {
|
||||
const base = webviewBaseRequest();
|
||||
if (base?.b_mid === 161) {
|
||||
createOrder("alipay_h5");
|
||||
return;
|
||||
|
@ -25,9 +23,24 @@ export default function Vip() {
|
|||
const [isVip, setIsVip] = useState(false);
|
||||
const [name, setName] = useState("");
|
||||
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 () => {
|
||||
try {
|
||||
const base = webviewBaseRequest();
|
||||
const signature = generateSignature({
|
||||
...base,
|
||||
mid: base.b_mid,
|
||||
|
@ -73,7 +86,6 @@ export default function Vip() {
|
|||
//创建充值订单
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const createOrder = async (type = "alipay_h5") => {
|
||||
const base = webviewBaseRequest();
|
||||
const body = {
|
||||
...base,
|
||||
product_id: "membership",
|
||||
|
|
|
@ -1,26 +1,40 @@
|
|||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState, useEffect, useMemo } from "react";
|
||||
import Divider from "@/components/Divider";
|
||||
import Link from "next/link";
|
||||
import { Toast, Switch } from "antd-mobile";
|
||||
import { generateSignature } from "@/utils/crypto";
|
||||
import webviewBaseRequest from "@/utils/webviewBaseRequest";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useRouter,useSearchParams } from "next/navigation";
|
||||
|
||||
export default function Pay({ params }) {
|
||||
const router = useRouter();
|
||||
|
||||
const searchParams = useSearchParams();
|
||||
//当前选购的商品数据
|
||||
const [data, setData] = useState({});
|
||||
//超粉商品数据
|
||||
const [superfanshipData, setSuperfanshipData] = useState();
|
||||
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 () => {
|
||||
try {
|
||||
const base = webviewBaseRequest();
|
||||
try {
|
||||
const body = {
|
||||
zid: parseInt(params.zid),
|
||||
moment_id: parseInt(params.moment_id),
|
||||
|
|
Loading…
Reference in New Issue