From 1616860da0d129b315a4d5d7ed65951fe46b07e8 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Thu, 19 Oct 2023 19:04:06 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=AF=B9=E6=8E=A5=E5=95=86?= =?UTF-8?q?=E6=88=B7=E7=BC=96=E8=BE=91=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/api.js | 5 + src/pages/distributor/list/list.js | 8 +- src/pages/distributor/merchant/index.jsx | 252 +++++++++++++---------- 3 files changed, 151 insertions(+), 114 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index cfc51307..50407311 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -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 } diff --git a/src/pages/distributor/list/list.js b/src/pages/distributor/list/list.js index 5b50d9af..24c6241d 100644 --- a/src/pages/distributor/list/list.js +++ b/src/pages/distributor/list/list.js @@ -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 = [ { diff --git a/src/pages/distributor/merchant/index.jsx b/src/pages/distributor/merchant/index.jsx index e708a5a8..0d350cfe 100644 --- a/src/pages/distributor/merchant/index.jsx +++ b/src/pages/distributor/merchant/index.jsx @@ -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() {
- + 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"} /> - + 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"} /> - -
- 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 ? ( + +
+ { Notify.clear() Notify.success("复制成功!") @@ -87,85 +127,77 @@ export default function Merchant() { > - ) : ( - - )} -
+
+
+ ) : null} + {state.rsa_private_key ? ( + +
+ + {state.rsa_private_key ? ( + { + Notify.clear() + Notify.success("复制成功!") + }} + > + + + ) : null} +
+
+ ) : null} + + + setState({ ...state, custom_rsa_public_key: target.value }) + } + value={state.custom_rsa_public_key} + placeholder={"请输入商户侧RSA公钥"} + labelWidth={"0px"} + width={"520px"} + alignment={"left"} + /> - -
- 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 ? ( - { - Notify.clear() - Notify.success("复制成功!") - }} - > - - - ) : ( - - )} -
-
- -
- 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 ? ( - { - Notify.clear() - Notify.success("复制成功!") - }} - > - - - ) : ( - - )} -
-
- + setState({ ...state, subscribe: target.value })} - value={state.subscribe} + onChange={({ target }) => setState({ ...state, encrypt_type: target.value })} + value={state.encrypt_type} > - - + RSA + 定制算法 + + + setState({ + ...state, + subscribe_event: value + }) + } + > + key码核销通知 + +
-