1 Star 0 Fork 2

onlylylt / uniuViewTemplate

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
App.vue 1.22 KB
一键复制 编辑 原始数据 按行查看 历史
mrdotyan 提交于 2021-04-01 11:01 . change notifier
<script>
export default {
onLaunch: function() {
console.log('onLaunch');
// 获取当前手机系统信息
const system = this.getSystemInfo();
this.$store.dispatch('saveSysinfoToVuex', system);
// 判断是否进入引导页
this.goHomeOrGoGuide();
},
onShow: function() {
console.log('App Show');
// 进入广告页
this.goAdvPage();
},
onHide: function() {
console.log('App Hide');
// hide的时候存储当前时间
uni.setStorageSync('advTimes', new Date());
},
methods: {
goAdvPage() {
const nowTimes = new Date();
const storageTimes = uni.getStorageSync('advTimes');
const oldTimes = new Date(storageTimes);
if (nowTimes - oldTimes > 30 * 60 * 60 * 1000) {
uni.reLaunch({
url: '/pages/adv/adv'
});
}
},
goHomeOrGoGuide() {
if (this.checkGuide()) {
uni.reLaunch({
url: '/pages/index/index'
});
} else {
uni.reLaunch({
url: '/pages/guide/guide'
});
}
},
getSystemInfo() {
return uni.getSystemInfoSync();
},
checkGuide() {
return uni.getStorageSync('guide') || false;
}
}
};
</script>
<style lang="scss">
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import 'uview-ui/index.scss';
</style>
1
https://gitee.com/onlymry/uniu-view-template.git
git@gitee.com:onlymry/uniu-view-template.git
onlymry
uniu-view-template
uniuViewTemplate
master

搜索帮助