list.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // pages/list/list.js
  2. const $api = require('../../utils/api.js').API;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. id:'',
  9. page:1,
  10. total:0,
  11. order1:1,
  12. order2: 1,
  13. order_by:'',
  14. list:[]
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. this.setData({
  21. id: options.id
  22. })
  23. this.getData();
  24. },
  25. getData(){
  26. var data={
  27. id: this.data.id,
  28. page: this.data.page,
  29. page_size:20,
  30. order_by: this.data.order_by
  31. }
  32. const list = this.data.list;
  33. wx.showNavigationBarLoading();
  34. $api.getRankList(data).then(res=>{
  35. const players = res.data.data.players;
  36. for (let i = 0; i < players.length; i++) {
  37. list.push(players[i])
  38. }
  39. this.setData({
  40. group: res.data.data.group,
  41. list: list,
  42. total: res.data.data.total,
  43. actual_person: res.data.data.actual_person,
  44. leave_person: res.data.data.leave_person,
  45. total_person: res.data.data.total_person,
  46. win_person: res.data.data.win_person,
  47. loss_person: res.data.data.loss_person
  48. })
  49. wx.setNavigationBarTitle({
  50. title: res.data.data.group.name,
  51. })
  52. wx.hideNavigationBarLoading()
  53. })
  54. },
  55. next: function () {
  56. if (this.data.list.length < this.data.total) {
  57. const page = this.data.page + 1
  58. this.setData({
  59. page: page
  60. })
  61. this.getData()
  62. }
  63. },
  64. //排序
  65. changeOrder1(){
  66. this.setData({
  67. order1:!this.data.order1,
  68. order_by: this.data.order1 ? 'today_income__asc' :'today_income__desc',
  69. page:1,
  70. total:0,
  71. list:[]
  72. })
  73. this.getData()
  74. },
  75. changeOrder2() {
  76. this.setData({
  77. order2: !this.data.order2,
  78. order_by: this.data.order2 ? 'total_income__asc' : 'total_income__desc',
  79. page: 1,
  80. total: 0,
  81. list: []
  82. })
  83. this.getData()
  84. },
  85. /**
  86. * 生命周期函数--监听页面初次渲染完成
  87. */
  88. onReady: function () {
  89. },
  90. /**
  91. * 生命周期函数--监听页面显示
  92. */
  93. onShow: function () {
  94. },
  95. /**
  96. * 生命周期函数--监听页面隐藏
  97. */
  98. onHide: function () {
  99. },
  100. /**
  101. * 生命周期函数--监听页面卸载
  102. */
  103. onUnload: function () {
  104. },
  105. /**
  106. * 页面相关事件处理函数--监听用户下拉动作
  107. */
  108. onPullDownRefresh: function () {
  109. },
  110. /**
  111. * 页面上拉触底事件的处理函数
  112. */
  113. onReachBottom: function () {
  114. },
  115. /**
  116. * 用户点击右上角分享
  117. */
  118. onShareAppMessage: function () {
  119. }
  120. })