index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. is_admin: false,
  14. },
  15. // 跳转页面
  16. routeBtn: function (e) {
  17. let type = e.currentTarget.dataset.type;
  18. if (type == '1') {
  19. wx.redirectTo({
  20. url: `/pages/basic/index?id=${app.globalData.wxInfo._id}`,
  21. });
  22. } else if (type == '2') {
  23. wx.redirectTo({
  24. url: `/pages/history/index?openid=${app.globalData.wxInfo.openid}`,
  25. });
  26. } else if(type=='3'){
  27. wx.redirectTo({
  28. url: `/pages/writeoff/index`,
  29. });
  30. }
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad: function (options) {
  36. const wxInfo = app.globalData.wxInfo;
  37. this.setData({
  38. is_admin: wxInfo.is_admin || false,
  39. });
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady: function () {},
  45. /**
  46. * 生命周期函数--监听页面显示
  47. */
  48. onShow: function () {
  49. if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  50. this.getTabBar().setData({
  51. selected: 3,
  52. });
  53. }
  54. },
  55. /**
  56. * 生命周期函数--监听页面隐藏
  57. */
  58. onHide: function () {},
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload: function () {},
  63. /**
  64. * 页面相关事件处理函数--监听用户下拉动作
  65. */
  66. onPullDownRefresh: function () {},
  67. /**
  68. * 页面上拉触底事件的处理函数
  69. */
  70. onReachBottom: function () {},
  71. /**
  72. * 用户点击右上角分享
  73. */
  74. onShareAppMessage: function () {},
  75. });