index.js 2.2 KB

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