group.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. var app = getApp()
  4. Page({
  5. data: {
  6. // text:"这是一个页面"
  7. openList: [],
  8. openList0: [],
  9. openList1: [],
  10. openList2: [],
  11. openList3: [],
  12. tabList: ['全部','待付款','拼团中','拼团成功','拼团失败'],
  13. tabIndex: 0,
  14. page: 1,
  15. size: 10,
  16. count: 0,
  17. scrollTop: 0,
  18. showPage: false
  19. },
  20. toggleTab(e){
  21. this.setData({
  22. tabIndex: e.currentTarget.dataset.index
  23. })
  24. },
  25. swiperChange(e){
  26. this.setData({
  27. tabIndex: e.detail.current
  28. })
  29. },
  30. getOpenList(){
  31. let that = this;
  32. util.request(api.GroupOpenMyList, {}).then(function (res) {
  33. if (res.errno === 0) {
  34. that.setData({
  35. openList: res.data,
  36. openList0: res.data.filter(item => item.attend_status == 0),
  37. openList1: res.data.filter(item => item.attend_status == 1),
  38. openList2: res.data.filter(item => item.attend_status == 2),
  39. openList3: res.data.filter(item => item.attend_status == 3)
  40. });
  41. that.data.openList.forEach((item, num) => {
  42. if (item.attend_status == 0 || item.attend_status == 1){
  43. util.countdown(that, that.data.openList, 'openList', num)
  44. }
  45. })
  46. that.data.openList0.forEach((item, num) => {
  47. util.countdown(that, that.data.openList0, 'openList0', num)
  48. })
  49. that.data.openList1.forEach((item, num) => {
  50. util.countdown(that, that.data.openList1, 'openList1', num)
  51. })
  52. }
  53. });
  54. },
  55. onLoad: function (options) {
  56. // 页面初始化 options为页面跳转所带来的参数
  57. this.getOpenList();
  58. },
  59. onReady: function () {
  60. // 页面渲染完成
  61. },
  62. onShow: function () {
  63. // 页面显示
  64. },
  65. onHide: function () {
  66. // 页面隐藏
  67. },
  68. onUnload: function () {
  69. // 页面关闭
  70. }
  71. })