diff --git a/src/App.tsx b/src/App.tsx index 9fc0471..97769f1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -144,7 +144,7 @@ const App: React.FC = () => { // } // } - + // const nav = useNavigate(); useEffect(() => { @@ -198,7 +198,6 @@ const App: React.FC = () => { - {/* */} diff --git a/src/components/payment/Payment.tsx b/src/components/payment/Payment.tsx index a3e8f66..45f5b64 100644 --- a/src/components/payment/Payment.tsx +++ b/src/components/payment/Payment.tsx @@ -20,7 +20,7 @@ import { import { ReloadOutlined } from '@ant-design/icons' -import { useEffect, useRef, useState } from "react"; +import { useEffect, useRef, useState, useContext } from "react"; import locale from 'antd/locale/zh_CN'; import dayjs from 'dayjs'; import 'dayjs/locale/zh-cn'; @@ -38,9 +38,11 @@ import type { import wx from '../../static/wx.png'; import zfb from '../../static/zfb.png'; import dg from '../../static/dg.png'; +import yue from '../../static/yue.png'; import nodate from '../../static/nodate.png'; +import { GlobalContext, GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts" // import { log } from 'console'; - +import { balanceBuyPackage } from '../../request/api.ts' // import { render } from 'react-dom'; interface DataType { key: React.Key; @@ -48,6 +50,7 @@ interface DataType { packageMoney: number; packageDescription: string; packageInfoId: string; + packageCount: number; } dayjs.locale('zh-cn'); @@ -80,7 +83,8 @@ type PaySystemBank = { enum ThirdPartyEnum { WX = '微信', ZFB = '支付宝', - DGZZ = '对公转账' + DGZZ = '对公转账', + YEZF = '余额支付' } interface IPaymentProps { @@ -89,8 +93,33 @@ interface IPaymentProps { handleCancel(): void; show: boolean; } +import { useDispatch } from 'react-redux' // import { GlobalContext } from "../../context/GlobalContext.ts"; export default function Payment(props: IPaymentProps) { + const dispath = useDispatch() + const getMyPackNum = () => { + get({ + messageApi, + url: `/api/proj/servicepkg/packageorder/count/self`, + onBefore() { + + }, + onSuccess({ data }) { + dispath({ + type: 'upPackNum', + val: { + ALL: data.ALL, + MATERIAL: data.MATERIAL, + } + }) + }, + onFinally() { + + } + }) + } + const globalDispatchContext = useContext(GlobalDispatchContext); + const globalContext = useContext(GlobalContext); // const globalContext = useContext(GlobalContext); const token = sessionStorage.getItem('token') // 服务包相关 @@ -110,6 +139,11 @@ export default function Payment(props: IPaymentProps) { }; const [packList, setPackList] = useState([]); const [packageInfoId, setPackageInfoId] = useState('');//单选 服务包id + const [packageName, setPackageName] = useState('');//单选 服务包名称 + const [packageMoney, setPackageMoney] = useState(0);//单选 服务包价格 + const [packageCount, setPackageCount] = useState(0);//单选 服务包件数 + // 余额支付弹窗 + const [balancePayModal, setBalancePayModal] = useState(false); // 获取套餐列表 const getPackageList = (value: string, page: number) => { get({ @@ -156,8 +190,8 @@ export default function Payment(props: IPaymentProps) { // // } // setShowWX(data.isWxPay == 1 ? true : false); // setShowZFB(data.isZfbPay == 1 ? true : false); - - + + // } // }) // }) @@ -247,6 +281,9 @@ export default function Payment(props: IPaymentProps) { onClick={() => { if (!packageInfoId) { setPackageInfoId(record.packageInfoId); + setPackageName(record.packageName); + setPackageMoney(record.packageMoney); + setPackageCount(record.packageCount); form.setFieldValue('rechargeMoney', (record.packageMoney) / 100); getPay(record.packageInfoId); } @@ -259,9 +296,19 @@ export default function Payment(props: IPaymentProps) { color: '#0B4AFF' }} onClick={() => { + // setThirdParty(ThirdPartyEnum.DGZZ); + // return setPackageInfoId(''); form.setFieldValue('rechargeMoney', 280); - getPay(''); + if (thirdParty !== '余额支付') { + getPay(''); + + } else { + setThirdParty(ThirdPartyEnum.DGZZ); + form.setFieldValue('thirdParty', '对公转账'); + } + + }} >取消 @@ -418,7 +465,10 @@ export default function Payment(props: IPaymentProps) { setThirdParty(ThirdPartyEnum.DGZZ) return; } - getPay(packageInfoId); + if (thirdParty !== '余额支付') { + getPay(packageInfoId); + + } // countdown() }, [thirdParty, refreshQrCodeCount]); @@ -742,6 +792,97 @@ export default function Payment(props: IPaymentProps) { ) } + if (thirdParty == '余额支付') { + return ( + <> +
+
余额支付
+
+
+
+
您的余额
+
{globalContext.user.balance}
+ +
+
+ 名称:{packageName} +
+
+ 价格:{packageMoney / 100}元 +
+
+ 次数:{packageCount} +
+
+
+
+ 需支付金额: + {packageMoney / 100} + +
+
+ 支付后余额:{(Number(globalContext.user.balance) - (packageMoney / 100)).toFixed(2)}元 +
+
= 0 ? 'none' : 'unset', + color: 'red', + }}> + 余额不足,请充值! +
+
+ +
+
+
+ + +
+ + ) + } return <>
@@ -969,20 +1110,27 @@ export default function Payment(props: IPaymentProps) { label="支付方式" name="thirdParty" rules={[{ required: true }]} - > - { - form.setFieldValue('thirdParty', e.target.value); - setThirdParty(e.target.value); - // console.log(e.target.value); - // setPackageInfoId(''); - setIsRechargeMoneyEdit(false) - // setValue('') - // form.setFieldValue('rechargeMoney', 280); - // setSelectedRowKeys([]); - }}> + > + { + if (e.target.value == '余额支付') { + setThirdParty(e.target.value); + // reloadUser(messageApi, globalDispatchContext) + return + } + form.setFieldValue('thirdParty', e.target.value); + setThirdParty(e.target.value); + // setPackageInfoId(''); + setIsRechargeMoneyEdit(false) + // setValue('') + // form.setFieldValue('rechargeMoney', 280); + // setSelectedRowKeys([]); + + + }}> @@ -990,7 +1138,7 @@ export default function Payment(props: IPaymentProps) { @@ -1003,6 +1151,16 @@ export default function Payment(props: IPaymentProps) { /> 对公转账 + + + + 余额支付 + + @@ -1202,6 +1360,53 @@ export default function Payment(props: IPaymentProps) {
确定对公转账{form.getFieldValue('rechargeMoney')} 吗?不确定请修改金额。
+ + + { + + try { + setBalancePayModal(false); + + setIsLoading(true); + await balanceBuyPackage(packageInfoId); + + getMyPackNum() + setIsLoading(false); + + reloadUser(messageApi, globalDispatchContext).then(() => { + messageApi.success('已购买套餐包'); + }); + setTimeout(() => { + props.handleConfirm(); + }, 1000); + } 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})`, + }); + } + } + }} + onCancel={() => { + setBalancePayModal(false); + }}> +
+
确定使用余额支付{packageMoney / 100}元吗?
+
+
) } \ No newline at end of file diff --git a/src/components/payment/payment.css b/src/components/payment/payment.css index 7578955..e77b00a 100644 --- a/src/components/payment/payment.css +++ b/src/components/payment/payment.css @@ -84,6 +84,36 @@ text-align: center; } +.balancePayMonye { + width: 100%; + height: 109px; + background: #E7F0FF; + padding: 20px 30px; + box-sizing: border-box; + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.balancePayMonyeTop { + font-size: 17px; + color: #6B778D; +} + +.balancePayMonyeBot { + font-weight: 800; + font-size: 36px; + color: #F29C38; + +} +.balancePayInfo{ + font-size: 18px; + width: 100%; + padding:0 10px; + box-sizing: border-box; + margin-top: 10px; + /* color: #6B778D; */ +} .paytip { margin-top: 10px; } @@ -94,5 +124,5 @@ background: #abc8ff; text-align: center; line-height: 36px; - color: #FFFFFF ; + color: #FFFFFF; } \ No newline at end of file diff --git a/src/layout/head/Head.tsx b/src/layout/head/Head.tsx index 0c2a6ef..999f9f1 100644 --- a/src/layout/head/Head.tsx +++ b/src/layout/head/Head.tsx @@ -21,7 +21,7 @@ import { // Empty, Dropdown, MenuProps, message, Modal, Space, Spin, Input, // Table, - Form, Button + Form, Button // Form, Button, InputNumber } from "antd"; // import { @@ -33,6 +33,7 @@ import line from '../../static/Phone/line.png' import pack from '@theme/img/pack.png' import PackAgeModal from '../../components/PackageModal/PackageModal.tsx' +import active from '../../static/active.gif' // import pack from '@theme/pack.png' // import type { TableProps, FormProps } from 'antd'; // interface DataType { @@ -382,6 +383,7 @@ export default function Head() { // const [packageType, setPackageType] = useState('') const packNum = redxuState.packNum const phoneModal = redxuState.phoneModal + // const activityModal = redxuState.activityModal // const packItems: MenuProps['items'] = [ // { // key: '1', @@ -424,6 +426,7 @@ export default function Head() { // ] + // 消息通知弹窗 const [noticeModal, setNoticeModal] = useState(false) // 客服弹窗 @@ -1282,6 +1285,20 @@ export default function Head() { {/*
*/}
+
{ + // setActivityModal(true) + dispath({ + type: 'setActivityModal', + val: true, + }) + }} + > + +
{ setkfModal(true) }}> diff --git a/src/layout/head/head.css b/src/layout/head/head.css index 721bcb7..c249dda 100644 --- a/src/layout/head/head.css +++ b/src/layout/head/head.css @@ -487,4 +487,7 @@ font-size: 14px; color: #B6B6B6; cursor: pointer; -} \ No newline at end of file +} + + + diff --git a/src/request/api.ts b/src/request/api.ts index a0c8061..451748f 100644 --- a/src/request/api.ts +++ b/src/request/api.ts @@ -1,4 +1,4 @@ -import {request,aiShopRequest,phoneRequest,newRequest} from './request' +import {request,aiShopRequest,phoneRequest,newRequest,activityRequset} from './request' // import newRequest from './request' // 开票功能operatorPluginBaseUrl------------------------------------------------------------------------------------------------------------------------------------------------------- // 获取登录标志 @@ -7,6 +7,11 @@ export const getLoginflag = (userId: string) => request.get(`/operator-plugin/ap export const getInvoiceRecordList = (userId: string, params: any) => request.get(`/operator-plugin/api/invoicerecharge/listpage/${userId}`, { params }) // 获取开票信息数组 export const getInvoiceList = (userId: string, params: any) => request.get(`/operator-plugin/api/invoice-config/listpage/${userId}`, { params }) +// 获取活动信息 +export const activityData = () => activityRequset.get(`/operator-plugin/api/user/invite/get`) +// 余额购买套餐包 +export const balanceBuyPackage = (packageInfoId: string) => activityRequset.post(`/operator-plugin/api/packageorder/buy/${packageInfoId} `) + // 新增开票信息 export const addInvoiceInfo = (userId: string, params: any) => request.post(`/operator-plugin/api/invoice-config/save/${userId}`, params) diff --git a/src/request/request.ts b/src/request/request.ts index 14a6ef5..95e1c99 100644 --- a/src/request/request.ts +++ b/src/request/request.ts @@ -62,7 +62,54 @@ request.interceptors.response.use( ); //----------------------------------------------------------------------------------------- +// 获取活动信息---------------------------------------------------------------------------- +const activityRequset = axios.create({ + // baseURL: operatorPluginBaseUrl, + baseURL: 'http://192.168.0.115:8099', + timeout: 5000, +}); +activityRequset.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 } + 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 } + } + } + if (config.method === 'delete') { + if (!config.data) { + config.data = { unused: 0 } + } + } + + return config; + }, + + (err) => Promise.reject(err) +); +activityRequset.interceptors.response.use( + (res) => { + return res.data; + }, + (err) => Promise.reject(err) +); +// --------------------------------------------------------------------------------------- // 买卖功能(交易中心/APP电子软著)---------------------------------------------------------------------------- const aiShopRequest = axios.create({ @@ -188,6 +235,8 @@ newRequest.interceptors.response.use( // 下载发票 export const downloadInvoice = (id: string) => { return `${operatorPluginBaseUrl}/operator-plugin/route/file/download/false/${id}` + //测试 + // return `http://192.168.0.115:8099/operator-plugin/route/file/download/false/${id}` }; @@ -229,4 +278,4 @@ export const uploadDeputeUrl = () => { return `${aiShopBaseUrl}/aishop/api/trademark/upload-weituo-file ` } -export { request,aiShopRequest,phoneRequest,newRequest}; +export { request,aiShopRequest,phoneRequest,newRequest,activityRequset}; diff --git a/src/route/index/Index.tsx b/src/route/index/Index.tsx index fdeb40f..0709d26 100644 --- a/src/route/index/Index.tsx +++ b/src/route/index/Index.tsx @@ -8,8 +8,10 @@ import { Modal, // Row, DatePicker, - InputNumber + InputNumber, + Checkbox } from 'antd'; +import { downloadInvoice } from '../../request/request.ts' import locale from 'antd/es/date-picker/locale/zh_CN'; import type { DatePickerProps, InputNumberProps } from 'antd'; import dayjs, { } from 'dayjs'; @@ -58,7 +60,8 @@ import { import { // getLanguageList, getSoftTypeList appGoodsList, - buyAppGoods, appOrderList, trademarkGoodsList + buyAppGoods, appOrderList, trademarkGoodsList, + activityData } from '../../request/api' import { setMenuActive, @@ -100,7 +103,58 @@ import yes from '../../static/trademark/yes.png' import firImg from '../../static/fir.png' import noFirImg from '../../static/noFir.png' + export default function Index() { + // 活动图片 + const [activityImg, setActivityImg] = useState('') + // 活动名称 + const [activityTitle, setActivityTitle] = useState('') + // 活动内容 + const [activityText, setActivityText] = useState('') + // 活动不显示天数 + const [activityCycle, setActivityCycle] = useState(0) + // 活动邀请码 + const [activityCode, setActivityCode] = useState('') + // 活动钱数 + const [activityMoney, setActivityMoney] = useState(0) + // 是否选中近期不在提示 + const [activityChecked, setActivityChecked] = useState(false) + const closeActivityModal = document.cookie.replace(/(?:(?:^|.*;\s*)closeActivityModal\s*=\s*([^;]*).*$)|^.*$/, "$1"); + + // 获取活动信息 + const getActivityData = async () => { + try { + const res: any = await activityData() + // console.log('活动信息', res); + if (closeActivityModal) { + setActivityChecked(true) + } + if (res.title && !closeActivityModal) { + dispath({ + type: 'setActivityModal', + val: true, + }) + } + setActivityImg(downloadInvoice(res.image)) + setActivityTitle(res.title) + setActivityText(res.help) + setActivityCycle(res.cycle) + setActivityMoney(res.money) + setActivityCode(res.code) + } 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 globalDispatchContext = useContext(GlobalDispatchContext); // const height = window.innerHeight - 180; const columns: TableColumnsType = [ @@ -232,7 +286,11 @@ export default function Index() { //redux的belongArray const redxuState: any = useSelector(state => state) const phoneModal = redxuState.phoneModal + const activityModal = redxuState.activityModal // const belongArray = redxuState.belongArray + //监听cookie里面如果有closeActivityModal这个值 则打印这个值 + + // const belongArrayList = belongArray.map((item:any) => ({ // value: item.projOwnerId , @@ -1129,7 +1187,7 @@ export default function Index() { const [trademarkModal, setTrademarkModal] = useState(false) // 申请商标弹窗 const [trademarkNewKeywords, setTrademarkNewKeywords] = useState('') // 临时关键字 const [trademarkKeywords, setTrademarkKeywords] = useState('') // 关键字 - const [trademarkStatus,setTrademarkStatus] = useState(null) + const [trademarkStatus, setTrademarkStatus] = useState(null) const trademarkKeyWordshandleSearch = () => { setTrademarkKeywords(trademarkNewKeywords) } @@ -1149,12 +1207,12 @@ export default function Index() { nav('/trademark-mall', { state: { keywords: trademarkKeywords, - trademarkStatus:trademarkStatus + trademarkStatus: trademarkStatus } }) } - }, [trademarkKeywords,trademarkStatus]) + }, [trademarkKeywords, trademarkStatus]) // const [toRradeMarkModal, setToRradeMarkModal] = useState(false) // 申请商标编辑弹窗 // ---------------------------------------------------------------------------------------------------- @@ -1948,6 +2006,11 @@ export default function Index() { // getSoftTypeListDate() // getTrademarkGoodsList() + getActivityData() + // 获取cookie里面的closeActivityModal的值 + + // console.log(closeActivityModal); + }, []); useEffect(() => { // loactionStorage里的activeMenu @@ -4370,10 +4433,10 @@ export default function Index() {
注:下证时间以提交盖章页第二个工作日算起
{ @@ -4672,7 +4735,119 @@ export default function Index() {
+ {/* { + dispath({ + type: 'setActivityModal', + val: false, + }) + }} + okButtonProps={{ style: { background: 'red', color: 'white' } }} + width={592} + centered + > + 活动 + */} +
+
+
+
+ {activityTitle} +
+
+ {activityMoney}元红包 +
+
+ {activityText} +
+
{ + // 优先使用 Clipboard API + if (navigator.clipboard && navigator.clipboard.writeText) { + navigator.clipboard.writeText( + 'http://127.0.0.1:5500/Register.html?code=' + activityCode + ).then(() => { + messageApi.success('邀请码已复制到剪贴板'); + }).catch(() => { + messageApi.error('复制失败,请手动复制'); + }); + } else { + // 兼容旧浏览器 + const input = document.createElement('input'); + input.value = 'http://127.0.0.1:5500/Register.html?code=' + activityCode; + document.body.appendChild(input); + input.select(); + try { + document.execCommand('copy'); + messageApi.success('邀请码已复制到剪贴板'); + } catch { + messageApi.error('复制失败,请手动复制'); + } + document.body.removeChild(input); + } + }} + >一键复制邀请码
+
+ {/* 多选框 */} + { + setActivityChecked(e.target.checked) + }} + style={{ + color: 'white', + }}> + 近期不再提示 +
+
+ + +
{ + dispath({ + type: 'setActivityModal', + val: false, + }) + // 当activityChecked为true时 再cooke中存入一个维持activityCycle天数的值 + if (activityChecked) { + const date = new Date(); + date.setDate(date.getDate() + activityCycle); + document.cookie = `closeActivityModal=${activityCycle}; expires=${date.toUTCString()}; path=/`; + } + }}> + +
+
+
) diff --git a/src/route/index/index.css b/src/route/index/index.css index 114b2f3..0dfe959 100644 --- a/src/route/index/index.css +++ b/src/route/index/index.css @@ -970,9 +970,11 @@ box-sizing: border-box; margin-top: 15px; } -.trademarkArrayItemText{ + +.trademarkArrayItemText { margin-left: 10px; } + .trademarkTextArrayBox { font-size: 16px; color: #625A31; @@ -1010,4 +1012,67 @@ color: #CBC1B0; /* 文字中线 */ text-decoration: line-through; +} + +.activityMask-close { + width: 65px; + height: 65px; + border-radius: 50%; + border: 2px solid #E5E5E5; + color: #E5E5E5; + display: flex; + align-items: center; + justify-content: center; + font-size: 40px; + margin-top: 10px; + cursor: pointer; +} + +.activityTitle { + margin-top: 204px; + color: #7D451B; + font-size: 30px; + font-weight: 700; +} + +.activityMoney { + margin-top: 72px; + color: #7D451B; + font-size: 30px; + font-weight: 700; +} + +.activitytext { + margin-top: 10px; + font-size: 18px; + color: #BF8102; + width: 300px; + text-align: center; + /* background-color: skyblue; */ + height: 50px; + display: flex; + justify-content: center; + align-items: center; +} + +.activityButton { + width: 363px; + height: 58px; + background: #FFD4AF; + display: flex; + justify-content: center; + align-items: center; + font-size: 24px; + color: #7D451B; + margin-top: 30px; + cursor: pointer; +} + +.activityCycle { + margin-top: 20px; + /* font-size: 18px; */ + color: #7D451B; + display: flex; + justify-content: center; + align-items: center; } \ No newline at end of file diff --git a/src/route/proj/ProjNew.tsx b/src/route/proj/ProjNew.tsx index b118ce6..2d09a14 100644 --- a/src/route/proj/ProjNew.tsx +++ b/src/route/proj/ProjNew.tsx @@ -750,7 +750,7 @@ export default function ProjNew() { position: 'absolute', left: 165, display: showTip ? 'unset' : 'none', color: 'green', - }}>系统全称建议以“软件”、“系统”、“平台”或“APP”结尾,禁止使用英文单引号
+ }}>系统全称建议以“软件”、“系统”、“平台”或“APP”结尾
{ } if (action.type == 'newReplace') { nstate.newReplace = action.val + } + if (action.type == 'setActivityModal') { + nstate.activityModal = action.val } return nstate }