couponGoods.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. couponName: '',
  9. goodsList: [],
  10. couponId: 0,
  11. addressInfo:{}
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. if (options.id) {
  18. this.setData({
  19. couponId: options.id
  20. })
  21. }
  22. var addressInfo = wx.getStorageSync("addressInfo");
  23. if (addressInfo) {
  24. this.setData({
  25. addressInfo: addressInfo
  26. })
  27. this.getGoodsList();
  28. }
  29. },
  30. getGoodsList: function () {
  31. var that = this;
  32. util.request(api.GoodsCoupon, {
  33. id: that.data.couponId,
  34. shopId:that.data.addressInfo.shopId
  35. })
  36. .then(function (res) {
  37. that.setData({
  38. goodsList: res.data.list,
  39. couponName: res.data.couponName
  40. });
  41. });
  42. },
  43. /**
  44. * 生命周期函数--监听页面初次渲染完成
  45. */
  46. onReady: function () {
  47. },
  48. /**
  49. * 生命周期函数--监听页面显示
  50. */
  51. onShow: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面隐藏
  55. */
  56. onHide: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面卸载
  60. */
  61. onUnload: function () {
  62. },
  63. /**
  64. * 页面相关事件处理函数--监听用户下拉动作
  65. */
  66. onPullDownRefresh: function () {
  67. },
  68. /**
  69. * 页面上拉触底事件的处理函数
  70. */
  71. onReachBottom: function () {
  72. },
  73. /**
  74. * 用户点击右上角分享
  75. */
  76. onShareAppMessage: function () {
  77. }
  78. })