home.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. list: [],
  8. page: 1,
  9. no_more: false,
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function () {
  15. this.getList();
  16. },
  17. /**
  18. * 页面相关事件处理函数--监听用户下拉动作
  19. */
  20. onPullDownRefresh: function () {
  21. this.setData({list:[],page:1,no_more:false});
  22. this.getList();
  23. wx.stopPullDownRefresh();
  24. },
  25. /**
  26. * 页面上拉触底事件的处理函数
  27. */
  28. onReachBottom: function () {
  29. this.getList();
  30. },
  31. /**
  32. * 用户点击右上角分享
  33. */
  34. onShareAppMessage() {
  35. return {
  36. title: "晋爱人才",
  37. path: "/pages/home/home/home",
  38. };
  39. },
  40. //列表
  41. getList() {
  42. var self = this;
  43. if (self.data.no_more) {
  44. return false;
  45. }
  46. app.post('rob/product/index',{
  47. page:self.data.page,
  48. },function(res){
  49. if (res.length < 10) {
  50. self.setData({no_more:true});
  51. }
  52. let list = self.data.list;
  53. list = list.concat(res);
  54. let page = self.data.page;
  55. page++;
  56. self.setData({list:list,page:page});
  57. });
  58. },
  59. //搜索
  60. bindSearch() {
  61. this.setData({list:[],page:1,no_more:false});
  62. this.getList();
  63. }
  64. })