document.addEventListener('UniAppJSBridgeReady', function () { uni.webView.postMessage({ data: { action: 'setPlatform' } }); window.backup = (from) => { if (from === 'backbutton') { const routes = getCurrentPages(); const route = routes[routes.length - 1].route; if ([ 'pagesMain/pages/index/index', 'pagesMain/pages/volunteer/volunteer', 'pagesMain/pages/me/me' ].includes(route)) { uni.webView.postMessage({ data: { action: 'quit' } }); } else { uni.navigateBack(); } } }; // 默认为h5平台 window.platform = 'h5'; window.setPlatform = (platform) => { window.platform = platform; }; });