2017-07-18 87 views
0

我正在尝试解决如何在用户第一次登录我的应用程序(填写个人资料信息)后向用户显示表单,然后才能进入常规网站。第一次登录时显示表格

任何人都可以指向正确的方向吗?

感谢

+0

尝试usewebstorage或cookie,这将允许您实现目标,除非用户清除cookie或删除本地存储。在这里阅读有关localstorage的信息https://www.w3schools.com/html/html5_webstorage.asp – Lekens

回答

0

我建议检查登录时的用户配置文件。如果配置文件不存在,请显示配置文件表格,否则,请转到常规站点。

2

可以使用应用程序的启动脚本做的伎俩: https://devsite.googleplex.com/appmaker/settings#app_start

假设你有剖面模型/数据源,在你的启动脚本代码将类似于此:

loader.suspendLoad(); 

var profileDs = app.datasources.Profile; 

// It would be more secure to move this filtering to the server side 
profileDs.query.filters.UserEmail._equals = app.user.email; 

profileDs.load({ 
    success: function() { 
    if (profileDs.item === null) { 
     app.showPage(app.pages.CreateProfile); 
    } else { 
     app.showPage(app.pages.HomePage); 
    } 

    loader.resumeLoad(); 
    }, 
    failure: function() { 
    loader.resumeLoad(); 
    // your fallback code goes here 
    } 
}); 

如果profile绝对必须的,我也建议执行在每个页面onAttach事件检查,但CreateProfile(防止直接链接导航):

// Profile datasource should be already loaded by startup script 
// when onAttach event is fired 
if (app.datasources.Profile.item === null) { 
    throw new Error('Invalid operation!'); 
} 
相关问题