mui.plusReady(function() {
//改变statusbar
plus.navigator.setStatusBarBackground('#41cea9');
navtitle = document.getElementById('nav-title');
mainWebView = plus.webview.currentWebview();
//判断是否已经登陆,若没有登陆将预加载登陆页面,知道登陆成功为止close登陆页面
judgelogin();
//初始化商品详情页面。
initProductDetail();
//初始化页面,
inittabitemWebviews();
//为每个bar-item添加点击事件
addEventForTabitem();
//接收自定义的事件页面切换
changeWebViewEvent();
});
例如其中选项卡点击监听也用函数来实现
function addEventForTabitem() {
mui('.mui-bar-tab').on('tap', '.mui-tab-item', function() {
var tabitem = this;
if (tabitem == curTabItem) {
return;
}
curTabItem = tabitem;
navtitle.innerText = tabitem.children[tabitem.children.length - 1].innerText;
//设置将显示当前webview
showCurWebView(tabitem.getAttribute('href'));
});
}