index.js 2.4 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. // onChange({ detail }, e) {
  13. // // 需要手动对 checked 状态进行更新
  14. // detail = e.currentTarget.dataset.item.status
  15. // // this.setData({ checked: detail });
  16. // },
  17. async getShopgoods() {
  18. let ShopStore = new Parse.Query('ShopStore')
  19. ShopStore.equalTo('user', this.data.merchant.objectId)
  20. let res = await ShopStore.first()
  21. let id = res.toJSON().objectId
  22. let Coupon = new Parse.Query('ShopGoods')
  23. Coupon.equalTo('shopStore', id)
  24. Coupon.equalTo('company', company)
  25. Coupon.equalTo('type', 'meal')
  26. let coupon = await Coupon.find()
  27. if (coupon && coupon.length > 0) {
  28. let listJSON = []
  29. coupon.forEach(c => {
  30. listJSON.push(c.toJSON())
  31. })
  32. this.setData({
  33. list: listJSON
  34. })
  35. }
  36. console.log(this.data.list);
  37. },
  38. append() {
  39. wx.navigateTo({
  40. url: '/nova-tourism/pages/my/merchant/merchant-home/package/append/index'
  41. });
  42. },
  43. appends(e) {
  44. let id = e.currentTarget.dataset.item.objectId
  45. wx.navigateTo({
  46. url: '/nova-tourism/pages/my/merchant/merchant-home/package/append/index?id=' + id
  47. });
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad: function(options) {
  53. let merchant = wx.getStorageSync('merchant'); //用户
  54. this.setData({ merchant: merchant })
  55. this.getShopgoods()
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady: function() {
  61. },
  62. /**
  63. * 生命周期函数--监听页面显示
  64. */
  65. onShow: function() {
  66. this.getShopgoods()
  67. },
  68. /**
  69. * 生命周期函数--监听页面隐藏
  70. */
  71. onHide: function() {
  72. },
  73. /**
  74. * 生命周期函数--监听页面卸载
  75. */
  76. onUnload: function() {
  77. },
  78. /**
  79. * 页面相关事件处理函数--监听用户下拉动作
  80. */
  81. onPullDownRefresh: function() {
  82. },
  83. /**
  84. * 页面上拉触底事件的处理函数
  85. */
  86. onReachBottom: function() {
  87. },
  88. /**
  89. * 用户点击右上角分享
  90. */
  91. onShareAppMessage: function() {
  92. }
  93. })