From db374522f79dfc528830e5b7c58b7bb343c04e1f Mon Sep 17 00:00:00 2001 From: zpc Date: Tue, 24 Jun 2025 18:51:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/platform/BasePlatform.js | 12 +++++- common/server/config.js | 10 +++++ common/server/other.js | 2 + common/system/request.js | 2 + pages/index/index.vue | 30 ++++++++++---- pages/mall/mall.vue | 29 +++++++++----- pages/me/me.vue | 9 ++++- pages/other/agreement.vue | 1 + pages/other/user-agreement.nvue | 70 +++++++++++++++++++++++++++++++++ pages/other/user-agreement.vue | 12 ------ 10 files changed, 145 insertions(+), 32 deletions(-) create mode 100644 pages/other/user-agreement.nvue delete mode 100644 pages/other/user-agreement.vue diff --git a/common/platform/BasePlatform.js b/common/platform/BasePlatform.js index 0f50cb5..318fedb 100644 --- a/common/platform/BasePlatform.js +++ b/common/platform/BasePlatform.js @@ -1,4 +1,4 @@ - +import { getPlatformConfig } from '../server/config'; /** * 多端平台抽象基类(父类) * 定义所有端必须实现的方法 @@ -12,10 +12,18 @@ class BasePlatform { this.env = ''; // 运行环境标识 this.config = null; this.version = '1.0.0'; + this.getConfigPromise = null; } async getConfig() { - return {}; + return new Promise(async (resolve, reject) => { + if (this.config) { + resolve(this.config); + } else { + this.config = await getPlatformConfig(this.version); + resolve(this.config); + } + });; } async appData() { diff --git a/common/server/config.js b/common/server/config.js index b458427..da4f75e 100644 --- a/common/server/config.js +++ b/common/server/config.js @@ -1,4 +1,5 @@ import HttpRequest from "../system/request"; +import { platform } from "../platform/PlatformFactory"; /** * 获取系统配置 @@ -8,3 +9,12 @@ export const getConfig = async () => { const res = await HttpRequest.getOrCache('/config'); return res.data; } +/** + * 获取平台配置 + * @param {string} version 版本号 + * @returns + */ +export const getPlatformConfig = async () => { + const res = await HttpRequest.getOrCache('/getPlatformConfig', { version: platform.version }, 500); + return res.data; +} \ No newline at end of file diff --git a/common/server/other.js b/common/server/other.js index 4e93bb7..891b08b 100644 --- a/common/server/other.js +++ b/common/server/other.js @@ -24,6 +24,8 @@ export const getAgreement = async (type) => { type_id = 5; } else if (type == "product") { type_id = 32; + } else { + type_id = type; } const res = await HttpRequest.get('/getAgreement', { type: type_id diff --git a/common/system/request.js b/common/system/request.js index 8372c48..83489e2 100644 --- a/common/system/request.js +++ b/common/system/request.js @@ -197,11 +197,13 @@ class HttpRequest { */ static async getOrCache(url, data = {}, time = 300, showLoading = false) { const cacheKey = 'cache_' + url + '_' + qs.stringify(data); + // console.log('getOrCache', cacheKey, '查询缓存'); const cacheData = getLocalStorage(cacheKey); if (cacheData) { console.log('getOrCache', cacheKey, '缓存命中'); return cacheData; } + const res = await HttpRequest.request(url, data, 'GET', showLoading); setLocalStorage(cacheKey, res, time); return res; diff --git a/pages/index/index.vue b/pages/index/index.vue index 35900eb..ffff949 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -10,10 +10,20 @@ \ No newline at end of file diff --git a/pages/other/user-agreement.vue b/pages/other/user-agreement.vue deleted file mode 100644 index 532b672..0000000 --- a/pages/other/user-agreement.vue +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file