list.js 2.7 KB

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