dev-v2
Joe 11 months ago
parent e786fcf71a
commit 3872f1fbdf

@ -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,

@ -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})$/,
//邮箱正则

@ -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<boolean>(false);
const columns: ProColumns<API.PbcScreenAdvertisement>[] = [
const columns: ProColumns<API.PbcBanner_>[] = [
{
title: '标题',
dataIndex: 'pbcTitle',
},
{
title: '预览',
dataIndex: 'pbcAdvertisement',
dataIndex: 'pbcBannerImage',
search: false,
width: 220,
render: (text) => {
const str = text?.toString()
return str && <Image style={{ objectFit: 'contain' }} src={str} width={200} height={200} />
}
},
{
title: '类型',
dataIndex: 'pbcBannerType',
valueEnum: Constants.pbcBannerType,
search: false
},
{
title: '链接',
dataIndex: 'pbcLink',
search: false
},
{
title: '排序',
dataIndex: 'pbcSort',
search: false,
width: 70,
render: (text: any, record) => <Space>
<span>{text + 1}</span>
<Space direction='vertical'>
<Button onClick={async () => {
const success = await handleMoveBanner(record.pbcId || 0, 'up');
if (success) {
actionRef.current?.reload();
}
}} icon={<CaretUpOutlined />} />
<Button onClick={async () => {
const success = await handleMoveBanner(record.pbcId || 0, 'down');
if (success) {
actionRef.current?.reload();
}
}} icon={<CaretDownOutlined />} />
</Space>
</Space>
},
{
title: '创建时间',
@ -117,9 +184,9 @@ const TableList: React.FC<{}> = () => {
<span>
<Access key="config" accessible={access.adBannerUpdate}>
<Switch
checked={record.pbcBusinessState === 1}
checked={record.pbcState === 1}
onChange={async (value) => {
const success = await handleUpdateState(record.pbcId || 0, value ? 1 : 0);
const success = await handleUpdateState(record.pbcId || 0, value ? 1 : 2);
if (success) {
if (actionRef.current) {
@ -142,7 +209,7 @@ const TableList: React.FC<{}> = () => {
</Access>
<Access key="remove" accessible={access.adBannerDelete}>
<Popconfirm
title="确定删除该开屏广告?"
title="确定删除该banner?"
onConfirm={async () => {
const success = await handleRemove(record.pbcId);
if (success) {
@ -166,7 +233,7 @@ const TableList: React.FC<{}> = () => {
breadcrumb: {},
}}
>
<ProTable<API.PbcScreenAdvertisement>
<ProTable<API.PbcBanner_>
columns={columns}
actionRef={actionRef}
request={fetchData}
@ -214,7 +281,7 @@ const TableList: React.FC<{}> = () => {
toolBarRender={() => []}
/>
{stepFormValues && Object.keys(stepFormValues).length ? (
<UpdateForm
<UpdateBannerForm
onSubmit={async (value: any) => {
const success = await handleUpdate(value);

@ -0,0 +1,151 @@
import React, { useRef } from 'react';
import { DrawerForm, ProFormInstance, ProFormSelect, ProFormText, ProFormUploadButton } from '@ant-design/pro-components';
import { message } from 'antd';
import Upload, { RcFile } from 'antd/es/upload';
import Constants from '@/constants';
export type FormValueType = {
target?: string;
template?: string;
type?: string;
time?: string;
frequency?: string;
} & Partial<API.PbcBanner_>;
export type UpdateBannerFormProps = {
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
onSubmit: (values: FormValueType) => Promise<void>;
afterClose: () => void;
updateModalVisible: boolean;
values: Partial<API.PbcBanner_>;
};
const UpdateBannerForm: React.FC<UpdateBannerFormProps> = (props) => {
const formRef = useRef<ProFormInstance>();
return (
<DrawerForm
width={640}
requiredMark={false}
title={props.values.pbcId ? '编辑' : '新增'}
open={props.updateModalVisible}
formRef={formRef}
onFinish={(value: any) => {
let pbcBannerImage = ""
if (value.pbcBannerImage && value.pbcBannerImage.length > 0) {
if (value.pbcBannerImage[0].uid === '-1') {
pbcBannerImage = value.pbcBannerImage[0].url || '';
}
if (
value.pbcBannerImage[0].response &&
value.pbcBannerImage[0].response.retcode
) {
pbcBannerImage = value.pbcBannerImage[0].response.data;
}
}
return props.onSubmit({ ...value, pbcBannerImage, pbcId: props.values.pbcId })
}}
drawerProps={{
destroyOnClose: true,
afterOpenChange: (visible) => {
if (!visible) props.afterClose();
}
}}
initialValues={{
pbcTitle: props.values.pbcTitle,
pbcBannerType: props.values.pbcBannerType ? props.values.pbcBannerType + '' : null,
pbcLink: props.values.pbcLink,
pbcBannerImage: props.values.pbcBannerImage ? [{
uid: '-1',
name: props.values.pbcBannerImage.substring(props.values.pbcBannerImage.lastIndexOf('/') + 1),
status: 'done',
url: props.values.pbcBannerImage,
}] : []
}}
onOpenChange={(visible) => {
formRef.current?.resetFields();
if (!visible) {
props.onCancel();
}
}}
>
<ProFormText
placeholder={'请输入标题'}
label="标题"
rules={[
{
required: true,
message: '标题为必填项',
},
]}
width="md"
name="pbcTitle"
/>
<ProFormUploadButton
label="banner图"
name="pbcBannerImage"
max={1}
fieldProps={{
name: 'file',
accept: 'image/*',
multiple: true,
headers: {
authorization: localStorage.getItem('token') ?? '',
},
onChange: (info: any) => {
switch (info.file.status) {
case 'done':
if (info.file.response.retcode === 0) {
message.error(info.file.response.retmsg);
formRef.current?.setFieldValue('pbcBannerImage', [])
}
break;
default:
break;
}
},
action: process.env.BASE_URL + '/oss/imgUpload',
beforeUpload(file: RcFile) {
const isLt10M = file.size / 1024 / 1024 < 10;
if (!isLt10M) {
message.error('图片大小不能超过10MB!');
}
return isLt10M || Upload.LIST_IGNORE;
},
onPreview: async (file) => {
if (file.uid === '-1') {
window.open(file.url);
}
if (file.response && file.response.retcode) {
window.open(file.response.data);
}
},
listType: 'picture-card',
}}
rules={[
{ required: true, message: '请上传banner图' }
]}
/>
<ProFormSelect
name="pbcBannerType"
label="类型"
width="md"
valueEnum={Constants.pbcBannerType}
placeholder="请选择类型"
rules={[{ required: true, message: '请选择类型' }]}
/>
<ProFormText
placeholder={'请输入链接'}
label="链接"
width="md"
name="pbcLink"
/>
{/* <ProFormDigit
placeholder={'请输入排序'}
label="排序"
min={1}
fieldProps={{ precision: 0 }}
/> */}
</DrawerForm>
);
};
export default UpdateBannerForm;

@ -6,7 +6,7 @@ import { Button, Image, message, Popconfirm, Switch } 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 { addOrUpdateScreenAdvertisementUsingPost, changeAdStateUsingGet, getScreenAdPageUsingPost, removeAdUsingGet } from '@/services/pop-b2b2c/pbcScreenAdvertisementController';
/**
*
@ -70,7 +70,7 @@ const handleRemove = async (id?: number) => {
if (!id) return false;
try {
const msg = await removeAdUsingPost({
const msg = await removeAdUsingGet({
pbcId: id,
});
hide();

@ -3,6 +3,7 @@
// API 更新时间:
// API 唯一标识:
import * as errorController from './errorController';
import * as pbcBannerController from './pbcBannerController';
import * as pbcBusinessApprovalController from './pbcBusinessApprovalController';
import * as pbcBusinessController from './pbcBusinessController';
import * as pbcBusinessPostConfigController from './pbcBusinessPostConfigController';
@ -35,6 +36,7 @@ export default {
pbcSmsLogController,
pbcImageController,
pbcLoginController,
pbcBannerController,
pbcBusinessPostConfigController,
pbcRoleController,
pbcScreenAdvertisementController,

@ -0,0 +1,109 @@
// @ts-ignore
/* eslint-disable */
import request from '@/utils/request';
/** 后台新增或者修改banner POST /b2b2c/pbcBanner/addOrUpdateBanner */
export async function addOrUpdateBannerUsingPost(
body: API.PbcBanner_,
options?: { [key: string]: any },
) {
return request<API.AjaxResult>('/b2b2c/pbcBanner/addOrUpdateBanner', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** 根据id获取banner信息 后台 GET /b2b2c/pbcBanner/bannerDetail */
export async function bannerDetailUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.bannerDetailUsingGETParams,
options?: { [key: string]: any },
) {
return request<API.AjaxResultPbcBanner_>('/b2b2c/pbcBanner/bannerDetail', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 更改banner状态 GET /b2b2c/pbcBanner/changeBannerState */
export async function changeBannerStateUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.changeBannerStateUsingGETParams,
options?: { [key: string]: any },
) {
return request<API.AjaxResultString_>('/b2b2c/pbcBanner/changeBannerState', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 前端使用获取banner列表 列表 GET /b2b2c/pbcBanner/getBannerList */
export async function getBannerListUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.getBannerListUsingGETParams,
options?: { [key: string]: any },
) {
return request<API.AjaxResultListPbcBanner_>('/b2b2c/pbcBanner/getBannerList', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 获取banner分页 分页 POST /b2b2c/pbcBanner/getBannerPage */
export async function getBannerPageUsingPost(
body: API.PbcBanner_,
options?: { [key: string]: any },
) {
return request<API.AjaxResultIPagePbcBanner_>('/b2b2c/pbcBanner/getBannerPage', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** 管理员上下移动banner,路径参数up上移down下移 移动单个 GET /b2b2c/pbcBanner/moveBanner/${param0} */
export async function moveBannerUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.moveBannerUsingGETParams,
options?: { [key: string]: any },
) {
const { type: param0, ...queryParams } = params;
return request<API.AjaxResult>(`/b2b2c/pbcBanner/moveBanner/${param0}`, {
method: 'GET',
params: {
...queryParams,
},
...(options || {}),
});
}
/** 根据id删除单个banner GET /b2b2c/pbcBanner/removeBanner */
export async function removeBannerUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.removeBannerUsingGETParams,
options?: { [key: string]: any },
) {
return request<API.AjaxResultString_>('/b2b2c/pbcBanner/removeBanner', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}

@ -36,3 +36,33 @@ export async function freshTokenUsingPost(
...(options || {}),
});
}
/** 小程序登录绑定open id如果不存在则注册用户loginCode使用的是 wx.login 接口获得临时登录凭证 code,mobileCode通过动态令牌换取用户手机号 GET /b2b2c/login/wxMiniAppBindAccount */
export async function wxMiniAppBindAccountUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.wxMiniAppBindAccountUsingGETParams,
options?: { [key: string]: any },
) {
return request<API.AjaxResult>('/b2b2c/login/wxMiniAppBindAccount', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 小程序登录此code使用的是 wx.login 接口获得临时登录凭证 code GET /b2b2c/login/wxMiniAppLogin */
export async function wxMiniAppLoginUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.wxMiniAppLoginUsingGETParams,
options?: { [key: string]: any },
) {
return request<API.AjaxResult>('/b2b2c/login/wxMiniAppLogin', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}

@ -76,14 +76,14 @@ export async function getScreenAdPageUsingPost(
);
}
/** 根据id删除单个开屏广告 POST /b2b2c/pbcScreenAdvertisement/removeAd */
export async function removeAdUsingPost(
/** 根据id删除单个开屏广告 GET /b2b2c/pbcScreenAdvertisement/removeAd */
export async function removeAdUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.removeAdUsingPOSTParams,
params: API.removeAdUsingGETParams,
options?: { [key: string]: any },
) {
return request<API.AjaxResultString_>('/b2b2c/pbcScreenAdvertisement/removeAd', {
method: 'POST',
method: 'GET',
params: {
...params,
},

@ -47,6 +47,12 @@ declare namespace API {
retmsg?: string;
};
type AjaxResultIPagePbcBanner_ = {
data?: IPagePbcBanner_;
retcode?: number;
retmsg?: string;
};
type AjaxResultIPagePbcBusiness_ = {
data?: IPagePbcBusiness_;
retcode?: number;
@ -155,6 +161,12 @@ declare namespace API {
retmsg?: string;
};
type AjaxResultListPbcBanner_ = {
data?: PbcBanner_[];
retcode?: number;
retmsg?: string;
};
type AjaxResultListPbcBusiness_ = {
data?: PbcBusiness[];
retcode?: number;
@ -269,6 +281,12 @@ declare namespace API {
retmsg?: string;
};
type AjaxResultPbcBanner_ = {
data?: PbcBanner_;
retcode?: number;
retmsg?: string;
};
type AjaxResultPbcBusiness_ = {
data?: PbcBusiness;
retcode?: number;
@ -358,6 +376,11 @@ declare namespace API {
pbcId: number;
};
type bannerDetailUsingGETParams = {
/** pbcId */
pbcId: number;
};
type businessAdminDeleteUserMemberUsingGETParams = {
/** pbcId */
pbcId: number;
@ -380,6 +403,13 @@ declare namespace API {
pbcId: number;
};
type changeBannerStateUsingGETParams = {
/** pbcId */
pbcId: number;
/** pbcState */
pbcState: number;
};
type changeProductStateForAdminUsingGETParams = {
/** pcbId */
pcbId: number;
@ -445,6 +475,11 @@ declare namespace API {
values?: string[];
};
type getBannerListUsingGETParams = {
/** pbcBannerType */
pbcBannerType: number;
};
type getBusinessImageUsingGETParams = {
/** businessId */
businessId: number;
@ -512,7 +547,7 @@ declare namespace API {
phone: string;
};
type getWXSignUsingGETParams = {
type getWXSignUsingGET1Params = {
/** url */
url: string;
};
@ -579,6 +614,14 @@ declare namespace API {
verificationCode: string;
};
type IPagePbcBanner_ = {
current?: number;
pages?: number;
records?: PbcBanner_[];
size?: number;
total?: number;
};
type IPagePbcBusiness_ = {
current?: number;
pages?: number;
@ -810,6 +853,13 @@ declare namespace API {
viewName?: string;
};
type moveBannerUsingGETParams = {
/** pbcId */
pbcId: number;
/** type */
type: string;
};
type moveProductHotRecordUsingGETParams = {
/** hotProductId */
hotProductId: number;
@ -926,6 +976,39 @@ declare namespace API {
selected?: number;
};
type PbcBanner_ = {
/** 当前页 */
current?: number;
/** 条数 */
pageSize?: number;
/** 图片 */
pbcBannerImage?: string;
/** 类型 */
pbcBannerType?: number;
/** 创建时间 */
pbcCreateAt?: string;
/** 创建人 */
pbcCreateBy?: number;
/** 创建人 */
pbcCreateByUserName?: string;
/** 主键 */
pbcId?: number;
/** banner链接 */
pbcLink?: string;
/** 排序 */
pbcSort?: number;
/** 状态,0是删除1是正常2是作废 */
pbcState?: number;
/** banner标题 */
pbcTitle?: string;
/** 更新时间 */
pbcUpdateAt?: string;
/** 更新人 */
pbcUpdateBy?: number;
/** 更新人 */
pbcUpdateByUserName?: string;
};
type PbcBusiness = {
/** 商户对公账户 */
pbcBusinessAccount?: string;
@ -1491,7 +1574,7 @@ declare namespace API {
pbcBusinessCode?: string;
/** 商户名称 */
pbcBusinessName?: string;
/** 有三种qrcodesharelink */
/** 有三种qrcodesharelink,以及mini app */
pbcDataSource?: string;
/** 序号 */
serialNumber?: number;
@ -2386,8 +2469,12 @@ declare namespace API {
pbcCreateByUserName?: string;
/** 主键 */
pbcId?: number;
/** 用户小程序的open id */
pbcOpenId?: string;
/** 状态,0是删除1是正常2是作废 */
pbcState?: number;
/** 用户微信的union id */
pbcUnionId?: string;
/** 更新时间 */
pbcUpdateAt?: string;
/** 更新人 */
@ -2596,8 +2683,12 @@ declare namespace API {
pbcCreateByUserName?: string;
/** 主键 */
pbcId?: number;
/** 用户小程序的open id */
pbcOpenId?: string;
/** 状态,0是删除1是正常2是作废 */
pbcState?: number;
/** 用户微信的union id */
pbcUnionId?: string;
/** 更新时间 */
pbcUpdateAt?: string;
/** 更新人 */
@ -2651,8 +2742,12 @@ declare namespace API {
pbcCreateByUserName?: string;
/** 主键 */
pbcId?: number;
/** 用户小程序的open id */
pbcOpenId?: string;
/** 状态,0是删除1是正常2是作废 */
pbcState?: number;
/** 用户微信的union id */
pbcUnionId?: string;
/** 更新时间 */
pbcUpdateAt?: string;
/** 更新人 */
@ -2748,7 +2843,12 @@ declare namespace API {
roleId: number;
};
type removeAdUsingPOSTParams = {
type removeAdUsingGETParams = {
/** pbcId */
pbcId: number;
};
type removeBannerUsingGETParams = {
/** pbcId */
pbcId: number;
};
@ -2950,4 +3050,16 @@ declare namespace API {
type View = {
contentType?: string;
};
type wxMiniAppBindAccountUsingGETParams = {
/** loginCode */
loginCode: string;
/** mobileCode */
mobileCode: string;
};
type wxMiniAppLoginUsingGETParams = {
/** code */
code: string;
};
}

@ -2,10 +2,18 @@
/* eslint-disable */
import request from '@/utils/request';
/** 获取微信小程序的token GET /b2b2c/wx/fetchMiniAppAccessToken */
export async function getWxSignUsingGet(options?: { [key: string]: any }) {
return request<string>('/b2b2c/wx/fetchMiniAppAccessToken', {
method: 'GET',
...(options || {}),
});
}
/** 获取微信签名sign的参数 获取微信签名sign的参数 GET /b2b2c/wx/getWXSign */
export async function getWxSignUsingGet(
export async function getWxSignUsingGet1(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.getWXSignUsingGETParams,
params: API.getWXSignUsingGET1Params,
options?: { [key: string]: any },
) {
return request<API.AjaxResultMapStringString_>('/b2b2c/wx/getWXSign', {

Loading…
Cancel
Save