From 3c6339750118f133ab235c3af8db701eab67629b Mon Sep 17 00:00:00 2001 From: lyp Date: Thu, 17 Apr 2025 08:36:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=A4=B4=E5=8A=A0=E5=85=A5Co?= =?UTF-8?q?ntent-Type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AiShopDetail/AiShopDetail.tsx | 345 ++++++++++++++++++ .../OrderDetailModal/components/File/File.css | 2 +- .../OrderDetailModal/components/File/File.tsx | 227 ++++++++++-- src/request/api.ts | 5 + src/request/request.ts | 40 +- src/route/CopyrightGgoods/CopyrightGgoods.tsx | 74 ++-- .../components/EditModal/EditModal.tsx | 2 +- src/route/TradingGoods/TradingGoods.tsx | 76 ++-- 8 files changed, 676 insertions(+), 95 deletions(-) create mode 100644 src/components/AiShopDetail/AiShopDetail.tsx diff --git a/src/components/AiShopDetail/AiShopDetail.tsx b/src/components/AiShopDetail/AiShopDetail.tsx new file mode 100644 index 0000000..45eabc4 --- /dev/null +++ b/src/components/AiShopDetail/AiShopDetail.tsx @@ -0,0 +1,345 @@ +// import React from 'react' +import { + Modal, + Spin, + + Image, + Button, + Input, + Checkbox +} from 'antd'; +import { GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts"; +import { goodsDetail, createOrder, confirmPayment } from '../../request/api' +import { showImage } from '../../request/request' +import { useState, useEffect,useContext } from 'react'; +import useMessage from "antd/es/message/useMessage"; +const { TextArea } = Input; +export default function AiShopDetail(props: any) { + const globalDispatchContext = useContext(GlobalDispatchContext); + const [isAgreed, setIsAgreed] = useState(false); // 新增状态,用于记录是否同意协议 + const [messageApi, messageContext] = useMessage(); + const [loading, setLoading] = useState(false) //加载中 + const [goodsDetailData, setGoodsDetailData] = useState({}) // 商品详情数据 + const [buyTipsModal, setBuyTipsModal] = useState(false) //卖提示框 + const [showTips, setShowTips] = useState(false) // 提示框 + const [goodsId, setGoodsId] = useState() //商品ID + const getGoodsDetail = async (goodsId: string) => { + try { + setLoading(true) + const res: any = await goodsDetail(goodsId) + // console.log(res); + setGoodsId(res.goodsId) + setGoodsDetailData(res) + setLoading(false) + } catch (error: any) { + // setLoading(false) + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } + } finally { + setLoading(false) + } + } + // 创建订单 + const createOrderFun = async (goodsId: string) => { + try { + // setPayLoading(true) + const res: any = await createOrder(goodsId) + // console.log(res); + confirmPaymentFun(res.data) + + } catch (error: any) { + + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + } + // 确认支付 + const confirmPaymentFun = async (orderId: string) => { + try { + // setLoading(true) + const res: any = await confirmPayment(orderId) + console.log(res); + // setLoading(false) + reloadUser(messageApi, globalDispatchContext).then(() => { + messageApi.success('扣款成功'); + }); + } catch (error: any) { + + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + } + useEffect(() => { + getGoodsDetail(props.goodsId) + }, []) + return ( + <> + {messageContext} + +
+
+ +
点击查看
+
+
+
+
软著名称
+ +
+ +
+
+
软著简称
+ +
+
+
软著证号
+ +
+
+ +
+
+
软著版本
+ +
+
+
取得时间
+ +
+
+ +
+
+
开发语言
+ +
+
+
取得方式
+ +
+
+ +
+
+
售卖价格
+ +
+
+
上架时间
+ +
+
+ + +
+
软著详情
+ +
+ + +
+
+
+ { + setIsAgreed(!isAgreed) + // if (value) { + // setShowTips(false) + // } + // console.log(value.target.checked); + if (value.target.checked) { + setShowTips(false) + } + // else{ + // setShowTips(true) + // } + + }}> + + + 我同意平台 { + // window.open('https://www.aimzhu.com/Seda.html') + }}>《购买协议》 + +
请阅读并且勾选《购买协议》
+
+
+ + +
+
+ { + setBuyTipsModal(false) + }} + onOk={() => { + // alert(goodsId) + // alert(props.orderId) + if (props.orderId) { + confirmPaymentFun(props.orderId) + + + } else { + createOrderFun(goodsId) + } + }} + // width={1200} + centered + > + 确定购买该商品吗? + + + ) +} diff --git a/src/components/OrderDetailModal/components/File/File.css b/src/components/OrderDetailModal/components/File/File.css index e625254..9cfa9f5 100644 --- a/src/components/OrderDetailModal/components/File/File.css +++ b/src/components/OrderDetailModal/components/File/File.css @@ -17,7 +17,7 @@ .upFileBox { display: flex; margin-top: 20px; - align-items: center; + /* align-items: center; */ } .phoneBoxLeft{ display: flex; diff --git a/src/components/OrderDetailModal/components/File/File.tsx b/src/components/OrderDetailModal/components/File/File.tsx index 77eddd1..56b39f4 100644 --- a/src/components/OrderDetailModal/components/File/File.tsx +++ b/src/components/OrderDetailModal/components/File/File.tsx @@ -1,14 +1,63 @@ import { useEffect, useState } from 'react' -import { Table, Space, Modal, Input, Form } from "antd" -import { sellSupplementList, buySupplementList, supplementDetail } from '../../../../request/api' +import { Table, Space, Modal, Input, Form, Upload, Button } from "antd" +import { UploadOutlined } from '@ant-design/icons'; +import { sellSupplementList, buySupplementList, supplementDetail, getFileTypeByIds, supplementData } from '../../../../request/api' +import { showImage, uploadFileUrl } from '../../../../request/request' const { Column } = Table; import useMessage from "antd/es/message/useMessage"; import './File.css' const { TextArea } = Input; export default function File(props: any) { + // 自定义验证函数 + const validateContentOrFile = (_rule: any, _value: any, callback: (error?: string) => void, form: any) => { + const { upCorrectionRemark, upFile } = form.getFieldsValue(); + if (upCorrectionRemark || (upFile && Array.isArray(upFile.fileList) && upFile.fileList.length > 0)) { + callback(); + } else { + callback('内容和附件至少需要填写或上传一项'); + } + }; + // 点击上传资料确定 + const submitData = async (params: any) => { + try { + await supplementData({ + correctionParentId: correctionId, + // correctionType: CorrectionType, + orderId: props.orderId, + correctionFiles: params.correctionFiles, + correctionRemark: params.correctionRemark, + }) + if (props.user == 'sell') { + getSellSupplementList() + } else if (props.user == 'buy') { + getBuySupplementList() + } + messageApi.open({ + type: 'success', + content: '已提交', + }) + setIsModalVisible(false) + // form.resetFields(); + + // console.log(res); + + } catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + } + const token = sessionStorage.getItem('token') const [form] = Form.useForm(); const [messageApi, messageContext] = useMessage(); const [correctionId, setCorrectionId] = useState('') // 点击查看内容选中的id + // const [CorrectionType, setCorrectionType] = useState('') // 补充资料弹窗 const [isModalVisible, setIsModalVisible] = useState(false) const [page, setPage] = useState(1) // 当前页码 @@ -68,13 +117,36 @@ export default function File(props: any) { } } } + const [fileList, setFileList] = useState([]) // 上传文件列表 + // 获取文件类型 + const getFileTypeByIdsArray = async (ids: string) => { + try { + const res: any = await getFileTypeByIds({ + ids: ids + }) + setFileList(res) + + } catch (error: any) { + + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + } // 补充资料详情 const [detailData, setDetailData] = useState({}) const getSupplementDetail = async (id: string) => { try { const res: any = await supplementDetail(id) - console.log(res); + // console.log(res); setDetailData(res) + await getFileTypeByIdsArray(res.correctionFiles) } catch (error: any) { @@ -120,7 +192,7 @@ export default function File(props: any) { } // pagination={false} // 不显示分页 style={{ textAlign: 'center' }} // 设置表格内容居中显示 - rowKey="orderId" // 指定数据项的唯一标识符 + rowKey="correctionId" // 指定数据项的唯一标识符 > 查看内容 @@ -191,14 +263,17 @@ export default function File(props: any) { destroyOnClose={true} open={isModalVisible} footer={null} // 将 footer 设置为 null 来隐藏自带按钮 - width={1152} + width={1000} onCancel={() => { setIsModalVisible(false); + // 清空表单 + form.resetFields(); }} centered >
- {correctionId} + {/* {correctionId} + {CorrectionType} */}
平台需要您补充的内容说明
@@ -224,10 +299,42 @@ export default function File(props: any) {
附件
- {detailData.correctionFile ? ( -
材料列表
+ {fileList.length > 0 ? ( + //
材料列表
+
+ { + fileList.map((item: any) => { + return ( +
{ + + window.open(showImage(item.fileId, false)) + + }} + > + {item.fileName} +
+ ) + }) + } +
+ ) : ( -
+
)} @@ -244,12 +351,27 @@ export default function File(props: any) { onFinish={(value) => { console.log(value); + // if (value.upFile && Array.isArray(value.upFile.fileList)) { + // const uids = value.upFile.fileList.map((file: any) => file.uid); + // const uidString = uids.join(','); + // console.log('提取的 uid 字符串:', uidString); + // // 你可以在这里继续处理 uid 字符串,比如发送请求等 + + // } + const uids = value.upFile ? (value.upFile.fileList.map((file: any) => file.uid)).join(',') : ''; + + // console.log('提取的 uid 字符串:', uids); + + submitData({ + correctionFiles: uids, + correctionRemark: value.upCorrectionRemark, + }) }} onFinishFailed={() => { messageApi.open({ type: 'error', - content: '请填写完整信息', + content: '内容和附件至少需要填写或上传一项', }) }} autoComplete="off" @@ -257,41 +379,80 @@ export default function File(props: any) {
内容
validateContentOrFile(rule, value, callback, form), + }, + + ]} > - - +
附件
- - - - +
+ validateContentOrFile(rule, value, callback, form), + }, + ]} + > + + + + + + + +
+
+ +
+ + +
+
diff --git a/src/request/api.ts b/src/request/api.ts index 4310690..5d692ec 100644 --- a/src/request/api.ts +++ b/src/request/api.ts @@ -87,6 +87,11 @@ export const goodsDetail = (goodsId: string) => aiShopRequest.get(`/aishop/api/g export const createOrder = (goodsId: string) => aiShopRequest.post(`/aishop/api/order/save/${goodsId}`) // 确认付款 export const confirmPayment = (orderId: string) => aiShopRequest.put(`/aishop/api/order/confirm-pay/${orderId}`) + +// 通过ids获取文件类型 +export const getFileTypeByIds = (params:any) => aiShopRequest.get(`/aishop/api/file/list`, { params }) +// 补充资料 +export const supplementData = (params:any) => aiShopRequest.post(`/aishop/api/correction/save`, params) //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/src/request/request.ts b/src/request/request.ts index 9fc56b6..e34ce07 100644 --- a/src/request/request.ts +++ b/src/request/request.ts @@ -1,5 +1,6 @@ import axios from "axios"; + // 正式与测试环境 import { operatorPluginBaseUrl,// 开票功能baseUrl @@ -13,7 +14,7 @@ import { // const aiShopBaseUrl = 'http://192.168.0.115:8081'//买卖' // const operatorBaseUrl = 'http://192.168.0.15:8091' //绑定手机号 - +// axios.defaults.headers['Content-Type'] = 'application/json'; // 设置默认请求头为 JSON 格式 // 开票功能---------------------------------------------------------------------------- const request = axios.create({ baseURL: operatorPluginBaseUrl, @@ -23,9 +24,11 @@ request.interceptors.request.use( (config) => { // 有token带token const token = sessionStorage.getItem('token') - config.headers = config.headers || {} config.headers['Auth'] = token ? `Bearer ${token}` : ''; + config.headers['Content-Type'] = 'application/json'; + config.data = { unused: 0 } + return config; }, @@ -40,6 +43,7 @@ request.interceptors.response.use( //----------------------------------------------------------------------------------------- + // 买卖功能---------------------------------------------------------------------------- const aiShopRequest = axios.create({ baseURL: aiShopBaseUrl, @@ -52,6 +56,24 @@ aiShopRequest.interceptors.request.use( config.headers = config.headers || {} config.headers['Auth'] = token ? `Bearer ${token}` : ''; + config.headers['Content-Type'] = 'application/json'; + config.data = { unused: 0 } + // if (config.method === 'get' ) { + // if (!config.data) { + // config.data = { unused: 0 } + // } + // } + // if (config.method === 'put') { + // if (!config.data) { + // config.data = { unused: 0 } + // } + // } + // if (config.method === 'post') { + // if (!config.data) { + // config.data = { unused: 0 } + // } + // } + return config; }, @@ -74,9 +96,10 @@ phoneRequest.interceptors.request.use( (config) => { // 有token带token const token = sessionStorage.getItem('token') - config.headers = config.headers || {} config.headers['Auth'] = token ? `Bearer ${token}` : ''; + config.headers['Content-Type'] = 'application/json'; + config.data = { unused: 0 } return config; }, @@ -123,7 +146,7 @@ export const downloadInvoice = (id: string) => { -// 显示图片 买卖功能 +// 显示图片 下载 预览文件 买卖功能 export const showImage = (fileId: string, isDownload?: boolean) => { return `${aiShopBaseUrl}/aishop/route/file/download/${isDownload == false}/${fileId}` } @@ -131,5 +154,14 @@ export const showImage = (fileId: string, isDownload?: boolean) => { export const uploadImageUrl = () => { return `${aiShopBaseUrl}/aishop/api/file/v2/upload-image` } +// // 下载 预览文件 买卖功能 +// export const downloadUrl = (fileId: string, isDownload?: boolean) => { +// return `${aiShopBaseUrl}/aishop/route/file/v2/download/${isDownload == false}/${fileId}` +// } + // export default request +// 上传文件 买卖功能 +export const uploadFileUrl = () => { + return `${aiShopBaseUrl}/aishop/api/file/v2/upload-file` +} export { request,aiShopRequest,phoneRequest,newRequest}; \ No newline at end of file diff --git a/src/route/CopyrightGgoods/CopyrightGgoods.tsx b/src/route/CopyrightGgoods/CopyrightGgoods.tsx index c936812..0b7d5aa 100644 --- a/src/route/CopyrightGgoods/CopyrightGgoods.tsx +++ b/src/route/CopyrightGgoods/CopyrightGgoods.tsx @@ -8,14 +8,17 @@ import { // InputNumber Spin, Modal, - Image, - Button, - Input + // Image, + // Button, + // Input } from 'antd'; -import { showImage } from '../../request/request' +// import { showImage } from '../../request/request' +import AiShopDetail from '../../components/AiShopDetail/AiShopDetail' import { useLocation } from 'react-router-dom'; import dayjs, { } from 'dayjs'; -import { buyGoodsList, goodsDetail, createOrder, confirmPayment } from '../../request/api' +import { buyGoodsList, + // goodsDetail, + createOrder, confirmPayment } from '../../request/api' // import type { InputNumberProps } from 'antd'; // import type { TableColumnsType } from 'antd'; // import { SearchOutlined, ClearOutlined } from '@ant-design/icons'; @@ -24,7 +27,7 @@ import { buyGoodsList, goodsDetail, createOrder, confirmPayment } from '../../re import { useState, useEffect } from 'react'; import useMessage from "antd/es/message/useMessage"; const { Column } = Table; -const { TextArea } = Input; +// const { TextArea } = Input; export default function CopyrightGgoods() { const [messageApi, messageContext] = useMessage(); const height = window.innerHeight - 180; @@ -130,32 +133,32 @@ export default function CopyrightGgoods() { } else { console.error(error) } - }finally { - setLoading(false) - } - } - const [goodsDetailData, setGoodsDetailData] = useState({}) // 商品详情数据 - const getGoodsDetail = async (goodsId: string) => { - try { - setLoading(true) - const res: any = await goodsDetail(goodsId) - // console.log(res); - setGoodsId(res.goodsId) - setGoodsDetailData(res) - setLoading(false) - } catch (error: any) { - // setLoading(false) - if (error.response) { - const data = error.response.data; - messageApi.open({ - type: 'error', - content: data.msg ? data.msg : `${data.path}(${data.status})`, - }); - } - }finally { + } finally { setLoading(false) } } + // const [goodsDetailData, setGoodsDetailData] = useState({}) // 商品详情数据 + // const getGoodsDetail = async (goodsId: string) => { + // try { + // setLoading(true) + // const res: any = await goodsDetail(goodsId) + // // console.log(res); + // setGoodsId(res.goodsId) + // setGoodsDetailData(res) + // setLoading(false) + // } catch (error: any) { + // // setLoading(false) + // if (error.response) { + // const data = error.response.data; + // messageApi.open({ + // type: 'error', + // content: data.msg ? data.msg : `${data.path}(${data.status})`, + // }); + // } + // } finally { + // setLoading(false) + // } + // } useEffect(() => { // console.log('copyrightKeywords', copyrightKeywords); // console.log('minPrice', minPrice); @@ -171,6 +174,9 @@ export default function CopyrightGgoods() { setPage(1) getBuyGoodsList(1) }, [state]) + useEffect(() => { + getBuyGoodsList(page) + },[page]) return ( @@ -239,7 +245,8 @@ export default function CopyrightGgoods() { // console.log(record); setGoodsDetailModal(true) - getGoodsDetail(record.goodsId) + // getGoodsDetail(record.goodsId) + setGoodsId(record.goodsId) }}>查看详情 )} @@ -275,7 +282,7 @@ export default function CopyrightGgoods() { width={1200} centered > - + {/*
购买
- + */} + { + setGoodsDetailModal(false) + }}> diff --git a/src/route/ProductRelease/components/EditModal/EditModal.tsx b/src/route/ProductRelease/components/EditModal/EditModal.tsx index 7c26c4d..27f261e 100644 --- a/src/route/ProductRelease/components/EditModal/EditModal.tsx +++ b/src/route/ProductRelease/components/EditModal/EditModal.tsx @@ -483,7 +483,7 @@ export default function EditModal(props: any) { wrapperCol={{ span: 24 }} // style={{ width: '600px' }} onFinish={(value) => { - console.log('上传图片的 ID', logoImgArray) + // console.log('上传图片的 ID', logoImgArray) // 打印form表单所有的值 console.log(form.getFieldsValue()) // console.log(form.getFieldValue('imageUrl')); diff --git a/src/route/TradingGoods/TradingGoods.tsx b/src/route/TradingGoods/TradingGoods.tsx index b37200a..e74f727 100644 --- a/src/route/TradingGoods/TradingGoods.tsx +++ b/src/route/TradingGoods/TradingGoods.tsx @@ -7,11 +7,12 @@ import { Modal, Spin } from 'antd'; +import AiShopDetail from '../../components/AiShopDetail/AiShopDetail' // import type { TableColumnsType } from 'antd'; // import { SearchOutlined, ClearOutlined } from '@ant-design/icons'; // import type { DatePickerProps } from 'antd'; // import locale from 'antd/es/date-picker/locale/zh_CN'; -import { getBuyOrderList, confirmPayment } from '../../request/api' +import { getBuyOrderList } from '../../request/api' import { useState, useEffect } from 'react'; import { useLocation } from 'react-router-dom'; import File from '../../components/OrderDetailModal/components/File/File' @@ -32,6 +33,8 @@ export default function TradingGoods() { const tradingEndTime = state ? state.tradingEndTime : '' const tradingStatus = state ? state.tradingStatus : '' const [orderId, setOrderId] = useState('') // 订单ID + const [aiShopDetailModal, setAiShopDetailModal] = useState(false) // 商品详情弹窗 + const [goodsId, setGoodsId] = useState('') // 商品ID const [loading, setLoading] = useState(false) // 加载中 const [fileModal, setFileModal] = useState(false) //补充资料弹窗 const [data, setData] = useState([]); // 表格数据 @@ -72,25 +75,25 @@ export default function TradingGoods() { } // 确认支付 - const confirmPaymentFun = async (orderId: string) => { - try { + // const confirmPaymentFun = async (orderId: string) => { + // try { - const res: any = await confirmPayment(orderId) - console.log(res); + // const res: any = await confirmPayment(orderId) + // console.log(res); - } catch (error: any) { + // } catch (error: any) { - if (error.response) { - const data = error.response.data; - messageApi.open({ - type: 'error', - content: data.msg ? data.msg : `${data.path}(${data.status})`, - }); - } else { - console.error(error) - } - } - } + // if (error.response) { + // const data = error.response.data; + // messageApi.open({ + // type: 'error', + // content: data.msg ? data.msg : `${data.path}(${data.status})`, + // }); + // } else { + // console.error(error) + // } + // } + // } useEffect(() => { // console.log('tradingKeywords', tradingKeywords); // console.log('tradingStartTime', tradingStartTime); @@ -130,7 +133,7 @@ export default function TradingGoods() { // }} pagination={false} // 不显示分页 style={{ textAlign: 'center' }} // 设置表格内容居中显示 - rowKey="order" // 指定数据项的唯一标识符 + rowKey="orderId" // 指定数据项的唯一标识符 locale={{ emptyText: '暂无数据' }} > ( {text} )} /> - + /> */} 订单已取消 买家待付款 - 待填写资料 + 待填写资料 过户进行中 过户已完成 买家已评价 @@ -208,7 +211,11 @@ export default function TradingGoods() { { - confirmPaymentFun(record.orderId) + // confirmPaymentFun(record.orderId) + // alert(record.goodsId) + setGoodsId(record.goodsId) + setOrderId(record.orderId) + setAiShopDetailModal(true) }} style={{ display: record.orderStatus == '1' ? 'unset' : 'none' @@ -231,7 +238,7 @@ export default function TradingGoods() { }} style={{ - display: record.orderStatus == '0' || record.orderStatus == '1' || record.orderStatus == '2' ? 'unset' : 'none' + display: record.orderStatus == '1' || record.orderStatus == '2' ? 'unset' : 'none' }} > 取消订单 @@ -295,6 +302,27 @@ export default function TradingGoods() { > + { + // setOrderDetailModal(false) + // }} + onCancel={() => { + setAiShopDetailModal(false) + }} + width={1200} + centered + > + + { + setAiShopDetailModal(false) + }}> +
) }