feat: 对接商户编辑接口

This commit is contained in:
wangsongsole 2023-10-19 19:04:06 +08:00
parent 18275de237
commit 1616860da0
3 changed files with 151 additions and 114 deletions

View File

@ -969,4 +969,9 @@ export const resendCardCode = (data) => {
return req("post", baseurl + "/order/resendCardCode", data)
}
/* 设置开发信息 */
export const setResellMerchant = (data) => {
return req("post", baseurl + "/reseller/resellMerchant/set", data)
}
export { req }

View File

@ -36,9 +36,9 @@ const Column = [
width: "20%"
},
{
title: "商户 ID",
name: "code",
prop: "code",
title: "商户编号",
name: "merchant",
prop: "merchant[merchant_id]",
type: "normal",
width: "20%"
},
@ -228,7 +228,7 @@ export default class acclist extends React.Component {
/* 开放信息 */
openInformation(row) {
sessionStorage.setItem("dataInfo", JSON.stringify(row))
sessionStorage.setItem("merchant", JSON.stringify(row))
sessionStorage.setItem("pathname2", "distributor-merchant")
let activeRou = [
{

View File

@ -1,31 +1,74 @@
import FormItem from "@/components/form-item/main"
import Form from "@/components/form/main"
import Ipt from "@/components/input/main"
import { useRef, useState } from "react"
import { Button, Card, CopyButton, Notify, Radio, RadioGroup } from "zent"
import { omit } from "lodash-es"
import { useEffect, useRef, useState } from "react"
import { Button, Card, Checkbox, CopyButton, Input, Notify, Radio, RadioGroup } from "zent"
import { setResellMerchant } from "@/assets/api"
import "./index"
export default function Merchant() {
const [state, setState] = useState({
merchantCallbacks: "",
merchantId: "",
systemRSA: "",
merchantRSA: "",
subscribe: 1
reseller_id: "",
merchant_id: "",
marketing_notify_url: [""],
custom_rsa_public_key: "",
encrypt_type: 2,
subscribe_event: [],
loading: false
})
const fromRef = useRef()
const rules = {
merchantId: [{ type: "required", message: "请获取商户编号" }],
systemRSAPublic: [{ type: "required", message: "请获取营销系统RSA公钥" }],
systemRSAPrivate: [{ type: "required", message: "请获取营销系统RSA私钥" }],
merchantRSA: [{ type: "required", message: "请获取商户侧RSA公钥" }],
merchantCallbacks: [{ type: "required", message: "请输入商户回调通知网关地址" }]
merchant_id: [
{ type: "required", message: "请输入商户编号" },
{
type: "regExp",
message: "请输入正确的商户号",
reg: /^[A-Za-z0-9]+$/
}
],
custom_rsa_public_key: [{ type: "required", message: "请输入商户侧RSA公钥" }],
marketing_notify_url: [
{ type: "required", message: "请输入商户回调通知网关地址" },
{
type: "regExp",
message: "请输入合法的回调通知网关地址",
reg: /(https?|ftp|file):\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]/
}
]
}
useEffect(() => {
const { merchant, id } = JSON.parse(sessionStorage.getItem("merchant"))
setState({ ...state, reseller_id: id, ...merchant })
}, [])
/* 提交 */
function submit() {
const valid = fromRef.current.validator()
if (valid) {
console.log(state)
setState({ loading: true })
const data = omit(state, [
"create_time",
"id",
"status",
"update_time",
"rsa_private_key",
"rsa_public_key",
"loading"
])
setResellMerchant(data).then(({ code, message }) => {
if (code === 200) {
Notify.success(message)
let clr = null
clr = setTimeout(() => {
window.history.go(-1)
clearTimeout(clr)
}, 1000)
} else {
Notify.success(message)
}
setState({ loading: false })
})
}
}
@ -34,27 +77,27 @@ export default function Merchant() {
<Card style={{ width: "100%" }} title={"更新信息"}>
<div className="adddistributor merchantForm">
<Form model={state} rules={rules} ref={fromRef}>
<FormItem labelname="商户编号" prop="merchantId">
<FormItem labelname="商户编号">
<Ipt
onChange={(value) => setState({ ...state, merchantId: value })}
onClearItem={() => setState({ ...state, merchantId: "" })}
onChange={(value) => setState({ ...state, merchant_id: value })}
onClearItem={() => setState({ ...state, merchant_id: "" })}
countShow={false}
value={state.merchantId}
value={state.merchant_id}
placeholder={"请输入商户编号"}
labelWidth={"0px"}
maxLength={32}
maxLength={20}
height={"36px"}
width={"520px"}
alignment={"left"}
/>
</FormItem>
<FormItem labelname="商户回调通知网关地址" prop="merchantCallbacks">
<FormItem labelname="商户回调通知网关地址" prop="marketing_notify_url">
<Ipt
onChange={(value) => setState({ ...state, merchantCallbacks: value })}
onClearItem={() => setState({ ...state, merchantCallbacks: "" })}
onChange={(value) => setState({ ...state, marketing_notify_url: value })}
onClearItem={() => setState({ ...state, marketing_notify_url: "" })}
countShow={false}
value={state.merchantCallbacks}
placeholder={"请输入商户回调通知网关地址"}
value={state.marketing_notify_url}
placeholder={"请输入网关地址"}
labelWidth={"0px"}
maxLength={32}
height={"36px"}
@ -62,24 +105,21 @@ export default function Merchant() {
alignment={"left"}
/>
</FormItem>
<FormItem labelname="营销系统RSA公钥" prop="systemRSAPublic">
<div className="phonet">
<Ipt
onChange={(value) => setState({ ...state, systemRSAPublic: value })}
disabled
onClearItem={(e) => setState({ ...state, systemRSAPublic: "" })}
countShow={false}
value={state.systemRSAPublic}
placeholder={"请获取营销系统RSA公钥"}
labelWidth={"0px"}
maxLength={32}
height={"36px"}
width={"520px"}
alignment={"left"}
/>
{state.systemRSAPublic ? (
{state.rsa_public_key ? (
<FormItem labelname="营销系统RSA公钥" prop="rsa_public_key">
<div className="phonet">
<Ipt
countShow={false}
value={state.rsa_public_key}
disabled
labelWidth={"0px"}
maxLength={32}
height={"36px"}
width={"520px"}
alignment={"left"}
/>
<CopyButton
text={"RSA公钥:" + state.systemRSAPublic}
text={state.rsa_public_key}
onCopySuccess={() => {
Notify.clear()
Notify.success("复制成功!")
@ -87,85 +127,77 @@ export default function Merchant() {
>
<Button type="info">复制RSA公钥</Button>
</CopyButton>
) : (
<Button type="info">获取RSA公钥</Button>
)}
</div>
</div>
</FormItem>
) : null}
{state.rsa_private_key ? (
<FormItem labelname="营销系统RSA私钥" prop="rsa_private_key">
<div className="phonet">
<Ipt
countShow={false}
value={state.rsa_private_key}
disabled
labelWidth={"0px"}
maxLength={32}
height={"36px"}
width={"520px"}
alignment={"left"}
/>
{state.rsa_private_key ? (
<CopyButton
text={state.rsa_private_key}
onCopySuccess={() => {
Notify.clear()
Notify.success("复制成功!")
}}
>
<Button type="info">复制RSA私钥</Button>
</CopyButton>
) : null}
</div>
</FormItem>
) : null}
<FormItem labelname="商户侧RSA公钥" prop="custom_rsa_public_key">
<Input
type="textarea"
autoSize
onChange={({ target }) =>
setState({ ...state, custom_rsa_public_key: target.value })
}
value={state.custom_rsa_public_key}
placeholder={"请输入商户侧RSA公钥"}
labelWidth={"0px"}
width={"520px"}
alignment={"left"}
/>
</FormItem>
<FormItem labelname="营销系统RSA私钥" prop="systemRSAPrivate">
<div className="phonet">
<Ipt
onChange={(value) => setState({ ...state, systemRSAPrivate: value })}
disabled
onClearItem={(e) => setState({ ...state, systemRSAPrivate: "" })}
countShow={false}
value={state.systemRSAPrivate}
placeholder={"请获取营销系统RSA私钥"}
labelWidth={"0px"}
maxLength={32}
height={"36px"}
width={"520px"}
alignment={"left"}
/>
{state.systemRSAPrivate ? (
<CopyButton
text={"RSA私钥:" + state.systemRSAPrivate}
onCopySuccess={() => {
Notify.clear()
Notify.success("复制成功!")
}}
>
<Button type="info">复制RSA私钥</Button>
</CopyButton>
) : (
<Button type="info">获取RSA私钥</Button>
)}
</div>
</FormItem>
<FormItem labelname="商户侧RSA公钥" prop="merchantRSA">
<div className="phonet">
<Ipt
disabled
onChange={(value) => setState({ ...state, merchantRSA: value })}
onClearItem={(e) => setState({ ...state, merchantRSA: "" })}
countShow={false}
value={state.merchantRSA}
placeholder={"请获取商户侧RSA公钥"}
labelWidth={"0px"}
maxLength={32}
height={"36px"}
width={"520px"}
alignment={"left"}
/>
{state.merchantRSA ? (
<CopyButton
text={"RSA公钥:" + state.merchantRSA}
onCopySuccess={() => {
Notify.clear()
Notify.success("复制成功!")
}}
>
<Button type="info">复制RSA公钥</Button>
</CopyButton>
) : (
<Button type="info">获取RSA公钥</Button>
)}
</div>
</FormItem>
<FormItem labelname="订阅事件" prop="subscribe">
<FormItem labelname="加密算法" prop="encrypt_type">
<RadioGroup
onChange={({ target }) => setState({ ...state, subscribe: target.value })}
value={state.subscribe}
onChange={({ target }) => setState({ ...state, encrypt_type: target.value })}
value={state.encrypt_type}
>
<Radio value={1}></Radio>
<Radio value={0}></Radio>
<Radio value={2}>RSA</Radio>
<Radio value={1}>定制算法</Radio>
</RadioGroup>
</FormItem>
<FormItem labelname="订阅事件" prop="subscribe_event" required="">
<Checkbox.Group
value={state.subscribe_event}
onChange={(value) =>
setState({
...state,
subscribe_event: value
})
}
>
<Checkbox value={"KEY.USED"}>key码核销通知</Checkbox>
</Checkbox.Group>
</FormItem>
</Form>
</div>
</Card>
<div className="distributorbtn">
<Button type="primary" onClick={submit}>
<Button type="primary" onClick={submit} loading={state.loading}>
提交
</Button>
<Button type="normal" onClick={() => window.history.back()}>