diff --git a/public/config.json b/public/config.json new file mode 100644 index 0000000..657732f --- /dev/null +++ b/public/config.json @@ -0,0 +1,4 @@ +{ + "tenantId": "000000", + "apiUrl": "http://124.222.254.188:8889" +} \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 73a0642..13b68d6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -19,18 +19,17 @@ import { getDefaultLocal } from '@/api/system/user'; const lang = localStorage.getItem('lang') -const _getDefaultLocal = () => { - getDefaultLocal().then(res => { - console.log('res', res) - if (lang !== res.defaultLocal) { - localStorage.setItem('lang', res.defaultLocal) - localStorage.setItem('defaultCoinUnit', res.defaultCoinUnit) - location.reload() - } - }) + +const init = async () => { + const defaultLocal = await getDefaultLocal() + if (lang !== defaultLocal.defaultLocal) { + localStorage.setItem('lang', defaultLocal.defaultLocal) + localStorage.setItem('defaultCoinUnit', defaultLocal.defaultCoinUnit) + location.reload() + } } -_getDefaultLocal() +init() diff --git a/src/config/index.ts b/src/config/index.ts index 17ba2e5..f94b52d 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -3,8 +3,10 @@ export type Config = { apiUrl: string; } -export const getConfig = (): Config => { - return t_000000 +export const getConfig = async (): Promise => { + const config = await fetch('/config.json').then(res => res.text()) + + return JSON.parse(config) as Config } // 配置文件 diff --git a/src/utils/http/axios/index.ts b/src/utils/http/axios/index.ts index 4af8c0f..97a541e 100644 --- a/src/utils/http/axios/index.ts +++ b/src/utils/http/axios/index.ts @@ -18,7 +18,7 @@ import {domainStoreWidthOut} from "@/store/modules/domain"; import { getConfig } from '@/config'; const urlPrefix = ''; -const tenantConfig = getConfig(); +const tenantConfig = await getConfig(); // import router from '@/router'; // import { storage } from '@/utils/Storage'; diff --git a/src/utils/index.ts b/src/utils/index.ts index a26d390..e690977 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,5 @@ import {isObject} from "@/utils/is"; +import { showToast } from 'vant'; /** px 转 vw, 375 是设置的屏幕宽度 */ export const px2vw = (px: number): string => { @@ -285,4 +286,21 @@ export function debounce(func: Function, time: number, immediate = false) { }, time) } } -} \ No newline at end of file +} + + +export function copyToClipboard(text) { + // 用原生的方式把微信码复制到剪切板 + const textarea = document.createElement('textarea'); + textarea.value = text; + document.body.appendChild(textarea); + textarea.select(); + try { + document.execCommand('copy'); + showToast('内容已复制到剪贴板') + } catch (err) { + console.error('无法复制内容', err); + } finally { + document.body.removeChild(textarea); + } +} diff --git a/src/views/index/my/index.vue b/src/views/index/my/index.vue index 548d7ba..b468965 100644 --- a/src/views/index/my/index.vue +++ b/src/views/index/my/index.vue @@ -4,6 +4,7 @@
{{ customerInfo.nickName }}
+
编号:{{ customerInfo.userCode }}(复制)
@@ -95,7 +96,7 @@