app.js 813 B

12345678910111213141516171819202122232425262728293031323334
  1. // app.js
  2. App({
  3. globalData: {
  4. isLoggedIn: false, // 登录状态
  5. },
  6. // 检查登录状态并弹出提示框
  7. checkLoginStatus() {
  8. const isLoggedIn = wx.getStorageSync('userInfo') || false;
  9. if (!isLoggedIn) {
  10. wx.showModal({
  11. title: '绑定手机号',
  12. content: '防止账号丢失以及方便找回,建议您绑定手机号码',
  13. confirmText: '立即绑定',
  14. cancelText: '取消',
  15. success: (res) => {
  16. if (res.confirm) {
  17. // 跳转到绑定手机号页面
  18. wx.navigateTo({
  19. url: '/pages/logins/logins',
  20. });
  21. }
  22. },
  23. });
  24. }
  25. return isLoggedIn;
  26. },
  27. onLaunch() {
  28. // wx.cloud.init({
  29. // env: 'cloud1-6g98iw7i28b01747',
  30. // traceUser: true
  31. // })
  32. }
  33. })