diff --git a/config/routes.ts b/config/routes.ts index 216d2dd..b6c0906 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -222,6 +222,12 @@ export default [ hideInMenu: true, component: './ProductList/add', }, + { + name: '编辑商品', + path: 'edit/:id', + hideInMenu: true, + component: './ProductList/add', + }, { name: '详情', path: 'detail/:id', diff --git a/src/access.ts b/src/access.ts index f0b19aa..c9ff9a7 100644 --- a/src/access.ts +++ b/src/access.ts @@ -50,6 +50,7 @@ export default function access(initialState: { currentUser?: API.PbcUsersVO | un productQuery: false, productAdd: false, productUpdateState: false, + productRemove: false, content: false, contentQuery: false, contentSave: false, diff --git a/src/components/CropImage/index.css b/src/components/CropImage/index.css new file mode 100644 index 0000000..9187915 --- /dev/null +++ b/src/components/CropImage/index.css @@ -0,0 +1,30 @@ +.crop-image { + position: fixed; + left: 0; + top: 0; + width: 100vw; + z-index: 99; + height: 100%; + background-color: #000; +} + +.crop-image .crop-container { + position: relative; +} + +.crop-image .crop-close-btn, +.crop-image .crop-ok-btn { + position: absolute; + bottom: 40px; + color: var(--primary-color); + z-index: 1; + font-size: 1.5rem; +} + +.crop-image .crop-close-btn { + left: 20px; +} + +.crop-image .crop-ok-btn { + right: 20px; +} \ No newline at end of file diff --git a/src/components/CropImage/index.tsx b/src/components/CropImage/index.tsx new file mode 100644 index 0000000..7d2994e --- /dev/null +++ b/src/components/CropImage/index.tsx @@ -0,0 +1,50 @@ +import { PlusOutlined } from "@ant-design/icons"; +import { message, Upload } from "antd"; +import ImgCrop from "antd-img-crop"; +import { RcFile, UploadChangeParam, UploadFile } from "antd/es/upload"; + +type ImageBase64UploadProps = { + value?: string; + onChange?: (info: UploadChangeParam>) => void; +}; +export default ((props) => { + return ( + + { + const isLt2M = file.size / 1024 / 1024 < 10; + if (!isLt2M) { + message.error('图片大小不能超过10MB!'); + } + return isLt2M || Upload.LIST_IGNORE; + }} + onPreview={async (file) => { + console.log(file) + if (file.uid === '-1') { + window.open(file.url); + } + if (file.response && file.response.retcode) { + window.open(file.response.data); + } + }} + onChange={props.onChange} + > + {!props.value && ( +
+ {} +
点击上传图片
+
+ )} +
+
+ ); +}) as React.FC; \ No newline at end of file diff --git a/src/pages/InnovativeService/components/UpdateForm.tsx b/src/pages/InnovativeService/components/UpdateForm.tsx index 3855b72..bf7990a 100644 --- a/src/pages/InnovativeService/components/UpdateForm.tsx +++ b/src/pages/InnovativeService/components/UpdateForm.tsx @@ -124,6 +124,12 @@ const UpdateForm: React.FC = (props) => { status: 'done', url: props.values.pbcPicAddress, }] : [], + pbcFile: props.values.pbcType === 3 && props.values.pbcPicAddress ? [{ + uid: '-1', + name: props.values.pbcPicAddress.substring(props.values.pbcPicAddress.lastIndexOf('/') + 1), + status: 'done', + url: props.values.pbcPicAddress, + }] : [], pbcContent: props.values.pbcContent }} onOpenChange={(visible) => { @@ -157,6 +163,10 @@ const UpdateForm: React.FC = (props) => { label: '视频', value: 2, }, + { + label: '文件', + value: 3, + }, ]} rules={[ { @@ -169,6 +179,7 @@ const UpdateForm: React.FC = (props) => { setPbcType(e.target.value) formRef.current?.setFieldValue('pbcImage', []); formRef.current?.setFieldValue('pbcVideo', []); + formRef.current?.setFieldValue('pbcFile', []); }, }} /> @@ -218,12 +229,12 @@ const UpdateForm: React.FC = (props) => { ]} /> : = (props) => { case 'done': if (info.file.response.retcode === 0) { message.error(info.file.response.retmsg); - formRef.current?.setFieldValue('pbcVideo', []) - } else if (info.file.response && info.file.response.retcode) { + if (pbcType === 2) { + formRef.current?.setFieldValue('pbcVideo', []) + } else { + + formRef.current?.setFieldValue('pbcFile', []) + } + } else if (info.file.response && info.file.response.retcode && pbcType === 2) { // 视频上传成功后,获取视频首帧作为缩略图 const videoUrl = info.file.response.data; generateVideoThumbnail(videoUrl); @@ -248,7 +264,7 @@ const UpdateForm: React.FC = (props) => { beforeUpload(file: RcFile) { const isLt30M = file.size / 1024 / 1024 < 30; if (!isLt30M) { - message.error('视频大小不能超过30MB!'); + message.error(`${pbcType === 2 ? '视频' : '文件'}大小不能超过30MB!`); } return isLt30M || Upload.LIST_IGNORE; }, @@ -263,10 +279,10 @@ const UpdateForm: React.FC = (props) => { listType: 'picture-card', }} rules={[ - { required: true, message: '请上传视频' }, + { required: true, message: `请上传${pbcType === 2 ? '视频' : '文件'}'` }, ]} />} - = (props) => { ]} > - + : null} ); }; diff --git a/src/pages/InnovativeService/index.tsx b/src/pages/InnovativeService/index.tsx index c78615e..3956988 100644 --- a/src/pages/InnovativeService/index.tsx +++ b/src/pages/InnovativeService/index.tsx @@ -98,6 +98,7 @@ const TableList: React.FC = () => { valueEnum: { 1: '图片', 2: '视频', + 3: '文件', }, }, { diff --git a/src/pages/ProductList/add.tsx b/src/pages/ProductList/add.tsx index 3937d2f..17557fa 100644 --- a/src/pages/ProductList/add.tsx +++ b/src/pages/ProductList/add.tsx @@ -2,7 +2,7 @@ import Constants from '@/constants'; import { getPbcBusinessListUsingPost } from '@/services/pop-b2b2c/pbcBusinessController'; import { listAdminTreeUsingGet } from '@/services/pop-b2b2c/pbcCategoryController'; import { getRecordByL3CategoryIdUsingGet } from '@/services/pop-b2b2c/pbcCommonDataController'; -import { addOrUpdateProductForAdminUsingPost } from '@/services/pop-b2b2c/pbcProductController'; +import { addOrUpdateProductForAdminUsingPost, productDetailForAdminUsingGet } from '@/services/pop-b2b2c/pbcProductController'; import { getCities } from '@/utils/cities'; import { ProCard, @@ -24,6 +24,9 @@ import Upload, { RcFile, UploadFile } from 'antd/es/upload'; import React, { useEffect, useRef, useState } from 'react'; import { CSS } from '@dnd-kit/utilities'; import { getLabelListForAdminUsingPost } from '@/services/pop-b2b2c/pbcProductLabelConfigController'; +import { useParams } from 'react-router-dom'; +import './index.less' +import CropImage from '@/components/CropImage'; interface DraggableUploadListItemProps { originNode: React.ReactElement>; @@ -57,7 +60,9 @@ const DraggableUploadListItem = ({ originNode, file }: DraggableUploadListItemPr }; const Detail: React.FC = () => { + const params = useParams(); const [cities] = useState(() => getCities()) + const [isEdit] = useState(() => !!params.id) const [colorData, setColorData] = useState() const [commonDataList, setCommonDataList] = useState() @@ -122,6 +127,70 @@ const Detail: React.FC = () => { getTags() }, [pbcBusinessId]) + useEffect(() => { + if (isEdit && params.id) { + productDetailForAdminUsingGet({ productId: parseInt(params.id) }).then((res) => { + if (res.retcode && res.data) { + const data = res.data; + // 处理表单数据 + const formData = { + ...data, + pbcProductCategoryIdList: [data.pbcProductTopCategoryId, data.pbcProductParentCategoryId, data.pbcProductCategoryId], + pbcZone: data.pbcProductOriginalProvince ? [data.pbcProductOriginalProvince, data.pbcProductOriginalCity] : undefined, + pbcProductImages: data.pbcProductImages ? data.pbcProductImages.split(',').map((url: string) => ({ + uid: url, + name: url, + status: 'done', + url: url, + response: { data: url } + })) : [], + pbcProductDetailImages: data.pbcProductDetailImages ? data.pbcProductDetailImages.split(',').map((url: string) => ({ + uid: url, + name: url, + status: 'done', + url: url, + response: { data: url } + })) : [], + colorItems: data.colorDataList?.map((item: any) => ({ + name: item.pbcCommonDataSystem, + pbcSkuPrice: item.pbcSkuPrice, + pbcSkuStock: item.pbcSkuStock, + value: item.pbcColorImageUrl ? [{ + uid: item.pbcColorImageUrl, + name: item.pbcColorImageUrl, + status: 'done', + url: item.pbcColorImageUrl, + response: { data: item.pbcColorImageUrl } + }] : [] + })) + }; + + // 设置标签选中状态 + if (data.labelAssociationList) { + setSelectedTags(data.labelAssociationList.map((item: any) => item.pbcId)); + } + + // 设置商户ID以加载标签 + if (data.pbcBusinessId) { + setPbcBusinessId(data.pbcBusinessId); + } + + if (data.pbcProductCategoryId) { + getRecordByL3CategoryIdUsingGet({ l3CategoryId: data.pbcProductCategoryId }).then(res => { + if (res.retcode && res.data) { + setColorData(res.data.colorData) + setCommonDataList(res.data.commonDataList) + } + }) + } + + // 设置表单数据 + formRef.current?.setFieldsValue(formData); + } + }); + } + }, [isEdit, params.id]); + // useEffect(() => { // if (inputVisible) { // inputRef.current?.focus(); @@ -175,6 +244,8 @@ const Detail: React.FC = () => { pbcSystemName: '颜色', pbcSystemInputType: 'text', pbcCommonDataSystem: element.name, + pbcSkuPrice: element.pbcSkuPrice, + pbcSkuStock: element.pbcSkuStock, pbcColorImageUrl: element.value.length > 0 ? element.value[0].response.data : '' }) } @@ -258,7 +329,7 @@ const Detail: React.FC = () => { 返回 , ]} > @@ -321,14 +392,10 @@ const Detail: React.FC = () => { - + - + @@ -413,18 +480,33 @@ const Detail: React.FC = () => { (
{listDom} @@ -432,13 +514,45 @@ const Detail: React.FC = () => {
)} > - - - + - - + ]} + fieldProps={{ + style: { width: '100%' } + }} + /> +
+ + +
+ + + + {/* = () => { return isLt2M || Upload.LIST_IGNORE; }, onPreview: async (file) => { - if (file.uid === '-1') { window.open(file.url); } @@ -465,14 +578,15 @@ const Detail: React.FC = () => { } }, listType: 'picture-card', + style: { width: '100%' } }} rules={[ { required: true, message: '请上传颜色图片' }, ]} max={1} /> - -
+ */} +
: null} diff --git a/src/pages/ProductList/index.less b/src/pages/ProductList/index.less new file mode 100644 index 0000000..6424a3e --- /dev/null +++ b/src/pages/ProductList/index.less @@ -0,0 +1,3 @@ +.ant-upload-list .ant-upload-list-item-container > div { + height: 100%; +} \ No newline at end of file diff --git a/src/pages/ProductList/index.tsx b/src/pages/ProductList/index.tsx index 02296af..72c9c78 100644 --- a/src/pages/ProductList/index.tsx +++ b/src/pages/ProductList/index.tsx @@ -3,12 +3,13 @@ import { getPbcBusinessListUsingPost } from '@/services/pop-b2b2c/pbcBusinessCon import { listAdminTreeUsingGet } from '@/services/pop-b2b2c/pbcCategoryController'; import { changeProductStateForAdminUsingGet, + deleteProductForAdminUsingGet, getProductPageForAdminUsingPost, } from '@/services/pop-b2b2c/pbcProductController'; import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; import { PageContainer } from '@ant-design/pro-layout'; -import { Access, Link, useAccess, history } from '@umijs/max'; -import { Button, message } from 'antd'; +import { Access, useAccess, history } from '@umijs/max'; +import { Button, message, Popconfirm, Space } from 'antd'; import moment from 'moment'; import React, { useRef } from 'react'; @@ -126,13 +127,22 @@ const TableList: React.FC<{}> = () => { { title: '操作', fixed: 'right', + width: 300, valueType: 'option', render: (text, record) => ( - - 详情 + + + + + {record.pbcState === 1 ? ( )} - + + { + deleteProductForAdminUsingGet({ pcbId: record.pbcId || 0 }).then( + (res) => { + if (res.retcode) { + message.success('已删除'); + actionRef.current?.reload(); + } else { + message.error(res.retmsg); + } + }, + ); + }} + > + + + + ), }, ]; diff --git a/src/services/pop-b2b2c/errorController.ts b/src/services/pop-b2b2c/errorController.ts index f29cc7f..5f0967b 100644 --- a/src/services/pop-b2b2c/errorController.ts +++ b/src/services/pop-b2b2c/errorController.ts @@ -2,41 +2,41 @@ /* eslint-disable */ import request from '@/utils/request'; -/** error GET /error */ -export async function errorUsingGet(options?: { [key: string]: any }) { - return request>('/error', { +/** errorHtml GET /error */ +export async function errorHtmlUsingGet(options?: { [key: string]: any }) { + return request('/error', { method: 'GET', ...(options || {}), }); } -/** error PUT /error */ -export async function errorUsingPut(options?: { [key: string]: any }) { - return request>('/error', { +/** errorHtml PUT /error */ +export async function errorHtmlUsingPut(options?: { [key: string]: any }) { + return request('/error', { method: 'PUT', ...(options || {}), }); } -/** error POST /error */ -export async function errorUsingPost(options?: { [key: string]: any }) { - return request>('/error', { +/** errorHtml POST /error */ +export async function errorHtmlUsingPost(options?: { [key: string]: any }) { + return request('/error', { method: 'POST', ...(options || {}), }); } -/** error DELETE /error */ -export async function errorUsingDelete(options?: { [key: string]: any }) { - return request>('/error', { +/** errorHtml DELETE /error */ +export async function errorHtmlUsingDelete(options?: { [key: string]: any }) { + return request('/error', { method: 'DELETE', ...(options || {}), }); } -/** error PATCH /error */ -export async function errorUsingPatch(options?: { [key: string]: any }) { - return request>('/error', { +/** errorHtml PATCH /error */ +export async function errorHtmlUsingPatch(options?: { [key: string]: any }) { + return request('/error', { method: 'PATCH', ...(options || {}), }); diff --git a/src/services/pop-b2b2c/pbcBusinessController.ts b/src/services/pop-b2b2c/pbcBusinessController.ts index 3e871e7..caf58ee 100644 --- a/src/services/pop-b2b2c/pbcBusinessController.ts +++ b/src/services/pop-b2b2c/pbcBusinessController.ts @@ -81,6 +81,21 @@ export async function getBusinessPosterUsingPost( }); } +/** 通过店铺id得到所有卖家账号 GET /b2b2c/pbcbusiness/getBusinessUserList */ +export async function getBusinessUserListUsingGet( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.getBusinessUserListUsingGETParams, + options?: { [key: string]: any }, +) { + return request('/b2b2c/pbcbusiness/getBusinessUserList', { + method: 'GET', + params: { + ...params, + }, + ...(options || {}), + }); +} + /** 商戶端获得所有首页模板 GET /b2b2c/pbcbusiness/getIndexPageTemplate */ export async function getIndexPageTemplateUsingGet(options?: { [key: string]: any }) { return request('/b2b2c/pbcbusiness/getIndexPageTemplate', { @@ -209,6 +224,14 @@ export async function pbcBusinessPageUsingPost(body: API.PageVO, options?: { [ke }); } +/** poster POST /b2b2c/pbcbusiness/poster */ +export async function posterUsingPost(options?: { [key: string]: any }) { + return request('/b2b2c/pbcbusiness/poster', { + method: 'POST', + ...(options || {}), + }); +} + /** 商家二维码 商家二维码 GET /b2b2c/pbcbusiness/qrcode */ export async function qrcodeUsingGet(options?: { [key: string]: any }) { return request('/b2b2c/pbcbusiness/qrcode', { diff --git a/src/services/pop-b2b2c/pbcOrderController.ts b/src/services/pop-b2b2c/pbcOrderController.ts index 262bfb2..cbdfe4c 100644 --- a/src/services/pop-b2b2c/pbcOrderController.ts +++ b/src/services/pop-b2b2c/pbcOrderController.ts @@ -33,7 +33,7 @@ export async function deliverGoodForOrderAdminUsingGet( ); } -/** 买家取消订单。这里暂时限定只有待出样状态的订单才能够取消掉 GET /b2b2c/pbcOrder/cancelOrderForBuyer/${param0} */ +/** 买家订单。这里暂时限定只有待出样状态的订单才能够取消掉 GET /b2b2c/pbcOrder/cancelOrderForBuyer/${param0} */ export async function cancelOrderForBuyerUsingGet( // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) params: API.cancelOrderForBuyerUsingGETParams, @@ -178,6 +178,20 @@ export async function getOrderPageForBuyerUsingPost( }); } +/** 订单核销 订单核销 GET /b2b2c/pbcOrder/orderCheck/${param0} */ +export async function orderCheckUsingGet( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.orderCheckUsingGETParams, + options?: { [key: string]: any }, +) { + const { orderNo: param0, ...queryParams } = params; + return request(`/b2b2c/pbcOrder/orderCheck/${param0}`, { + method: 'GET', + params: { ...queryParams }, + ...(options || {}), + }); +} + /** 后台获取订单详情 分页 GET /b2b2c/pbcOrder/orderDetailForAdmin/${param0} */ export async function orderDetailForAdminUsingGet( // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) @@ -220,6 +234,34 @@ export async function orderDetailForBuyerUsingGet( }); } +/** 根据订单编号获取手机号 根据订单编号获取手机号 GET /b2b2c/pbcOrder/orderMobile/${param0} */ +export async function orderMobileUsingGet( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.orderMobileUsingGETParams, + options?: { [key: string]: any }, +) { + const { orderNo: param0, ...queryParams } = params; + return request(`/b2b2c/pbcOrder/orderMobile/${param0}`, { + method: 'GET', + params: { ...queryParams }, + ...(options || {}), + }); +} + +/** 根据订单号更新订单抽奖状态 根据订单号更新订单抽奖状态 GET /b2b2c/pbcOrder/orderPrize/${param0} */ +export async function orderPrizeUsingGet( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.orderPrizeUsingGETParams, + options?: { [key: string]: any }, +) { + const { orderNo: param0, ...queryParams } = params; + return request(`/b2b2c/pbcOrder/orderPrize/${param0}`, { + method: 'GET', + params: { ...queryParams }, + ...(options || {}), + }); +} + /** 买家下单接口 POST /b2b2c/pbcOrder/saveOrderForBuyer */ export async function saveOrderForBuyerUsingPost( body: API.PbcOrder_[], diff --git a/src/services/pop-b2b2c/pbcProductController.ts b/src/services/pop-b2b2c/pbcProductController.ts index 6f6dcab..853ecf4 100644 --- a/src/services/pop-b2b2c/pbcProductController.ts +++ b/src/services/pop-b2b2c/pbcProductController.ts @@ -225,7 +225,7 @@ export async function gogoYayaUsingPost(options?: { [key: string]: any }) { } /** 根据商品id生成商品分享海报 分享海报 POST /b2b2c/pbcproduct/poster */ -export async function posterUsingPost( +export async function posterUsingPost1( body: API.PbcProductPosterVO, options?: { [key: string]: any }, ) { diff --git a/src/services/pop-b2b2c/pbcRequirementController.ts b/src/services/pop-b2b2c/pbcRequirementController.ts index e338df9..3d790de 100644 --- a/src/services/pop-b2b2c/pbcRequirementController.ts +++ b/src/services/pop-b2b2c/pbcRequirementController.ts @@ -179,7 +179,7 @@ export async function getAddressForRequirementUsingGet( ); } -/** 当前登陆人,获取自己的跟进中、已被采纳、已取消的需求各自的数量 需求 GET /b2b2c/pbcRequirement/getRequirementCountForFront */ +/** 当前登陆人,获取自己跟进别人需求的跟进中、已被采纳、已取消的需求各自的数量 需求 GET /b2b2c/pbcRequirement/getRequirementCountForFront */ export async function getRequirementCountForFrontUsingGet(options?: { [key: string]: any }) { return request( '/b2b2c/pbcRequirement/getRequirementCountForFront', diff --git a/src/services/pop-b2b2c/pbcUserBusinessController.ts b/src/services/pop-b2b2c/pbcUserBusinessController.ts index d2bb179..68c2e95 100644 --- a/src/services/pop-b2b2c/pbcUserBusinessController.ts +++ b/src/services/pop-b2b2c/pbcUserBusinessController.ts @@ -113,6 +113,14 @@ export async function checkMemberShipUsingGet( }); } +/** 默认商户 默认商户 GET /b2b2c/pbcuserbusiness/defaultBusiness */ +export async function defaultBusinessUsingGet(options?: { [key: string]: any }) { + return request('/b2b2c/pbcuserbusiness/defaultBusiness', { + method: 'GET', + ...(options || {}), + }); +} + /** 买家申请成为商户会员,等待商户审核,并且默认切换成该商户 新增 GET /b2b2c/pbcuserbusiness/saveuserbusinessrecord */ export async function saveUserBusinessRecordUsingGet( // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) diff --git a/src/services/pop-b2b2c/pbcUsersController.ts b/src/services/pop-b2b2c/pbcUsersController.ts index 4918f3e..8a46b5b 100644 --- a/src/services/pop-b2b2c/pbcUsersController.ts +++ b/src/services/pop-b2b2c/pbcUsersController.ts @@ -94,11 +94,25 @@ export async function getPageUsingPost3(body: API.UserPageDTO, options?: { [key: }); } -/** 会员详情 GET /b2b2c/pbcusers/getUserDetailInfo/${param0} */ +/** 会员详情 GET /b2b2c/pbcusers/getUseInfo/${param0} */ export async function getUserDetailInfoUsingGet( // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) params: API.getUserDetailInfoUsingGETParams, options?: { [key: string]: any }, +) { + const { pbcUserMobile: param0, ...queryParams } = params; + return request(`/b2b2c/pbcusers/getUseInfo/${param0}`, { + method: 'GET', + params: { ...queryParams }, + ...(options || {}), + }); +} + +/** 会员详情 GET /b2b2c/pbcusers/getUserDetailInfo/${param0} */ +export async function getUserDetailInfoUsingGet1( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.getUserDetailInfoUsingGET1Params, + options?: { [key: string]: any }, ) { const { userId: param0, ...queryParams } = params; return request(`/b2b2c/pbcusers/getUserDetailInfo/${param0}`, { @@ -258,6 +272,14 @@ export async function updateMemberRecordStateUsingGet( }); } +/** updatePrizeStatus POST /b2b2c/pbcusers/updatePrizeStatus */ +export async function updatePrizeStatusUsingPost(options?: { [key: string]: any }) { + return request('/b2b2c/pbcusers/updatePrizeStatus', { + method: 'POST', + ...(options || {}), + }); +} + /** updateRecordState 后台修改用户状态,保存前端传过来的状态 GET /b2b2c/pbcusers/updaterecordstate */ export async function updateUserRecordStateUsingGet( // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) @@ -287,3 +309,17 @@ export async function userListByConditionUsingPost( ...(options || {}), }); } + +/** 核销完善资料抽奖信息 GET /b2b2c/pbcusers/writeOffPrize/${param0} */ +export async function writeOffPrizeUsingGet( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.writeOffPrizeUsingGETParams, + options?: { [key: string]: any }, +) { + const { pbcUserMobile: param0, ...queryParams } = params; + return request(`/b2b2c/pbcusers/writeOffPrize/${param0}`, { + method: 'GET', + params: { ...queryParams }, + ...(options || {}), + }); +} diff --git a/src/services/pop-b2b2c/typings.d.ts b/src/services/pop-b2b2c/typings.d.ts index 2f05204..c5161fe 100644 --- a/src/services/pop-b2b2c/typings.d.ts +++ b/src/services/pop-b2b2c/typings.d.ts @@ -938,6 +938,11 @@ declare namespace API { lv3CategoryId: number; }; + type getBusinessUserListUsingGETParams = { + /** businessId */ + businessId: number; + }; + type getEmailVerificationCodeUsingGETParams = { /** email */ email: string; @@ -1005,11 +1010,16 @@ declare namespace API { teamId: number; }; - type getUserDetailInfoUsingGETParams = { + type getUserDetailInfoUsingGET1Params = { /** userId */ userId: number; }; + type getUserDetailInfoUsingGETParams = { + /** pbcUserMobile */ + pbcUserMobile: string; + }; + type getUserProductScanRecordUsingGETParams = { /** userId */ userId: number; @@ -1468,6 +1478,11 @@ declare namespace API { type: string; }; + type orderCheckUsingGETParams = { + /** orderNo */ + orderNo: string; + }; + type orderDetailForAdminUsingGETParams = { /** orderId */ orderId: number; @@ -1488,6 +1503,16 @@ declare namespace API { column?: string; }; + type orderMobileUsingGETParams = { + /** orderNo */ + orderNo: string; + }; + + type orderPrizeUsingGETParams = { + /** orderNo */ + orderNo: string; + }; + type PagePbcBusiness_ = { countId?: string; current?: number; @@ -2012,6 +2037,8 @@ declare namespace API { pbcBusinessUserPostUrl?: string; /** 商家用户二维码:团队成员展示的二维码均不相同,此处为二维码链接 */ pbcBusinessUserQrCode?: string; + /** 商家用户二维码:团队成员展示的二维码均不相同,此处为二维码链接 */ + pbcBusinessUserSunCode?: string; /** 创建时间 */ pbcCreateAt?: string; /** 创建人 */ @@ -2382,6 +2409,8 @@ declare namespace API { image?: string; /** 海报配置id,不传默认用第一个 */ pbcBusinessPostConfigId?: number; + /** 海报类型:1.h5 2.小程序 */ + postType?: number; }; type PbcImageSearchDTO = { @@ -2614,6 +2643,10 @@ declare namespace API { pbcOrderType?: number; /** 自取时间 */ pbcPickupTime?: string; + /** 抽奖二维码 */ + pbcPrizeCode?: string; + /** 订单状态:抽奖状态 */ + pbcPrizeState?: number; /** 订单里商品名称的组合,用于应付后台筛选,不用传 */ pbcProductCombine?: string; /** 状态,0是删除,1是正常,2是作废 */ @@ -2901,6 +2934,8 @@ declare namespace API { pbcProductParentCategoryId?: number; /** 商品中类 */ pbcProductParentCategoryName?: string; + /** 商品价格 */ + pbcProductPrice?: string; /** 货架号 */ pbcProductShelfNumber?: string; /** 商品库存,不用传 */ @@ -3103,6 +3138,8 @@ declare namespace API { type PbcProductPosterVO = { /** 图片url */ image?: string; + /** 海报类型:1.h5 2.小程序 */ + postType?: number; /** 商品id */ productId?: number; }; @@ -3318,6 +3355,7 @@ declare namespace API { pbcUpdateByUserName?: string; /** 申请人的userId,不需要传 */ pbcUserId?: number; + pbcUsers?: PbcUsers; /** 手机验证码 */ pbcValidCode?: string; }; @@ -3433,6 +3471,7 @@ declare namespace API { }; type PbcRequirement_ = { + adoptUsers?: PbcUsers; /** 商户id,不要使用这个参数 */ businessId?: number; /** 当前页 */ @@ -3468,11 +3507,19 @@ declare namespace API { pbcId?: number; /** 需求图片 */ pbcImages?: string; + /** 抽奖二维码 */ + pbcPrizeCode?: string; + /** 订单状态:抽奖状态 */ + pbcPrizeState?: number; /** 采纳的用户所在商户的id */ pbcPurchaseAgentId?: number; pbcPurchaseAgentInfo?: PbcPurchaseAgentInfo_; /** 当类型是指定小哥时,必传 */ pbcPurchaseAgentInfoList?: PbcPurchaseAgentInfo_[]; + /** 需求完成时间 */ + pbcRequirementCompletionTime?: string; + /** 需求单号,不用传,后台生成 */ + pbcRequirementNo?: string; pbcRequirementOrderInfo?: PbcRequirementOrderInfo_; /** 状态,0是删除,1是正常,2是作废 */ pbcState?: number; @@ -4039,6 +4086,8 @@ declare namespace API { current?: number; /** 条数 */ pageSize?: number; + /** 用户类型:详细信息:专职采购商,鞋企采购商 */ + pbcBusinessDetailType?: string; /** 商户id */ pbcBusinessId?: number; pbcBusinessInfo?: PbcBusiness; @@ -4047,16 +4096,24 @@ declare namespace API { /** 商户认证状态,false是未认证,true是已认证 */ pbcBusinessState?: boolean; pbcBusinessTeam?: PbcBusinessTeam_; + /** 用户类型:采购员、商家、从业者、其他 */ + pbcBusinessType?: string; + /** 公司 */ + pbcCompany?: string; /** 创建时间 */ pbcCreateAt?: string; /** 创建人 */ pbcCreateBy?: number; /** 创建人 */ pbcCreateByUserName?: string; + /** 是否抽奖:0.未完善,1.待抽奖,2.已抽奖 */ + pbcHasPrize?: number; /** 主键 */ pbcId?: number; /** 用户小程序的open id */ pbcOpenId?: string; + /** 抽奖二维码 */ + pbcPrizeCode?: string; pbcSourceUser?: PbcUsers; /** 状态,0是删除,1是正常,2是作废 */ pbcState?: number; @@ -4268,6 +4325,8 @@ declare namespace API { }; type PbcUsers = { + /** 用户类型:详细信息:专职采购商,鞋企采购商 */ + pbcBusinessDetailType?: string; /** 商户id */ pbcBusinessId?: number; pbcBusinessInfo?: PbcBusiness; @@ -4276,16 +4335,24 @@ declare namespace API { /** 商户认证状态,false是未认证,true是已认证 */ pbcBusinessState?: boolean; pbcBusinessTeam?: PbcBusinessTeam_; + /** 用户类型:采购员、商家、从业者、其他 */ + pbcBusinessType?: string; + /** 公司 */ + pbcCompany?: string; /** 创建时间 */ pbcCreateAt?: string; /** 创建人 */ pbcCreateBy?: number; /** 创建人 */ pbcCreateByUserName?: string; + /** 是否抽奖:0.未完善,1.待抽奖,2.已抽奖 */ + pbcHasPrize?: number; /** 主键 */ pbcId?: number; /** 用户小程序的open id */ pbcOpenId?: string; + /** 抽奖二维码 */ + pbcPrizeCode?: string; pbcSourceUser?: PbcUsers; /** 状态,0是删除,1是正常,2是作废 */ pbcState?: number; @@ -4328,6 +4395,8 @@ declare namespace API { type PbcUsersVO = { /** 用户权限集 */ currentAuthority?: string[]; + /** 用户类型:详细信息:专职采购商,鞋企采购商 */ + pbcBusinessDetailType?: string; /** 商户id */ pbcBusinessId?: number; pbcBusinessInfo?: PbcBusiness; @@ -4336,16 +4405,24 @@ declare namespace API { /** 商户认证状态,false是未认证,true是已认证 */ pbcBusinessState?: boolean; pbcBusinessTeam?: PbcBusinessTeam_; + /** 用户类型:采购员、商家、从业者、其他 */ + pbcBusinessType?: string; + /** 公司 */ + pbcCompany?: string; /** 创建时间 */ pbcCreateAt?: string; /** 创建人 */ pbcCreateBy?: number; /** 创建人 */ pbcCreateByUserName?: string; + /** 是否抽奖:0.未完善,1.待抽奖,2.已抽奖 */ + pbcHasPrize?: number; /** 主键 */ pbcId?: number; /** 用户小程序的open id */ pbcOpenId?: string; + /** 抽奖二维码 */ + pbcPrizeCode?: string; pbcSourceUser?: PbcUsers; /** 状态,0是删除,1是正常,2是作废 */ pbcState?: number; @@ -4686,8 +4763,18 @@ declare namespace API { }; type UserDTO = { + /** 用户类型:详细信息:专职采购商,鞋企采购商 */ + pbcBusinessDetailType?: string; + /** 用户类型:1.采购员 2.设计师 3.代购小哥 4.鞋材商家 5.鞋企 6.其他 */ + pbcBusinessType?: string; + /** 公司 */ + pbcCompany?: string; + /** 是否抽奖:0.未完善,1.待抽奖,2.已抽奖 */ + pbcHasPrize?: number; /** 用户id */ pbcId?: number; + /** 抽奖二维码 */ + pbcPrizeCode?: string; /** 用户头像 */ pbcUserImage?: string; /** 用户姓名 */ @@ -4757,6 +4844,11 @@ declare namespace API { contentType?: string; }; + type writeOffPrizeUsingGETParams = { + /** pbcUserMobile */ + pbcUserMobile: string; + }; + type wxMiniAppBindAccountUsingGETParams = { /** loginCode */ loginCode: string; diff --git a/src/utils/cropImage.ts b/src/utils/cropImage.ts new file mode 100644 index 0000000..6c116b8 --- /dev/null +++ b/src/utils/cropImage.ts @@ -0,0 +1,101 @@ +export const createImage = (url: string) => + new Promise((resolve, reject) => { + const image = new Image() + image.addEventListener('load', () => resolve(image)) + image.addEventListener('error', (error) => reject(error)) + image.setAttribute('crossOrigin', 'anonymous') // needed to avoid cross-origin issues on CodeSandbox + image.src = url + }) + +export function getRadianAngle(degreeValue: number) { + return (degreeValue * Math.PI) / 180 +} + +/** + * Returns the new bounding area of a rotated rectangle. + */ +export function rotateSize(width: number, height: number, rotation: number) { + const rotRad = getRadianAngle(rotation) + + return { + width: + Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height), + height: + Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height), + } +} + +/** + * This function was adapted from the one in the ReadMe of https://github.com/DominicTobias/react-image-crop + */ +export default async function getCroppedImg( + imageSrc: string, + pixelCrop: any, + rotation = 0, + flip = { horizontal: false, vertical: false } +) { + const image = await createImage(imageSrc) + const canvas = document.createElement('canvas') + const ctx = canvas.getContext('2d') + + if (!ctx) { + return null + } + + const rotRad = getRadianAngle(rotation) + + // calculate bounding box of the rotated image + const { width: bBoxWidth, height: bBoxHeight } = rotateSize( + image.width, + image.height, + rotation + ) + + // set canvas size to match the bounding box + canvas.width = bBoxWidth + canvas.height = bBoxHeight + + // translate canvas context to a central location to allow rotating and flipping around the center + ctx.translate(bBoxWidth / 2, bBoxHeight / 2) + ctx.rotate(rotRad) + ctx.scale(flip.horizontal ? -1 : 1, flip.vertical ? -1 : 1) + ctx.translate(-image.width / 2, -image.height / 2) + + // draw rotated image + ctx.drawImage(image, 0, 0) + + const croppedCanvas = document.createElement('canvas') + + const croppedCtx = croppedCanvas.getContext('2d') + + if (!croppedCtx) { + return null + } + + // Set the size of the cropped canvas + croppedCanvas.width = pixelCrop.width + croppedCanvas.height = pixelCrop.height + + // Draw the cropped image onto the new canvas + croppedCtx.drawImage( + canvas, + pixelCrop.x, + pixelCrop.y, + pixelCrop.width, + pixelCrop.height, + 0, + 0, + pixelCrop.width, + pixelCrop.height + ) + + // As Base64 string + // return croppedCanvas.toDataURL('image/jpeg'); + + // As a blob + return new Promise((resolve) => { + croppedCanvas.toBlob((file: any) => { + resolve(file) + }, 'image/jpeg') + }) +} \ No newline at end of file