rank.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // pages/rank/rank.js
  2. const $api = require('../../utils/api.js').API;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. datas:{},
  9. date:'',
  10. match:[],
  11. index:0,
  12. match_id:''
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. // var y = new Date().getFullYear(), m = (new Date().getMonth() + 1), d = new Date().getDate();
  19. // m = m > 9 ? m : '0' + m;
  20. // d = d > 9 ? d : '0' + d;
  21. // this.setData({
  22. // date: y + '-' + m + '-' + d
  23. // })
  24. $api.getsignup().then(res=>{
  25. this.setData({
  26. info:res.data.data
  27. })
  28. })
  29. $api.getMatchList().then(res=>{
  30. let l = res.data.data.length - 1;
  31. this.setData({
  32. match:res.data.data,
  33. index: l,
  34. match_id: res.data.data[l].id
  35. })
  36. this.getDate()
  37. })
  38. },
  39. getDate(){
  40. $api.getDate({ match_id: this.data.match_id }).then(res => {
  41. this.setData({
  42. date: res.data.data
  43. })
  44. this.getData()
  45. })
  46. },
  47. getData() {
  48. wx.showNavigationBarLoading()
  49. if (!this.data.match_id){
  50. return
  51. }
  52. $api.getRank({ stock_date: this.data.date, match_id: this.data.match_id}).then(res => {
  53. wx.hideNavigationBarLoading()
  54. this.setData({
  55. datas:res.data.data,
  56. })
  57. })
  58. .catch(err=>{
  59. wx.hideNavigationBarLoading()
  60. })
  61. },
  62. bindChange(e) {
  63. let match=this.data.match;
  64. this.setData({
  65. index: e.detail.value,
  66. match_id: match[e.detail.value].id
  67. })
  68. this.getDate()
  69. },
  70. bindDateChange(e) {
  71. this.setData({
  72. date: e.detail.value
  73. })
  74. this.getData()
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面显示
  83. */
  84. onShow: function () {
  85. wx.hideNavigationBarLoading()
  86. if (!this.data.datas.groups){
  87. $api.getDate().then(res => {
  88. this.setData({
  89. date: res.data.data
  90. })
  91. this.getData()
  92. })
  93. }else{
  94. wx.showNavigationBarLoading()
  95. this.getData()
  96. }
  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. })