Handy_Cao преди 1 година
родител
ревизия
c4d4e708a8

+ 3 - 0
src/business/login/index.ts

@@ -11,6 +11,7 @@ import { encryptBody } from '@/services/websocket/package/crypto'
 import { checkToken, checkTokenLoop } from '@/business/common'
 import eventBus from '@/services/bus'
 import cryptojs from 'crypto-js'
+import { useCommonStore } from '@/stores/modules/common'
 
 /**
  * 登录业务模块
@@ -27,6 +28,7 @@ export function useLogin(persist = false) {
     const futuresStore = useFuturesStore()
     const deliveryRelationStore = useDeliveryRelationStore()
     const goodsCollectionStore = useGoodsCollectionStore()
+    const commonStore = useCommonStore()
 
     const { logining, token } = loginStore.$toRefs()
 
@@ -45,6 +47,7 @@ export function useLogin(persist = false) {
             userStore.getSystemParams()
         ])
         goodsCollectionStore.fetchGoodsCollections()
+        commonStore.fetcheDocuments()
     }
 
     const loadUserData = async () => {

+ 2 - 2
src/packages/tss/router/index.ts

@@ -308,7 +308,7 @@ const routes: Array<RouteRecordRaw> = [
       {
         path: "gywm",
         name: "rules-gywm",
-        component: () => import("@mobile/views/rules/gywm/Index.vue"),
+        component: () => import("../views/rules/gywm/Index.vue"),
         meta: {
           ignoreAuth: true,
         },
@@ -316,7 +316,7 @@ const routes: Array<RouteRecordRaw> = [
       {
         path: "fwrx",
         name: "rules-fwrx",
-        component: () => import("@mobile/views/rules/fwrx/Index.vue"),
+        component: () => import("../views/rules/fwrx/Index.vue"),
         meta: {
           ignoreAuth: true,
         },

+ 10 - 0
src/packages/tss/views/rules/benefits/index.vue

@@ -4,8 +4,18 @@
         <template #header>
             <app-navbar :title="$t('tss.benefits')" />
         </template>
+        <p style="padding: 15px" v-html="documentcontent"></p>
     </app-view>
 </template>
 
 <script lang="ts" setup>
+import { useCommonStore } from '@/stores/modules/common';
+import { computed } from 'vue';
+
+const commonStore = useCommonStore()
+
+const documentcontent = computed(() => {
+    return commonStore.getDocumentById(101)?.documentcontent ?? ''
+})
+
 </script>

+ 20 - 0
src/packages/tss/views/rules/fwrx/Index.vue

@@ -0,0 +1,20 @@
+<template>
+    <app-view>
+        <template #header>
+            <app-navbar :title="$t('rules.fwrx')" />
+        </template>
+        <p style="padding: 15px" v-html="documentcontent"></p>
+    </app-view>
+</template>
+
+<script lang="ts" setup>
+import { useCommonStore } from '@/stores/modules/common';
+import { computed } from 'vue';
+
+const commonStore = useCommonStore()
+
+const documentcontent = computed(() => {
+    return commonStore.getDocumentById(1)?.documentcontent ?? ''
+})
+
+</script>

+ 20 - 0
src/packages/tss/views/rules/gywm/Index.vue

@@ -0,0 +1,20 @@
+<template>
+    <app-view>
+        <template #header>
+            <app-navbar :title="$t('routes.about')" />
+        </template>
+        <p style="padding: 15px" v-html="documentcontent"></p>
+    </app-view>
+</template>
+
+<script lang="ts" setup>
+import { useCommonStore } from '@/stores/modules/common';
+import { computed } from 'vue';
+
+const commonStore = useCommonStore()
+
+const documentcontent = computed(() => {
+    return commonStore.getDocumentById(2)?.documentcontent ?? ''
+})
+
+</script>

+ 10 - 0
src/packages/tss/views/rules/logistics/index.vue

@@ -4,8 +4,18 @@
         <template #header>
             <app-navbar :title="$t('tss.logistics')" />
         </template>
+        <p style="padding: 15px" v-html="documentcontent"></p>
     </app-view>
 </template>
 
 <script lang="ts" setup>
+import { useCommonStore } from '@/stores/modules/common';
+import { computed } from 'vue';
+
+const commonStore = useCommonStore()
+
+const documentcontent = computed(() => {
+    return commonStore.getDocumentById(103)?.documentcontent ?? ''
+})
+
 </script>

+ 10 - 0
src/packages/tss/views/rules/malls/index.vue

@@ -4,8 +4,18 @@
         <template #header>
             <app-navbar :title="$t('tss.malls')" />
         </template>
+        <p style="padding: 15px" v-html="documentcontent"></p>
     </app-view>
 </template>
 
 <script lang="ts" setup>
+import { useCommonStore } from '@/stores/modules/common';
+import { computed } from 'vue';
+
+const commonStore = useCommonStore()
+
+const documentcontent = computed(() => {
+    return commonStore.getDocumentById(102)?.documentcontent ?? ''
+})
+
 </script>

+ 10 - 0
src/services/api/common/index.ts

@@ -300,4 +300,14 @@ export function fetchSystemParams(config: RequestConfig = {}) {
         url: '/Common/GetSystemParams',
         params: config.data,
     })
+}
+
+/**
+ * 获取终端文档配置信息
+ */
+export function getClientDocumnetConfigs(config: RequestConfig = {}) {
+    return http.commonRequest<Model.DocumnetConfigsRsp[]>({
+        url: '/Common/GetClientDocumnetConfigs',
+        params: config.data,
+    })
 }

+ 51 - 0
src/stores/modules/common.ts

@@ -0,0 +1,51 @@
+
+import { reactive, toRefs, computed } from 'vue'
+import { defineStore } from '../store'
+import { getClientDocumnetConfigs } from '@/services/api/common'
+import { Language } from '@/constants/language'
+import { i18n } from './language'
+
+export const useCommonStore = defineStore(() => {
+    const state = reactive({
+        loading: false,
+        documents: <Model.DocumnetConfigsRsp[]>[], // 文档集合
+    })
+
+    // 本地化商品集合
+    const documents = computed<Model.DocumnetConfigsRsp[]>(() => state.documents.map((e) => {
+        const localizedProperties: { [K in Language]: { [P in 'documentcontent']: string } } = {
+            'zh-CN': { documentcontent: e.documentcontent },
+            'en-US': { documentcontent: e.documentcontenten },
+            'th': { documentcontent: e.documentcontentth },
+            'zh-TW': { documentcontent: e.documentcontenttw },
+        }
+
+        const localizedValues = localizedProperties[i18n.global.locale] // 本地化语言
+
+        return {
+            ...e,
+            ...localizedValues
+        }
+    }))
+
+    // 根据商品 ID 查找对应的商品信息
+    const getDocumentById = (id: number) => documents.value.find((e) => e.documenttype === id)
+
+    // 获取商品集合列表
+    const fetcheDocuments = async () => {
+        try {
+            state.loading = true
+            const res = await getClientDocumnetConfigs()
+            state.documents = res.data
+        } finally {
+            state.loading = false
+        }
+    }
+
+    return {
+        ...toRefs(state),
+        fetcheDocuments,
+        documents, 
+        getDocumentById
+    }
+})

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

@@ -368,5 +368,14 @@ declare global {
             langcode: string; // 编码
             langname: string; // 名称
         }
+
+        /** 获取终端文档配置信息 响应 */
+        interface DocumnetConfigsRsp {
+            documentcontent: string; // 文档内容(简体)
+            documentcontenten: string; // 文档内容(英文)
+            documentcontentth: string; // 文档内容(泰文)
+            documentcontenttw: string; // 文档内容(繁体)
+            documenttype: number; // 文档类型
+        }
     }
 }