index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. nav:[],
  6. list:[],
  7. isLoadMore:false,
  8. pageSize: 20,
  9. page:1,
  10. vtype:0
  11. },
  12. onLoad: function (options) {
  13. let that = this;
  14. util.ajax({
  15. func:"v2/articleReviewType/list",
  16. data:{},
  17. load:false
  18. },function(res){
  19. if(res.code == 0){
  20. let nav = [{ id: 0, title: '全部' }, ...res.data.list];
  21. that.setData({nav});
  22. that.getList(true);
  23. }else{
  24. util.showTips(res.reason);
  25. }
  26. })
  27. },
  28. chooseNav(e) {
  29. this.setData({ vtype: e.currentTarget.dataset.vtype, page:1 });
  30. this.getList(true);
  31. },
  32. getList:function(load){
  33. let that = this;
  34. util.ajax({
  35. func:"v2/articleReview/list",
  36. data: {"type":that.data.vtype,"pageIndex":that.data.page,"pageSize":that.data.pageSize},
  37. load: load
  38. },function(res){
  39. if(res.code == 0){
  40. let isLoadMore = true;
  41. let list = load ? res.data.list : [...that.data.list, ...res.data.list];
  42. if (res.data.list.length < that.data.pageSize && list.length > that.data.pageSize) {
  43. isLoadMore = false;
  44. }
  45. that.setData({ list, isLoadMore: isLoadMore });
  46. }else{
  47. util.showTips(res.reason)
  48. }
  49. })
  50. },
  51. onPullDownRefresh: function () {
  52. var self = this;
  53. wx.showNavigationBarLoading();
  54. setTimeout(function () {
  55. self.setData({ page: 1 });
  56. self.getList(true);
  57. wx.hideNavigationBarLoading();
  58. wx.stopPullDownRefresh();
  59. }, 1000);
  60. },
  61. onReachBottom() {
  62. var self = this;
  63. if (self.data.isLoadMore == false) return false;
  64. setTimeout(function () {
  65. self.setData({ page: self.data.page + 1 });
  66. self.getList(false);
  67. }, 1000);
  68. },
  69. onShareAppMessage() {
  70. return {
  71. title: '精彩回顾',
  72. path: '/pages/public/wonderful/index'
  73. }
  74. }
  75. })