aBulkList.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // pages/aBulkList/aBulkList.js
  2. var http = require("../../utils/http.js");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. aBulkList: [], //商品列表
  9. current: 1,
  10. size: 10,
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. this.getAbulkList()
  17. },
  18. /**
  19. * 获取团购商品列表
  20. */
  21. getAbulkList:function() {
  22. wx.showLoading()
  23. var params = {
  24. url: "/groupProd/page",
  25. method: "GET",
  26. data: {
  27. current: this.data.current,
  28. size: 10
  29. },
  30. callBack: (res) => {
  31. wx.hideLoading();
  32. var aBulkList = [];
  33. if (res.current == 1) {
  34. aBulkList = res.records;
  35. } else {
  36. aBulkList = this.data.aBulkList;
  37. Array.prototype.push.apply(aBulkList, res.records);
  38. }
  39. this.setData({
  40. aBulkList: aBulkList,
  41. pages: res.pages,
  42. current: res.current,
  43. });
  44. console.log(this.data.aBulkList)
  45. }
  46. };
  47. http.request(params)
  48. },
  49. /**
  50. * 跳转到拼团商品详情
  51. */
  52. toAbulkListPage: function (e) {
  53. var prodId = e.currentTarget.dataset.prodid;
  54. var groupActivityId = e.currentTarget.dataset.groupactivityid;
  55. console.log(groupActivityId)
  56. wx.navigateTo({
  57. url: '/pages/prod/prod?prodid=' + prodId + "&groupActivityId=" + groupActivityId,
  58. })
  59. },
  60. /**
  61. * 生命周期函数--监听页面初次渲染完成
  62. */
  63. onReady: function () {
  64. },
  65. /**
  66. * 生命周期函数--监听页面显示
  67. */
  68. onShow: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面隐藏
  72. */
  73. onHide: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面卸载
  77. */
  78. onUnload: function () {
  79. },
  80. /**
  81. * 页面相关事件处理函数--监听用户下拉动作
  82. */
  83. onPullDownRefresh: function () {
  84. },
  85. /**
  86. * 页面上拉触底事件的处理函数
  87. */
  88. onReachBottom: function () {
  89. if(this.data.current<this.data.pages){
  90. this.setData({
  91. current: this.data.current+1
  92. })
  93. this.getAbulkList()
  94. }
  95. },
  96. /**
  97. * 用户点击右上角分享
  98. */
  99. onShareAppMessage: function () {
  100. }
  101. })