75 lines
2.0 KiB
JavaScript
Executable File
75 lines
2.0 KiB
JavaScript
Executable File
jumpPage();
|
||
|
||
function jumpPage() {
|
||
//跳转页面
|
||
var subpages = ['collect_commodity.html', 'collect_store.html'];
|
||
var subpage_style = {
|
||
top: '66px',
|
||
bottom: '0px',
|
||
scrollIndicator: 'none'
|
||
};
|
||
|
||
var aniShow = {}; //动画显示
|
||
//当前激活选项
|
||
var activeTab = subpages[0];
|
||
//选项卡点击事件
|
||
mui('.nav').on('tap', 'a', function(e) {
|
||
var targetTab = this.getAttribute('href');
|
||
if(targetTab == activeTab) {
|
||
return;
|
||
}
|
||
//显示目标选项卡
|
||
//若为iOS平台或非首次显示,则直接显示
|
||
if(mui.os.ios || aniShow[targetTab]) {
|
||
plus.webview.show(targetTab);
|
||
|
||
} else {
|
||
//否则,使用fade-in动画,且保存变量
|
||
var temp = {};
|
||
temp[targetTab] = "true";
|
||
mui.extend(aniShow, temp);
|
||
plus.webview.show(targetTab, "fade-in", 300);
|
||
}
|
||
//隐藏当前;
|
||
plus.webview.hide(activeTab);
|
||
//更改当前活跃的选项卡
|
||
activeTab = targetTab;
|
||
if(targetTab == 'collect_commodity.html') {
|
||
document.getElementsByClassName('p1')[1].classList.remove('on')
|
||
this.classList.add('on');
|
||
}
|
||
if(targetTab == 'collect_store.html') {
|
||
document.getElementsByClassName('p1')[0].classList.remove('on')
|
||
this.classList.add('on');
|
||
}
|
||
});
|
||
|
||
//首次启动切滑效果
|
||
mui.plusReady(function() {
|
||
// launchScreen();
|
||
// plus.navigator.setStatusBarStyle('dark');
|
||
// console.log(plus.navigator.getStatusBarStyle())
|
||
var self = plus.webview.currentWebview();
|
||
|
||
for(var i = 0; i < subpages.length; i++) {
|
||
var temp = {};
|
||
//http://www.html5plus.org/doc/zh_cn/webview.html#plus.webview.create
|
||
var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
|
||
if(i > 0) {
|
||
sub.hide();
|
||
} else {
|
||
temp[subpages[i]] = "true";
|
||
mui.extend(aniShow, temp); //合并对象
|
||
}
|
||
self.append(sub);
|
||
}
|
||
var data_href = self.data_href;
|
||
if(data_href == 'collect_store.html') {
|
||
var defaultTab = document.getElementsByClassName("p1")[1];
|
||
//模拟首页点击
|
||
mui.trigger(defaultTab, 'tap');
|
||
}
|
||
|
||
});
|
||
|
||
} |