system-copyright-react/src/layout/head/Head.tsx

670 lines
24 KiB
TypeScript
Raw Normal View History

2024-03-11 19:13:42 +08:00
import './head.css'
2024-07-31 16:00:30 +08:00
import { useDispatch } from 'react-redux'
2024-03-11 23:33:03 +08:00
import BalanceHead from '../../components/balance/BalanceHead.tsx';
import RechargeHead from '../../components/recharge/RechargeHead.tsx';
2024-08-12 14:43:58 +08:00
import { Dropdown, MenuProps, message, Modal, Space, Spin, Input } from "antd";
import { DownOutlined, UserOutlined, KeyOutlined, LogoutOutlined, AccountBookOutlined, ContainerOutlined, MenuFoldOutlined, UsergroupAddOutlined } from "@ant-design/icons";
2024-04-29 17:22:26 +08:00
import { useContext, useEffect, useState } from "react";
2024-08-12 14:43:58 +08:00
import { put, get, post } from "../../util/AjaxUtils.ts";
2024-04-29 17:22:26 +08:00
import { GlobalContext, GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts";
2024-04-02 18:45:46 +08:00
import UserEdit from "../../components/user/UserEdit.tsx";
import PasswordChange from "../../components/password/PasswordChange.tsx";
2024-04-29 17:22:26 +08:00
// import headRightBg from '../../assets/head-right-bg.png';
2024-04-02 18:45:46 +08:00
import InvoiceList from "../../components/invoice/InvoiceList.tsx";
2024-04-29 17:22:26 +08:00
import logoImg from '../../static/head/logo.png'
2024-05-23 14:57:22 +08:00
import userImg from '../../static/homeimg/userimg.png'
2024-05-28 18:00:42 +08:00
import { reMenuActive } from '../../util/cache';
2024-06-19 11:08:39 +08:00
// import BelongPeople from '../../components/BelongPeople/BelongPeople.tsx'
import BelongPeople from '../../components/BelongPeople/BelongPeople.tsx'
2024-06-21 16:18:01 +08:00
import ContactPeople from '../../components/ContactPeople/ContactPeople.tsx'
2024-08-12 14:43:58 +08:00
import inv from '../../static/inv.png'
import MyOrder from '../../components/myOrder/MyOrder.tsx'
2024-03-11 19:13:42 +08:00
export default function Head() {
2024-08-12 14:43:58 +08:00
// 邀请码弹窗
const [invitationModal, setinvitationModal] = useState(false)
// 解除绑定邀请码弹窗
// const [relieveModal, setRelieveModal] = useState(false)
// 申请的邀请码
const [invNum, setInvNum] = useState('')
// 输入的邀请码
const [inInvNum, setInInvNum] = useState('')
// 已绑定的邀请码
const [bindingInvNum, setBindingInvNum] = useState('')
// 邀请码申请状态
const [icStatus, setIcStatus] = useState('')
// 邀请码返利比例
const [icRebateRatio, seticRebateRatio] = useState('')
// 获取邀请码申请状态
const getIcStatus = () => {
get<any>({
messageApi,
url: '/api/ic/apply/get/self',
onSuccess({ data }) {
console.log(data);
if (data) {
setIcStatus(data.applyStatus)
}
}
})
}
// 获取邀请码信息
const getIc = () => {
get<any>({
messageApi,
url: '/api/ic/get/self',
onSuccess({ data }) {
console.log(data);
setInvNum(data.ic)
setBindingInvNum(data.relationIc)
seticRebateRatio(data.icRebateRatio)
if (data.ic == '') {
getIcStatus()
}
}
})
}
// 绑定邀请码
const putIc = () => {
put<any>({
messageApi,
url: `/api/ic/update-relation-ic`,
body: {
value: inInvNum
},
onBefore() {
},
onSuccess() {
// messageApi.success('保存成功,点击编辑按钮可继续修改项目简介');
// console.log(data);
getIc()
},
onFinally() {
}
})
}
// 确定输入的邀请码事件
const postInvNum = () => {
if (!inInvNum) {
messageApi.open({
type: 'error',
content: '请输入邀请码'
})
} else {
// setBindingInvNum(inInvNum)
// messageApi.open({
// type: 'success',
// content: '已绑定邀请码'
// })
putIc()
}
}
// 点击获取邀请码
const getInvNum = () => {
post<any>({
messageApi,
url: `/api/ic/apply/apply`,
onBefore() {
},
onSuccess() {
messageApi.success('已申请')
getIcStatus()
},
onFinally() {
}
})
// setInvNum('RSDNQ5H7')
}
// 复制邀请码
const copyInvNum = () => {
// navigator.clipboard.writeText(invNum)
// messageApi.open({
// type: 'success',
// content: '已复制到剪切板'
// })
// 创建一个临时的 input 元素
const tempInput = document.createElement('input');
document.body.appendChild(tempInput);
tempInput.value = invNum;
// 选中 input 中的内容
tempInput.select();
tempInput.setSelectionRange(0, 99999); // 对于移动设备的支持
// 执行复制操作
try {
document.execCommand('copy');
messageApi.open({
type: 'success',
content: '已复制到剪切板'
})
} catch (err) {
messageApi.open({
type: 'error',
content: '复制失败,请手动复制'
})
}
// 移除临时的 input 元素
document.body.removeChild(tempInput);
}
2024-07-31 16:00:30 +08:00
const dispath = useDispatch()
2024-08-12 14:43:58 +08:00
// 更新所属者表格储存至redux
const upBelongArray = () => {
2024-07-31 16:00:30 +08:00
get({
messageApi,
url: `/api/proj-owner/list/self`,
onBefore() {
},
onSuccess(data: any) {
// console.log('所属者表格', data.data);
// setBelongPeopleArray(data.data)
// 存redux的belongArray
dispath({
type: 'uparray',
val: data.data
})
},
onFinally() {
}
})
}
2024-03-26 21:09:41 +08:00
const globalContext = useContext(GlobalContext);
const globalDispatchContext = useContext(GlobalDispatchContext);
const [messageApi, contextHolder] = message.useMessage();
const [modal, modalHolder] = Modal.useModal();
const [loading, setLoading] = useState<boolean>(false);
const [isSelfModalOpen, setIsSelfModalOpen] = useState(false);
2024-03-27 11:04:38 +08:00
const [isPasswordModalOpen, setIsPasswordModalOpen] = useState(false);
2024-04-07 17:37:09 +08:00
const [isInvoiceModalOpen, setIsInvoiceModalOpen] = useState(false);
2024-08-12 14:43:58 +08:00
// 我的订单弹窗
const [myorderModal, setMyorderModal] = useState(false)
2024-06-19 11:08:39 +08:00
// 所属者弹窗
2024-07-05 13:38:59 +08:00
const [belongModal, setBelongModal] = useState(false)
2024-06-19 11:08:39 +08:00
const [belongPeopleInfo, setBelongPeopleInfo] = useState({
authorName: '',
authorType: '',
authorIdCardType: '',
authorIdCard: '',
2024-07-05 13:38:59 +08:00
authorCrcAccount: '',
authorId: '',
authorProvinceCity: ''
2024-06-19 11:08:39 +08:00
})
2024-07-29 17:22:42 +08:00
2024-06-19 11:08:39 +08:00
const setValue = () => {
// console.log(value);
2024-07-15 16:58:47 +08:00
}
2024-07-29 17:22:42 +08:00
const setConcatValue = () => {
2024-06-19 11:08:39 +08:00
}
2024-06-21 16:18:01 +08:00
// 联系人弹窗
2024-07-05 13:38:59 +08:00
const [contactModal, setContactModal] = useState(false)
2024-07-29 17:22:42 +08:00
const [concatPeopleInfo, setConcatPeopleInfo] = useState({
applyConcatId: '',
applyContactCsaNo: '',
applyContactEmail: '',
applyContactName: '',
applyContactPhone: '',
applyContactCompany: ''
2024-07-15 16:58:47 +08:00
})
2024-07-31 16:00:30 +08:00
// const [belongArray,setBelongArray] = useState([])
// // 获取初始所属者数组
// const getLength = () => {
// get({
// messageApi,
// url: `/api/proj-owner/list/self`,
// onBefore() {
// },
// onSuccess(data: any) {
// // console.log('所属者表格', data.data);
// // setBelongPeopleArray(data.data)
// setBelongArray(data.data )
// },
// onFinally() {
// }
// })
// }
// // 获取更新的所属者数组并且做对比查看是否刷新网页
// const getNewLength = () => {
// get({
// messageApi,
// url: `/api/proj-owner/list/self`,
// onBefore() {
// },
// onSuccess(data: any) {
// // console.log('所属者表格', data.data);
// // setBelongPeopleArray(data.data)
// console.log('查看结果',data.data != belongArray);
2024-08-12 14:43:58 +08:00
2024-07-31 16:00:30 +08:00
// // if (data.data == belongArray) {
// // window.location.reload();
// // }
// },
// onFinally() {
2024-07-29 19:48:37 +08:00
2024-07-31 16:00:30 +08:00
// }
// })
// }
2024-08-12 14:43:58 +08:00
2024-03-26 21:09:41 +08:00
useEffect(() => {
2024-07-31 16:00:30 +08:00
// getLength()
2024-04-02 18:45:46 +08:00
reloadUser(messageApi, globalDispatchContext).then((data) => {
if (!data.hasUserInfo) {
setIsSelfModalOpen(true);
2024-03-26 21:09:41 +08:00
}
2024-04-02 18:45:46 +08:00
});
2024-03-26 21:09:41 +08:00
}, [globalContext.user]);
2024-08-12 14:43:58 +08:00
// useEffect(()=>{
// getIc()
// },[])
2024-03-16 23:12:49 +08:00
const items: MenuProps['items'] = [
{
key: 'userinfo',
label: (
<div className="dropdown-item">
2024-04-29 17:22:26 +08:00
<UserOutlined />
2024-03-16 23:12:49 +08:00
<span className="title"></span>
</div>
),
2024-03-26 21:09:41 +08:00
onClick: () => {
setIsSelfModalOpen(true);
}
2024-03-16 23:12:49 +08:00
},
{
key: 'changePass',
label: (
<div className="dropdown-item">
2024-04-29 17:22:26 +08:00
<KeyOutlined />
2024-03-16 23:12:49 +08:00
<span className="title"></span>
</div>
),
2024-03-27 11:04:38 +08:00
onClick: () => {
setIsPasswordModalOpen(true);
}
2024-03-16 23:12:49 +08:00
},
2024-04-02 18:45:46 +08:00
{
key: 'invoice',
label: (
<div className="dropdown-item">
<AccountBookOutlined />
<span className="title"></span>
</div>
),
onClick: () => {
2024-04-07 17:37:09 +08:00
setIsInvoiceModalOpen(true);
2024-04-02 18:45:46 +08:00
}
},
2024-08-12 14:43:58 +08:00
{
key: 'myorder',
label: (
<div className="dropdown-item">
{/* <UsergroupAddOutlined /> */}
<ContainerOutlined />
<span className="title"></span>
</div>
),
onClick: () => {
setMyorderModal(true)
}
},
2024-03-16 23:12:49 +08:00
{
2024-06-20 09:14:36 +08:00
key: 'belong',
2024-03-16 23:12:49 +08:00
label: (
<div className="dropdown-item">
2024-07-05 13:38:59 +08:00
<MenuFoldOutlined />
2024-06-20 09:14:36 +08:00
<span className="title"></span>
2024-03-16 23:12:49 +08:00
</div>
),
2024-04-12 14:12:38 +08:00
onClick: () => {
2024-06-20 09:14:36 +08:00
setBelongModal(true)
2024-04-12 14:12:38 +08:00
}
2024-03-16 23:12:49 +08:00
},
2024-06-21 16:18:01 +08:00
{
key: 'contact',
label: (
<div className="dropdown-item">
2024-07-05 13:38:59 +08:00
<UsergroupAddOutlined />
2024-06-21 16:18:01 +08:00
<span className="title"></span>
</div>
),
onClick: () => {
setContactModal(true)
}
},
2024-08-12 14:43:58 +08:00
2024-06-19 11:08:39 +08:00
{
2024-06-20 09:14:36 +08:00
key: 'logout',
2024-06-19 11:08:39 +08:00
label: (
<div className="dropdown-item">
2024-06-20 09:14:36 +08:00
<LogoutOutlined />
<span className="title">退</span>
2024-06-19 11:08:39 +08:00
</div>
),
onClick: () => {
2024-06-20 09:14:36 +08:00
reMenuActive()
window.location.href = '/copyright/logout'
2024-06-19 11:08:39 +08:00
}
},
2024-07-05 13:38:59 +08:00
2024-03-16 23:12:49 +08:00
]
2024-03-11 19:13:42 +08:00
return (
2024-03-26 21:09:41 +08:00
<>
<div className="head">
<div className="center">
<div className="left">
2024-04-29 17:22:26 +08:00
{/* <span className="sys-title">AI</span>
2024-03-26 21:09:41 +08:00
<Divider type="vertical"/>
2024-04-29 17:22:26 +08:00
<span className="sys-title-sub"></span> */}
<img src={logoImg} alt="" />
2024-03-26 21:09:41 +08:00
</div>
2024-04-29 17:22:26 +08:00
{/* <div className="right" style={{backgroundImage: `url(${headRightBg})`}}> */}
2024-07-05 13:38:59 +08:00
2024-04-29 17:22:26 +08:00
<div className="right">
2024-08-12 14:43:58 +08:00
<div className='invitationButton' onClick={() => {
setinvitationModal(true)
getIc()
}}>
</div>
2024-07-29 17:22:42 +08:00
<div className='head-nav' onClick={() => {
2024-07-25 17:33:07 +08:00
window.open('https://www.aimzhu.com/operator/route/agreementportal/view?agreementId=c0c5683a-bef3-40c3-8395-900a362ea234&title=系统操作流程')
2024-07-05 13:38:59 +08:00
}}>
</div>
2024-04-29 17:22:26 +08:00
<BalanceHead />
<RechargeHead />
2024-03-26 21:09:41 +08:00
{/*<MessageHead/>*/}
2024-04-29 17:22:26 +08:00
<div style={{ display: 'flex', alignContent: 'center', padding: '0 10px', cursor: 'pointer' }}>
2024-07-05 13:38:59 +08:00
<div style={{ width: '50px', height: '50px', borderRadius: '25px', marginLeft: '20px', marginRight: '10px' }} >
<img src={userImg} alt="" width={50} height={50} />
2024-05-23 14:57:22 +08:00
</div>
2024-03-26 21:09:41 +08:00
<Dropdown menu={{
items: items
}}>
<Space>
2024-04-29 17:22:26 +08:00
{/* 您好:{globalContext.user.nickname} */}
<DownOutlined />
2024-03-26 21:09:41 +08:00
</Space>
</Dropdown>
</div>
2024-03-16 23:12:49 +08:00
</div>
2024-03-11 19:13:42 +08:00
</div>
</div>
2024-03-26 21:09:41 +08:00
<Modal open={isSelfModalOpen}
2024-07-29 17:22:42 +08:00
destroyOnClose={true}
2024-04-29 17:22:26 +08:00
title="个人信息"
footer={false}
onCancel={() => {
2024-07-29 19:48:37 +08:00
if (!globalContext.user.hasUserInfo) {
2024-04-29 17:22:26 +08:00
messageApi.info('请完善个人信息');
return;
}
setIsSelfModalOpen(false)
2024-07-29 17:22:42 +08:00
// console.log('用户信息',globalContext.user.hasUserInfo);
2024-07-29 19:48:37 +08:00
2024-04-29 17:22:26 +08:00
}}>
2024-03-26 21:09:41 +08:00
<UserEdit handleConfirm={(data) => {
modal.confirm({
2024-03-27 11:04:38 +08:00
title: '提示',
2024-03-26 21:09:41 +08:00
content: '确定保存吗?',
okText: '确认',
cancelText: '取消',
okButtonProps: {
style: {
backgroundColor: 'var(--color-primary)'
}
},
onOk: () => {
setIsSelfModalOpen(false);
put({
messageApi,
url: '/api/user-info/update-self',
body: data,
onBefore() {
setLoading(true);
},
onSuccess() {
messageApi.success('修改成功');
},
onFinally() {
setLoading(false);
}
})
2024-03-27 11:04:38 +08:00
}
});
2024-04-29 17:22:26 +08:00
}} />
2024-03-27 11:04:38 +08:00
</Modal>
<Modal open={isPasswordModalOpen}
2024-04-29 17:22:26 +08:00
title="修改密码"
footer={false}
onCancel={() => {
setIsPasswordModalOpen(false)
}}>
2024-03-27 11:04:38 +08:00
<PasswordChange handleConfirm={(data) => {
modal.confirm({
title: '提示',
content: '确定修改吗?',
okText: '确认',
cancelText: '取消',
okButtonProps: {
style: {
backgroundColor: 'var(--color-primary)'
}
},
onOk: () => {
put({
messageApi,
url: '/api/user/update-password',
body: data,
onBefore() {
setLoading(true);
},
onSuccess() {
setIsPasswordModalOpen(false);
messageApi.success('修改成功,重新登录生效');
},
onFinally() {
setLoading(false);
}
})
2024-03-26 21:09:41 +08:00
}
});
2024-04-29 17:22:26 +08:00
}} />
2024-03-26 21:09:41 +08:00
</Modal>
2024-04-07 17:37:09 +08:00
<Modal open={isInvoiceModalOpen}
2024-04-29 17:22:26 +08:00
title="发票管理"
width={1100}
footer={false}
onCancel={() => setIsInvoiceModalOpen(false)}
2024-04-01 20:39:22 +08:00
>
2024-04-29 17:22:26 +08:00
<InvoiceList />
2024-04-01 20:39:22 +08:00
</Modal>
2024-06-20 09:14:36 +08:00
<Modal title="知识产权所属者"
2024-06-19 11:08:39 +08:00
destroyOnClose
open={belongModal}
width={1200}
footer={null}
onCancel={() => {
2024-07-31 16:00:30 +08:00
upBelongArray()
// getNewLength()
2024-06-19 11:08:39 +08:00
setBelongModal(false)
}}>
2024-07-05 13:38:59 +08:00
<BelongPeople closeModal={() => { setBelongModal(false) }} setBelongPeopleInfo={setBelongPeopleInfo} belongPeopleInfo={belongPeopleInfo} setValue={setValue} isShow={false} ></BelongPeople>
2024-06-21 16:18:01 +08:00
</Modal>
<Modal title="知识产权联系人"
destroyOnClose
open={contactModal}
width={1200}
footer={null}
onCancel={() => {
setContactModal(false)
}}>
2024-07-29 17:22:42 +08:00
<ContactPeople isShow={false} closeModal={() => { setContactModal(false) }} setConcatPeopleInfo={setConcatPeopleInfo} concatPeopleInfo={concatPeopleInfo} setConcatValue={setConcatValue}></ContactPeople>
2024-06-19 11:08:39 +08:00
</Modal>
2024-08-12 14:43:58 +08:00
<Modal title="邀请码"
destroyOnClose
open={invitationModal}
width={578}
footer={null}
onCancel={() => {
// getNewLength()
setinvitationModal(false)
setInvNum('')
}}>
<div className='invitation-box'>
<div className='invBox-top'>
<div className='invBox-title'>
</div>
<div className='invBox-line'></div>
<div className='invBox-btn' onClick={() => {
getInvNum()
}} style={{ display: invNum || icStatus ? 'none' : 'block' }}>
</div>
<div className='invBox-btnTwo' style={{ display: icStatus == 'PENDING' ? 'block' : 'none' }}>
</div>
<div className='invBox-btnthree' style={{ display: icStatus == 'REJECTED' ? 'block' : 'none' }}>
<div className='errorBox'>
<div className='errorBox-title'> !</div>
<div className='errorBox-btn' onClick={() => {
getInvNum()
}}></div>
</div>
</div>
<div className='invBox-Num' style={{ display: invNum ? 'block' : 'none' }}>
<div className='invNum-box'>
<div className='invNum'>
{invNum}
</div>
<div className='copyBtn' onClick={() => {
copyInvNum()
}}>
</div>
</div>
</div>
</div>
{/* <div style={{ display: icRebateRatio ? 'block' : 'none' }}> */}
<div className='invBox-bot'>
<div className='invBox-tips' >
{icRebateRatio ? `邀请码分享给他人,即可获得${icRebateRatio}%佣金` : '邀请码分享给他人,即可获得佣金'}
{/* 邀请码分享给他人,即可获得{icRebateRatio}%佣金 */}
</div>
{/* <div className='invBox-tips'>
XXXXXX导致,
</div> */}
</div>
{/* </div> */}
</div>
<div className='invitation-box'>
<div className='invBox-top'>
<div className='invBox-title' style={{ fontSize: '24px' }}>
</div>
<div className='invBox-line'></div>
<div className='invBox-input' style={{ display: bindingInvNum ? 'none' : 'block' }}>
<div className='invInput'>
<Input value={inInvNum} style={{ width: 261, height: 60, borderRadius: 25, fontSize: 24, textAlign: 'center' }} onChange={(e) => {
setInInvNum(e.target.value)
}} />
<div className='invImg' onClick={() => {
postInvNum()
}}>
<img src={inv} alt="" style={{ width: 31, height: 30 }} />
</div>
</div>
</div>
<div className='invBox-input' style={{ display: bindingInvNum ? 'block' : 'none' }}>
<div className='invInput'>
<div className='invNum-box'>
<div className='invNum' >
{bindingInvNum}
</div>
{/* <div className='relieveBtn' onClick={() => {
setRelieveModal(true)
}}>
</div> */}
</div>
</div>
</div>
</div>
<div className='invBox-bot'>
<div className='invBox-tips' >
{bindingInvNum ? '已绑定邀请码' : '输入他人的邀请码,即可获得相应优惠'}
</div>
</div>
</div>
</Modal>
{/* <Modal title=""
okText="确认"
cancelText="取消"
destroyOnClose
open={relieveModal}
onOk={() => {
setBindingInvNum('')
setInInvNum('')
setRelieveModal(false)
}}
onCancel={() => {
setRelieveModal(false)
}}>
<div>
?
</div>
</Modal> */}
<Modal title="我的订单"
footer={null}
// okText="确认"
// cancelText="取消"
destroyOnClose
open={myorderModal}
// onOk={() => {
// setBindingInvNum('')
// setInInvNum('')
// setRelieveModal(false)
// }}
width={1500}
onCancel={() => {
setMyorderModal(false)
}}>
<MyOrder></MyOrder>
</Modal>
2024-04-29 17:22:26 +08:00
<Spin tip="正在提交..." spinning={loading} fullscreen />
2024-03-26 21:09:41 +08:00
{contextHolder}
{modalHolder}
</>
2024-03-11 19:13:42 +08:00
)
}