aftersaleList.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. aftersaleList: [],
  6. showType: 1,
  7. page: 1,
  8. limit: 10,
  9. totalPages: 1
  10. },
  11. onLoad: function (options) {
  12. },
  13. getAftersaleList() {
  14. let that = this;
  15. util.request(api.AftersaleList, {
  16. status: that.data.showType,
  17. page: that.data.page,
  18. limit: that.data.limit
  19. }).then(function (res) {
  20. if (res.errno === 0) {
  21. console.log(res.data);
  22. that.setData({
  23. aftersaleList: that.data.aftersaleList.concat(res.data.list),
  24. totalPages: res.data.pages
  25. });
  26. }
  27. });
  28. },
  29. onReachBottom() {
  30. if (this.data.totalPages > this.data.page) {
  31. this.setData({
  32. page: this.data.page + 1
  33. });
  34. this.getAftersaleList();
  35. } else {
  36. wx.showToast({
  37. title: '没有更多售后了',
  38. icon: 'none',
  39. duration: 2000
  40. });
  41. return false;
  42. }
  43. },
  44. switchTab: function (event) {
  45. let showType = event.currentTarget.dataset.index;
  46. this.setData({
  47. aftersaleList: [],
  48. showType: showType,
  49. page: 1,
  50. limit: 10,
  51. totalPages: 1
  52. });
  53. this.getAftersaleList();
  54. },
  55. onReady: function () {
  56. // 页面渲染完成
  57. },
  58. onShow: function () {
  59. // 页面显示
  60. this.getAftersaleList();
  61. },
  62. onHide: function () {
  63. // 页面隐藏
  64. this.setData({
  65. aftersaleList:[]
  66. });
  67. },
  68. onUnload: function () {
  69. // 页面关闭
  70. }
  71. })