li.shaoyi 5 månader sedan
förälder
incheckning
e35378b83b

+ 4 - 10
src/packages/mobile/views/notice/list/components/detail/index.vue

@@ -1,5 +1,5 @@
 <template>
-    <app-modal direction="right-top" height="100%" width="100%" v-model:show="showModal" :refresh="refresh">
+    <app-modal direction="right-top" height="100%" width="100%" v-model:show="showModal">
         <app-view class="notice-detail">
             <template #header>
                 <app-navbar :title="$t('notices.details')" @back="closed" />
@@ -18,7 +18,7 @@
 <script lang="ts" setup>
 import { shallowRef, PropType, onMounted } from 'vue'
 import { formatDate, formatHtmlString } from '@/filters'
-import { postNoticeReaded } from '@/services/api/common'
+import { useNoticeStore } from '@/stores'
 import AppModal from '@/components/base/modal/index.vue'
 import HtmlContainer from '@mobile/components/base/html-container/index.vue'
 
@@ -29,8 +29,8 @@ const props = defineProps({
     }
 })
 
+const noticeStore = useNoticeStore()
 const showModal = shallowRef(true)
-const refresh = shallowRef(false) // 是否刷新父组件数据
 
 // 关闭弹窗
 const closed = () => {
@@ -39,13 +39,7 @@ const closed = () => {
 
 onMounted(() => {
     if (!props.selectedRow.readed) {
-        postNoticeReaded({
-            data: {
-                noticeID: props.selectedRow.autoid
-            }
-        }).then(() => {
-            refresh.value = true
-        })
+        noticeStore.updateNoticeReaded(props.selectedRow.autoid)
     }
 })
 

+ 14 - 34
src/packages/mobile/views/notice/list/index.vue

@@ -3,20 +3,21 @@
         <template #header>
             <app-navbar :title="$t('notices.title')" />
         </template>
-        <Tabs v-model:active="active" @change="onTabChange">
+        <Tabs v-model:active="active">
             <Tab :title="$t('notices.announcement')" :name="1" />
             <Tab :title="$t('notices.notice')" :name="2" />
         </Tabs>
-        <app-pull-refresh ref="pullRefreshRef" v-model:loading="loading" v-model:error="error"
-            v-model:pageIndex="pageIndex" :page-count="pageCount" @refresh="onRefresh">
+        <app-pull-refresh ref="pullRefreshRef" v-model:loading="noticeStore.loading" @refresh="onRefresh">
             <CellGroup class="article" style="background-color: transparent;padding-top: 10px;" v-if="dataList.length">
                 <template v-for="(item, index) in dataList" :key="index">
                     <Cell :value="formatDate(item.createtime, 'YYYY/MM/DD HH:mm:ss')" @click="openDetail(item)">
                         <template #title>
-                            <TextEllipsis :content="item.title" />
+                            <TextEllipsis :content="handleNoneValue(item.title)" />
                         </template>
                         <template #value>
-                            <span style="font-size: 13px">{{ formatDate(item.createtime, 'YYYY/MM/DD HH:mm:ss') }}</span>
+                            <span style="font-size: 13px">
+                                {{ formatDate(item.createtime, 'YYYY/MM/DD HH:mm:ss') }}
+                            </span>
                         </template>
                         <template #right-icon v-if="!item.readed">
                             <Badge :offset="[0, 5]" dot />
@@ -31,52 +32,31 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, defineAsyncComponent } from 'vue'
+import { shallowRef, defineAsyncComponent, computed } from 'vue'
 import { Tab, Tabs, CellGroup, Cell, TextEllipsis, Badge } from 'vant'
-import { formatDate } from '@/filters'
+import { formatDate, handleNoneValue } from '@/filters'
 import { useComponent } from '@/hooks/component'
-import { useRequest } from '@/hooks/request'
-import { queryNotice } from '@/services/api/common'
+import { useNoticeStore } from '@/stores'
 import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
 
 const componentMap = new Map<string, unknown>([
     ['detail', defineAsyncComponent(() => import('./components/detail/index.vue'))],
 ])
 
-const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => onTabChange())
+const noticeStore = useNoticeStore()
+
+const { componentRef, componentId, openComponent, closeComponent } = useComponent()
 const active = shallowRef(1)
-const error = shallowRef(false)
-const dataList = shallowRef<Model.NoticeRsp[]>([])
 const selectedRow = shallowRef<Model.NoticeRsp>()
 
-const { loading, pageIndex, pageCount, run } = useRequest(queryNotice, {
-    params: {
-        msgType: active.value,
-    },
-    onSuccess: (res) => {
-        if (pageIndex.value === 1) {
-            dataList.value = []
-        }
-        dataList.value.push(...res.data)
-    },
-    onError: () => {
-        error.value = true
-    }
-})
+const dataList = computed(() => noticeStore.localizedNoticeList.filter((e) => e.msgtype === active.value))
 
 const openDetail = (item: Model.NoticeRsp) => {
     selectedRow.value = item
     openComponent('detail')
 }
 
-const onTabChange = () => {
-    pageIndex.value = 1
-    onRefresh()
-}
-
 const onRefresh = () => {
-    run({
-        msgType: active.value,
-    })
+    noticeStore.getNoticeList()
 }
 </script>

+ 21 - 0
src/stores/modules/notice.ts

@@ -1,6 +1,8 @@
 import { reactive, toRefs, computed } from 'vue'
 import { timerTask } from '@/utils/timer'
 import { queryNotice, postNoticeReaded } from '@/services/api/common'
+import { Language } from '@/constants/language'
+import { i18n } from './language'
 import { defineStore } from '../store'
 import eventBus from '@/services/bus'
 
@@ -14,6 +16,24 @@ export const useNoticeStore = defineStore(() => {
         isInitialized: false // 是否已初始化
     })
 
+    // 本地化通知列表
+    const localizedNoticeList = computed<Model.NoticeRsp[]>(() => state.noticeList.map((e) => {
+        const localizedProperties: { [K in Language]: { [P in 'title' | 'content']: string } } = {
+            'zh-CN': { title: e.title, content: e.content, },
+            'en-US': { title: e.titleen, content: e.contenten, },
+            'th': { title: e.titleth, content: e.contentth, },
+            'zh-TW': { title: e.titletw, content: e.contenttw, },
+            'vi': { title: e.titlevi, content: e.contentvi, },
+        }
+
+        const localizedValues = localizedProperties[i18n.global.locale] // 本地化语言
+
+        return {
+            ...e,
+            ...localizedValues
+        }
+    }))
+
     // 未读消息数
     const unreadCount = computed(() => {
         return state.noticeList.reduce((count, e) => e.readed ? count : count + 1, 0)
@@ -64,6 +84,7 @@ export const useNoticeStore = defineStore(() => {
 
     return {
         ...toRefs(state),
+        localizedNoticeList,
         unreadCount,
         getNoticeList,
         updateNoticeReaded,

+ 9 - 9
src/types/model/common.d.ts

@@ -298,25 +298,25 @@ declare global {
 
         /** 通知公告系统消息查询 响应 */
         interface NoticeRsp {
-            auditoruserid: number; // 审核人
-            auditremark: string; // 审核备注
-            audittime: string; // 审核日期
             autoid: number; // 自增ID
-            content: string; // 内容
+            content: string; // 内容 - 返回content2
+            contenten: string; // 内容 - 返回content2(英文)
+            contentth: string; // 内容 - 返回content2(泰文)
+            contenttw: string; // 内容 - 返回content2(繁体)
+            contentvi: string; // 内容 - 返回content2(越南语)
             createtime: string; // 创建时间
-            creatorid: number; // 建仓人
-            endtime: string; // 结束时间
             isforcedisplay: number; // 是否强制显示 - 0:不强制 1:强制
             istop: number; // 是否置顶 - 0:不置顶 1:置顶
             msgiconurl: string; // 消息图标Url
             msgtype: number; // 消息类型 - 1:公告通知 2:系统消息 3:商品到期提货通知
             publisher: string; // 消息发布者
             readed: boolean; // 是否已读
-            scheduletime: string; // 计划发送时间
-            sendtype: number; // 推送方式 - 1:全体广播 2:按会员广播 3:个人推送 4:按会员广播(仅会员)
             sentstatus: number; // 推送状态 - 0:未推送 1:已推送 2:审核拒绝
             title: string; // 标题
-            userid: number; // 会员/投资者ID推送方式 为 个人时,填写投资者ID
+            titleen: string; // 标题(英文)
+            titleth: string; // 标题(泰文)
+            titletw: string; // 标题(繁体)
+            titlevi: string; // 标题(越南语)
         }
 
         /** 通知公告设置已读 请求 */