feat: 对接动态商户加密类型

This commit is contained in:
wangsongsole 2024-03-04 11:28:07 +08:00
parent 7e89178ff0
commit 462843304e
2 changed files with 21 additions and 7 deletions

View File

@ -1019,4 +1019,9 @@ export const notifyReseller = (data) => {
return req("post", baseurl + "/order/notifyReseller", data) return req("post", baseurl + "/order/notifyReseller", data)
} }
/* 获取商户加密类型 */
export const getApiMode = () => {
return req("get", baseurl + "/reseller/merchant/getApiMode")
}
export { req } export { req }

View File

@ -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 FormItem from "@/components/form-item/main"
import Form from "@/components/form/main" import Form from "@/components/form/main"
import Ipt from "@/components/input/main" import Ipt from "@/components/input/main"
@ -9,6 +9,7 @@ import "./index.less"
export default function Merchant() { export default function Merchant() {
const [state, setState] = useState({ const [state, setState] = useState({
loading: false, loading: false,
apiMode: [],
reseller_id: 0 /* 分销商id */, reseller_id: 0 /* 分销商id */,
merchant_id: "", // * merchant_id: "", // *
pos_id: "", //id * pos_id: "", //id *
@ -45,7 +46,10 @@ export default function Merchant() {
useEffect(() => { useEffect(() => {
const { merchant, id } = JSON.parse(sessionStorage.getItem("merchant")) 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() {
/> />
</FormItem> </FormItem>
{state.api_mode === 2 ? ( {state.apiMode.filter((item) => item.key === state.api_mode)[0]?.store_id ? (
<FormItem labelname="店铺ID" prop="store_id"> <FormItem labelname="店铺ID" prop="store_id">
<Ipt <Ipt
onChange={(value) => setState({ ...state, store_id: value })} onChange={(value) => setState({ ...state, store_id: value })}
@ -146,7 +150,7 @@ export default function Merchant() {
/> />
</FormItem> </FormItem>
) : null} ) : null}
{state.api_mode === 2 ? ( {state.apiMode.filter((item) => item.key === state.api_mode)[0]?.secret_key ? (
<FormItem labelname="SM4秘钥" prop="secret_key"> <FormItem labelname="SM4秘钥" prop="secret_key">
<Ipt <Ipt
onChange={(value) => setState({ ...state, secret_key: value })} onChange={(value) => setState({ ...state, secret_key: value })}
@ -234,11 +238,16 @@ export default function Merchant() {
</FormItem> </FormItem>
<FormItem labelname="对接类型" prop="api_mode"> <FormItem labelname="对接类型" prop="api_mode">
<RadioGroup <RadioGroup
onChange={({ target }) => setState({ ...state, api_mode: target.value })} onChange={({ target }) => {
setState({ ...state, api_mode: target.value })
}}
value={state.api_mode} value={state.api_mode}
> >
<Radio value={2}>国密模式</Radio> {state.apiMode.map((item) => (
<Radio value={1}>RSA模式</Radio> <Radio key={item.key} value={item.key}>
{item.label}
</Radio>
))}
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<FormItem labelname="订阅事件" prop="subscribe_event" required=""> <FormItem labelname="订阅事件" prop="subscribe_event" required="">