index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import { getGroomList } from '../../api/store.js';
  2. const app=getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. parameter: {
  9. 'navbar': '1',
  10. 'return': '1',
  11. 'title': '促销单品'
  12. },
  13. loading:false,
  14. loadend:false,
  15. page:1,
  16. limit:20
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. this.getIndexGroomList();
  23. },
  24. getIndexGroomList: function(){
  25. var that=this
  26. if(this.data.loadend) return false;
  27. if(this.data.loading) return false;
  28. that.setData({loading:true,loadTitle:'正在搜索'});
  29. getGroomList(4,{ page: that.data.page, limit: that.data.limit }).then(res=>{
  30. var list=res.data.list,loadend=list.length < that.data.limit;
  31. var bastList = app.SplitArray(list, that.data.bastList);
  32. that.setData({
  33. loading: false,
  34. bastList: bastList,
  35. page:that.data.page+1,
  36. loadend: loadend,
  37. loadTitle: loadend ? '已全部加载' : '加载更多',
  38. imgUrls: res.data.banner
  39. });
  40. }).catch(err=>{
  41. that.setData({ loading: false, loadTitle: "加载更多" });
  42. });
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面隐藏
  56. */
  57. onHide: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload: function () {
  63. },
  64. /**
  65. * 页面相关事件处理函数--监听用户下拉动作
  66. */
  67. onPullDownRefresh: function () {
  68. },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom: function () {
  73. this.getIndexGroomList();
  74. },
  75. /**
  76. * 用户点击右上角分享
  77. */
  78. onShareAppMessage: function () {
  79. }
  80. })