index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // pages/home/index.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. height: app.globalData.height * 2 + 25,
  9. windowHeight: app.globalData.windowHeight,
  10. navbarData: {
  11. name: '我的'
  12. },
  13. userInfo: {}
  14. },
  15. // 跳转页面
  16. routeBtn: function (e) {
  17. let type = e.currentTarget.dataset.type;
  18. if (type == '1') {
  19. wx.redirectTo({
  20. url: `/pages/history/index?openid=${app.globalData.userInfo.openid}`
  21. })
  22. } else if (type == '2') {
  23. app.globalData.userInfo = {}
  24. wx.redirectTo({
  25. url: '/pages/login/index'
  26. })
  27. }
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad: function (options) {
  33. let data = app.globalData.userInfo;
  34. console.log(data);
  35. if (data) this.setData({ userInfo: data })
  36. },
  37. /**
  38. * 生命周期函数--监听页面初次渲染完成
  39. */
  40. onReady: function () {
  41. },
  42. /**
  43. * 生命周期函数--监听页面显示
  44. */
  45. onShow: function () {
  46. if (typeof this.getTabBar === 'function' &&
  47. this.getTabBar()) {
  48. this.getTabBar().setData({
  49. selected: 3
  50. })
  51. }
  52. },
  53. /**
  54. * 生命周期函数--监听页面隐藏
  55. */
  56. onHide: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面卸载
  60. */
  61. onUnload: function () {
  62. },
  63. /**
  64. * 页面相关事件处理函数--监听用户下拉动作
  65. */
  66. onPullDownRefresh: function () {
  67. },
  68. /**
  69. * 页面上拉触底事件的处理函数
  70. */
  71. onReachBottom: function () {
  72. },
  73. /**
  74. * 用户点击右上角分享
  75. */
  76. onShareAppMessage: function () {
  77. }
  78. })