Commit 2c4fccea authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents 036a0c11 9884b79b
......@@ -17,17 +17,17 @@
"build:dev": "pm2 start scripts/devServer.js",
"build:analyze": "ANALYZE=1 umi build",
"build:clean": "umi build",
"build:scm": "cross-env SITE_ID=1 BACK_GATEWAY=http://lingxi-scm.wg.shushangyun.com yarn build",
"build:10": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.10:8100 yarn build",
"build:25": "cross-env SITE_ID=352 BACK_GATEWAY=http://10.0.0.25:8100 yarn build",
"build:scm": "cross-env SITE_ID=1 BACK_GATEWAY=http://lingxi-scm.wg.shushangyun.com SOCKET_URL=ws://lingxi-scm.wg.shushangyun.com yarn build",
"build:10": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.10:8100 SOCKET_URL=ws://10.0.0.10:9400 yarn build",
"build:25": "cross-env SITE_ID=352 BACK_GATEWAY=http://10.0.0.25:8100 SOCKET_URL=ws://10.0.0.25:9400 yarn build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
"test": "umi-test",
"test:coverage": "umi-test --coverage",
"start:cross": "cross-env SITE_ID=352 SOCKET_URL=ws://10.0.0.25:8100 yarn start",
"start:cross-dev": "cross-env SITE_ID=352 SOCKET_URL=ws://10.0.0.25:8100 yarn start",
"start:10": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.10:8100 yarn start",
"start:scm": "cross-env BACK_GATEWAY=http://lingxi-scm.wg.shushangyun.com SITE_ID=1 yarn start"
"start:cross": "cross-env SITE_ID=352 SOCKET_URL=ws://10.0.0.25:9400 yarn start",
"start:cross-dev": "cross-env SITE_ID=352 SOCKET_URL=ws://10.0.0.25:9400 yarn start:dev",
"start:10": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.10:8100 SOCKET_URL=ws://10.0.0.10:9400 yarn start",
"start:scm": "cross-env BACK_GATEWAY=http://lingxi-scm.wg.shushangyun.com SOCKET_URL=ws://lingxi-scm.wg.shushangyun.com SITE_ID=1 yarn start"
},
"lint-staged": {
"*.{js,jsx,less,md,json}": [
......
export const NOT_CHANGE_VALUE = 'hello, world'
// socket的链接地址, 默认会使用后端接口网关地址
export const SOCKET_URL = process.env.SOCKET_URL || process.env.BACK_GATEWAY?.replace('http', 'ws') || "ws://10.0.0.25:9400"
export const SOCKET_URL = process.env.SOCKET_URL?.replace('http|https', 'ws') || process.env.BACK_GATEWAY?.replace('http|https', 'ws')
// 会员角色类型
export const MEMBER_ROLE_LISTS = [
......
import React, { useState, useEffect, useRef, useCallback, useLayoutEffect } from 'react'
import { Link, history } from 'umi'
import { Menu, Dropdown, List, Avatar, Skeleton} from 'antd'
import { Menu, Dropdown, List, Avatar, Modal, Badge} from 'antd'
import { BellOutlined, CaretDownOutlined } from '@ant-design/icons'
import styles from './index.less'
import { removeAuth, getAuth } from '@/utils/auth'
......@@ -8,21 +8,43 @@ import { PublicApi } from '@/services/api';
import moment from 'moment';
import msg_system from '@/asserts/msg_system.png'
import msg_platform from '@/asserts/msg_platform.png'
import { SOCKET_URL } from '@/constants';
import PwdModal from './components/PwdModal';
import { encryptedByAES } from '@/utils/cryptoAes'
const RightContent: React.FC<{}> = (props) => {
const [visible, setVisible] = useState(false);
const [messageData, setMessageData] = useState<any[]>([]);
const [loading, setLoading] = useState(true);
const ws = useRef<WebSocket | null>(null);
const [unreadMsg, setUnReadMsg] = useState<number>(0);
const [msgloading, setMsgLoading] = useState(true);
const [editPwdVisible, setEditPwdVisible] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(false);
const ws = useRef<WebSocket | null>(null);
const toLogin = () => {
removeAuth()
history.replace('/login')
}
const handleChangePwd = useCallback((value: any) => {
setConfirmLoading(true)
PublicApi.postMemberManageSecurityPswUpdate({
oldPassword: encryptedByAES(value.oldPwd),
newPassword: encryptedByAES(value.newPwd)
}).then((data) => {
setEditPwdVisible(false);
setConfirmLoading(false);
})
}, [])
const handleCancel = useCallback(() => {
setEditPwdVisible(false)
}, [])
const menu = (
<Menu>
<Menu.Item>
<Menu.Item onClick={() => setEditPwdVisible(true)}>
密码修改
</Menu.Item>
<Menu.Item onClick={toLogin}>
......@@ -34,11 +56,11 @@ const RightContent: React.FC<{}> = (props) => {
const userInfo = getAuth()
useEffect(() => {
if(visible) {
setLoading(true)
setMsgLoading(true)
PublicApi.getReportMessagePlatformPage({current: '1', pageSize: '4'})
.then((data) => {
if(data.code === 1000) {
setLoading(false)
setMsgLoading(false)
setMessageData(data.data.data);
}
})
......@@ -47,17 +69,22 @@ const RightContent: React.FC<{}> = (props) => {
const webSocketInit = useCallback(() => {
console.log(ws.current)
if (!ws.current || ws.current.readyState === 3) {
ws.current = new WebSocket(`ws://10.0.0.25:8100/report/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}`);
if (SOCKET_URL && /ws\:\/\//.test(SOCKET_URL) && (!ws.current || ws.current.readyState === 3) && userInfo) {
const url = `${SOCKET_URL}/report/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}&token=${userInfo.token}&source=${99}`
ws.current = new WebSocket(url);
ws.current.onopen = (e) => {
console.log(e)
}
ws.current.onmessage = (e) => {
console.log(e)
const data = JSON.parse(e.data);
if(data.type === 1) {
setUnReadMsg(data.data)
}
};
ws.current.onclose = (e) => {
console.log("关闭连接")
}
}
ws.current.onerror = (e) => {
console.log("socket 出错")
}
......@@ -65,7 +92,7 @@ const RightContent: React.FC<{}> = (props) => {
}, [ws]);
useLayoutEffect(() => {
// webSocketInit();
webSocketInit();
return () => {
ws.current?.close();
};
......@@ -76,6 +103,7 @@ const RightContent: React.FC<{}> = (props) => {
<div className={styles.header}>消息列表</div>
<List
itemLayout="horizontal"
loading={msgloading}
dataSource={messageData}
footer={
<a className={styles.messageFooter} href="/message/messageList">
......@@ -85,17 +113,17 @@ const RightContent: React.FC<{}> = (props) => {
renderItem={(item:any) => {
return (
<List.Item>
<Skeleton paragraph={{ rows: 1 }} loading={loading} active avatar>
{/* <Skeleton paragraph={{ rows: 1 }} loading={loading} active avatar> */}
<div className={styles.msgContainer}>
<div className={styles.msgItemIcon}>
<Avatar src={item.type == 1 ? msg_system : msg_platform} />
</div>
<div>
<div className={styles.msgTitle}>{item.title}</div>
<div className={styles.msgTime}>{moment(item.sendTime).format('YYYY-MM-DD HH:mm:ss')}</div>
<div className={styles.msgTitle}>{item.title}</div>
<div className={styles.msgTime}>{moment(item.sendTime).format('YYYY-MM-DD HH:mm:ss')}</div>
</div>
</div>
</Skeleton>
{/* </Skeleton> */}
</List.Item>
)
}}
......@@ -103,28 +131,34 @@ const RightContent: React.FC<{}> = (props) => {
</div>
)
return <div className={styles.lxLayoutRight}>
<Link to="/home" className={styles.lxLink}>返回首页</Link>
<Dropdown overlay={menuMessage} trigger={['click']} visible={visible}>
<a
href=""
rel="noopener noreferrer"
className={styles.topMessage}
>
<BellOutlined onClick={() => setVisible(!visible)}/>
<span className="pulse"></span>
</a>
</Dropdown>
<Dropdown overlay={menu}>
<div className={styles.avatarWrap}>
<div className={styles.avatar}></div>
<div className="ant-dropdown-link" onClick={e => e.preventDefault()}>
<span>{userInfo?.name || '未知用户'}</span>
<CaretDownOutlined />
return (
<div className={styles.lxLayoutRight}>
<Link to="/home" className={styles.lxLink}>返回首页</Link>
<Dropdown overlay={menuMessage} trigger={['click']} visible={visible}>
<span className={styles.topMessage}>
<Badge count={unreadMsg} size={"small"}>
<BellOutlined onClick={() => setVisible(!visible)}/>
</Badge>
</span>
</Dropdown>
<Dropdown overlay={menu}>
<div className={styles.avatarWrap}>
<div className={styles.avatar}></div>
<div className="ant-dropdown-link" onClick={e => e.preventDefault()}>
<span>{userInfo?.name || '未知用户'}</span>
<CaretDownOutlined />
</div>
</div>
</div>
</Dropdown>
</div>
</Dropdown>
<PwdModal
visible={editPwdVisible}
onCancel={handleCancel}
onOk={handleChangePwd}
confirmLoading={confirmLoading}
/>
</div>
)
}
export default RightContent
\ No newline at end of file
export default RightContent
import React from 'react';
import { Modal, Input } from 'antd';
import NiceForm from '@/components/NiceForm';
import { registerValidationRules, createAsyncFormActions, FormEffectHooks } from '@formily/antd';
const actions = createAsyncFormActions ();
const Password = Input.Password;
registerValidationRules({
passwordRule: value => {
const pattern = /^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$)^.{8,16}$/;
return !pattern.test(value) ? "8-16个字符,由英文字母(区分大小写)、数字组成,请勿使用简单密码。" : ""
},
passwordIsSame: async (value) => {
const newPwd = await actions.getFieldValue('newPwd');
return newPwd !== value ? "两次密码不一致" : '';
}
})
const schema = {
type: 'object',
properties: {
layout: {
type: 'object',
'x-component': 'mega-layout',
"x-component-props": {
"labelAlign": "top",
"full": true
},
properties: {
oldPwd: {
type: 'string',
title: '旧密码',
'x-component': 'Password',
'x-component-props': {
style: {
width: '100%'
}
},
'x-rules': [
{
required: true,
message: '请填写旧密码'
},
]
},
newPwd: {
type: 'password',
title: '新密码',
'x-rules': [
{
required: true,
message: '请填写新密码'
},
{
passwordRule: true,
}
]
},
comfirmPwd: {
type: 'password',
title: '新密码',
'x-rules': [
{
required: true,
message: '请填写新密码'
},
{
passwordIsSame: true
}
]
}
}
}
}
}
const PwdModal = (props) => {
const { visible, onCancel, onOk, confirmLoading } = props;
const handleSubmit = (value) => {
!!onOk && onOk(value)
}
const handleOk = () => {
actions.submit();
}
return (
<Modal
visible={visible}
title="修改密码"
onCancel={onCancel}
confirmLoading={confirmLoading}
onOk={handleOk}
maskClosable={false}
>
{
visible
? <NiceForm
components={{Password}}
schema={schema}
actions={actions}
onSubmit={handleSubmit}
></NiceForm>
: null
}
</Modal>
)
}
export default React.memo(PwdModal)
......@@ -138,7 +138,6 @@
.topMessage{
color: rgba(255,255,255,.6);
margin-right: 30px;
position: relative;
:global{
.anticon{
font-size: 18px;
......@@ -170,16 +169,16 @@
justify-content: center;
align-items: center;
margin: 0;
border-top: 1px solid #f0f0f0;
text-align: center;
border-top: 1px solid #f0f0f0;
text-align: center;
height: 46px;
line-height: 46px;
font-size: 14px;
span{
flex: 0 0 50%;
&:last-child{
border-left: 1px solid #f0f0f0;
border-left: 1px solid #f0f0f0;
}
cursor: pointer;
}
}
\ No newline at end of file
}
......@@ -41,8 +41,8 @@ import {
const payActions = createFormActions()
/**
* @description: 会员弹窗列表
* @param {type}
* @return {type}
* @param {type}
* @return {type}
*/
const fetchMemberList = async (params) => {
const res = await PublicApi.getMemberManageAllProviderPage(params)
......@@ -61,7 +61,7 @@ const PaySetting: React.FC<{}> = () => {
levelList: [],
roleList: []
})
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({ customKey: 'memberId' })
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({ customKey: 'id' })
const [optionType, setoptionType] = useState(0)
const { preview, pageStatus } = usePageStatus()
// const initValue = useInitValue(PublicApi.getPayPayMemberTacticsDetails)
......@@ -172,15 +172,14 @@ const PaySetting: React.FC<{}> = () => {
PublicApi.getPayPayMemberTacticsDetails({ id: usePageStatus().id }).then(res => {
if (res.code === 1000) {
let { data } = res
console.log('结果', res.data)
payActions.setFieldValue('paymentPolicyName', data.paymentPolicyName)
data.paymentPolicyPayWayRequests.forEach((item: any, index) => {
payActions.setFieldValue(`id-${index}`, item.id)
payActions.setFieldValue(`ruleConfigurationId-${index}`, item.ruleConfigurationId)
// payActions.setFieldValue(`payWayIds-${index}`,item.payWayIds)
const ids: any = [];
item.payWays.forEach((v) => {
payActions.setFieldValue(`payWayIds-${index}`, v.id)
const payWayIds: any = [];
item.payWays.forEach((v, idx) => {
payWayIds.push(v.id)
payActions.setFieldValue(`payWayIds-${index}`, payWayIds)
})
})
payActions.setFieldValue('isSelected', data.isSelected)
......@@ -192,6 +191,8 @@ const PaySetting: React.FC<{}> = () => {
}).then(res => {
if (res.code === 1000) {
let { data } = res.data
memberRowCtl.setSelectedRowKeys(data.map(v => v.memberId))
memberRowCtl.setSelectRow(data)
payActions.setFieldValue('applyMember', data)
}
})
......@@ -416,6 +417,7 @@ const PaySetting: React.FC<{}> = () => {
}
}
//新增
console.log(param, 10086)
if (param.memberIdRoleIds.length === 0 && values.isSelected === 0) {
message.error('请选择指定的会员');
return
......@@ -493,10 +495,10 @@ const PaySetting: React.FC<{}> = () => {
}
}
tableProps={{
rowKey: 'memberId'
rowKey: 'id'
}}
/>
</PageHeaderWrapper>
)
}
export default PaySetting
\ No newline at end of file
export default PaySetting
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment