From 8b301a19d711777c3e707fad8e8ff0e7a2c995b6 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Wed, 15 Nov 2023 09:30:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=9B=9E=E8=B0=83=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/api.js | 15 +++ src/components/subnav/main.js | 1 + src/pages/callbackMessage/index.jsx | 148 +++++++++++++++++++++++++++ src/pages/callbackMessage/index.less | 30 ++++++ src/pages/distributor/list/list.js | 34 ++++++ src/pages/plan/key/list.js | 33 +++++- src/pages/plan/list/list.js | 30 +++++- src/router/index.js | 5 + 8 files changed, 293 insertions(+), 3 deletions(-) create mode 100644 src/pages/callbackMessage/index.jsx create mode 100644 src/pages/callbackMessage/index.less diff --git a/src/assets/api.js b/src/assets/api.js index 50407311..d0212d2b 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -974,4 +974,19 @@ export const setResellMerchant = (data) => { return req("post", baseurl + "/reseller/resellMerchant/set", data) } +/* 设置分销商通知地址 */ +export const setResellerConf = (data) => { + return req("post", baseurl + "/voucher/setResellerConf", data) +} + +/* 设置key批次通知地址 */ +export const setKeyBatchConf = (data) => { + return req("post", baseurl + "/voucher/setKeyBatchConf", data) +} + +/* 设置计划通知地址 */ +export const setPlanConf = (data) => { + return req("post", baseurl + "/voucher/setPlanConf", data) +} + export { req } diff --git a/src/components/subnav/main.js b/src/components/subnav/main.js index 0781ff4c..be0b735a 100644 --- a/src/components/subnav/main.js +++ b/src/components/subnav/main.js @@ -99,6 +99,7 @@ export default class topNav extends React.Component { pathnamestr.includes("plan-edit") || pathnamestr.includes("product-edit") || pathnamestr.includes("distributor-merchant") || + pathnamestr.includes("callback-message") || pathnamestr.includes("coupon-commodity") let sedcbreakflag = pathnamestr.includes("plan-create") let planbreakflag = pathnamestr.includes("mytempMould") diff --git a/src/pages/callbackMessage/index.jsx b/src/pages/callbackMessage/index.jsx new file mode 100644 index 00000000..74979b19 --- /dev/null +++ b/src/pages/callbackMessage/index.jsx @@ -0,0 +1,148 @@ +import { setResellerConf, setKeyBatchConf, setPlanConf } from "@/assets/api" +import FormItem from "@/components/form-item/main" +import Form from "@/components/form/main" +import Ipt from "@/components/input/main" +import { omit } from "lodash-es" +import { useEffect, useRef, useState } from "react" +import { Button, Card, Notify } from "zent" +import "./index" +export default function Merchant() { + const fromRef = useRef() + const [state, setState] = useState({ + voucher_status_notify: "", + voucher_receive_notify: "", + loading: false + }) + + /* 通译字段: + * callBackId:分销商id 计划id key批次id + * callBackType: 分销商->1 计划->2 key批次->3 + */ + const callBackId = sessionStorage.getItem("callBackId") + const callBackType = Number(sessionStorage.getItem("callBackType")) + const http = /(https?|ftp|file):\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]/ + const rules = { + voucher_status_notify: [ + { type: "required", message: "请输入券状态通知地址" }, + { + type: "regExp", + message: "请输入合法的券状态通知地址", + reg: http + } + ], + voucher_receive_notify: [ + { type: "required", message: "请输入券领取通知地址" }, + { + type: "regExp", + message: "请输入合法的券领取通知地址", + reg: http + } + ] + } + + useEffect(() => {}, []) + + /* 提交 */ + function submit() { + const valid = fromRef.current.validator() + if (valid) { + setState({ loading: true }) + const data = omit(state, ["loading"]) + switch (callBackType) { + case 1: + data["reseller_id"] = callBackId + setResellerConf(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 }) + }) + break + case 2: + data["plan_id"] = callBackId + setPlanConf(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 }) + }) + break + case 3: + data["key_batch_id"] = callBackId + setKeyBatchConf(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 }) + }) + break + } + } + } + + return ( +
+ +
+
+ + setState({ ...state, voucher_status_notify: value })} + onClearItem={() => setState({ ...state, voucher_status_notify: "" })} + countShow={false} + value={state.voucher_status_notify} + placeholder={"请输入券状态通知地址"} + labelWidth={"0px"} + height={"36px"} + width={"520px"} + alignment={"left"} + /> + + + setState({ ...state, voucher_receive_notify: value })} + onClearItem={() => setState({ ...state, voucher_receive_notify: "" })} + countShow={false} + value={state.voucher_receive_notify} + placeholder={"请输入券领取通知地址"} + labelWidth={"0px"} + height={"36px"} + width={"520px"} + alignment={"left"} + /> + +
+
+
+
+ + +
+
+ ) +} diff --git a/src/pages/callbackMessage/index.less b/src/pages/callbackMessage/index.less new file mode 100644 index 00000000..75d515e6 --- /dev/null +++ b/src/pages/callbackMessage/index.less @@ -0,0 +1,30 @@ +.zent-form-horizontal[data-zv="9.11.0"] .zent-form-label { + flex-basis: 118px !important; + justify-content: flex-start !important; +} + +.zent-form-horizontal[data-zv="9.11.0"] .zent-form-control-content { + margin-left: 0; +} + +.adddistributor .iptfillself .label { + margin-right: 66px; +} + +// .zent-select-v2-popup{ +// width: 250px !important; +// } +.zent-btn-info[data-zv="9.11.0"] { + width: 120px; + color: #296bef !important; + border: none !important; +} + +.zent-dialog-r-anchor .zent-dialog-r[data-zv="9.11.0"] { + margin-top: -180px; +} + +.tip-reseller { + color: red; + font-size: 12px; +} \ No newline at end of file diff --git a/src/pages/distributor/list/list.js b/src/pages/distributor/list/list.js index 76801b63..7e381264 100644 --- a/src/pages/distributor/list/list.js +++ b/src/pages/distributor/list/list.js @@ -250,6 +250,31 @@ export default class acclist extends React.Component { this.props.history.push("/home/distributor-merchant") } + /* 设置回调地址 */ + callBack(row) { + sessionStorage.setItem("callBackId", JSON.stringify(row.id)) + sessionStorage.setItem("callBackType", JSON.stringify(1)) + sessionStorage.setItem("pathname2", "callback-message") + let activeRou = [ + { + pagetitle: "回调地址", + items: [ + { + path: "distributor-list", + name: "分销商一" + row.name + }, + { + path: "callback-message", + name: "设置回调通知地址" + } + ] + } + ] + sessionStorage.setItem("breaknav", JSON.stringify(activeRou)) + sessionStorage.setItem("linkshowname", "分销商管理") + this.props.history.push("/home/callback-message") + } + onSwitchChange(status, row) { let _self = this Sweetalert.confirm({ @@ -469,6 +494,15 @@ export default class acclist extends React.Component { > 开放信息 */} + + { + this.callBack(rowData) + }} + > + 设置回调 +
diff --git a/src/pages/plan/key/list.js b/src/pages/plan/key/list.js index c2e182ca..b46b0134 100644 --- a/src/pages/plan/key/list.js +++ b/src/pages/plan/key/list.js @@ -73,7 +73,7 @@ const Column = [ name: "plan", type: "slot", prop: "edit", - width: "250px" + width: "260px" }, { title: "状态", @@ -677,6 +677,34 @@ export default class acclist extends React.Component { console.log("pages/plan/key/list.js =>", err) } } + if (key == 6) { + this.callBack(row) + } + } + + /* 设置回调地址 */ + callBack(row) { + sessionStorage.setItem("callBackId", JSON.stringify(row.id)) + sessionStorage.setItem("callBackType", JSON.stringify(3)) + sessionStorage.setItem("pathname2", "callback-message") + let activeRou = [ + { + pagetitle: "回调地址", + items: [ + { + path: "distributor-list", + name: "key批次一" + row.batch_name + }, + { + path: "callback-message", + name: "设置回调通知地址" + } + ] + } + ] + sessionStorage.setItem("breaknav", JSON.stringify(activeRou)) + sessionStorage.setItem("linkshowname", "key批次") + this.props.history.push("/home/callback-message") } //limit @@ -868,13 +896,14 @@ export default class acclist extends React.Component { onVisibleChange={(v) => this.setState({ visible: v })} > -
+
更多
this.menuItemClick(key, rowData)}> 发送密码及压缩包 + 设置回调 日志 diff --git a/src/pages/plan/list/list.js b/src/pages/plan/list/list.js index f0434eaf..ceb46f25 100644 --- a/src/pages/plan/list/list.js +++ b/src/pages/plan/list/list.js @@ -465,7 +465,6 @@ export default class acclist extends React.Component { menuItemClick(key, row) { this.setState({ plan_id: row.id }) - if (row.status == 6) { Notify.clear() Notify.error("该状态下的数据不允许编辑") @@ -558,6 +557,9 @@ export default class acclist extends React.Component { parentComponent: this }) } + if (key == 6) { + this.callBack(row) + } } //清空 @@ -566,6 +568,31 @@ export default class acclist extends React.Component { this.setState({ selectiondata: [] }) } + /* 设置回调地址 */ + callBack(row) { + sessionStorage.setItem("callBackId", JSON.stringify(row.id)) + sessionStorage.setItem("callBackType", JSON.stringify(2)) + sessionStorage.setItem("pathname2", "callback-message") + let activeRou = [ + { + pagetitle: "回调地址", + items: [ + { + path: "distributor-list", + name: "营销计划一" + row.title + }, + { + path: "callback-message", + name: "设置回调通知地址" + } + ] + } + ] + sessionStorage.setItem("breaknav", JSON.stringify(activeRou)) + sessionStorage.setItem("linkshowname", "营销计划") + this.props.history.push("/home/callback-message") + } + //选中表格的选框 selection(selection) { this.setState({ selectiondata: selection }) @@ -794,6 +821,7 @@ export default class acclist extends React.Component { this.menuItemClick(key, rowData)}> 发送密码及压缩包 + 设置回调 日志 diff --git a/src/router/index.js b/src/router/index.js index 617c352b..6891e128 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -13,6 +13,7 @@ // src\pages\plan\keyorder\keyorder.js // src\pages\exchangecode\addinfoform\addinfoform.js // src\pages\exchangecode\addruleform\addruleform.js +import CallbackMessage from "@/pages/callbackMessage" import CouponAddEdit from "@/pages/coupon/addEdit" import UseCouponCommodity from "@/pages/coupon/commodity" import CouponList from "@/pages/coupon/list" @@ -231,6 +232,10 @@ const router = [ { path: "/home/coupon-commodity", component: UseCouponCommodity + }, + { + path: "/home/callback-message", + component: CallbackMessage } ] From 79511b6cb1264ef5f5dd974ed3bf3052301275f9 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Wed, 15 Nov 2023 20:54:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E5=89=A9=E4=BD=99=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/callbackMessage/index.jsx | 34 +++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index d0212d2b..92b0eedf 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -989,4 +989,9 @@ export const setPlanConf = (data) => { return req("post", baseurl + "/voucher/setPlanConf", data) } +/* 查询通知地址 */ +export const queryConfig = (data) => { + return req("get", baseurl + "/voucher/queryConfig", data) +} + export { req } diff --git a/src/pages/callbackMessage/index.jsx b/src/pages/callbackMessage/index.jsx index 74979b19..0f3c85af 100644 --- a/src/pages/callbackMessage/index.jsx +++ b/src/pages/callbackMessage/index.jsx @@ -1,4 +1,4 @@ -import { setResellerConf, setKeyBatchConf, setPlanConf } from "@/assets/api" +import { setResellerConf, setKeyBatchConf, setPlanConf, queryConfig } from "@/assets/api" import FormItem from "@/components/form-item/main" import Form from "@/components/form/main" import Ipt from "@/components/input/main" @@ -40,7 +40,37 @@ export default function Merchant() { ] } - useEffect(() => {}, []) + useEffect(() => { + query() + }, []) + + /* 查询详情 */ + function query() { + const data = { + reseller_id: "", + plan_id: "", + key_batch_id: "" + } + switch (callBackType) { + case 1: + data["reseller_id"] = callBackId + break + case 2: + data["plan_id"] = callBackId + break + case 3: + data["key_batch_id"] = callBackId + break + } + queryConfig(data).then((res) => { + const { voucher_notify_url, voucher_receive_url } = res.data + setState({ + ...state, + voucher_status_notify: voucher_notify_url, + voucher_receive_notify: voucher_receive_url + }) + }) + } /* 提交 */ function submit() { From f5a565721b5de10c9c8617661ba265c30f15841b Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Thu, 16 Nov 2023 18:20:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=9B=9E=E8=B0=83=E5=9C=B0=E5=9D=80=E5=BF=85=E5=A1=AB?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/callbackMessage/index.jsx | 141 +++++++++++++--------------- 1 file changed, 65 insertions(+), 76 deletions(-) diff --git a/src/pages/callbackMessage/index.jsx b/src/pages/callbackMessage/index.jsx index 0f3c85af..91e40801 100644 --- a/src/pages/callbackMessage/index.jsx +++ b/src/pages/callbackMessage/index.jsx @@ -20,25 +20,6 @@ export default function Merchant() { */ const callBackId = sessionStorage.getItem("callBackId") const callBackType = Number(sessionStorage.getItem("callBackType")) - const http = /(https?|ftp|file):\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]/ - const rules = { - voucher_status_notify: [ - { type: "required", message: "请输入券状态通知地址" }, - { - type: "regExp", - message: "请输入合法的券状态通知地址", - reg: http - } - ], - voucher_receive_notify: [ - { type: "required", message: "请输入券领取通知地址" }, - { - type: "regExp", - message: "请输入合法的券领取通知地址", - reg: http - } - ] - } useEffect(() => { query() @@ -74,60 +55,68 @@ export default function Merchant() { /* 提交 */ function submit() { - const valid = fromRef.current.validator() - if (valid) { - setState({ loading: true }) - const data = omit(state, ["loading"]) - switch (callBackType) { - case 1: - data["reseller_id"] = callBackId - setResellerConf(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 }) - }) - break - case 2: - data["plan_id"] = callBackId - setPlanConf(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 }) - }) - break - case 3: - data["key_batch_id"] = callBackId - setKeyBatchConf(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 }) - }) - break - } + const http = /(https?|ftp|file):\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]/ + const { voucher_status_notify, voucher_receive_notify } = state + + if (voucher_status_notify && !http.test(voucher_status_notify)) { + return Notify.warn("请入合法的券状态通知地址!") + } + + if (voucher_receive_notify && !http.test(voucher_receive_notify)) { + return Notify.warn("请入合法的券领取通知地址!") + } + + setState({ loading: true }) + const data = omit(state, ["loading"]) + switch (callBackType) { + case 1: + data["reseller_id"] = callBackId + setResellerConf(data).then(({ code, message }) => { + if (code === 200) { + Notify.success(message) + let clr = null + clr = setTimeout(() => { + window.history.go(-1) + clearTimeout(clr) + }, 1000) + } else { + Notify.error(message) + } + setState({ loading: false }) + }) + break + case 2: + data["plan_id"] = callBackId + setPlanConf(data).then(({ code, message }) => { + if (code === 200) { + Notify.success(message) + let clr = null + clr = setTimeout(() => { + window.history.go(-1) + clearTimeout(clr) + }, 1000) + } else { + Notify.error(message) + } + setState({ loading: false }) + }) + break + case 3: + data["key_batch_id"] = callBackId + setKeyBatchConf(data).then(({ code, message }) => { + if (code === 200) { + Notify.success(message) + let clr = null + clr = setTimeout(() => { + window.history.go(-1) + clearTimeout(clr) + }, 1000) + } else { + Notify.error(message) + } + setState({ loading: false }) + }) + break } } @@ -135,8 +124,8 @@ export default function Merchant() {
-
- + + setState({ ...state, voucher_status_notify: value })} onClearItem={() => setState({ ...state, voucher_status_notify: "" })} @@ -149,7 +138,7 @@ export default function Merchant() { alignment={"left"} /> - + setState({ ...state, voucher_receive_notify: value })} onClearItem={() => setState({ ...state, voucher_receive_notify: "" })}