index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // pages/home/index.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. height: app.globalData.height * 2 + 25,
  9. navbarData: {
  10. name: '节俭会'
  11. },
  12. heat: 80,
  13. heatColor: {
  14. '0%': '#E1FFFF',
  15. '25%': '#00FF7F',
  16. '50%': '#191970',
  17. '75%': '#ee0a24',
  18. '100%': '#ff0000',
  19. },
  20. },
  21. // 查看本周菜谱
  22. reserveBtn: function () {
  23. wx.redirectTo({
  24. url: '/pages/food/index',
  25. })
  26. },
  27. // 报餐:1,余菜打包:2,卡路里计算:3
  28. twoBtn: function (e) {
  29. let type = e.currentTarget.dataset.smile
  30. if (type == '1') {
  31. wx.switchTab({
  32. url: '/pages/reserve/index',
  33. })
  34. } else if (type == '2') {
  35. wx.showToast({
  36. title: '暂无开通',
  37. })
  38. } else {
  39. wx.redirectTo({
  40. url: '/pages/calorie/index',
  41. })
  42. }
  43. },
  44. /**
  45. * 生命周期函数--监听页面加载
  46. */
  47. onLoad: function (options) {
  48. // const test = `${app.globalData.publicUrl}/api/st/dining/arrange`;
  49. // console.log(test);
  50. wx.request({
  51. url: `${app.globalData.publicUrl}/api/st/dining/arrange`,
  52. method: "get",
  53. header: {
  54. 'x-tenant': app.globalData.tenant
  55. },
  56. data: {},
  57. success: res => {
  58. console.log(res);
  59. },
  60. error: err => {
  61. wx.showToast({
  62. title: err.msg,
  63. icon: 'error'
  64. })
  65. }
  66. })
  67. },
  68. /**
  69. * 生命周期函数--监听页面初次渲染完成
  70. */
  71. onReady: function () {
  72. },
  73. /**
  74. * 生命周期函数--监听页面显示
  75. */
  76. onShow: function () {
  77. if (typeof this.getTabBar === 'function' &&
  78. this.getTabBar()) {
  79. this.getTabBar().setData({
  80. selected: 0
  81. })
  82. }
  83. },
  84. /**
  85. * 生命周期函数--监听页面隐藏
  86. */
  87. onHide: function () {
  88. },
  89. /**
  90. * 生命周期函数--监听页面卸载
  91. */
  92. onUnload: function () {
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh: function () {
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom: function () {
  103. },
  104. /**
  105. * 用户点击右上角分享
  106. */
  107. onShareAppMessage: function () {
  108. }
  109. })