list.js 2.9 KB

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