From 3872f1fbdfbf022e972cc09a8283bfe03c25cbff Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 5 Feb 2025 17:33:02 +0800 Subject: [PATCH] up --- config/proxy.ts | 4 +- src/constants.ts | 6 + src/pages/ScreenAdvertisement/banner.tsx | 101 ++++++++++-- .../components/UpdateBannerForm.tsx | 151 ++++++++++++++++++ src/pages/ScreenAdvertisement/index.tsx | 4 +- src/services/pop-b2b2c/index.ts | 2 + src/services/pop-b2b2c/pbcBannerController.ts | 109 +++++++++++++ src/services/pop-b2b2c/pbcLoginController.ts | 30 ++++ .../pbcScreenAdvertisementController.ts | 8 +- src/services/pop-b2b2c/typings.d.ts | 118 +++++++++++++- src/services/pop-b2b2c/wxController.ts | 12 +- 11 files changed, 515 insertions(+), 30 deletions(-) create mode 100644 src/pages/ScreenAdvertisement/components/UpdateBannerForm.tsx create mode 100644 src/services/pop-b2b2c/pbcBannerController.ts diff --git a/config/proxy.ts b/config/proxy.ts index 1afaeda..1530bd3 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -15,7 +15,7 @@ export default { // localhost:8000/api/** -> https://preview.pro.ant.design/api/** '/b2b2c': { // 要代理的地址 - target: 'http://10.10.137.202:8084', + target: 'http://127.0.0.1:8084', // 配置了这个可以从 http 代理到 https // 依赖 origin 的功能可能需要这个,比如 cookie changeOrigin: true, @@ -23,7 +23,7 @@ export default { }, '/oss': { // 要代理的地址 - target: 'http://10.10.137.202:8084', + target: 'http://127.0.0.1:8084', // 配置了这个可以从 http 代理到 https // 依赖 origin 的功能可能需要这个,比如 cookie changeOrigin: true, diff --git a/src/constants.ts b/src/constants.ts index 79a2616..9783f03 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -143,6 +143,12 @@ const Constants = { select: '下拉框', text: '文本框', }, + /** + * banner类型 + */ + pbcBannerType: { + 1: '平台首页', + }, // 手机正则 PHONE_PATTERN: /^(?:(0\d{2,3}-)?\d{7,8}|1[3-9]\d{9})$/, //邮箱正则 diff --git a/src/pages/ScreenAdvertisement/banner.tsx b/src/pages/ScreenAdvertisement/banner.tsx index 71628b1..a62ab9e 100644 --- a/src/pages/ScreenAdvertisement/banner.tsx +++ b/src/pages/ScreenAdvertisement/banner.tsx @@ -1,19 +1,20 @@ /* eslint-disable no-param-reassign */ -import { PlusOutlined } from '@ant-design/icons'; +import { CaretDownOutlined, CaretUpOutlined, PlusOutlined } from '@ant-design/icons'; import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; import { PageContainer } from '@ant-design/pro-layout'; -import { Button, message, Popconfirm, Switch } from 'antd'; +import { Button, message, Popconfirm, Switch, Image, Space } from 'antd'; import React, { useRef, useState } from 'react'; import { Access, useAccess } from 'umi'; -import UpdateForm from './components/UpdateForm'; -import { addOrUpdateScreenAdvertisementUsingPost, changeAdStateUsingGet, getScreenAdPageUsingPost, removeAdUsingPost } from '@/services/pop-b2b2c/pbcScreenAdvertisementController'; +import { addOrUpdateBannerUsingPost, changeBannerStateUsingGet, getBannerPageUsingPost, moveBannerUsingGet, removeBannerUsingGet } from '@/services/pop-b2b2c/pbcBannerController'; +import UpdateBannerForm from './components/UpdateBannerForm'; +import Constants from '@/constants'; /** * 查询表格 * @param param0 */ -const fetchData = async (params: API.PbcScreenAdvertisement) => { - const msg = await getScreenAdPageUsingPost(params); +const fetchData = async (params: API.PbcBanner_) => { + const msg = await getBannerPageUsingPost(params); return { data: msg.data?.records, total: msg.data?.total, @@ -25,11 +26,11 @@ const fetchData = async (params: API.PbcScreenAdvertisement) => { * 更新节点 * @param fields */ -const handleUpdate = async (fields: API.PbcScreenAdvertisement) => { +const handleUpdate = async (fields: API.PbcBanner_) => { const hide = message.loading('正在保存'); try { - const msg = await addOrUpdateScreenAdvertisementUsingPost(fields); + const msg = await addOrUpdateBannerUsingPost(fields); hide(); if (msg.retcode) { message.success(!fields.pbcId ? '添加成功' : '保存成功'); @@ -47,7 +48,7 @@ const handleUpdateState = async (id: number, state: number) => { const hide = message.loading('正在保存'); if (!id) return false; try { - const msg = await changeAdStateUsingGet({ pbcId: id, pbcBusinessState: state }); + const msg = await changeBannerStateUsingGet({ pbcId: id, pbcState: state }); hide(); if (msg.retcode) { message.success(!id ? '新增成功!' : '保存成功!'); @@ -61,6 +62,32 @@ const handleUpdateState = async (id: number, state: number) => { return false; } }; +/** + * 移动节点 + * @param id + */ +const handleMoveBanner = async (id: number, type: string) => { + const hide = message.loading('正在保存'); + if (!id) return false; + + try { + const msg = await moveBannerUsingGet({ + type, + pbcId: id, + }); + hide(); + if (msg.retcode) { + message.success('保存成功,即将刷新'); + } else { + message.error(msg.retmsg ?? '保存失败,请重试'); + } + return true; + } catch (error) { + hide(); + message.error('保存失败,请重试'); + return false; + } +}; /** * 删除节点 * @param id @@ -70,7 +97,7 @@ const handleRemove = async (id?: number) => { if (!id) return false; try { - const msg = await removeAdUsingPost({ + const msg = await removeBannerUsingGet({ pbcId: id, }); hide(); @@ -94,14 +121,54 @@ const TableList: React.FC<{}> = () => { const [stepFormValues, setStepFormValues] = useState({}); const [updateModalVisible, handleUpdateModalVisible] = useState(false); - const columns: ProColumns[] = [ + const columns: ProColumns[] = [ { title: '标题', dataIndex: 'pbcTitle', }, { title: '预览', - dataIndex: 'pbcAdvertisement', + dataIndex: 'pbcBannerImage', + search: false, + width: 220, + render: (text) => { + const str = text?.toString() + return str && + } + }, + { + title: '类型', + dataIndex: 'pbcBannerType', + valueEnum: Constants.pbcBannerType, + search: false + }, + { + title: '链接', + dataIndex: 'pbcLink', + search: false + }, + { + title: '排序', + dataIndex: 'pbcSort', + search: false, + width: 70, + render: (text: any, record) => + {text + 1} + +