rank.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.getMatchList().then(res=>{
  25. let l = res.data.data.length - 1;
  26. this.setData({
  27. match:res.data.data,
  28. index: l,
  29. match_id: res.data.data[l].id
  30. })
  31. $api.getDate().then(res => {
  32. this.setData({
  33. date: res.data.data
  34. })
  35. this.getData()
  36. })
  37. })
  38. },
  39. getData() {
  40. wx.showNavigationBarLoading()
  41. $api.getRank({ stock_date: this.data.date, match_id: this.data.match_id}).then(res => {
  42. wx.hideNavigationBarLoading()
  43. this.setData({
  44. datas:res.data.data,
  45. })
  46. })
  47. .catch(err=>{
  48. wx.hideNavigationBarLoading()
  49. })
  50. },
  51. bindChange(e) {
  52. let match=this.data.match;
  53. this.setData({
  54. index: e.detail.value,
  55. match_id: match[e.detail.value].id
  56. })
  57. this.getData()
  58. },
  59. bindDateChange(e) {
  60. this.setData({
  61. date: e.detail.value
  62. })
  63. this.getData()
  64. },
  65. /**
  66. * 生命周期函数--监听页面初次渲染完成
  67. */
  68. onReady: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面显示
  72. */
  73. onShow: function () {
  74. $api.getMyStyle().then(res => {
  75. if (!res.data.data.init_fund) {
  76. wx.navigateTo({
  77. url: '../style/style',
  78. })
  79. }
  80. })
  81. wx.hideNavigationBarLoading()
  82. if (!this.data.datas.groups){
  83. $api.getDate().then(res => {
  84. this.setData({
  85. date: res.data.data
  86. })
  87. this.getData()
  88. })
  89. }
  90. },
  91. /**
  92. * 生命周期函数--监听页面隐藏
  93. */
  94. onHide: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面卸载
  98. */
  99. onUnload: function () {
  100. },
  101. /**
  102. * 页面相关事件处理函数--监听用户下拉动作
  103. */
  104. onPullDownRefresh: function () {
  105. },
  106. /**
  107. * 页面上拉触底事件的处理函数
  108. */
  109. onReachBottom: function () {
  110. },
  111. /**
  112. * 用户点击右上角分享
  113. */
  114. onShareAppMessage: function () {
  115. }
  116. })