隐藏创建邀请码

This commit is contained in:
lyp 2025-03-07 10:58:17 +08:00
parent 890ef56f53
commit 45fd7c0e5d

View File

@ -5,8 +5,12 @@ import { useDispatch,
} from 'react-redux'
import BalanceHead from '../../components/balance/BalanceHead.tsx';
import RechargeHead from '../../components/recharge/RechargeHead.tsx';
import { Empty, Dropdown, MenuProps, message, Modal, Space, Spin, Input, Table, Form, Button, InputNumber } from "antd";
import type { TableProps, FormProps } from 'antd';
import {
// Empty,
Dropdown, MenuProps, message, Modal, Space, Spin, Input, Table,
// Form, Button, InputNumber
} from "antd";
// import type { TableProps, FormProps } from 'antd';
interface DataType {
usericId: string;
icPriceMaterial: number;
@ -14,23 +18,23 @@ interface DataType {
createTime: string;
}
interface icDataType {
contactName: string;//联系人姓名
contactPhone: string;//联系人电话
idCardNumber: string;//证件号
idCardType: string;//证件类型
lastLoginTime: string;//最后登录时间
userId: string;//用户id
userInfoId: string;//主键
userInfoName: string;//用户名称
userInfoNameEn: string;//用户英文名称
userInfoType: string;//用户类型
userUsername: string;//用户名
}
type FieldType = {
icPriceMaterial: string;
icPriceAll: string;
};
// interface icDataType {
// contactName: string;//联系人姓名
// contactPhone: string;//联系人电话
// idCardNumber: string;//证件号
// idCardType: string;//证件类型
// lastLoginTime: string;//最后登录时间
// userId: string;//用户id
// userInfoId: string;//主键
// userInfoName: string;//用户名称
// userInfoNameEn: string;//用户英文名称
// userInfoType: string;//用户类型
// userUsername: string;//用户名
// }
// type FieldType = {
// icPriceMaterial: string;
// icPriceAll: string;
// };
// const data: DataType[] = [
// {
@ -99,7 +103,7 @@ import { DownOutlined, UserOutlined, QuestionCircleOutlined, BellOutlined, KeyOu
import { useContext, useEffect, useState } from "react";
import {
put, get,
post,
// post,
getUseUrl
} from "../../util/AjaxUtils.ts";
import { GlobalContext, GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts";
@ -155,14 +159,18 @@ export default function Head() {
// useEffect(() => {
// getPickList();
// }, [packPage]);
const [page, setPage] = useState(1) //邀请码使用人数分页
const [total, setTotal] = useState(0) //邀请码使用人数总量
const [icListLoading, setIcListLoading] = useState(false)
const [myInvModal, setMyInvModal] = useState(false) //我的邀请码弹窗
const [createInvModal, setCreateInvModal] = useState(false) //创建邀请码弹窗
const [icModal, setIcModal] = useState(false) //查看邀请码详情弹窗
const [selectIc, setSelectIc] = useState('') //选中的邀请码
// const [page, setPage] = useState(1) //邀请码使用人数分页
// const [total, setTotal] = useState(0) //邀请码使用人数总量
// const [icListLoading, setIcListLoading] = useState(false)
// const [myInvModal, setMyInvModal] = useState(false) //我的邀请码弹窗
// const [createInvModal, setCreateInvModal] = useState(false) //创建邀请码弹窗
// const [icModal, setIcModal] = useState(false) //查看邀请码详情弹窗
// const [selectIc, setSelectIc] = useState('') //选中的邀请码
// const redxuState: any = useSelector(state => state)
// const packNum = redxuState.packNum
// 消息通知弹窗
@ -198,7 +206,7 @@ export default function Head() {
// 邀请码申请状态
// const [icStatus, setIcStatus] = useState('')
// 邀请码返利比例
const [icRebateRatio, seticRebateRatio] = useState('')
// const [icRebateRatio, seticRebateRatio] = useState('')
// 全托管分账
// const [icPriceAll, seticPriceAll] = useState(0)
// 写材料分账
@ -228,7 +236,7 @@ export default function Head() {
// console.log(data);
// setInvNum(data.ic)
setBindingInvNum(data.relationIc)
seticRebateRatio(data.icRebateRatio)
// seticRebateRatio(data.icRebateRatio)
// seticPriceAll(Number(data.icPriceAll) / 100 * Number(data.icRebateRatio) / 100)
// seticPriceMaterial(Number(data.icPriceMaterial) / 100 * Number(data.icRebateRatio) / 100)
if (data.ic == '') {
@ -278,75 +286,75 @@ export default function Head() {
}
}
// 我的邀请码列表
const [myIcList, setMyIcList] = useState([])
// const [myIcList, setMyIcList] = useState([])
// 获取我得邀请码列表
const getMyIcList = () => {
get<any>({
messageApi,
url: '/api/ic/v2/list/self',
// body: {
// value: inInvNum
// },
onBefore() {
setIcListLoading(true)
},
onSuccess({ data }) {
// console.log(data);
setMyIcList(data)
// setMyIcList([])
},
onFinally() {
setIcListLoading(false)
}
})
}
const [minAllPrice, setMinAllPrice] = useState(0) //最低全托管折扣价
const [minMaterialPrice, setMinMaterialPrice] = useState(0) //最低写材料折扣价
// const getMyIcList = () => {
// get<any>({
// messageApi,
// url: '/api/ic/v2/list/self',
// // body: {
// // value: inInvNum
// // },
// onBefore() {
// setIcListLoading(true)
// },
// onSuccess({ data }) {
// // console.log(data);
// setMyIcList(data)
// // setMyIcList([])
// },
// onFinally() {
// setIcListLoading(false)
// }
// })
// }
// const [minAllPrice, setMinAllPrice] = useState(0) //最低全托管折扣价
// const [minMaterialPrice, setMinMaterialPrice] = useState(0) //最低写材料折扣价
// 查看我得最低定价
const getMyIcMinPrice = () => {
get<any>({
messageApi,
url: '/api/proj/charge/get',
onBefore() {
// const getMyIcMinPrice = () => {
// get<any>({
// messageApi,
// url: '/api/proj/charge/get',
// onBefore() {
},
onSuccess({ data }) {
// console.log(data.projTypes);
// console.log((data.projTypes.find((item:any) => item.type === 'MATERIAL')).price/100);
// },
// onSuccess({ data }) {
// // console.log(data.projTypes);
// // console.log((data.projTypes.find((item:any) => item.type === 'MATERIAL')).price/100);
setMinAllPrice((data.projTypes.find((item: any) => item.type === 'ALL')).price / 100)
setMinMaterialPrice((data.projTypes.find((item: any) => item.type === 'MATERIAL')).price / 100)
// setMinAllPrice((data.projTypes.find((item: any) => item.type === 'ALL')).price / 100)
// setMinMaterialPrice((data.projTypes.find((item: any) => item.type === 'MATERIAL')).price / 100)
},
onFinally() {
// },
// onFinally() {
}
})
}
// }
// })
// }
// 查看我的邀请码是否超出限制
const getIcLimit = () => {
get<any>({
messageApi,
url: '/api/ic/v2/list/self',
onBefore() {
// const getIcLimit = () => {
// get<any>({
// messageApi,
// url: '/api/ic/v2/list/self',
// onBefore() {
},
onSuccess({ data }) {
// console.log(data);
// console.log(data.length);
// },
// onSuccess({ data }) {
// // console.log(data);
// // console.log(data.length);
if (data.length >= 10) {
messageApi.open({
type: 'error',
content: '您的邀请码已达上限'
})
} else {
setCreateInvModal(true)
getMyIcMinPrice()
}
}
})
}
// if (data.length >= 10) {
// messageApi.open({
// type: 'error',
// content: '您的邀请码已达上限'
// })
// } else {
// setCreateInvModal(true)
// getMyIcMinPrice()
// }
// }
// })
// }
// 点击获取邀请码
// const getInvNum = () => {
// post<any>({
@ -367,207 +375,207 @@ export default function Head() {
// }
// 表单事件
const onFinish: FormProps<FieldType>['onFinish'] = (values: any) => {
// console.log('Success:', values.icPriceAll);
// console.log('Success:', values.icPriceMaterial);
post<any>({
messageApi,
url: `/api/ic/v2/save`,
body: {
icPriceAll: values.icPriceAll * 100,
icPriceMaterial: values.icPriceMaterial * 100
},
onBefore() {
setIcListLoading(true)
},
onSuccess() {
// console.log(data);
messageApi.success('创建成功')
// 关闭弹窗
setCreateInvModal(false)
// const onFinish: FormProps<FieldType>['onFinish'] = (values: any) => {
// // console.log('Success:', values.icPriceAll);
// // console.log('Success:', values.icPriceMaterial);
// post<any>({
// messageApi,
// url: `/api/ic/v2/save`,
// body: {
// icPriceAll: values.icPriceAll * 100,
// icPriceMaterial: values.icPriceMaterial * 100
// },
// onBefore() {
// setIcListLoading(true)
// },
// onSuccess() {
// // console.log(data);
// messageApi.success('创建成功')
// // 关闭弹窗
// setCreateInvModal(false)
},
onFinally() {
setIcListLoading(false)
}
})
};
// },
// onFinally() {
// setIcListLoading(false)
// }
// })
// };
// const onFinishFailed: FormProps<FieldType>['onFinishFailed'] = (errorInfo) => {
// console.log('Failed:', errorInfo);
// };
// 使用的邀请码的人的信息列表
const [icList, setIcList] = useState<icDataType[]>([]);
// const [icList, setIcList] = useState<icDataType[]>([]);
// 获取使用的邀请码的人的信息
const getIcUserInfo = (id: string, page: number) => {
get<any>({
messageApi,
url: `/api/ic/v2/user-list/${id}`,
config: {
params: {
page: page,
rows: 10
}
},
onBefore() {
setIcListLoading(true)
},
onSuccess({ data }) {
setIcList(data.rows)
setTotal(data.total)
// const getIcUserInfo = (id: string, page: number) => {
// get<any>({
// messageApi,
// url: `/api/ic/v2/user-list/${id}`,
// config: {
// params: {
// page: page,
// rows: 10
// }
// },
// onBefore() {
// setIcListLoading(true)
// },
// onSuccess({ data }) {
// setIcList(data.rows)
// setTotal(data.total)
},
onFinally() {
setIcListLoading(false)
}
// },
// onFinally() {
// setIcListLoading(false)
// }
})
}
// })
// }
// 复制邀请码
const copyInvNum = (code: any) => {
// 创建一个临时的 input 元素
const tempInput = document.createElement('input');
document.body.appendChild(tempInput);
tempInput.value = code;
// const copyInvNum = (code: any) => {
// // 创建一个临时的 input 元素
// const tempInput = document.createElement('input');
// document.body.appendChild(tempInput);
// tempInput.value = code;
// 选中 input 中的内容
tempInput.select();
tempInput.setSelectionRange(0, 99999); // 对于移动设备的支持
// // 选中 input 中的内容
// tempInput.select();
// tempInput.setSelectionRange(0, 99999); // 对于移动设备的支持
// 执行复制操作
try {
document.execCommand('copy');
messageApi.open({
type: 'success',
content: '已复制到剪切板'
})
} catch (err) {
messageApi.open({
type: 'error',
content: '复制失败,请手动复制'
})
}
// // 执行复制操作
// try {
// document.execCommand('copy');
// messageApi.open({
// type: 'success',
// content: '已复制到剪切板'
// })
// } catch (err) {
// messageApi.open({
// type: 'error',
// content: '复制失败,请手动复制'
// })
// }
// 移除临时的 input 元素
document.body.removeChild(tempInput);
}
const columns: TableProps<DataType>['columns'] = [
{
title: '序号',
align: 'center',
dataIndex: 'usericId',
key: 'usericId',
render: (_text, _record, index) => <div>
{index + 1}
</div>,
},
{
title: '邀请码',
align: 'center',
dataIndex: 'usericId',
key: 'usericId',
// render: (text) => <a>{text}</a>,
},
{
title: '创建时间',
align: 'center',
dataIndex: 'createTime',
key: 'usericId',
// render: (text) => <a>{text}</a>,
},
{
title: '写材料价格',
align: 'center',
dataIndex: 'icPriceMaterial',
key: 'usericId',
render: (text) => <>{text / 100}</>
},
{
title: '全托管价格',
align: 'center',
dataIndex: 'icPriceAll',
key: 'usericId',
render: (text) => <>{text / 100}</>
},
// {
// title: '返利比例',
// align: 'center',
// dataIndex: 'icRebateTatio',
// key: 'usericId',
// render: (text) => <>{text}%</>,
// },
// {
// title: '产生的成交金额',
// align: 'center',
// dataIndex: 'totalMoney',
// key: 'usericId',
// },
// // 移除临时的 input 元素
// document.body.removeChild(tempInput);
// }
// const columns: TableProps<DataType>['columns'] = [
// {
// title: '序号',
// align: 'center',
// dataIndex: 'usericId',
// key: 'usericId',
// render: (_text, _record, index) => <div>
// {index + 1}
// </div>,
// },
// {
// title: '邀请码',
// align: 'center',
// dataIndex: 'usericId',
// key: 'usericId',
// // render: (text) => <a>{text}</a>,
// },
// {
// title: '创建时间',
// align: 'center',
// dataIndex: 'createTime',
// key: 'usericId',
// // render: (text) => <a>{text}</a>,
// },
// {
// title: '写材料价格',
// align: 'center',
// dataIndex: 'icPriceMaterial',
// key: 'usericId',
// render: (text) => <>{text / 100}元</>
// },
// {
// title: '全托管价格',
// align: 'center',
// dataIndex: 'icPriceAll',
// key: 'usericId',
// render: (text) => <>{text / 100}元</>
// },
// // {
// // title: '返利比例',
// // align: 'center',
// // dataIndex: 'icRebateTatio',
// // key: 'usericId',
// // render: (text) => <>{text}%</>,
// // },
// // {
// // title: '产生的成交金额',
// // align: 'center',
// // dataIndex: 'totalMoney',
// // key: 'usericId',
// // },
{
title: '操作',
align: 'center',
key: 'usericId',
render: (_, record) => (
<Space size="middle">
// {
// title: '操作',
// align: 'center',
// key: 'usericId',
// render: (_, record) => (
// <Space size="middle">
<a style={{
textDecoration: 'underline',
}} onClick={() => {
copyInvNum(record.usericId)
}}></a>
<a style={{
textDecoration: 'underline',
}} onClick={() => {
setIcModal(true)
setSelectIc(record.usericId)
getIcUserInfo(record.usericId, page)
}}>使</a>
// <a style={{
// textDecoration: 'underline',
// }} onClick={() => {
// copyInvNum(record.usericId)
// }}>复制</a>
// <a style={{
// textDecoration: 'underline',
// }} onClick={() => {
// setIcModal(true)
// setSelectIc(record.usericId)
// getIcUserInfo(record.usericId, page)
// }}>查看使用用户</a>
</Space>
),
},
];
const icColumns: TableProps<icDataType>['columns'] = [
{
title: '序号',
align: 'center',
dataIndex: 'index',
key: 'userInfoId',
render: (_text, _record, index) => <div>
{index + 1}
</div>,
},
// {
// title: '用户ID',
// align: 'center',
// dataIndex: 'userId',
// key: 'userInfoId',
// // render: (text) => <a>{text}</a>,
// },
{
title: '账号',
align: 'center',
dataIndex: 'userUsername',
key: 'userInfoId',
// render: (text) => <a>{text}</a>,
},
{
title: '昵称',
align: 'center',
dataIndex: 'userInfoName',
key: 'userInfoId',
// render: (text) => <a>{text}</a>,
},
{
title: '最近登录时间',
align: 'center',
dataIndex: 'lastLoginTime',
key: 'userInfoId',
// render: (text) => <a>{text}</a>,
},
// </Space>
// ),
// },
// ];
// const icColumns: TableProps<icDataType>['columns'] = [
// {
// title: '序号',
// align: 'center',
// dataIndex: 'index',
// key: 'userInfoId',
// render: (_text, _record, index) => <div>
// {index + 1}
// </div>,
// },
// // {
// // title: '用户ID',
// // align: 'center',
// // dataIndex: 'userId',
// // key: 'userInfoId',
// // // render: (text) => <a>{text}</a>,
// // },
// {
// title: '账号',
// align: 'center',
// dataIndex: 'userUsername',
// key: 'userInfoId',
// // render: (text) => <a>{text}</a>,
// },
// {
// title: '昵称',
// align: 'center',
// dataIndex: 'userInfoName',
// key: 'userInfoId',
// // render: (text) => <a>{text}</a>,
// },
// {
// title: '最近登录时间',
// align: 'center',
// dataIndex: 'lastLoginTime',
// key: 'userInfoId',
// // render: (text) => <a>{text}</a>,
// },
]
// ]
const dispath = useDispatch()
// 更新所属者表格储存至redux
const upBelongArray = () => {
@ -1185,7 +1193,7 @@ export default function Head() {
setInInvNum('')
}}>
<Spin tip="加载中..." spinning={isLoading}>
<div className='invitation-box'>
{/* <div className='invitation-box'> */}
{/* <div className='invBox-top'>
<div className='invBox-title'>
@ -1221,7 +1229,7 @@ export default function Head() {
</div>
</div>
</div> */}
<div className='invBox-top'>
{/* <div className='invBox-top'>
<div className='invBox-titleTop'
>
@ -1238,7 +1246,7 @@ export default function Head() {
<div className='createInv'>
<span
onClick={() => {
// setCreateInvModal(true)
getIcLimit()
}}
@ -1246,29 +1254,27 @@ export default function Head() {
cursor: 'pointer'
}}></span>
</div>
</div>
</div> */}
{/* <div style={{ display: icRebateRatio ? 'block' : 'none' }}> */}
<div className='invBox-bot'>
{/* <div className='invBox-bot'>
<div className='invBox-tips' >
{/* {icRebateRatio ? `邀请码分享给他人,即可获得${icRebateRatio}%佣金` : '邀请码分享给他人,即可获得佣金'} */}
{icRebateRatio ?
(<div>
<div> {icRebateRatio}%</div>
{/* <div style={{ paddingBottom: 20 }}>全托管佣金:{icPriceAll}元,写材料佣金:{icPriceMaterial}元</div> */}
</div>
)
: (<></>)}
{/* */}
</div>
{/* <div className='invBox-tips'>
XXXXXX导致,
</div> */}
</div>
{/* </div> */}
</div>
{/* </div> */}
<div className='invitation-box'>
<div className='invBox-top'>
<div className='invBox-title' style={{
@ -1406,7 +1412,7 @@ export default function Head() {
// setCouponModal(false)
}}></HeadCouponModal>
</Modal> */}
<Modal title="我的邀请码"
{/* <Modal title=""
// footer={null}
centered
destroyOnClose
@ -1443,8 +1449,8 @@ export default function Head() {
/>
</div>
</Spin>
</Modal>
<Modal title="创建邀请码"
</Modal> */}
{/* <Modal title=""
// footer={null}
centered
destroyOnClose
@ -1551,8 +1557,8 @@ export default function Head() {
</Form>
</Spin>
</div>
</Modal>
<Modal title={`邀请码${selectIc}使用用户`}
</Modal> */}
{/* <Modal title={`${selectIc}使`}
// footer={null}
centered
destroyOnClose
@ -1601,7 +1607,7 @@ export default function Head() {
/>
</Spin>
</Modal>
</Modal> */}
<Spin tip="正在提交..." spinning={loading} fullscreen />
{contextHolder}
{modalHolder}