!(function() { console.log('W2A[launchWebview]:wap2appquit'); if (!window.wap2app) { console.log('W2A[launchWebview]:wap2appquit[wap2app is undefined]'); return; } var ID = '__W2A_QUIT_IFRAME'; var FEEDBACK_ID = '__W2A_FEEDBACK'; //var REVERSE_VENDORS = ['HTC', 'Sony', 'LGE', 'HUAWEI','Meizu']; var REVERSE_VENDORS = ['SONY', 'HTC', 'LGE', 'MOTOROLA']; var REVERSE_NEXUS_MODEL = 'NEXUS'; var isReverse = function() { var vendor = plus.device.vendor.toUpperCase(); var model = plus.device.model.toUpperCase(); if (~REVERSE_VENDORS.indexOf(vendor)) { return true; } if (~model.indexOf(REVERSE_NEXUS_MODEL)) { return true; } return false; }; /** * 打开反馈页面 */ var openFeedback = function() { plus.nativeUI.showWaiting(); var feedbackOptions = wap2app.getW2AOptions().globalOptions.feedback; var url = feedbackOptions.url; var params = feedbackOptions.params; if (typeof params === 'function') { params = params(); } if (wap2app.util.isObject(params)) { url = wap2app.ajax.appendQuery(url, wap2app.extend(params, { p: plus.os.name === 'Android' ? 'a' : plus.os.name === 'iOS' ? 'i' : '', plus_version: plus.runtime.innerVersion, vendor: plus.device.vendor, md: plus.device.model })); } var feedbackWebview = plus.webview.create(url, FEEDBACK_ID); feedbackWebview.addEventListener('titleUpdate', function() { plus.nativeUI.closeWaiting(); feedbackWebview.show('slide-in-right', 300); }); }; /** * 退出应用 */ var quit = function() { plus.runtime.quit(); }; wap2app.plusReady(function() { console.log('W2A[launchWebview]:wap2appquit[plusready]'); var confirm = wap2app.confirm; plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) { console.log('W2A[launchWebview]:wap2appquit[' + wgtinfo.name + ']'); wap2app.domReady(function() { confirm.init({ id: ID, html: '
确定要退出吗?
欢迎使用轻量省电的{W2A_QUIT_APP_NAME}流应用版
如有问题请点左下角反馈意见
'.replace('{W2A_QUIT_APP_NAME}', wgtinfo.name).replace('{W2A_QUIT_CONFIRM_REVERSE}', isReverse() ? 'mui-confirm-reverse' : ''), callback: function(e) { switch (e.index) { case -2: //点击遮罩关闭 break; case -1: //点击返回键关闭 break; case 0: //点击反馈意见 openFeedback(); break; case 1: //点击回到应用 break; case 2: //点击直接退出 quit(); break; } } }); }); }); wap2app.quit = function() { var confirmElem = confirm.isVisible(); if (confirmElem) { //退出时,如果confirm已显示,则直接退出 quit(); } else { //退出时,如果quit未显示,则需要先显示,然后开始计时,直接返回 confirm.open(ID); } }; }); })();