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