index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. activeName: 0,
  14. list: [],
  15. mealList: [
  16. { label: '早餐', key: 'breakfast' },
  17. { label: "午餐", key: 'lunch' },
  18. { label: "晚餐", key: "dinner" }
  19. ]
  20. },
  21. onChange(event) {
  22. console.log(event);
  23. console.log(event.detail);
  24. this.setData({ activeName: Number(event.detail) });
  25. },
  26. // 返回
  27. back: function () {
  28. wx.switchTab({
  29. url: '/pages/my/index',
  30. })
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad: function (options) {
  36. if (!options.openid) {
  37. wx.request({
  38. url: `${app.globalData.publicUrl}/api/st/dining/order?openid=${'oDiAy5JAhb2ReM-LwmqbTCx5OteA'}`,
  39. method: "get",
  40. header: { 'x-tenant': app.globalData.tenant },
  41. data: {},
  42. success: res => {
  43. console.log(res);
  44. const { data } = res.data;
  45. this.setData({
  46. list: data
  47. })
  48. },
  49. error: err => {
  50. wx.showToast({
  51. title: err.msg,
  52. icon: 'error'
  53. })
  54. }
  55. })
  56. }
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow: function () {
  67. // if (typeof this.getTabBar === 'function' &&
  68. // this.getTabBar()) {
  69. // this.getTabBar().setData({
  70. // selected: 3
  71. // })
  72. // }
  73. },
  74. /**
  75. * 生命周期函数--监听页面隐藏
  76. */
  77. onHide: function () {
  78. },
  79. /**
  80. * 生命周期函数--监听页面卸载
  81. */
  82. onUnload: function () {
  83. },
  84. /**
  85. * 页面相关事件处理函数--监听用户下拉动作
  86. */
  87. onPullDownRefresh: function () {
  88. },
  89. /**
  90. * 页面上拉触底事件的处理函数
  91. */
  92. onReachBottom: function () {
  93. },
  94. /**
  95. * 用户点击右上角分享
  96. */
  97. onShareAppMessage: function () {
  98. }
  99. })