diff --git a/package.json b/package.json
index 8809e6d..c25796d 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,8 @@
"react-dom": "^18.2.0",
"react-i18next": "^14.1.2",
"react-router-dom": "^6.10.0",
- "react-to-pdf": "^1.0.1"
+ "react-to-pdf": "^1.0.1",
+ "zustand": "^4.5.2"
},
"devDependencies": {
"@types/react": "^18.0.28",
diff --git a/src/stores/Auth.js b/src/stores/Auth.js
index 0110238..1b4d2f4 100644
--- a/src/stores/Auth.js
+++ b/src/stores/Auth.js
@@ -1,5 +1,5 @@
import { makeAutoObservable, runInAction } from "mobx";
-import { fetchJSON, postForm } from '@/utils/request';
+import { appendRequestParams, fetchJSON, postForm } from '@/utils/request';
import { HT_HOST } from "@/config";
import { isNotEmpty, prepareUrl } from '@/utils/commons';
import { loadPageSpy } from '@/pageSpy';
@@ -17,6 +17,7 @@ class Auth {
this.login.userId = root.getSession(KEY_USER_ID);
this.login.travelAgencyId = root.getSession(KEY_TRAVEL_AGENCY_ID);
if (isNotEmpty(this.login.token)) {
+ appendRequestParams('token', this.login.token);
this.fetchUserDetail();
}
}
@@ -35,6 +36,7 @@ class Auth {
this.login.timeout = false;
});
this.root.putSession(KEY_LOGIN_TOKEN, json.Result.token);
+ appendRequestParams('token', json.Result.token);
return json.Result.WU_LMI_SN;
} else {
throw new Error(json.errmsg + ': ' + json.errcode);
diff --git a/src/stores/Notice1.js b/src/stores/Notice1.js
new file mode 100644
index 0000000..c9ea0b3
--- /dev/null
+++ b/src/stores/Notice1.js
@@ -0,0 +1,51 @@
+import { create } from 'zustand';
+import { devtools } from 'zustand/middleware';
+
+import { fetchJSON, postForm, } from '@/utils/request';
+import { HT_HOST } from '@/config';
+
+/**
+ * Notice 相关的请求
+ */
+
+export const fetchBulletinList = async (LMI_SN) => {
+ const { errcode, Result } = await fetchJSON(`${HT_HOST}/service-Cooperate/Cooperate/GetBulletinList`, { LMI_SN });
+ return errcode !== 0 ? [] : Result;
+};
+
+export const fetchBulletinUnReadCount = async (LMI_SN) => {
+ const { errcode, Result } = await fetchJSON(`${HT_HOST}/service-Cooperate/Cooperate/GetBulletinUnReadCount`, { LMI_SN });
+ return errcode !== 0 ? 0 : Result.CCP_BulletinCount;
+}
+
+export const fetchNoticeDetail = async (LMI_SN, CCP_BLID) => {
+ const { errcode, Result } = await fetchJSON(`${HT_HOST}/service-Cooperate/Cooperate/GetBulletinDetail`, { LMI_SN, CCP_BLID });
+ return errcode !== 0 ? {} : Result;
+}
+
+/**
+ * Notice Store
+ */
+const initialState = {
+ noticeUnRead: 0, //未读公告数量
+};
+export const useNoticeStore = create(
+ devtools((set, get) => ({
+ // 初始化状态
+ ...initialState,
+
+ // state actions
+ setNoticeUnRead: (noticeUnRead) => set(() => ({ noticeUnRead })),
+
+ reset: () => set(initialState),
+
+ // side effects
+ getBulletinUnReadCount: async (LMI_SN) => {
+ const { setNoticeUnRead } = get();
+ const noticeUnRead = await fetchBulletinUnReadCount(LMI_SN);
+ setNoticeUnRead(noticeUnRead);
+ },
+
+ }))
+);
+export default useNoticeStore;
diff --git a/src/utils/request.js b/src/utils/request.js
index e56af36..dcd6def 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -18,6 +18,20 @@ function getRequestHeader() {
}, {});
}
+const initParams = [];
+export function appendRequestParams(n, v) {
+ initParams.push({
+ name: n,
+ value: v
+ })
+}
+function getRequestInitParams() {
+ return initParams.reduce((acc, item) => {
+ acc[item.name] = item.value;
+ return acc;
+ }, {});
+}
+
function checkStatus(response) {
if (response.status >= 200 && response.status < 300) {
return response
@@ -46,7 +60,9 @@ export function fetchText(url) {
})
}
-export function fetchJSON(url, data) {
+export function fetchJSON(url, data = {}) {
+ const initParams = getRequestInitParams();
+ Object.assign(data, initParams);
const params = data ? new URLSearchParams(data).toString() : '';
const ifp = url.includes('?') ? '&' : '?';
const headerObj = getRequestHeader();
diff --git a/src/views/notice/Detail.jsx b/src/views/notice/Detail.jsx
index 2006a07..5a0d708 100644
--- a/src/views/notice/Detail.jsx
+++ b/src/views/notice/Detail.jsx
@@ -1,42 +1,43 @@
-import { NavLink, useParams } from "react-router-dom";
-import { useEffect, useState } from "react";
-import { observer } from "mobx-react";
-import { toJS } from "mobx";
-import { Row, Col, Space, Button, Table, Input, Typography, Badge, Divider } from "antd";
-import { useStore } from "@/stores/StoreContext.js";
-import * as config from "@/config";
-import * as comm from "@/utils/commons";
-import dayjs from "dayjs";
+import { NavLink, useParams } from 'react-router-dom';
+import { useEffect, useState } from 'react';
+import { Row, Col, Space, Typography, Divider } from 'antd';
+import { useStore } from '@/stores/StoreContext.js';
+import * as comm from '@/utils/commons';
+import { useTranslation } from 'react-i18next';
+import { fetchNoticeDetail } from '@/stores/Notice1';
-const { Title, Paragraph, Text } = Typography;
+const { Title, Paragraph } = Typography;
function Detail() {
- const { noticeStore, authStore } = useStore();
- const { noticeInfo } = noticeStore;
- const { CCP_BLID } = useParams();
+ const { t } = useTranslation();
+ const { authStore } = useStore();
+ const { CCP_BLID } = useParams();
- useEffect(() => {
- console.info("notice detail .useEffect " + CCP_BLID);
- noticeStore.getNoticeDetail(authStore.login.userId, CCP_BLID);
- }, []);
+ const [noticeInfo, setNoticeInfo] = useState({});
+ useEffect(() => {
+ // console.info("notice detail .useEffect " + CCP_BLID);
+ fetchNoticeDetail(authStore.login.userId, CCP_BLID).then((res) => {
+ setNoticeInfo(res);
+ });
+ }, []);
- return (
-