From 462843304ebbfb958e57b27bbe4cf831888c6aff Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Mon, 4 Mar 2024 11:28:07 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=AF=B9=E6=8E=A5=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E5=95=86=E6=88=B7=E5=8A=A0=E5=AF=86=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/api.js | 5 +++++ src/pages/distributor/merchant/index.jsx | 23 ++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index 6fe4a6c4..bbafab27 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -1019,4 +1019,9 @@ export const notifyReseller = (data) => { return req("post", baseurl + "/order/notifyReseller", data) } +/* 获取商户加密类型 */ +export const getApiMode = () => { + return req("get", baseurl + "/reseller/merchant/getApiMode") +} + export { req } diff --git a/src/pages/distributor/merchant/index.jsx b/src/pages/distributor/merchant/index.jsx index 121e4edd..08553f7f 100644 --- a/src/pages/distributor/merchant/index.jsx +++ b/src/pages/distributor/merchant/index.jsx @@ -1,4 +1,4 @@ -import { generateRsaKey, setResellMerchant } from "@/assets/api" +import { generateRsaKey, setResellMerchant, getApiMode } from "@/assets/api" import FormItem from "@/components/form-item/main" import Form from "@/components/form/main" import Ipt from "@/components/input/main" @@ -9,6 +9,7 @@ import "./index.less" export default function Merchant() { const [state, setState] = useState({ loading: false, + apiMode: [], reseller_id: 0 /* 分销商id */, merchant_id: "", //商户号 * pos_id: "", //平台id 目前都是单平台 * @@ -45,7 +46,10 @@ export default function Merchant() { useEffect(() => { const { merchant, id } = JSON.parse(sessionStorage.getItem("merchant")) - setState({ ...state, reseller_id: id, ...merchant }) + /* 获取加密类型 */ + getApiMode().then(({ data }) => { + setState({ ...state, apiMode: data, reseller_id: id, ...merchant }) + }) }, []) /* 获取密钥 */ @@ -130,7 +134,7 @@ export default function Merchant() { /> - {state.api_mode === 2 ? ( + {state.apiMode.filter((item) => item.key === state.api_mode)[0]?.store_id ? ( setState({ ...state, store_id: value })} @@ -146,7 +150,7 @@ export default function Merchant() { /> ) : null} - {state.api_mode === 2 ? ( + {state.apiMode.filter((item) => item.key === state.api_mode)[0]?.secret_key ? ( setState({ ...state, secret_key: value })} @@ -234,11 +238,16 @@ export default function Merchant() { setState({ ...state, api_mode: target.value })} + onChange={({ target }) => { + setState({ ...state, api_mode: target.value }) + }} value={state.api_mode} > - 国密模式 - RSA模式 + {state.apiMode.map((item) => ( + + {item.label} + + ))}