diff --git a/App.vue b/App.vue index f131b0f..26d3ab4 100644 --- a/App.vue +++ b/App.vue @@ -10,8 +10,6 @@ export default { }, onLaunch: function (options) { // console.log("App Launch", options, window.location.href); - - var that = this; this.$config.init().then(async (data) => { diff --git a/common/config.js b/common/config.js index 315ef2e..676aebb 100644 --- a/common/config.js +++ b/common/config.js @@ -8,7 +8,7 @@ import RequestManager from '@/common/request.js' let configData = null; let isLoading = false; let loadPromise = null; -const wx_version = "110"; +const wx_version = "111"; // 白名单页面(不需要登录即可访问) export const whiteList = [ diff --git a/common/platform/BasePlatform.js b/common/platform/BasePlatform.js index e631783..b21c8ca 100644 --- a/common/platform/BasePlatform.js +++ b/common/platform/BasePlatform.js @@ -1,5 +1,9 @@ -import { navigateTo } from '@/common/router' -import { getPlatform } from '../server/config'; +import { + navigateTo +} from '@/common/router' +import { + getPlatform +} from '../server/config'; /** * 多端平台抽象基类(父类) * 定义所有端必须实现的方法 @@ -11,6 +15,7 @@ class BasePlatform { } this.code = ''; // 平台代码(WEB/MP/APP) this.env = ''; // 运行环境标识 + this.config = null; } async getConfig() { if (this.config) { @@ -89,8 +94,7 @@ class BasePlatform { * @returns {Array} 菜单项数组,每项包含id, show, title, icon, path和handler */ getUserMenuList() { - let m = [ - { + let m = [{ id: 1, show: true, title: '消费记录', diff --git a/common/platform/MiniProgramPlatform.js b/common/platform/MiniProgramPlatform.js index 32ba174..ccd2ce2 100644 --- a/common/platform/MiniProgramPlatform.js +++ b/common/platform/MiniProgramPlatform.js @@ -12,9 +12,10 @@ import { */ class MiniProgramPlatform extends BasePlatform { constructor() { + super(); this.code = 'MP-WEIXIN'; this.env = 'miniProgram'; - super(); + } getPayData(url, data) { @@ -189,6 +190,7 @@ class MiniProgramPlatform extends BasePlatform { }); } AppLaunch(options) { + this.getConfig(); console.log("AppLaunch", options); const updateManager = uni.getUpdateManager(); updateManager.onCheckForUpdate(function (res) { diff --git a/common/platform/PlatformFactory.js b/common/platform/PlatformFactory.js index 09d0374..343715a 100644 --- a/common/platform/PlatformFactory.js +++ b/common/platform/PlatformFactory.js @@ -1,4 +1,7 @@ +import BasePlatform from './BasePlatform.js'; +//#ifdef MP-WEIXIN import MiniProgramPlatform from './MiniProgramPlatform'; +//#endif //#ifdef APP-PLUS import AppPlatform from './AppPlatform'; import IOSPlatform from './IOSPlatform'; @@ -52,14 +55,14 @@ class PlatformFactory { return new H5Platform(); //#endif - // 默认返回 小程序 - return new MiniProgramPlatform(); + // 默认返回 + return new BasePlatform(); } } // 使用示例 const platform = PlatformFactory.create(); -console.log(platform.env,"获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台"); +// console.log(platform.env,"获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台获取平台"); export { platform }; \ No newline at end of file