<h2>要实现APP首次进入弹出模态框</h2>
判断Storage中是否存在一个字段,如果有则多次进入,如果没有则首次进入(首次进入之后设置该storage即可,我是在模态框确定之后设置的storage,根据需求变化)
在首页中methods中写下如下代码,并在onShow中调用,注意此处获取缓存必须是同步
isFirstEnter(){
var firstEnter = uni.getStorageSync('firstEnter');//同步获取缓存中是否有首次进入字段
let that = this;
uni.getSystemInfo({
success(data){
// 如果是安卓并且没有firstEnter缓存则弹出模态框
if(data.platform === 'android'){
//如果渠道包是应用宝则弹出模态框
if (plus.runtime.channel == 'yyb') {
!firstEnter ? that.neilShow = true : that.neilShow = false;
}
}else{
that.neilShow = false;
}
}
})
},