dev-v2
Joe 5 months ago
parent 30244c1598
commit 25476835e3

@ -222,6 +222,12 @@ export default [
hideInMenu: true, hideInMenu: true,
component: './ProductList/add', component: './ProductList/add',
}, },
{
name: '编辑商品',
path: 'edit/:id',
hideInMenu: true,
component: './ProductList/add',
},
{ {
name: '详情', name: '详情',
path: 'detail/:id', path: 'detail/:id',

@ -50,6 +50,7 @@ export default function access(initialState: { currentUser?: API.PbcUsersVO | un
productQuery: false, productQuery: false,
productAdd: false, productAdd: false,
productUpdateState: false, productUpdateState: false,
productRemove: false,
content: false, content: false,
contentQuery: false, contentQuery: false,
contentSave: false, contentSave: false,

@ -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;
}

@ -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<UploadFile<any>>) => void;
};
export default ((props) => {
return (
<ImgCrop rotationSlider>
<Upload
name="file"
accept="image/*"
listType="picture-card"
headers={{
authorization: localStorage.getItem('token') ?? '',
}}
maxCount={1}
action={process.env.BASE_URL + '/oss/imgUpload'}
style={{ width: '100%' }}
beforeUpload={(file: RcFile) => {
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 && (
<div>
{<PlusOutlined />}
<div style={{ marginTop: 8 }}></div>
</div>
)}
</Upload>
</ImgCrop>
);
}) as React.FC<ImageBase64UploadProps>;

@ -124,6 +124,12 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
status: 'done', status: 'done',
url: props.values.pbcPicAddress, 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 pbcContent: props.values.pbcContent
}} }}
onOpenChange={(visible) => { onOpenChange={(visible) => {
@ -157,6 +163,10 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
label: '视频', label: '视频',
value: 2, value: 2,
}, },
{
label: '文件',
value: 3,
},
]} ]}
rules={[ rules={[
{ {
@ -169,6 +179,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
setPbcType(e.target.value) setPbcType(e.target.value)
formRef.current?.setFieldValue('pbcImage', []); formRef.current?.setFieldValue('pbcImage', []);
formRef.current?.setFieldValue('pbcVideo', []); formRef.current?.setFieldValue('pbcVideo', []);
formRef.current?.setFieldValue('pbcFile', []);
}, },
}} }}
/> />
@ -218,12 +229,12 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
]} ]}
/> : /> :
<ProFormUploadButton <ProFormUploadButton
label="上传视频" label={pbcType === 2 ? "上传视频" : "上传文件"}
name="pbcVideo" name={pbcType === 2 ? "pbcVideo" : "pbcFile"}
max={1} max={1}
fieldProps={{ fieldProps={{
name: 'file', name: 'file',
accept: 'video/mp4', accept: pbcType === 2 ? 'video/mp4' : '.pdf',
multiple: true, multiple: true,
headers: { headers: {
authorization: localStorage.getItem('token') ?? '', authorization: localStorage.getItem('token') ?? '',
@ -233,8 +244,13 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
case 'done': case 'done':
if (info.file.response.retcode === 0) { if (info.file.response.retcode === 0) {
message.error(info.file.response.retmsg); message.error(info.file.response.retmsg);
formRef.current?.setFieldValue('pbcVideo', []) if (pbcType === 2) {
} else if (info.file.response && info.file.response.retcode) { 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; const videoUrl = info.file.response.data;
generateVideoThumbnail(videoUrl); generateVideoThumbnail(videoUrl);
@ -248,7 +264,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
beforeUpload(file: RcFile) { beforeUpload(file: RcFile) {
const isLt30M = file.size / 1024 / 1024 < 30; const isLt30M = file.size / 1024 / 1024 < 30;
if (!isLt30M) { if (!isLt30M) {
message.error('视频大小不能超过30MB!'); message.error(`${pbcType === 2 ? '视频' : '文件'}大小不能超过30MB!`);
} }
return isLt30M || Upload.LIST_IGNORE; return isLt30M || Upload.LIST_IGNORE;
}, },
@ -263,10 +279,10 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
listType: 'picture-card', listType: 'picture-card',
}} }}
rules={[ rules={[
{ required: true, message: '请上传视频' }, { required: true, message: `请上传${pbcType === 2 ? '视频' : '文件'}'` },
]} ]}
/>} />}
<ProForm.Item {pbcType !== 3 ? <ProForm.Item
name="pbcContent" name="pbcContent"
label="创新服务内容" label="创新服务内容"
rules={[ rules={[
@ -277,7 +293,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
]} ]}
> >
<Editor /> <Editor />
</ProForm.Item> </ProForm.Item> : null}
</DrawerForm> </DrawerForm>
); );
}; };

@ -98,6 +98,7 @@ const TableList: React.FC<any> = () => {
valueEnum: { valueEnum: {
1: '图片', 1: '图片',
2: '视频', 2: '视频',
3: '文件',
}, },
}, },
{ {

@ -2,7 +2,7 @@ import Constants from '@/constants';
import { getPbcBusinessListUsingPost } from '@/services/pop-b2b2c/pbcBusinessController'; import { getPbcBusinessListUsingPost } from '@/services/pop-b2b2c/pbcBusinessController';
import { listAdminTreeUsingGet } from '@/services/pop-b2b2c/pbcCategoryController'; import { listAdminTreeUsingGet } from '@/services/pop-b2b2c/pbcCategoryController';
import { getRecordByL3CategoryIdUsingGet } from '@/services/pop-b2b2c/pbcCommonDataController'; 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 { getCities } from '@/utils/cities';
import { import {
ProCard, ProCard,
@ -24,6 +24,9 @@ import Upload, { RcFile, UploadFile } from 'antd/es/upload';
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { CSS } from '@dnd-kit/utilities'; import { CSS } from '@dnd-kit/utilities';
import { getLabelListForAdminUsingPost } from '@/services/pop-b2b2c/pbcProductLabelConfigController'; import { getLabelListForAdminUsingPost } from '@/services/pop-b2b2c/pbcProductLabelConfigController';
import { useParams } from 'react-router-dom';
import './index.less'
import CropImage from '@/components/CropImage';
interface DraggableUploadListItemProps { interface DraggableUploadListItemProps {
originNode: React.ReactElement<any, string | React.JSXElementConstructor<any>>; originNode: React.ReactElement<any, string | React.JSXElementConstructor<any>>;
@ -57,7 +60,9 @@ const DraggableUploadListItem = ({ originNode, file }: DraggableUploadListItemPr
}; };
const Detail: React.FC<any> = () => { const Detail: React.FC<any> = () => {
const params = useParams();
const [cities] = useState(() => getCities()) const [cities] = useState(() => getCities())
const [isEdit] = useState(() => !!params.id)
const [colorData, setColorData] = useState<API.PbcCommonData[]>() const [colorData, setColorData] = useState<API.PbcCommonData[]>()
const [commonDataList, setCommonDataList] = useState<API.PbcCommonData[]>() const [commonDataList, setCommonDataList] = useState<API.PbcCommonData[]>()
@ -122,6 +127,70 @@ const Detail: React.FC<any> = () => {
getTags() getTags()
}, [pbcBusinessId]) }, [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(() => { // useEffect(() => {
// if (inputVisible) { // if (inputVisible) {
// inputRef.current?.focus(); // inputRef.current?.focus();
@ -175,6 +244,8 @@ const Detail: React.FC<any> = () => {
pbcSystemName: '颜色', pbcSystemName: '颜色',
pbcSystemInputType: 'text', pbcSystemInputType: 'text',
pbcCommonDataSystem: element.name, pbcCommonDataSystem: element.name,
pbcSkuPrice: element.pbcSkuPrice,
pbcSkuStock: element.pbcSkuStock,
pbcColorImageUrl: element.value.length > 0 ? element.value[0].response.data : '' pbcColorImageUrl: element.value.length > 0 ? element.value[0].response.data : ''
}) })
} }
@ -258,7 +329,7 @@ const Detail: React.FC<any> = () => {
</Button>, </Button>,
<Button type="primary" key="submit" onClick={onSave}> <Button type="primary" key="submit" onClick={onSave}>
{isEdit ? '保存' : '创建'}
</Button> </Button>
]} ]}
> >
@ -321,14 +392,10 @@ const Detail: React.FC<any> = () => {
<ProFormCascader label="产地" name="pbcZone" fieldProps={{ options: cities }} /> <ProFormCascader label="产地" name="pbcZone" fieldProps={{ options: cities }} />
</Col> </Col>
<Col span={8}> <Col span={8}>
<ProFormText label="价格" name="pbcProductPrice" rules={[ <ProFormText label="价格" name="pbcProductPrice" fieldProps={{ prefix: '¥' }} />
{ required: true, message: '请输入商品价格' },
]} fieldProps={{ prefix: '¥' }} />
</Col> </Col>
<Col span={8}> <Col span={8}>
<ProFormDigit label="库存" name="pbcProductStock" min={0} fieldProps={{ precision: 0 }} rules={[ <ProFormDigit label="库存" name="pbcProductStock" min={0} fieldProps={{ precision: 0 }} />
{ required: true, message: '请输入商品库存' },
]} />
</Col> </Col>
</Row> </Row>
<Row gutter={20}> <Row gutter={20}>
@ -413,18 +480,33 @@ const Detail: React.FC<any> = () => {
<ProFormList <ProFormList
name="colorItems" name="colorItems"
creatorButtonProps={{ creatorButtonProps={{
creatorButtonText: '新增', creatorButtonText: '新增颜色',
icon: false, icon: false,
type: 'link', type: 'link',
style: { width: 'unset' }, style: {
width: 'unset',
marginTop: 8,
fontSize: 14,
color: '#1890ff'
},
}} }}
copyIconProps={false} copyIconProps={false}
deleteIconProps={{ tooltipText: '删除' }} deleteIconProps={{
tooltipText: '删除'
}}
itemRender={({ listDom, action }) => ( itemRender={({ listDom, action }) => (
<div <div
style={{ style={{
display: 'inline-flex', display: 'inline-flex',
marginInlineEnd: 25, alignItems: 'flex-start',
marginRight: 16,
marginBottom: 16,
padding: 12,
border: '1px solid #f0f0f0',
borderRadius: 4,
backgroundColor: '#fafafa',
width: 'calc(33.33% - 16px)',
minWidth: 300
}} }}
> >
{listDom} {listDom}
@ -432,13 +514,45 @@ const Detail: React.FC<any> = () => {
</div> </div>
)} )}
> >
<Row align="middle" gutter={20}> <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<Col span={12}> <ProFormText
<ProFormText width="sm" name={['name']} placeholder="请输入颜色名" rules={[ width="sm"
name={['name']}
placeholder="请输入颜色名"
rules={[
{ required: true, message: '请输入颜色名' } { required: true, message: '请输入颜色名' }
]} /> ]}
</Col> fieldProps={{
<Col span={12}> style: { width: '100%' }
}}
/>
<div style={{ display: 'flex', gap: 8 }}>
<ProFormText
width="sm"
name="pbcSkuPrice"
placeholder="请输入价格"
fieldProps={{
prefix: '¥',
style: { width: '100%' }
}}
/>
<ProFormDigit
width="sm"
name="pbcSkuStock"
placeholder="请输入库存"
min={0}
fieldProps={{
precision: 0,
style: { width: '100%' }
}}
/>
</div>
<ProForm.Item name={['value']} label="" rules={[
{ required: true, message: '请上传颜色图片' },
]}>
<CropImage />
</ProForm.Item>
{/* <ImgCrop rotationSlider>
<ProFormUploadButton <ProFormUploadButton
name={['value']} name={['value']}
fieldProps={{ fieldProps={{
@ -456,7 +570,6 @@ const Detail: React.FC<any> = () => {
return isLt2M || Upload.LIST_IGNORE; return isLt2M || Upload.LIST_IGNORE;
}, },
onPreview: async (file) => { onPreview: async (file) => {
if (file.uid === '-1') { if (file.uid === '-1') {
window.open(file.url); window.open(file.url);
} }
@ -465,14 +578,15 @@ const Detail: React.FC<any> = () => {
} }
}, },
listType: 'picture-card', listType: 'picture-card',
style: { width: '100%' }
}} }}
rules={[ rules={[
{ required: true, message: '请上传颜色图片' }, { required: true, message: '请上传颜色图片' },
]} ]}
max={1} max={1}
/> />
</Col> </ImgCrop> */}
</Row> </div>
</ProFormList> </ProFormList>
</ProForm.Item> : null} </ProForm.Item> : null}
<Row gutter={20}> <Row gutter={20}>

@ -0,0 +1,3 @@
.ant-upload-list .ant-upload-list-item-container > div {
height: 100%;
}

@ -3,12 +3,13 @@ import { getPbcBusinessListUsingPost } from '@/services/pop-b2b2c/pbcBusinessCon
import { listAdminTreeUsingGet } from '@/services/pop-b2b2c/pbcCategoryController'; import { listAdminTreeUsingGet } from '@/services/pop-b2b2c/pbcCategoryController';
import { import {
changeProductStateForAdminUsingGet, changeProductStateForAdminUsingGet,
deleteProductForAdminUsingGet,
getProductPageForAdminUsingPost, getProductPageForAdminUsingPost,
} from '@/services/pop-b2b2c/pbcProductController'; } from '@/services/pop-b2b2c/pbcProductController';
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { Access, Link, useAccess, history } from '@umijs/max'; import { Access, useAccess, history } from '@umijs/max';
import { Button, message } from 'antd'; import { Button, message, Popconfirm, Space } from 'antd';
import moment from 'moment'; import moment from 'moment';
import React, { useRef } from 'react'; import React, { useRef } from 'react';
@ -126,13 +127,22 @@ const TableList: React.FC<{}> = () => {
{ {
title: '操作', title: '操作',
fixed: 'right', fixed: 'right',
width: 300,
valueType: 'option', valueType: 'option',
render: (text, record) => ( render: (text, record) => (
<span> <Space>
<Link to={'/product/detail/' + record.pbcId}></Link> <Button type='link' size="small" onClick={() => {
history.push('/product/detail/' + record.pbcId)
}}></Button>
<Access accessible={access.productAdd}>
<Button type='link' size="small" onClick={() => {
history.push('/product/edit/' + record.pbcId)
}}></Button>
</Access>
<Access key="config" accessible={access.productUpdateState}> <Access key="config" accessible={access.productUpdateState}>
{record.pbcState === 1 ? ( {record.pbcState === 1 ? (
<Button <Button
size="small"
type="link" type="link"
onClick={() => { onClick={() => {
changeProductStateForAdminUsingGet({ pcbId: record.pbcId || 0, state: 2 }).then( changeProductStateForAdminUsingGet({ pcbId: record.pbcId || 0, state: 2 }).then(
@ -152,6 +162,7 @@ const TableList: React.FC<{}> = () => {
) : ( ) : (
<Button <Button
type="link" type="link"
size="small"
onClick={() => { onClick={() => {
changeProductStateForAdminUsingGet({ pcbId: record.pbcId || 0, state: 1 }).then( changeProductStateForAdminUsingGet({ pcbId: record.pbcId || 0, state: 1 }).then(
(res) => { (res) => {
@ -169,7 +180,28 @@ const TableList: React.FC<{}> = () => {
</Button> </Button>
)} )}
</Access> </Access>
</span> <Access key="remove" accessible={access.productRemove}>
<Popconfirm
title={`确定需要删除该商品?`}
onConfirm={async () => {
deleteProductForAdminUsingGet({ pcbId: record.pbcId || 0 }).then(
(res) => {
if (res.retcode) {
message.success('已删除');
actionRef.current?.reload();
} else {
message.error(res.retmsg);
}
},
);
}}
>
<Button size="small" type="link" danger>
</Button>
</Popconfirm>
</Access>
</Space>
), ),
}, },
]; ];

@ -2,41 +2,41 @@
/* eslint-disable */ /* eslint-disable */
import request from '@/utils/request'; import request from '@/utils/request';
/** error GET /error */ /** errorHtml GET /error */
export async function errorUsingGet(options?: { [key: string]: any }) { export async function errorHtmlUsingGet(options?: { [key: string]: any }) {
return request<Record<string, any>>('/error', { return request<API.ModelAndView>('/error', {
method: 'GET', method: 'GET',
...(options || {}), ...(options || {}),
}); });
} }
/** error PUT /error */ /** errorHtml PUT /error */
export async function errorUsingPut(options?: { [key: string]: any }) { export async function errorHtmlUsingPut(options?: { [key: string]: any }) {
return request<Record<string, any>>('/error', { return request<API.ModelAndView>('/error', {
method: 'PUT', method: 'PUT',
...(options || {}), ...(options || {}),
}); });
} }
/** error POST /error */ /** errorHtml POST /error */
export async function errorUsingPost(options?: { [key: string]: any }) { export async function errorHtmlUsingPost(options?: { [key: string]: any }) {
return request<Record<string, any>>('/error', { return request<API.ModelAndView>('/error', {
method: 'POST', method: 'POST',
...(options || {}), ...(options || {}),
}); });
} }
/** error DELETE /error */ /** errorHtml DELETE /error */
export async function errorUsingDelete(options?: { [key: string]: any }) { export async function errorHtmlUsingDelete(options?: { [key: string]: any }) {
return request<Record<string, any>>('/error', { return request<API.ModelAndView>('/error', {
method: 'DELETE', method: 'DELETE',
...(options || {}), ...(options || {}),
}); });
} }
/** error PATCH /error */ /** errorHtml PATCH /error */
export async function errorUsingPatch(options?: { [key: string]: any }) { export async function errorHtmlUsingPatch(options?: { [key: string]: any }) {
return request<Record<string, any>>('/error', { return request<API.ModelAndView>('/error', {
method: 'PATCH', method: 'PATCH',
...(options || {}), ...(options || {}),
}); });

@ -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<API.AjaxResultListPbcUsers_>('/b2b2c/pbcbusiness/getBusinessUserList', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 商戶端获得所有首页模板 GET /b2b2c/pbcbusiness/getIndexPageTemplate */ /** 商戶端获得所有首页模板 GET /b2b2c/pbcbusiness/getIndexPageTemplate */
export async function getIndexPageTemplateUsingGet(options?: { [key: string]: any }) { export async function getIndexPageTemplateUsingGet(options?: { [key: string]: any }) {
return request<API.AjaxResult>('/b2b2c/pbcbusiness/getIndexPageTemplate', { return request<API.AjaxResult>('/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<any>('/b2b2c/pbcbusiness/poster', {
method: 'POST',
...(options || {}),
});
}
/** 商家二维码 商家二维码 GET /b2b2c/pbcbusiness/qrcode */ /** 商家二维码 商家二维码 GET /b2b2c/pbcbusiness/qrcode */
export async function qrcodeUsingGet(options?: { [key: string]: any }) { export async function qrcodeUsingGet(options?: { [key: string]: any }) {
return request<API.AjaxResultString_>('/b2b2c/pbcbusiness/qrcode', { return request<API.AjaxResultString_>('/b2b2c/pbcbusiness/qrcode', {

@ -33,7 +33,7 @@ export async function deliverGoodForOrderAdminUsingGet(
); );
} }
/** 买家取消订单。这里暂时限定只有待出样状态的订单才能够取消掉 GET /b2b2c/pbcOrder/cancelOrderForBuyer/${param0} */ /** 买家订单。这里暂时限定只有待出样状态的订单才能够取消掉 GET /b2b2c/pbcOrder/cancelOrderForBuyer/${param0} */
export async function cancelOrderForBuyerUsingGet( export async function cancelOrderForBuyerUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象) // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.cancelOrderForBuyerUsingGETParams, 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<API.AjaxResultString_>(`/b2b2c/pbcOrder/orderCheck/${param0}`, {
method: 'GET',
params: { ...queryParams },
...(options || {}),
});
}
/** 后台获取订单详情 分页 GET /b2b2c/pbcOrder/orderDetailForAdmin/${param0} */ /** 后台获取订单详情 分页 GET /b2b2c/pbcOrder/orderDetailForAdmin/${param0} */
export async function orderDetailForAdminUsingGet( export async function orderDetailForAdminUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象) // 叠加生成的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<API.AjaxResultJSONObject_>(`/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<API.AjaxResultString_>(`/b2b2c/pbcOrder/orderPrize/${param0}`, {
method: 'GET',
params: { ...queryParams },
...(options || {}),
});
}
/** 买家下单接口 POST /b2b2c/pbcOrder/saveOrderForBuyer */ /** 买家下单接口 POST /b2b2c/pbcOrder/saveOrderForBuyer */
export async function saveOrderForBuyerUsingPost( export async function saveOrderForBuyerUsingPost(
body: API.PbcOrder_[], body: API.PbcOrder_[],

@ -225,7 +225,7 @@ export async function gogoYayaUsingPost(options?: { [key: string]: any }) {
} }
/** 根据商品id生成商品分享海报 分享海报 POST /b2b2c/pbcproduct/poster */ /** 根据商品id生成商品分享海报 分享海报 POST /b2b2c/pbcproduct/poster */
export async function posterUsingPost( export async function posterUsingPost1(
body: API.PbcProductPosterVO, body: API.PbcProductPosterVO,
options?: { [key: string]: any }, options?: { [key: string]: any },
) { ) {

@ -179,7 +179,7 @@ export async function getAddressForRequirementUsingGet(
); );
} }
/** 当前登陆人,获取自己的跟进中、已被采纳、已取消的需求各自的数量 需求 GET /b2b2c/pbcRequirement/getRequirementCountForFront */ /** 当前登陆人,获取自己跟进别人需求的跟进中、已被采纳、已取消的需求各自的数量 需求 GET /b2b2c/pbcRequirement/getRequirementCountForFront */
export async function getRequirementCountForFrontUsingGet(options?: { [key: string]: any }) { export async function getRequirementCountForFrontUsingGet(options?: { [key: string]: any }) {
return request<API.AjaxResultPbcRequirementAdoptVO_>( return request<API.AjaxResultPbcRequirementAdoptVO_>(
'/b2b2c/pbcRequirement/getRequirementCountForFront', '/b2b2c/pbcRequirement/getRequirementCountForFront',

@ -113,6 +113,14 @@ export async function checkMemberShipUsingGet(
}); });
} }
/** 默认商户 默认商户 GET /b2b2c/pbcuserbusiness/defaultBusiness */
export async function defaultBusinessUsingGet(options?: { [key: string]: any }) {
return request<API.AjaxResult>('/b2b2c/pbcuserbusiness/defaultBusiness', {
method: 'GET',
...(options || {}),
});
}
/** 买家申请成为商户会员,等待商户审核,并且默认切换成该商户 新增 GET /b2b2c/pbcuserbusiness/saveuserbusinessrecord */ /** 买家申请成为商户会员,等待商户审核,并且默认切换成该商户 新增 GET /b2b2c/pbcuserbusiness/saveuserbusinessrecord */
export async function saveUserBusinessRecordUsingGet( export async function saveUserBusinessRecordUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象) // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)

@ -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( export async function getUserDetailInfoUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象) // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.getUserDetailInfoUsingGETParams, params: API.getUserDetailInfoUsingGETParams,
options?: { [key: string]: any }, options?: { [key: string]: any },
) {
const { pbcUserMobile: param0, ...queryParams } = params;
return request<API.AjaxResultPbcUsers_>(`/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; const { userId: param0, ...queryParams } = params;
return request<API.AjaxResultPbcUsers_>(`/b2b2c/pbcusers/getUserDetailInfo/${param0}`, { return request<API.AjaxResultPbcUsers_>(`/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<API.AjaxResult>('/b2b2c/pbcusers/updatePrizeStatus', {
method: 'POST',
...(options || {}),
});
}
/** updateRecordState 后台修改用户状态,保存前端传过来的状态 GET /b2b2c/pbcusers/updaterecordstate */ /** updateRecordState 后台修改用户状态,保存前端传过来的状态 GET /b2b2c/pbcusers/updaterecordstate */
export async function updateUserRecordStateUsingGet( export async function updateUserRecordStateUsingGet(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象) // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
@ -287,3 +309,17 @@ export async function userListByConditionUsingPost(
...(options || {}), ...(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<API.AjaxResultPbcUsers_>(`/b2b2c/pbcusers/writeOffPrize/${param0}`, {
method: 'GET',
params: { ...queryParams },
...(options || {}),
});
}

@ -938,6 +938,11 @@ declare namespace API {
lv3CategoryId: number; lv3CategoryId: number;
}; };
type getBusinessUserListUsingGETParams = {
/** businessId */
businessId: number;
};
type getEmailVerificationCodeUsingGETParams = { type getEmailVerificationCodeUsingGETParams = {
/** email */ /** email */
email: string; email: string;
@ -1005,11 +1010,16 @@ declare namespace API {
teamId: number; teamId: number;
}; };
type getUserDetailInfoUsingGETParams = { type getUserDetailInfoUsingGET1Params = {
/** userId */ /** userId */
userId: number; userId: number;
}; };
type getUserDetailInfoUsingGETParams = {
/** pbcUserMobile */
pbcUserMobile: string;
};
type getUserProductScanRecordUsingGETParams = { type getUserProductScanRecordUsingGETParams = {
/** userId */ /** userId */
userId: number; userId: number;
@ -1468,6 +1478,11 @@ declare namespace API {
type: string; type: string;
}; };
type orderCheckUsingGETParams = {
/** orderNo */
orderNo: string;
};
type orderDetailForAdminUsingGETParams = { type orderDetailForAdminUsingGETParams = {
/** orderId */ /** orderId */
orderId: number; orderId: number;
@ -1488,6 +1503,16 @@ declare namespace API {
column?: string; column?: string;
}; };
type orderMobileUsingGETParams = {
/** orderNo */
orderNo: string;
};
type orderPrizeUsingGETParams = {
/** orderNo */
orderNo: string;
};
type PagePbcBusiness_ = { type PagePbcBusiness_ = {
countId?: string; countId?: string;
current?: number; current?: number;
@ -2012,6 +2037,8 @@ declare namespace API {
pbcBusinessUserPostUrl?: string; pbcBusinessUserPostUrl?: string;
/** 商家用户二维码:团队成员展示的二维码均不相同,此处为二维码链接 */ /** 商家用户二维码:团队成员展示的二维码均不相同,此处为二维码链接 */
pbcBusinessUserQrCode?: string; pbcBusinessUserQrCode?: string;
/** 商家用户二维码:团队成员展示的二维码均不相同,此处为二维码链接 */
pbcBusinessUserSunCode?: string;
/** 创建时间 */ /** 创建时间 */
pbcCreateAt?: string; pbcCreateAt?: string;
/** 创建人 */ /** 创建人 */
@ -2382,6 +2409,8 @@ declare namespace API {
image?: string; image?: string;
/** 海报配置id,不传默认用第一个 */ /** 海报配置id,不传默认用第一个 */
pbcBusinessPostConfigId?: number; pbcBusinessPostConfigId?: number;
/** 海报类型1.h5 2.小程序 */
postType?: number;
}; };
type PbcImageSearchDTO = { type PbcImageSearchDTO = {
@ -2614,6 +2643,10 @@ declare namespace API {
pbcOrderType?: number; pbcOrderType?: number;
/** 自取时间 */ /** 自取时间 */
pbcPickupTime?: string; pbcPickupTime?: string;
/** 抽奖二维码 */
pbcPrizeCode?: string;
/** 订单状态:抽奖状态 */
pbcPrizeState?: number;
/** 订单里商品名称的组合,用于应付后台筛选,不用传 */ /** 订单里商品名称的组合,用于应付后台筛选,不用传 */
pbcProductCombine?: string; pbcProductCombine?: string;
/** 状态,0是删除1是正常2是作废 */ /** 状态,0是删除1是正常2是作废 */
@ -2901,6 +2934,8 @@ declare namespace API {
pbcProductParentCategoryId?: number; pbcProductParentCategoryId?: number;
/** 商品中类 */ /** 商品中类 */
pbcProductParentCategoryName?: string; pbcProductParentCategoryName?: string;
/** 商品价格 */
pbcProductPrice?: string;
/** 货架号 */ /** 货架号 */
pbcProductShelfNumber?: string; pbcProductShelfNumber?: string;
/** 商品库存,不用传 */ /** 商品库存,不用传 */
@ -3103,6 +3138,8 @@ declare namespace API {
type PbcProductPosterVO = { type PbcProductPosterVO = {
/** 图片url */ /** 图片url */
image?: string; image?: string;
/** 海报类型1.h5 2.小程序 */
postType?: number;
/** 商品id */ /** 商品id */
productId?: number; productId?: number;
}; };
@ -3318,6 +3355,7 @@ declare namespace API {
pbcUpdateByUserName?: string; pbcUpdateByUserName?: string;
/** 申请人的userId不需要传 */ /** 申请人的userId不需要传 */
pbcUserId?: number; pbcUserId?: number;
pbcUsers?: PbcUsers;
/** 手机验证码 */ /** 手机验证码 */
pbcValidCode?: string; pbcValidCode?: string;
}; };
@ -3433,6 +3471,7 @@ declare namespace API {
}; };
type PbcRequirement_ = { type PbcRequirement_ = {
adoptUsers?: PbcUsers;
/** 商户id,不要使用这个参数 */ /** 商户id,不要使用这个参数 */
businessId?: number; businessId?: number;
/** 当前页 */ /** 当前页 */
@ -3468,11 +3507,19 @@ declare namespace API {
pbcId?: number; pbcId?: number;
/** 需求图片 */ /** 需求图片 */
pbcImages?: string; pbcImages?: string;
/** 抽奖二维码 */
pbcPrizeCode?: string;
/** 订单状态:抽奖状态 */
pbcPrizeState?: number;
/** 采纳的用户所在商户的id */ /** 采纳的用户所在商户的id */
pbcPurchaseAgentId?: number; pbcPurchaseAgentId?: number;
pbcPurchaseAgentInfo?: PbcPurchaseAgentInfo_; pbcPurchaseAgentInfo?: PbcPurchaseAgentInfo_;
/** 当类型是指定小哥时,必传 */ /** 当类型是指定小哥时,必传 */
pbcPurchaseAgentInfoList?: PbcPurchaseAgentInfo_[]; pbcPurchaseAgentInfoList?: PbcPurchaseAgentInfo_[];
/** 需求完成时间 */
pbcRequirementCompletionTime?: string;
/** 需求单号,不用传,后台生成 */
pbcRequirementNo?: string;
pbcRequirementOrderInfo?: PbcRequirementOrderInfo_; pbcRequirementOrderInfo?: PbcRequirementOrderInfo_;
/** 状态,0是删除1是正常2是作废 */ /** 状态,0是删除1是正常2是作废 */
pbcState?: number; pbcState?: number;
@ -4039,6 +4086,8 @@ declare namespace API {
current?: number; current?: number;
/** 条数 */ /** 条数 */
pageSize?: number; pageSize?: number;
/** 用户类型:详细信息:专职采购商,鞋企采购商 */
pbcBusinessDetailType?: string;
/** 商户id */ /** 商户id */
pbcBusinessId?: number; pbcBusinessId?: number;
pbcBusinessInfo?: PbcBusiness; pbcBusinessInfo?: PbcBusiness;
@ -4047,16 +4096,24 @@ declare namespace API {
/** 商户认证状态false是未认证true是已认证 */ /** 商户认证状态false是未认证true是已认证 */
pbcBusinessState?: boolean; pbcBusinessState?: boolean;
pbcBusinessTeam?: PbcBusinessTeam_; pbcBusinessTeam?: PbcBusinessTeam_;
/** 用户类型:采购员、商家、从业者、其他 */
pbcBusinessType?: string;
/** 公司 */
pbcCompany?: string;
/** 创建时间 */ /** 创建时间 */
pbcCreateAt?: string; pbcCreateAt?: string;
/** 创建人 */ /** 创建人 */
pbcCreateBy?: number; pbcCreateBy?: number;
/** 创建人 */ /** 创建人 */
pbcCreateByUserName?: string; pbcCreateByUserName?: string;
/** 是否抽奖0.未完善1.待抽奖2.已抽奖 */
pbcHasPrize?: number;
/** 主键 */ /** 主键 */
pbcId?: number; pbcId?: number;
/** 用户小程序的open id */ /** 用户小程序的open id */
pbcOpenId?: string; pbcOpenId?: string;
/** 抽奖二维码 */
pbcPrizeCode?: string;
pbcSourceUser?: PbcUsers; pbcSourceUser?: PbcUsers;
/** 状态,0是删除1是正常2是作废 */ /** 状态,0是删除1是正常2是作废 */
pbcState?: number; pbcState?: number;
@ -4268,6 +4325,8 @@ declare namespace API {
}; };
type PbcUsers = { type PbcUsers = {
/** 用户类型:详细信息:专职采购商,鞋企采购商 */
pbcBusinessDetailType?: string;
/** 商户id */ /** 商户id */
pbcBusinessId?: number; pbcBusinessId?: number;
pbcBusinessInfo?: PbcBusiness; pbcBusinessInfo?: PbcBusiness;
@ -4276,16 +4335,24 @@ declare namespace API {
/** 商户认证状态false是未认证true是已认证 */ /** 商户认证状态false是未认证true是已认证 */
pbcBusinessState?: boolean; pbcBusinessState?: boolean;
pbcBusinessTeam?: PbcBusinessTeam_; pbcBusinessTeam?: PbcBusinessTeam_;
/** 用户类型:采购员、商家、从业者、其他 */
pbcBusinessType?: string;
/** 公司 */
pbcCompany?: string;
/** 创建时间 */ /** 创建时间 */
pbcCreateAt?: string; pbcCreateAt?: string;
/** 创建人 */ /** 创建人 */
pbcCreateBy?: number; pbcCreateBy?: number;
/** 创建人 */ /** 创建人 */
pbcCreateByUserName?: string; pbcCreateByUserName?: string;
/** 是否抽奖0.未完善1.待抽奖2.已抽奖 */
pbcHasPrize?: number;
/** 主键 */ /** 主键 */
pbcId?: number; pbcId?: number;
/** 用户小程序的open id */ /** 用户小程序的open id */
pbcOpenId?: string; pbcOpenId?: string;
/** 抽奖二维码 */
pbcPrizeCode?: string;
pbcSourceUser?: PbcUsers; pbcSourceUser?: PbcUsers;
/** 状态,0是删除1是正常2是作废 */ /** 状态,0是删除1是正常2是作废 */
pbcState?: number; pbcState?: number;
@ -4328,6 +4395,8 @@ declare namespace API {
type PbcUsersVO = { type PbcUsersVO = {
/** 用户权限集 */ /** 用户权限集 */
currentAuthority?: string[]; currentAuthority?: string[];
/** 用户类型:详细信息:专职采购商,鞋企采购商 */
pbcBusinessDetailType?: string;
/** 商户id */ /** 商户id */
pbcBusinessId?: number; pbcBusinessId?: number;
pbcBusinessInfo?: PbcBusiness; pbcBusinessInfo?: PbcBusiness;
@ -4336,16 +4405,24 @@ declare namespace API {
/** 商户认证状态false是未认证true是已认证 */ /** 商户认证状态false是未认证true是已认证 */
pbcBusinessState?: boolean; pbcBusinessState?: boolean;
pbcBusinessTeam?: PbcBusinessTeam_; pbcBusinessTeam?: PbcBusinessTeam_;
/** 用户类型:采购员、商家、从业者、其他 */
pbcBusinessType?: string;
/** 公司 */
pbcCompany?: string;
/** 创建时间 */ /** 创建时间 */
pbcCreateAt?: string; pbcCreateAt?: string;
/** 创建人 */ /** 创建人 */
pbcCreateBy?: number; pbcCreateBy?: number;
/** 创建人 */ /** 创建人 */
pbcCreateByUserName?: string; pbcCreateByUserName?: string;
/** 是否抽奖0.未完善1.待抽奖2.已抽奖 */
pbcHasPrize?: number;
/** 主键 */ /** 主键 */
pbcId?: number; pbcId?: number;
/** 用户小程序的open id */ /** 用户小程序的open id */
pbcOpenId?: string; pbcOpenId?: string;
/** 抽奖二维码 */
pbcPrizeCode?: string;
pbcSourceUser?: PbcUsers; pbcSourceUser?: PbcUsers;
/** 状态,0是删除1是正常2是作废 */ /** 状态,0是删除1是正常2是作废 */
pbcState?: number; pbcState?: number;
@ -4686,8 +4763,18 @@ declare namespace API {
}; };
type UserDTO = { type UserDTO = {
/** 用户类型:详细信息:专职采购商,鞋企采购商 */
pbcBusinessDetailType?: string;
/** 用户类型1.采购员 2.设计师 3.代购小哥 4.鞋材商家 5.鞋企 6.其他 */
pbcBusinessType?: string;
/** 公司 */
pbcCompany?: string;
/** 是否抽奖0.未完善1.待抽奖2.已抽奖 */
pbcHasPrize?: number;
/** 用户id */ /** 用户id */
pbcId?: number; pbcId?: number;
/** 抽奖二维码 */
pbcPrizeCode?: string;
/** 用户头像 */ /** 用户头像 */
pbcUserImage?: string; pbcUserImage?: string;
/** 用户姓名 */ /** 用户姓名 */
@ -4757,6 +4844,11 @@ declare namespace API {
contentType?: string; contentType?: string;
}; };
type writeOffPrizeUsingGETParams = {
/** pbcUserMobile */
pbcUserMobile: string;
};
type wxMiniAppBindAccountUsingGETParams = { type wxMiniAppBindAccountUsingGETParams = {
/** loginCode */ /** loginCode */
loginCode: string; loginCode: string;

@ -0,0 +1,101 @@
export const createImage = (url: string) =>
new Promise<HTMLImageElement>((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<Blob>((resolve) => {
croppedCanvas.toBlob((file: any) => {
resolve(file)
}, 'image/jpeg')
})
}
Loading…
Cancel
Save