index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. let Parse = getApp().Parse;
  2. const company = getApp().globalData.company
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. list: null,
  9. merchant: null,
  10. id: null,
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. let merchant = wx.getStorageSync('merchant'); //用户
  17. // let ShopStore = new Parse.Query('ShopStore')
  18. // ShopStore.equalTo('user', this.data.merchant.objectId)
  19. // let res = await ShopStore.first()
  20. // let id = res.toJSON().objectId
  21. let id = options.id
  22. this.setData({
  23. merchant: merchant,
  24. id: id
  25. })
  26. this.getFood()
  27. },
  28. async getFood() {
  29. let Coupon = new Parse.Query('Food')
  30. Coupon.equalTo('store', this.data.id)
  31. Coupon.equalTo('company', company)
  32. Coupon.include('category')
  33. let coupon = await Coupon.find()
  34. if (coupon && coupon.length > 0) {
  35. let listJSON = []
  36. coupon.forEach(c => {
  37. listJSON.push(c.toJSON())
  38. })
  39. this.setData({
  40. list: listJSON
  41. })
  42. }
  43. console.log(this.data.list);
  44. },
  45. append() {
  46. wx.navigateTo({
  47. url: '/nova-tourism/pages/my/merchant/merchant-home/dishes/dishes-details/index'
  48. });
  49. },
  50. appends(e) {
  51. let id = e.currentTarget.dataset.item.objectId
  52. wx.navigateTo({
  53. url: '/nova-tourism/pages/my/merchant/merchant-home/dishes/dishes-details/index?id=' + id
  54. });
  55. },
  56. /**
  57. * 生命周期函数--监听页面初次渲染完成
  58. */
  59. onReady: function () {
  60. },
  61. /**
  62. * 生命周期函数--监听页面显示
  63. */
  64. onShow: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面隐藏
  68. */
  69. onHide: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面卸载
  73. */
  74. onUnload: function () {
  75. },
  76. /**
  77. * 页面相关事件处理函数--监听用户下拉动作
  78. */
  79. onPullDownRefresh: function () {
  80. },
  81. /**
  82. * 页面上拉触底事件的处理函数
  83. */
  84. onReachBottom: function () {
  85. },
  86. /**
  87. * 用户点击右上角分享
  88. */
  89. onShareAppMessage: function () {
  90. }
  91. })