请求头加入Content-Type

This commit is contained in:
lyp 2025-04-17 08:36:10 +08:00
parent 151ff2a3fe
commit 3c63397501
8 changed files with 676 additions and 95 deletions

View File

@ -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<any>({}) // 商品详情数据
const [buyTipsModal, setBuyTipsModal] = useState(false) //卖提示框
const [showTips, setShowTips] = useState(false) // 提示框
const [goodsId, setGoodsId] = useState<any>() //商品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}
<Spin tip="正在加载..." size="small" spinning={loading}>
<div className='goodsDetail'>
<div className='goodsDetailImg' style={{
position: 'relative',
}}>
<Image src={showImage(goodsDetailData.goodsPhoto, false)} preview={{
mask: '查看', // 设置点击放大时显示的文字
}}
height={'100%'}
style={{ maxWidth: '100%' }}
></Image>
<div style={{
position: 'absolute',
bottom: '3px',
left: '265px',
color: 'rgb(160, 160, 160)',
// backgroundColor: 'rgba(0, 0, 0, 0.5)', // 半透明背景色
}}></div>
</div>
<div className='goodsDetailInputBox'>
<div className='detailBox'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsName} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
<div style={{
display: 'flex',
justifyContent: 'space-between',
}}>
<div className='detailBox'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsSubName} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
<div className='detailBox detailBoxRight'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsNumber} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
</div>
<div style={{
display: 'flex',
justifyContent: 'space-between',
}}>
<div className='detailBox'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsVersion} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
<div className='detailBox'>
<div className='detailBoxTitle detailBoxRight'></div>
<Input value={goodsDetailData.goodsGetTime} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
</div>
<div style={{
display: 'flex',
justifyContent: 'space-between',
}}>
<div className='detailBox'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsDevelop} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
<div className='detailBox'>
<div className='detailBoxTitle detailBoxRight'></div>
<Input value={goodsDetailData.goodsGetType} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
</div>
<div style={{
display: 'flex',
justifyContent: 'space-between',
}}>
<div className='detailBox'>
<div className='detailBoxTitle'></div>
<Input value={goodsDetailData.goodsOpenPrice} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
<div className='detailBox'>
<div className='detailBoxTitle detailBoxRight'></div>
<Input value={goodsDetailData.goodsStatusTime} style={{
// height: '40px',
color: 'black',
}} disabled></Input>
</div>
</div>
<div className='detailBoxText'>
<div className='detailBoxTitle'></div>
<TextArea
disabled
style={{
width: '100%',
// width: 1100,
height: 150,
fontSize: 16,
color: "#5C5C5C",
resize: 'none',
background: '#F5F5F9'
}} value={goodsDetailData.goodsDescription}></TextArea>
</div>
</div>
</div>
<div style={{
position: 'relative',
// background:'pink'
marginTop: 10,
marginLeft: 20
}}>
<Checkbox checked={isAgreed} onChange={(value) => {
setIsAgreed(!isAgreed)
// if (value) {
// setShowTips(false)
// }
// console.log(value.target.checked);
if (value.target.checked) {
setShowTips(false)
}
// else{
// setShowTips(true)
// }
}}>
</Checkbox>
<span style={{
marginLeft: 10,
}}> <a onClick={() => {
// window.open('https://www.aimzhu.com/Seda.html')
}}></a></span>
<div style={{
position: 'absolute',
top: '25px',
left: '20px',
color: 'red',
// background:'skyblue',
fontSize: 12,
display: showTips ? 'unset' : 'none',
}}></div>
</div>
<div style={{
display: 'flex',
justifyContent: 'center',
marginTop: 20
}}>
<Button style={{
marginRight: 20,
fontSize: 16,
color: '#7C7C7C ',
background: '#E9E9E9',
fontWeight: '700',
height: 40,
width: 100,
}}
onClick={() => {
// setGoodsDetailModal(false)
props.closeModal()
}}
></Button>
<Button style={{
fontSize: 16,
// color: '#FFFFFF',
// background: '#FFA800',
fontWeight: '700',
height: 40,
width: 100,
}}
type="primary"
onClick={() => {
// setBuyTipsModal(true)
if (isAgreed) {
setBuyTipsModal(true);
} else {
setShowTips(true)
messageApi.open({
type: 'warning',
content: '请阅读并且勾选《购买协议》',
});
}
}}
></Button>
</div>
</Spin>
<Modal
title="提示"
okText="确认"
cancelText="取消"
destroyOnClose={true}
open={buyTipsModal}
onCancel={() => {
setBuyTipsModal(false)
}}
onOk={() => {
// alert(goodsId)
// alert(props.orderId)
if (props.orderId) {
confirmPaymentFun(props.orderId)
} else {
createOrderFun(goodsId)
}
}}
// width={1200}
centered
>
</Modal>
</>
)
}

View File

@ -17,7 +17,7 @@
.upFileBox { .upFileBox {
display: flex; display: flex;
margin-top: 20px; margin-top: 20px;
align-items: center; /* align-items: center; */
} }
.phoneBoxLeft{ .phoneBoxLeft{
display: flex; display: flex;

View File

@ -1,14 +1,63 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { Table, Space, Modal, Input, Form } from "antd" import { Table, Space, Modal, Input, Form, Upload, Button } from "antd"
import { sellSupplementList, buySupplementList, supplementDetail } from '../../../../request/api' import { UploadOutlined } from '@ant-design/icons';
import { sellSupplementList, buySupplementList, supplementDetail, getFileTypeByIds, supplementData } from '../../../../request/api'
import { showImage, uploadFileUrl } from '../../../../request/request'
const { Column } = Table; const { Column } = Table;
import useMessage from "antd/es/message/useMessage"; import useMessage from "antd/es/message/useMessage";
import './File.css' import './File.css'
const { TextArea } = Input; const { TextArea } = Input;
export default function File(props: any) { 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 [form] = Form.useForm();
const [messageApi, messageContext] = useMessage(); const [messageApi, messageContext] = useMessage();
const [correctionId, setCorrectionId] = useState('') // 点击查看内容选中的id const [correctionId, setCorrectionId] = useState('') // 点击查看内容选中的id
// const [CorrectionType, setCorrectionType] = useState('')
// 补充资料弹窗 // 补充资料弹窗
const [isModalVisible, setIsModalVisible] = useState(false) const [isModalVisible, setIsModalVisible] = useState(false)
const [page, setPage] = useState(1) // 当前页码 const [page, setPage] = useState(1) // 当前页码
@ -68,13 +117,36 @@ export default function File(props: any) {
} }
} }
} }
const [fileList, setFileList] = useState<any>([]) // 上传文件列表
// 获取文件类型
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<any>({}) const [detailData, setDetailData] = useState<any>({})
const getSupplementDetail = async (id: string) => { const getSupplementDetail = async (id: string) => {
try { try {
const res: any = await supplementDetail(id) const res: any = await supplementDetail(id)
console.log(res); // console.log(res);
setDetailData(res) setDetailData(res)
await getFileTypeByIdsArray(res.correctionFiles)
} catch (error: any) { } catch (error: any) {
@ -120,7 +192,7 @@ export default function File(props: any) {
} }
// pagination={false} // 不显示分页 // pagination={false} // 不显示分页
style={{ textAlign: 'center' }} // 设置表格内容居中显示 style={{ textAlign: 'center' }} // 设置表格内容居中显示
rowKey="orderId" // 指定数据项的唯一标识符 rowKey="correctionId" // 指定数据项的唯一标识符
> >
<Column <Column
width={70} width={70}
@ -180,7 +252,7 @@ export default function File(props: any) {
setCorrectionId(record.correctionId) setCorrectionId(record.correctionId)
getSupplementDetail(record.correctionId) getSupplementDetail(record.correctionId)
setIsModalVisible(true) setIsModalVisible(true)
// setCorrectionType(record.correctionType)
}}></span> }}></span>
</Space> </Space>
@ -191,14 +263,17 @@ export default function File(props: any) {
destroyOnClose={true} destroyOnClose={true}
open={isModalVisible} open={isModalVisible}
footer={null} // 将 footer 设置为 null 来隐藏自带按钮 footer={null} // 将 footer 设置为 null 来隐藏自带按钮
width={1152} width={1000}
onCancel={() => { onCancel={() => {
setIsModalVisible(false); setIsModalVisible(false);
// 清空表单
form.resetFields();
}} }}
centered centered
> >
<div> <div>
{correctionId} {/* {correctionId}
{CorrectionType} */}
<div className='editModal-title'> <div className='editModal-title'>
<div className='editModal-title-box'></div> <div className='editModal-title-box'></div>
<div className='editModal-title-name'></div> <div className='editModal-title-name'></div>
@ -224,10 +299,42 @@ export default function File(props: any) {
</div> </div>
<div className='upFileBox'> <div className='upFileBox'>
<div className='correctionTitle'></div> <div className='correctionTitle'></div>
{detailData.correctionFile ? ( {fileList.length > 0 ? (
<div></div> // <div>材料列表</div>
<div>
{
fileList.map((item: any) => {
return (
<div
key={item.fileId}
style={{
// background: 'pink',
marginBottom: 5,
maxWidth: 800,
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
cursor: 'pointer',
color: '#1B8BD2',
//下划线
textDecoration: 'underline',
}}
title={item.fileName}
onClick={() => {
window.open(showImage(item.fileId, false))
}}
>
{item.fileName}
</div>
)
})
}
</div>
) : ( ) : (
<div style={{ fontSize: 18 }}> <div style={{ fontSize: 18, fontWeight: 700 }}>
</div> </div>
)} )}
@ -244,12 +351,27 @@ export default function File(props: any) {
onFinish={(value) => { onFinish={(value) => {
console.log(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={() => { onFinishFailed={() => {
messageApi.open({ messageApi.open({
type: 'error', type: 'error',
content: '请填写完整信息', content: '内容和附件至少需要填写或上传一项',
}) })
}} }}
autoComplete="off" autoComplete="off"
@ -257,41 +379,80 @@ export default function File(props: any) {
<div className='correctionRemarkBox'> <div className='correctionRemarkBox'>
<div className='correctionTitle'></div> <div className='correctionTitle'></div>
<Form.Item <Form.Item
// label="软著名称"
name="correctionRemark" name="upCorrectionRemark"
rules={[{ required: true, message: '请输入软著名称' }]} rules={[
// { required: true, message: '请输入需要补充内容' },
{
validator: (rule, value, callback) => validateContentOrFile(rule, value, callback, form),
},
]}
> >
<TextArea value={detailData.correctionRemark} style={{ <TextArea style={{
height: 100, height: 100,
resize: 'none', resize: 'none',
width: 1050 width: 900,
}} }}
placeholder='请输入需要补充内容'
></TextArea> ></TextArea>
</Form.Item> </Form.Item>
</div> </div>
<div className='correctionRemarkBox' style={{ <div className='correctionRemarkBox' style={{
marginTop:0 marginTop: 0
}}> }}>
<div className='correctionTitle'></div> <div className='correctionTitle'></div>
<Form.Item <div style={{
// label="软著名称" maxWidth: 800,
name="correctionRemark" overflow: 'hidden',
rules={[{ required: true, message: '请输入软著名称' }]} textOverflow: 'ellipsis',
> whiteSpace: 'nowrap',
<TextArea value={detailData.correctionRemark} style={{ }}>
height: 100, <Form.Item
resize: 'none',
width: 1050 name="upFile"
}} rules={[
// { required: true, message: '请上传附件' },
></TextArea> {
</Form.Item> validator: (rule, value, callback) => validateContentOrFile(rule, value, callback, form),
},
]}
>
<Upload
name="file"
action={uploadFileUrl()}
headers={{ 'Auth': `Bearer ${token}` }}
>
<Button icon={<UploadOutlined />}></Button>
</Upload>
</Form.Item>
</div>
</div> </div>
<Form.Item
>
<div style={{
display: 'flex',
justifyContent: 'flex-end',
gap: 10,
// marginTop: 20
}}>
<Button onClick={() => {
setIsModalVisible(false)
form.resetFields();
}}></Button>
<Button type="primary" htmlType="submit" ></Button>
</div>
</Form.Item>
</Form> </Form>

View File

@ -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 createOrder = (goodsId: string) => aiShopRequest.post(`/aishop/api/order/save/${goodsId}`)
// 确认付款 // 确认付款
export const confirmPayment = (orderId: string) => aiShopRequest.put(`/aishop/api/order/confirm-pay/${orderId}`) 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)
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -1,5 +1,6 @@
import axios from "axios"; import axios from "axios";
// 正式与测试环境 // 正式与测试环境
import { import {
operatorPluginBaseUrl,// 开票功能baseUrl operatorPluginBaseUrl,// 开票功能baseUrl
@ -13,7 +14,7 @@ import {
// const aiShopBaseUrl = 'http://192.168.0.115:8081'//买卖' // const aiShopBaseUrl = 'http://192.168.0.115:8081'//买卖'
// const operatorBaseUrl = 'http://192.168.0.15:8091' //绑定手机号 // const operatorBaseUrl = 'http://192.168.0.15:8091' //绑定手机号
// axios.defaults.headers['Content-Type'] = 'application/json'; // 设置默认请求头为 JSON 格式
// 开票功能---------------------------------------------------------------------------- // 开票功能----------------------------------------------------------------------------
const request = axios.create({ const request = axios.create({
baseURL: operatorPluginBaseUrl, baseURL: operatorPluginBaseUrl,
@ -23,9 +24,11 @@ request.interceptors.request.use(
(config) => { (config) => {
// 有token带token // 有token带token
const token = sessionStorage.getItem('token') const token = sessionStorage.getItem('token')
config.headers = config.headers || {} config.headers = config.headers || {}
config.headers['Auth'] = token ? `Bearer ${token}` : ''; config.headers['Auth'] = token ? `Bearer ${token}` : '';
config.headers['Content-Type'] = 'application/json';
config.data = { unused: 0 }
return config; return config;
}, },
@ -40,6 +43,7 @@ request.interceptors.response.use(
//----------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------
// 买卖功能---------------------------------------------------------------------------- // 买卖功能----------------------------------------------------------------------------
const aiShopRequest = axios.create({ const aiShopRequest = axios.create({
baseURL: aiShopBaseUrl, baseURL: aiShopBaseUrl,
@ -52,6 +56,24 @@ aiShopRequest.interceptors.request.use(
config.headers = config.headers || {} config.headers = config.headers || {}
config.headers['Auth'] = token ? `Bearer ${token}` : ''; 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; return config;
}, },
@ -74,9 +96,10 @@ phoneRequest.interceptors.request.use(
(config) => { (config) => {
// 有token带token // 有token带token
const token = sessionStorage.getItem('token') const token = sessionStorage.getItem('token')
config.headers = config.headers || {} config.headers = config.headers || {}
config.headers['Auth'] = token ? `Bearer ${token}` : ''; config.headers['Auth'] = token ? `Bearer ${token}` : '';
config.headers['Content-Type'] = 'application/json';
config.data = { unused: 0 }
return config; return config;
}, },
@ -123,7 +146,7 @@ export const downloadInvoice = (id: string) => {
// 显示图片 买卖功能 // 显示图片 下载 预览文件 买卖功能
export const showImage = (fileId: string, isDownload?: boolean) => { export const showImage = (fileId: string, isDownload?: boolean) => {
return `${aiShopBaseUrl}/aishop/route/file/download/${isDownload == false}/${fileId}` return `${aiShopBaseUrl}/aishop/route/file/download/${isDownload == false}/${fileId}`
} }
@ -131,5 +154,14 @@ export const showImage = (fileId: string, isDownload?: boolean) => {
export const uploadImageUrl = () => { export const uploadImageUrl = () => {
return `${aiShopBaseUrl}/aishop/api/file/v2/upload-image` 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 default request
// 上传文件 买卖功能
export const uploadFileUrl = () => {
return `${aiShopBaseUrl}/aishop/api/file/v2/upload-file`
}
export { request,aiShopRequest,phoneRequest,newRequest}; export { request,aiShopRequest,phoneRequest,newRequest};

View File

@ -8,14 +8,17 @@ import {
// InputNumber // InputNumber
Spin, Spin,
Modal, Modal,
Image, // Image,
Button, // Button,
Input // Input
} from 'antd'; } 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 { useLocation } from 'react-router-dom';
import dayjs, { } from 'dayjs'; 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 { InputNumberProps } from 'antd';
// import type { TableColumnsType } from 'antd'; // import type { TableColumnsType } from 'antd';
// import { SearchOutlined, ClearOutlined } from '@ant-design/icons'; // import { SearchOutlined, ClearOutlined } from '@ant-design/icons';
@ -24,7 +27,7 @@ import { buyGoodsList, goodsDetail, createOrder, confirmPayment } from '../../re
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import useMessage from "antd/es/message/useMessage"; import useMessage from "antd/es/message/useMessage";
const { Column } = Table; const { Column } = Table;
const { TextArea } = Input; // const { TextArea } = Input;
export default function CopyrightGgoods() { export default function CopyrightGgoods() {
const [messageApi, messageContext] = useMessage(); const [messageApi, messageContext] = useMessage();
const height = window.innerHeight - 180; const height = window.innerHeight - 180;
@ -130,32 +133,32 @@ export default function CopyrightGgoods() {
} else { } else {
console.error(error) console.error(error)
} }
}finally { } finally {
setLoading(false)
}
}
const [goodsDetailData, setGoodsDetailData] = useState<any>({}) // 商品详情数据
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) setLoading(false)
} }
} }
// const [goodsDetailData, setGoodsDetailData] = useState<any>({}) // 商品详情数据
// 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(() => { useEffect(() => {
// console.log('copyrightKeywords', copyrightKeywords); // console.log('copyrightKeywords', copyrightKeywords);
// console.log('minPrice', minPrice); // console.log('minPrice', minPrice);
@ -171,6 +174,9 @@ export default function CopyrightGgoods() {
setPage(1) setPage(1)
getBuyGoodsList(1) getBuyGoodsList(1)
}, [state]) }, [state])
useEffect(() => {
getBuyGoodsList(page)
},[page])
return ( return (
@ -239,7 +245,8 @@ export default function CopyrightGgoods() {
// console.log(record); // console.log(record);
setGoodsDetailModal(true) setGoodsDetailModal(true)
getGoodsDetail(record.goodsId) // getGoodsDetail(record.goodsId)
setGoodsId(record.goodsId)
}}></span> }}></span>
</Space> </Space>
)} )}
@ -275,7 +282,7 @@ export default function CopyrightGgoods() {
width={1200} width={1200}
centered centered
> >
<Spin tip="正在加载..." size="small" spinning={loading}> {/* <Spin tip="..." size="small" spinning={loading}>
<div className='goodsDetail'> <div className='goodsDetail'>
<div className='goodsDetailImg' style={{ <div className='goodsDetailImg' style={{
position: 'relative', position: 'relative',
@ -446,7 +453,10 @@ export default function CopyrightGgoods() {
}} }}
></Button> ></Button>
</div> </div>
</Spin> </Spin> */}
<AiShopDetail goodsId={goodsId} closeModal={() => {
setGoodsDetailModal(false)
}}></AiShopDetail>
</Modal> </Modal>

View File

@ -483,7 +483,7 @@ export default function EditModal(props: any) {
wrapperCol={{ span: 24 }} wrapperCol={{ span: 24 }}
// style={{ width: '600px' }} // style={{ width: '600px' }}
onFinish={(value) => { onFinish={(value) => {
console.log('上传图片的 ID', logoImgArray) // console.log('上传图片的 ID', logoImgArray)
// 打印form表单所有的值 // 打印form表单所有的值
console.log(form.getFieldsValue()) console.log(form.getFieldsValue())
// console.log(form.getFieldValue('imageUrl')); // console.log(form.getFieldValue('imageUrl'));

View File

@ -7,11 +7,12 @@ import {
Modal, Modal,
Spin Spin
} from 'antd'; } from 'antd';
import AiShopDetail from '../../components/AiShopDetail/AiShopDetail'
// import type { TableColumnsType } from 'antd'; // import type { TableColumnsType } from 'antd';
// import { SearchOutlined, ClearOutlined } from '@ant-design/icons'; // import { SearchOutlined, ClearOutlined } from '@ant-design/icons';
// import type { DatePickerProps } from 'antd'; // import type { DatePickerProps } from 'antd';
// import locale from 'antd/es/date-picker/locale/zh_CN'; // 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 { useState, useEffect } from 'react';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import File from '../../components/OrderDetailModal/components/File/File' import File from '../../components/OrderDetailModal/components/File/File'
@ -32,6 +33,8 @@ export default function TradingGoods() {
const tradingEndTime = state ? state.tradingEndTime : '' const tradingEndTime = state ? state.tradingEndTime : ''
const tradingStatus = state ? state.tradingStatus : '' const tradingStatus = state ? state.tradingStatus : ''
const [orderId, setOrderId] = useState('') // 订单ID const [orderId, setOrderId] = useState('') // 订单ID
const [aiShopDetailModal, setAiShopDetailModal] = useState(false) // 商品详情弹窗
const [goodsId, setGoodsId] = useState('') // 商品ID
const [loading, setLoading] = useState(false) // 加载中 const [loading, setLoading] = useState(false) // 加载中
const [fileModal, setFileModal] = useState(false) //补充资料弹窗 const [fileModal, setFileModal] = useState(false) //补充资料弹窗
const [data, setData] = useState<any[]>([]); // 表格数据 const [data, setData] = useState<any[]>([]); // 表格数据
@ -72,25 +75,25 @@ export default function TradingGoods() {
} }
// 确认支付 // 确认支付
const confirmPaymentFun = async (orderId: string) => { // const confirmPaymentFun = async (orderId: string) => {
try { // try {
const res: any = await confirmPayment(orderId) // const res: any = await confirmPayment(orderId)
console.log(res); // console.log(res);
} catch (error: any) { // } catch (error: any) {
if (error.response) { // if (error.response) {
const data = error.response.data; // const data = error.response.data;
messageApi.open({ // messageApi.open({
type: 'error', // type: 'error',
content: data.msg ? data.msg : `${data.path}(${data.status})`, // content: data.msg ? data.msg : `${data.path}(${data.status})`,
}); // });
} else { // } else {
console.error(error) // console.error(error)
} // }
} // }
} // }
useEffect(() => { useEffect(() => {
// console.log('tradingKeywords', tradingKeywords); // console.log('tradingKeywords', tradingKeywords);
// console.log('tradingStartTime', tradingStartTime); // console.log('tradingStartTime', tradingStartTime);
@ -130,7 +133,7 @@ export default function TradingGoods() {
// }} // }}
pagination={false} // 不显示分页 pagination={false} // 不显示分页
style={{ textAlign: 'center' }} // 设置表格内容居中显示 style={{ textAlign: 'center' }} // 设置表格内容居中显示
rowKey="order" // 指定数据项的唯一标识符 rowKey="orderId" // 指定数据项的唯一标识符
locale={{ emptyText: '暂无数据' }} locale={{ emptyText: '暂无数据' }}
> >
<Column title="序号" <Column title="序号"
@ -152,17 +155,17 @@ export default function TradingGoods() {
/> />
<Column title="订单价格" dataIndex="payMoney" align="center" <Column title="订单价格" dataIndex="payMoney" align="center"
width={110} width={110}
fixed="left" // fixed="left"
render={(text) => ( render={(text) => (
<span style={{ color: '#FF5D15', fontSize: '24px', fontWeight: '700' }}>{text}</span> <span style={{ color: '#FF5D15', fontSize: '24px', fontWeight: '700' }}>{text}</span>
)} /> )} />
<Column {/* <Column
title="订单编号" title="订单编号"
dataIndex="orderNumber" dataIndex="orderNumber"
align="center" align="center"
width={210} width={210}
/> /> */}
<Column title="订单状态" dataIndex="orderStatus" align="center" <Column title="订单状态" dataIndex="orderStatus" align="center"
width={120} width={120}
@ -172,7 +175,7 @@ export default function TradingGoods() {
}}> }}>
<span style={{ display: text == '0' ? 'unset' : 'none' }}></span> <span style={{ display: text == '0' ? 'unset' : 'none' }}></span>
<span style={{ display: text == '1' ? 'unset' : 'none' }}></span> <span style={{ display: text == '1' ? 'unset' : 'none' }}></span>
<span style={{ display: text == '2' ? 'unset' : 'none' }}></span> <span style={{ display: text == '2' ? 'unset' : 'none' ,color:'red'}}></span>
<span style={{ display: text == '3' ? 'unset' : 'none' }}></span> <span style={{ display: text == '3' ? 'unset' : 'none' }}></span>
<span style={{ display: text == '4' ? 'unset' : 'none' }}></span> <span style={{ display: text == '4' ? 'unset' : 'none' }}></span>
<span style={{ display: text == '5' ? 'unset' : 'none' }}></span> <span style={{ display: text == '5' ? 'unset' : 'none' }}></span>
@ -208,7 +211,11 @@ export default function TradingGoods() {
</span> </span>
<span className='trading-goods-table-btn' onClick={() => { <span className='trading-goods-table-btn' onClick={() => {
confirmPaymentFun(record.orderId) // confirmPaymentFun(record.orderId)
// alert(record.goodsId)
setGoodsId(record.goodsId)
setOrderId(record.orderId)
setAiShopDetailModal(true)
}} }}
style={{ style={{
display: record.orderStatus == '1' ? 'unset' : 'none' display: record.orderStatus == '1' ? 'unset' : 'none'
@ -231,7 +238,7 @@ export default function TradingGoods() {
}} }}
style={{ 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() {
> >
<File user={'buy'} orderId={orderId}></File> <File user={'buy'} orderId={orderId}></File>
</Modal> </Modal>
<Modal
title="著作权商品信息"
okText="确认"
cancelText="取消"
destroyOnClose={true}
footer={null}
open={aiShopDetailModal}
// onOk={() => {
// setOrderDetailModal(false)
// }}
onCancel={() => {
setAiShopDetailModal(false)
}}
width={1200}
centered
>
<AiShopDetail goodsId={goodsId} orderId={orderId} closeModal={() => {
setAiShopDetailModal(false)
}}></AiShopDetail>
</Modal>
</div> </div>
) )
} }