✨ feat: 对接商户编辑接口
This commit is contained in:
parent
18275de237
commit
1616860da0
|
@ -969,4 +969,9 @@ export const resendCardCode = (data) => {
|
||||||
return req("post", baseurl + "/order/resendCardCode", data)
|
return req("post", baseurl + "/order/resendCardCode", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 设置开发信息 */
|
||||||
|
export const setResellMerchant = (data) => {
|
||||||
|
return req("post", baseurl + "/reseller/resellMerchant/set", data)
|
||||||
|
}
|
||||||
|
|
||||||
export { req }
|
export { req }
|
||||||
|
|
|
@ -36,9 +36,9 @@ const Column = [
|
||||||
width: "20%"
|
width: "20%"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "商户 ID",
|
title: "商户编号",
|
||||||
name: "code",
|
name: "merchant",
|
||||||
prop: "code",
|
prop: "merchant[merchant_id]",
|
||||||
type: "normal",
|
type: "normal",
|
||||||
width: "20%"
|
width: "20%"
|
||||||
},
|
},
|
||||||
|
@ -228,7 +228,7 @@ export default class acclist extends React.Component {
|
||||||
|
|
||||||
/* 开放信息 */
|
/* 开放信息 */
|
||||||
openInformation(row) {
|
openInformation(row) {
|
||||||
sessionStorage.setItem("dataInfo", JSON.stringify(row))
|
sessionStorage.setItem("merchant", JSON.stringify(row))
|
||||||
sessionStorage.setItem("pathname2", "distributor-merchant")
|
sessionStorage.setItem("pathname2", "distributor-merchant")
|
||||||
let activeRou = [
|
let activeRou = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,31 +1,74 @@
|
||||||
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"
|
||||||
import { useRef, useState } from "react"
|
import { omit } from "lodash-es"
|
||||||
import { Button, Card, CopyButton, Notify, Radio, RadioGroup } from "zent"
|
import { useEffect, useRef, useState } from "react"
|
||||||
|
import { Button, Card, Checkbox, CopyButton, Input, Notify, Radio, RadioGroup } from "zent"
|
||||||
|
import { setResellMerchant } from "@/assets/api"
|
||||||
import "./index"
|
import "./index"
|
||||||
export default function Merchant() {
|
export default function Merchant() {
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
merchantCallbacks: "",
|
reseller_id: "",
|
||||||
merchantId: "",
|
merchant_id: "",
|
||||||
systemRSA: "",
|
marketing_notify_url: [""],
|
||||||
merchantRSA: "",
|
custom_rsa_public_key: "",
|
||||||
subscribe: 1
|
encrypt_type: 2,
|
||||||
|
subscribe_event: [],
|
||||||
|
loading: false
|
||||||
})
|
})
|
||||||
const fromRef = useRef()
|
const fromRef = useRef()
|
||||||
const rules = {
|
const rules = {
|
||||||
merchantId: [{ type: "required", message: "请获取商户编号" }],
|
merchant_id: [
|
||||||
systemRSAPublic: [{ type: "required", message: "请获取营销系统RSA公钥" }],
|
{ type: "required", message: "请输入商户编号" },
|
||||||
systemRSAPrivate: [{ type: "required", message: "请获取营销系统RSA私钥" }],
|
{
|
||||||
merchantRSA: [{ type: "required", message: "请获取商户侧RSA公钥" }],
|
type: "regExp",
|
||||||
merchantCallbacks: [{ type: "required", message: "请输入商户回调通知网关地址" }]
|
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() {
|
function submit() {
|
||||||
const valid = fromRef.current.validator()
|
const valid = fromRef.current.validator()
|
||||||
if (valid) {
|
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={"更新信息"}>
|
<Card style={{ width: "100%" }} title={"更新信息"}>
|
||||||
<div className="adddistributor merchantForm">
|
<div className="adddistributor merchantForm">
|
||||||
<Form model={state} rules={rules} ref={fromRef}>
|
<Form model={state} rules={rules} ref={fromRef}>
|
||||||
<FormItem labelname="商户编号" prop="merchantId">
|
<FormItem labelname="商户编号">
|
||||||
<Ipt
|
<Ipt
|
||||||
onChange={(value) => setState({ ...state, merchantId: value })}
|
onChange={(value) => setState({ ...state, merchant_id: value })}
|
||||||
onClearItem={() => setState({ ...state, merchantId: "" })}
|
onClearItem={() => setState({ ...state, merchant_id: "" })}
|
||||||
countShow={false}
|
countShow={false}
|
||||||
value={state.merchantId}
|
value={state.merchant_id}
|
||||||
placeholder={"请输入商户编号"}
|
placeholder={"请输入商户编号"}
|
||||||
labelWidth={"0px"}
|
labelWidth={"0px"}
|
||||||
maxLength={32}
|
maxLength={20}
|
||||||
height={"36px"}
|
height={"36px"}
|
||||||
width={"520px"}
|
width={"520px"}
|
||||||
alignment={"left"}
|
alignment={"left"}
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem labelname="商户回调通知网关地址" prop="merchantCallbacks">
|
<FormItem labelname="商户回调通知网关地址" prop="marketing_notify_url">
|
||||||
<Ipt
|
<Ipt
|
||||||
onChange={(value) => setState({ ...state, merchantCallbacks: value })}
|
onChange={(value) => setState({ ...state, marketing_notify_url: value })}
|
||||||
onClearItem={() => setState({ ...state, merchantCallbacks: "" })}
|
onClearItem={() => setState({ ...state, marketing_notify_url: "" })}
|
||||||
countShow={false}
|
countShow={false}
|
||||||
value={state.merchantCallbacks}
|
value={state.marketing_notify_url}
|
||||||
placeholder={"请输入商户回调通知网关地址"}
|
placeholder={"请输入网关地址"}
|
||||||
labelWidth={"0px"}
|
labelWidth={"0px"}
|
||||||
maxLength={32}
|
maxLength={32}
|
||||||
height={"36px"}
|
height={"36px"}
|
||||||
|
@ -62,24 +105,21 @@ export default function Merchant() {
|
||||||
alignment={"left"}
|
alignment={"left"}
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem labelname="营销系统RSA公钥" prop="systemRSAPublic">
|
{state.rsa_public_key ? (
|
||||||
<div className="phonet">
|
<FormItem labelname="营销系统RSA公钥" prop="rsa_public_key">
|
||||||
<Ipt
|
<div className="phonet">
|
||||||
onChange={(value) => setState({ ...state, systemRSAPublic: value })}
|
<Ipt
|
||||||
disabled
|
countShow={false}
|
||||||
onClearItem={(e) => setState({ ...state, systemRSAPublic: "" })}
|
value={state.rsa_public_key}
|
||||||
countShow={false}
|
disabled
|
||||||
value={state.systemRSAPublic}
|
labelWidth={"0px"}
|
||||||
placeholder={"请获取营销系统RSA公钥"}
|
maxLength={32}
|
||||||
labelWidth={"0px"}
|
height={"36px"}
|
||||||
maxLength={32}
|
width={"520px"}
|
||||||
height={"36px"}
|
alignment={"left"}
|
||||||
width={"520px"}
|
/>
|
||||||
alignment={"left"}
|
|
||||||
/>
|
|
||||||
{state.systemRSAPublic ? (
|
|
||||||
<CopyButton
|
<CopyButton
|
||||||
text={"RSA公钥:" + state.systemRSAPublic}
|
text={state.rsa_public_key}
|
||||||
onCopySuccess={() => {
|
onCopySuccess={() => {
|
||||||
Notify.clear()
|
Notify.clear()
|
||||||
Notify.success("复制成功!")
|
Notify.success("复制成功!")
|
||||||
|
@ -87,85 +127,77 @@ export default function Merchant() {
|
||||||
>
|
>
|
||||||
<Button type="info">复制RSA公钥</Button>
|
<Button type="info">复制RSA公钥</Button>
|
||||||
</CopyButton>
|
</CopyButton>
|
||||||
) : (
|
</div>
|
||||||
<Button type="info">获取RSA公钥</Button>
|
</FormItem>
|
||||||
)}
|
) : null}
|
||||||
</div>
|
{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>
|
||||||
<FormItem labelname="营销系统RSA私钥" prop="systemRSAPrivate">
|
<FormItem labelname="加密算法" prop="encrypt_type">
|
||||||
<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">
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
onChange={({ target }) => setState({ ...state, subscribe: target.value })}
|
onChange={({ target }) => setState({ ...state, encrypt_type: target.value })}
|
||||||
value={state.subscribe}
|
value={state.encrypt_type}
|
||||||
>
|
>
|
||||||
<Radio value={1}>是</Radio>
|
<Radio value={2}>RSA</Radio>
|
||||||
<Radio value={0}>否</Radio>
|
<Radio value={1}>定制算法</Radio>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</FormItem>
|
</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>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
<div className="distributorbtn">
|
<div className="distributorbtn">
|
||||||
<Button type="primary" onClick={submit}>
|
<Button type="primary" onClick={submit} loading={state.loading}>
|
||||||
提交
|
提交
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="normal" onClick={() => window.history.back()}>
|
<Button type="normal" onClick={() => window.history.back()}>
|
||||||
|
|
Loading…
Reference in New Issue