li.shaoyi 1 jaar geleden
bovenliggende
commit
b43ebc56ba

+ 1 - 1
oem/gcszt/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ]
 }

+ 1 - 1
oem/gstj/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "totalvolume"
   ]
 }

+ 1 - 1
oem/gzcj/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ]
 }

+ 1 - 1
oem/mobile52/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ],
   "forcedPasswordChange": false,

+ 1 - 1
oem/nhgj/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ]
 }

+ 1 - 1
oem/qdhs/config/appconfig.json

@@ -8,7 +8,7 @@
   "modules": [
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ]
 }

+ 1 - 1
oem/quote/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ],
   "forcedPasswordChange": true,

+ 1 - 1
oem/qxst/config/appconfig.json

@@ -8,7 +8,7 @@
   "modules": [
     "register"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ]
 }

+ 3 - 2
oem/sbyj/config/appconfig.json

@@ -9,9 +9,10 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ],
   "forcedPasswordChange": true,
-  "riskType": 1
+  "riskType": 1,
+  "i18nEnabled": false
 }

+ 1 - 1
oem/sdr/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ],
   "forcedPasswordChange": false,

+ 1 - 1
oem/tc/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ]
 }

+ 1 - 1
oem/thj/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "totalvolume"
   ],
   "registrationCodeRule": 0

+ 1 - 1
oem/tjmd/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "totalvolume"
   ]
 }

+ 1 - 1
oem/tss/config/appconfig.json

@@ -9,7 +9,7 @@
   "modules": [
     "register"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ]
 }

+ 1 - 1
oem/ykhj/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ],
   "forcedPasswordChange": false,

+ 1 - 1
oem/zrwyt/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ]
 }

+ 1 - 1
oem/zrwyt2/config/appconfig.json

@@ -9,7 +9,7 @@
     "register",
     "delivery"
   ],
-  "quotationPropertys": [
+  "quotationProperties": [
     "holdvolume"
   ]
 }

+ 1 - 2
public/config/appconfig.json

@@ -10,8 +10,7 @@
     "register",
     "delivery"
   ],
-  "slogan": "app.title",
-  "quotationPropertys": [
+  "quotationProperties": [
     "totalvolume",
     "holdvolume"
   ],

+ 23 - 4
src/constants/language.ts

@@ -2,8 +2,25 @@
  * 系统语言
  */
 export enum Language {
-    ZhCN = 'zh-cn',
-    EN = 'en',
+    Simplified = 'zh-CN',
+    Traditional = 'zh-TW',
+    English = 'en-US',
+    Thai = 'th'
+}
+
+/**
+ * 获取客户端语言
+ * @returns 
+ */
+export function getClientLanguage() {
+    const rules = [
+        { result: Language.Simplified, code: ['zh-CN'] },
+        { result: Language.Traditional, code: ['zh-TW'] },
+        { result: Language.English, code: ['en', 'en-US'] },
+        { result: Language.Thai, code: ['th', 'th-TH'] },
+    ]
+    const lang = rules.find(rule => rule.code.includes(navigator.language))
+    return lang ? lang.result : Language.English
 }
 
 /**
@@ -12,7 +29,9 @@ export enum Language {
  */
 export function getLanguageList() {
     return [
-        { label: '中文', value: Language.ZhCN },
-        { label: '英文', value: Language.EN },
+        { label: '简体中文', value: Language.Simplified },
+        { label: '繁体中文', value: Language.Traditional },
+        { label: 'English', value: Language.English },
+        { label: 'ภาษาไทย', value: Language.Thai },
     ]
 }

+ 16 - 0
src/packages/mobile/components/layouts/login/index.less

@@ -9,6 +9,22 @@
         }
     }
 
+    &-luanguage {
+        position: fixed;
+        right: 0;
+        top: 0;
+        z-index: 1;
+        display: inline-flex;
+
+        .app-luanguage {
+            display: flex;
+            justify-content: center;
+            align-items: center;
+            height: var(--navbar-height);
+            padding: 0 14px;
+        }
+    }
+
     &-logo {
         text-align: center;
         padding: 50px 0;

+ 12 - 61
src/packages/mobile/components/layouts/login/index.vue

@@ -1,6 +1,9 @@
 <template>
   <app-statusbar class="login">
     <app-navback class="login-navback" />
+    <app-statusbar class="login-luanguage" v-if="globalStore.getSystemInfo('i18nEnabled')">
+      <app-luanguage />
+    </app-statusbar>
     <div class="login-logo">
       <slot name="logo">
         <img :src="logoSrc" />
@@ -8,25 +11,25 @@
     </div>
     <Form class="login-form" @submit="formSubmit">
       <CellGroup inset>
-        <Field v-model="formData.userName" name="account" :label="$t('user.login.username')" label-align="top" size="large" :placeholder="$t('user.login.Pleaseenterausername')"
+        <Field v-model="formData.userName" name="account" :label="$t('user.login.username')" label-align="top"
+          size="large" :placeholder="$t('user.login.Pleaseenterausername')"
           :rules="[{ required: true, message: $t('user.login.Pleaseenterausername') }]" />
-        <Field v-model="formData.password" name="password" type="password" :label="$t('user.login.password')" label-align="top" size="large"
-          :placeholder="$t('user.login.Pleaseenterthepassword')" :rules="[{ required: true, message: $t('user.login.Pleaseenterthepassword') }]" autocomplete="off" />
+        <Field v-model="formData.password" name="password" type="password" :label="$t('user.login.password')"
+          label-align="top" size="large" :placeholder="$t('user.login.Pleaseenterthepassword')"
+          :rules="[{ required: true, message: $t('user.login.Pleaseenterthepassword') }]" autocomplete="off" />
         <Field>
           <template #input>
             <SliderVerify @statu="slide" style="max-width: 100%;margin: auto;" v-if="showSliderVerify" />
           </template>
         </Field>
-        <div style="margin: 10px 16px;">
-            <app-select v-model="luanguage" :options="dataList.filter(e => e.isvalid === 1)" :optionProps="{ label: 'langname', value: 'langcode' }" @confirm="changeLuanguage"/>
-        </div>
       </CellGroup>
       <div class="button-submit">
         <Button type="primary" native-type="submit" round block>{{ $t('user.login.login') }}</Button>
       </div>
     </Form>
     <div class="login-link">
-      <span @click="navigationTo('user-register')" v-if="globalStore.hasSystemModule('register')">{{ $t('user.login.register') }}</span>
+      <span @click="navigationTo('user-register')" v-if="globalStore.hasSystemModule('register')">{{
+        $t('user.login.register') }}</span>
       <span @click="navigationTo('user-forget')">{{ $t('user.login.forgetpassword') }}</span>
     </div>
     <div class="login-footer">
@@ -46,24 +49,16 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, computed } from 'vue'
+import { shallowRef } from 'vue'
 import { Button, Field, CellGroup, Form, Checkbox, showFailToast, showToast } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { useLogin } from '@/business/login'
 import { useNavigation } from '@mobile/router/navigation'
 import { useGlobalStore, i18n } from '@/stores'
-import { useRequest } from '@/hooks/request'
-import { getI18nConfigs } from '@/services/api/common'
-import { Locale } from 'vant'
-import { localData } from '@/stores/storage'
 import service from '@/services'
 import SliderVerify from '@/components/base/slider-verify/index.vue' // 临时调用,待优化
 import logoImage from '../../../assets/images/login-logo.png'
-import AppSelect from '@mobile/components/base/select/index.vue'
-import enUS from 'vant/es/locale/lang/en-US'
-import enCN from 'vant/es/locale/lang/zh-CN'
-import thTH from 'vant/es/locale/lang/th-TH'
-import zhTW from 'vant/es/locale/lang/zh-TW'
+import AppLuanguage from '@mobile/components/modules/luanguage/index.vue'
 
 defineProps({
   logoSrc: {
@@ -87,46 +82,6 @@ const sliderVerifyStatus = shallowRef(false) // 滑块验证状态
 const meta = document.getElementsByTagName('meta')
 const appVersion = meta.namedItem('revised')?.content ?? '0'
 
-const { dataList, run } = useRequest(getI18nConfigs, {
-  manual: true
-})
-
-const luanguage = computed(() => {
-    switch (i18n.global.locale) {
-        case 'zh-CN':
-            return 'zh-CN'
-        case 'en-US':
-            return 'en'
-        case 'zh-TW':
-            return 'zh-TW'
-        default:
-            return 'th'
-    }
-})
-
-const changeLuanguage = (e: string) => {
-    switch (e) {
-        case 'zh-CN':
-            i18n.global.locale = 'zh-CN'
-            Locale.use(i18n.global.locale, enCN)
-            break;
-        case 'en':
-            i18n.global.locale = 'en-US'
-            Locale.use(i18n.global.locale, enUS)
-            break;
-        case 'zh-TW':
-            i18n.global.locale ='zh-TW'
-            Locale.use(i18n.global.locale, zhTW)
-            break;
-        default:
-            i18n.global.locale = 'th'
-            Locale.use(i18n.global.locale, thTH)
-            break;
-    }
-    /// 设置语言
-    localData.setValue('appLanguage', i18n.global.locale)
-}
-
 // 导航跳转
 const navigationTo = (name: string) => {
   fullloading((hideLoading) => {
@@ -178,10 +133,6 @@ const formSubmit = () => {
     }
   }
 }
-
-service.onReady().then(() => {
-  run()
-})
 </script>
 
 <style lang="less">

+ 77 - 0
src/packages/mobile/components/modules/luanguage/index.vue

@@ -0,0 +1,77 @@
+<template>
+    <div class="app-luanguage" @click="show = true">
+        <slot>{{ language }}</slot>
+        <Popup v-model:show="show" position="bottom" teleport="body" round>
+            <Picker :columns="columns" @cancel="show = false" @confirm="onConfirm"
+                :confirm-button-text="$t('operation.confirm')" :cancel-button-text="$t('operation.cancel')">
+                <template #option="{ text, index }">
+                    <slot name="option" :row="columns[index]" :index="index">
+                        <span>{{ text }}</span>
+                    </slot>
+                </template>
+            </Picker>
+        </Popup>
+    </div>
+</template>
+
+<script lang="ts" setup>
+import { shallowRef, computed } from 'vue'
+import { Popup, Picker, PickerConfirmEventParams, Locale } from 'vant'
+import { Language } from '@/constants/language'
+import { useRequest } from '@/hooks/request'
+import { getI18nConfigs } from '@/services/api/common'
+import { localData } from '@/stores/storage'
+import { i18n } from '@/stores'
+import service from '@/services'
+import enUS from 'vant/es/locale/lang/en-US'
+import zhCN from 'vant/es/locale/lang/zh-CN'
+import thTH from 'vant/es/locale/lang/th-TH'
+import zhTW from 'vant/es/locale/lang/zh-TW'
+
+const emit = defineEmits(['confirm'])
+
+const show = shallowRef(false)
+
+const languageMap: { [key: string]: string } = {
+    'zh-CN': Language.Simplified,
+    'en': Language.English,
+    'zh-TW': Language.Traditional,
+    'th': Language.Thai
+}
+
+const vantlocaleMap = {
+    [Language.Simplified]: zhCN,
+    [Language.Traditional]: zhTW,
+    [Language.English]: enUS,
+    [Language.Thai]: thTH,
+}
+
+// 当前语言
+const language = computed(() => {
+    const locale = columns.value.find((e) => e.value === i18n.global.locale)
+    return locale?.text ?? i18n.global.locale
+})
+
+// 语言列表
+const columns = computed(() => dataList.value.map((e, i) => ({
+    text: e.langname,
+    value: languageMap[e.langcode],
+    index: i
+})))
+
+const { dataList, run } = useRequest(getI18nConfigs, {
+    manual: true
+})
+
+const onConfirm = ({ selectedIndexes: [index], selectedValues: [value] }: PickerConfirmEventParams) => {
+    show.value = false
+    localData.setValue('appLanguage', value.toString())
+    i18n.global.locale = value as Language
+    Locale.use(value.toString(), vantlocaleMap[i18n.global.locale])
+    emit('confirm', value, index)
+}
+
+service.onReady().then(() => {
+    run()
+})
+</script>

+ 5 - 58
src/packages/mobile/views/mine/setting/Index.vue

@@ -15,12 +15,12 @@
                         <app-iconfont icon="g-icon-cancel">{{ $t('routes.usercancel') }}</app-iconfont>
                     </template>
                 </Cell>
-                <Field is-link v-if="i18nEnabled">
+                <Field is-link v-if="globalStore.getSystemInfo('i18nEnabled')">
                     <template #left-icon>
                         <app-iconfont icon="g-icon-lang">{{ $t('mine.setting.language') }}</app-iconfont>
                     </template>
                     <template #button>
-                        <app-select v-model="luanguage" :options="dataList.filter(e => e.isvalid === 1)" :optionProps="{ label: 'langname', value: 'langcode' }" @confirm="changeLuanguage"/>
+                        <app-luanguage />
                     </template>
                 </Field>
             </CellGroup>
@@ -29,70 +29,17 @@
 </template>
 
 <script lang="ts" setup>
-import { computed } from 'vue'
 import { Cell, CellGroup, Field } from 'vant'
 import AppIconfont from '@/components/base/iconfont/index.vue'
-import { useRequest } from '@/hooks/request'
-import { getI18nConfigs } from '@/services/api/common'
-import { i18n } from '@/stores'
-import { Locale } from 'vant'
-import { localData } from '@/stores/storage'
-import AppSelect from '@mobile/components/base/select/index.vue'
-import enUS from 'vant/es/locale/lang/en-US'
-import enCN from 'vant/es/locale/lang/zh-CN'
-import thTH from 'vant/es/locale/lang/th-TH'
-import zhTW from 'vant/es/locale/lang/zh-TW'
-import router from '@/packages/gcszt/router'
+import { useGlobalStore } from '@/stores'
+import AppLuanguage from '@mobile/components/modules/luanguage/index.vue'
 
 defineProps({
-    i18nEnabled: {
-        type: Boolean,
-        default: true
-    },
     showCancel: {
         type: Boolean,
         default: true
     }
 })
 
-const luanguage = computed(() => {
-    switch (i18n.global.locale) {
-        case 'zh-CN':
-            return 'zh-CN'
-        case 'en-US':
-            return 'en'
-        case 'zh-TW':
-            return 'zh-TW'
-        default:
-            return 'th'
-    }
-})
-
-const { dataList } = useRequest(getI18nConfigs, {})
-
-const changeLuanguage = (e: string) => {
-    switch (e) {
-        case 'zh-CN':
-            i18n.global.locale = 'zh-CN'
-            Locale.use(i18n.global.locale, enCN)
-            break;
-        case 'en':
-            i18n.global.locale = 'en-US'
-            Locale.use(i18n.global.locale, enUS)
-            break;
-        case 'zh-TW':
-            i18n.global.locale ='zh-TW'
-            Locale.use(i18n.global.locale, zhTW)
-            break;
-        default:
-            i18n.global.locale = 'th'
-            Locale.use(i18n.global.locale, thTH)
-            break;
-    }
-    /// 设置语言
-    localData.setValue('appLanguage', i18n.global.locale)
-    /// 返回上一页
-    router.back()  
-}
-
+const globalStore = useGlobalStore()
 </script>

+ 0 - 3
src/packages/sbyj/router/index.ts

@@ -260,9 +260,6 @@ const routes: Array<RouteRecordRaw> = [
         path: 'setting',
         name: 'mine-setting',
         component: () => import('@mobile/views/mine/setting/Index.vue'),
-        props: {
-          i18nEnabled: false
-        }
       },
       {
         path: 'wechat',

+ 7 - 5
src/stores/modules/global.ts

@@ -11,12 +11,13 @@ export interface SystemInfo {
     versionCode: string; // 应用版本号
     apiUrl: string; // 接口地址
     tradeChannel: 'http' | 'ws'; // 交易通道
-    showLoginAlert: false, // 登录是否显示弹窗
+    showLoginAlert: boolean; // 登录是否显示弹窗
     modules: ('register' | 'delivery')[]; // 应用包含的模块
-    quotationPropertys: (keyof Model.QuoteDayRsp)[]; // 盘面可显示的属性
+    quotationProperties: (keyof Model.QuoteDayRsp)[]; // 盘面可显示的属性
     forcedPasswordChange: boolean; // 首次登录是否强制修改密码
     registrationCodeRule: -1 | 0 | 1; // 注册编码规则,-1隐藏,0非必填,1必填
     riskType: 0 | 1 | 2; // 风控类型,1按单风控,2按账户风控
+    i18nEnabled: boolean; // 是否启用多语言设置
 }
 
 export const useGlobalStore = defineStore(() => {
@@ -38,10 +39,11 @@ export const useGlobalStore = defineStore(() => {
             tradeChannel: 'ws',
             showLoginAlert: false,
             modules: [],
-            quotationPropertys: [],
+            quotationProperties: [],
             forcedPasswordChange: false,
             registrationCodeRule: 1,
-            riskType: 0
+            riskType: 0,
+            i18nEnabled: true,
         }
     })
 
@@ -82,7 +84,7 @@ export const useGlobalStore = defineStore(() => {
 
     // 判断盘面是否包含某个属性
     const hasQuotationProperty = (prop: keyof Model.QuoteDayRsp) => {
-        return state.systemInfo.quotationPropertys.includes(prop)
+        return state.systemInfo.quotationProperties.includes(prop)
     }
 
     // 获取APP权限状态

+ 14 - 16
src/stores/modules/language.ts

@@ -3,35 +3,33 @@ import zhCN from '@public/locales/zh-CN.json'
 import enUS from '@public/locales/en-US.json'
 import thTH from '@public/locales/th-TH.json'
 import zhTW from '@public/locales/zh-TW.json'
+import { Language } from '@/constants/language'
 import { createI18n } from 'vue-i18n'
 import { localData } from '../storage'
 
-const appLanguage = localData.getRef('appLanguage')
-
 export const i18n = createI18n({
-    locale: appLanguage.value,
-    fallbackLocale: 'zh-CN',
+    locale: localData.getValue('appLanguage'),
+    fallbackLocale: Language.English,
     messages: {
-        'zh-CN': zhCN,
-        'en-US': enUS,
-        'th': thTH,
-        'zh-TW': zhTW
+        [Language.Simplified]: zhCN,
+        [Language.Traditional]: zhTW,
+        [Language.English]: enUS,
+        [Language.Thai]: thTH,
     }
 })
 
 axios('./locales/extras/zh-CN.json').then((res) => {
-    i18n.global.mergeLocaleMessage('zh-CN', res.data)
+    i18n.global.mergeLocaleMessage(Language.Simplified, res.data)
 })
 
-axios('./locales/extras/en-US.json').then((res) => {
-    i18n.global.mergeLocaleMessage('en-US', res.data)
+axios('./locales/extras/zh-TW.json').then((res) => {
+    i18n.global.mergeLocaleMessage(Language.Traditional, res.data)
 })
 
-axios('./locales/extras/th-TH.json').then((res) => {
-    i18n.global.mergeLocaleMessage('th', res.data)
+axios('./locales/extras/en-US.json').then((res) => {
+    i18n.global.mergeLocaleMessage(Language.English, res.data)
 })
 
-
-axios('./locales/extras/zh-TW.json').then((res) => {
-    i18n.global.mergeLocaleMessage('zh-TW', res.data)
+axios('./locales/extras/th-TH.json').then((res) => {
+    i18n.global.mergeLocaleMessage(Language.Thai, res.data)
 })