top.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. const app = getApp()
  2. Page({
  3. data: {
  4. loading: true,
  5. curIndex: 0,
  6. page: 0,
  7. item: []
  8. },
  9. //载入
  10. onLoad: function () {
  11. this.geItem();
  12. },
  13. onShow: function () {
  14. app.setTabBarCartNumber();
  15. },
  16. //上拉加载
  17. onReachBottom: function () {
  18. var that = this;
  19. if (app.globalData.config.set_tab_style) {
  20. that.setData({
  21. loading: true,
  22. });
  23. that.geItem();
  24. }
  25. },
  26. //读取团购数据
  27. geItem: function () {
  28. let that = this;
  29. if (that.data.loading) {
  30. var param = {
  31. page: that.data.page + 1,
  32. cate_id: 0,
  33. types: 2
  34. }
  35. app.api().Get('api/v3/fastshop/shop/cateItem', param, function (result) {
  36. if (result.code == 200) {
  37. var item = that.data.item;
  38. for (let i in result.data) {
  39. item.push(result.data[i]);
  40. }
  41. that.setData({
  42. item: item,
  43. page: param.page
  44. });
  45. }
  46. that.setData({
  47. loading: false,
  48. });
  49. })
  50. }
  51. },
  52. //搜索
  53. onSearch: function (event) {
  54. let that = this;
  55. if (!app.util().isNull(event.detail)) {
  56. var keyword = event.detail;
  57. wx.navigateTo({
  58. url: '../shop/search?keyword=' + keyword,
  59. })
  60. }
  61. }
  62. })