list.js 2.8 KB

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