在进入 app 的第一个页面判断是否是第一次进入:
是,进入欢迎页;
是,进入欢迎页;
不是,进入主页。
判断方法,使用 api.getPrefs 。如果获得值为空,则是第一次进入(并通过 api.setPrefs 设置值,这样以后进入时便不为空了);否则,就不是第一次进入。
注:prefs 的特点是更新 app 后会被清空,这样就能使欢迎页只在更新后出现。
js 代码:
apiready = function(){
api.getPrefs({
key: 'isNeedWelcome'
},function( ret, err ){
if( ret.value === '' ){
fnShowWelcome();
api.setPrefs({
key: 'isNeedWelcome',
value: true
})
}else{
api.openWin({
name: 'main',
url: './html/main_win.html',
bounces: false
})
}
})
}
function fnShowWelcome(){
api.openFrameGroup({
name: 'welcomeGroup',
scrollEnable: true,
ract: {
x: 0,
y: 0,
w: 'auto',
h: 'auto'
},
index: 0,
frames: [{
name: 'welcome1',
url: './html/welcome1_frm.html',
bgcolor: './image/welcome/1.png',
bounces: false
},{
name: 'welcome2',
url: './html/welcome2_frm.html',
bgcolor: './image/welcome/2.png',
bounces: false
},{
name: 'welcome3',
url: './html/welcome3_frm.html',
bgcolor: './image/welcome/3.png',
bounces: false
},{
name: 'welcome4',
url: './html/welcome4_frm.html',
bgcolor: './image/welcome/4.png',
bounces: false
}]
},function( ret, err ){
var name = ret.name;
var index = ret.index;
})
}
如果需要在页面右上角加一个‘跳过’按钮:
<div class="button" tapmode οnclick="cancel(event)">
<span id="second">5</span>S跳过
</div>
function cancel(event){
// 阻止事件冒泡
if(event) event.stopPropagation();
clearInterval(isinerval);
document.getElementById('header').style.display = 'none';
if($api.getStorage('LOGIN_DATA')){
api.openWin({
name: 'main_win',
url: './html/main_win.html',
animation : {
type : 'fade'
},
slidBackEnabled: false
});
} else {
api.openWin({
name: 'login_win',
url: './html/login/login_win.html',
animation : {
type : 'fade'
},
slidBackEnabled: false
});
}
}