classify_detail.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // pages/classify_detail/classify_detail.js
  2. // const { http } = require('../../utils/util')
  3. const { getClassifyGoods } = require('../../API/appraise')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. classifyShow: [],
  10. page: 1,
  11. pageSize: 6,
  12. id: 1,
  13. title: "",
  14. //节流阀
  15. isLoading: false
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad(options) {
  21. this.getGoods()
  22. this.setData({
  23. // 传递点击的分类id
  24. id: options.classify_id,
  25. //传递点击的分类名称
  26. title: options.title
  27. })
  28. },
  29. getGoods() {
  30. //加载的loading效果
  31. wx.showLoading({
  32. title: '数据获取中',
  33. })
  34. getClassifyGoods(this.data).then((res) => {
  35. const { data } = res.data;
  36. console.log(res);
  37. this.setData({
  38. classifyShow: [...this.data.classifyShow , ...data.data],
  39. isLoading: true
  40. })
  41. console.log(this.data.classifyShow);
  42. })
  43. this.setData({
  44. isLoading: false
  45. })
  46. },
  47. /**
  48. * 生命周期函数--监听页面初次渲染完成
  49. */
  50. onReady() {
  51. },
  52. /**
  53. * 生命周期函数--监听页面显示
  54. */
  55. onShow() {
  56. },
  57. /**
  58. * 生命周期函数--监听页面隐藏
  59. */
  60. onHide() {
  61. },
  62. /**
  63. * 生命周期函数--监听页面卸载
  64. */
  65. onUnload() {
  66. },
  67. /**
  68. * 页面相关事件处理函数--监听用户下拉动作
  69. */
  70. onPullDownRefresh() {
  71. },
  72. /**
  73. * 页面上拉触底事件的处理函数
  74. */
  75. onReachBottom() {
  76. if(this.data.isLoading) {
  77. this.setData({
  78. page: this.data.page + 1,
  79. })
  80. this.getGoods()
  81. }
  82. },
  83. /**
  84. * 用户点击右上角分享
  85. */
  86. onShareAppMessage() {
  87. }
  88. })