This commit is contained in:
zpc 2025-05-26 16:07:50 +08:00
parent af0eb1a9ff
commit 8c1ae3ce9d
5 changed files with 18 additions and 11 deletions

View File

@ -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) => {

View File

@ -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 = [

View File

@ -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: '消费记录',

View File

@ -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) {

View File

@ -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
};