index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. var user = require('../../../utils/user.js');
  4. var app = getApp();
  5. Page({
  6. data: {
  7. aboutShow: true,
  8. userInfo: {
  9. nickName: '点击登录',
  10. avatarUrl: 'http://yanxuan.nosdn.127.net/8945ae63d940cc42406c3f67019c5cb6.png'
  11. }
  12. },
  13. onLoad: function(options) {
  14. },
  15. onReady: function() {
  16. },
  17. onShow: function() {
  18. //获取用户的登录信息
  19. if (app.globalData.hasLogin) {
  20. let userInfo = wx.getStorageSync('userInfo');
  21. this.setData({
  22. aboutShow: true,
  23. userInfo: userInfo,
  24. });
  25. }
  26. },
  27. onHide: function() {
  28. // 页面隐藏
  29. },
  30. onUnload: function() {
  31. // 页面关闭
  32. },
  33. goLogin() {
  34. if (!app.globalData.hasLogin) {
  35. wx.navigateTo({
  36. url: "/pages/auth/login/login"
  37. });
  38. }
  39. },
  40. goOrder() {
  41. if (app.globalData.hasLogin) {
  42. wx.navigateTo({
  43. url: "/pages/ucenter/order/order"
  44. });
  45. } else {
  46. wx.navigateTo({
  47. url: "/pages/auth/login/login"
  48. });
  49. }
  50. },
  51. goCoupon() {
  52. if (app.globalData.hasLogin) {
  53. wx.navigateTo({
  54. url: "/pages/ucenter/coupon/coupon"
  55. });
  56. } else {
  57. wx.navigateTo({
  58. url: "/pages/auth/login/login"
  59. });
  60. };
  61. },
  62. goGroupon() {
  63. if (app.globalData.hasLogin) {
  64. wx.navigateTo({
  65. url: "/pages/groupon/myGroupon/myGroupon"
  66. });
  67. } else {
  68. wx.navigateTo({
  69. url: "/pages/auth/login/login"
  70. });
  71. };
  72. },
  73. goCollect() {
  74. if (app.globalData.hasLogin) {
  75. wx.navigateTo({
  76. url: "/pages/ucenter/collect/collect"
  77. });
  78. } else {
  79. wx.navigateTo({
  80. url: "/pages/auth/login/login"
  81. });
  82. };
  83. },
  84. goFootprint() {
  85. if (app.globalData.hasLogin) {
  86. wx.navigateTo({
  87. url: "/pages/ucenter/footprint/footprint"
  88. });
  89. } else {
  90. wx.navigateTo({
  91. url: "/pages/auth/login/login"
  92. });
  93. };
  94. },
  95. goAddress() {
  96. if (app.globalData.hasLogin) {
  97. wx.navigateTo({
  98. url: "/pages/ucenter/address/address"
  99. });
  100. } else {
  101. wx.navigateTo({
  102. url: "/pages/auth/login/login"
  103. });
  104. };
  105. },
  106. exitLogin: function() {
  107. wx.showModal({
  108. title: '',
  109. confirmColor: '#b4282d',
  110. content: '退出登录?',
  111. success: function(res) {
  112. if (res.confirm) {
  113. wx.removeStorageSync('token');
  114. wx.removeStorageSync('userInfo');
  115. wx.switchTab({
  116. url: '/pages/index/index'
  117. });
  118. }
  119. }
  120. })
  121. }
  122. })