day.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // pages/day/day.js
  2. const app = getApp();
  3. var host = app.globalData.host;
  4. var id;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad(options) {
  15. id = options.id
  16. this.setData({
  17. id: id
  18. })
  19. wx.showNavigationBarLoading()
  20. /**获取token */
  21. wx.getStorage({
  22. key: 'userInfo',
  23. success: res => {
  24. this.setData({
  25. userInfo: res.data
  26. })
  27. this.getData(options.id);
  28. },
  29. fail: error => {
  30. //跳转到登陆页面
  31. wx.switchTab({
  32. url: '../user/user',
  33. })
  34. }
  35. })
  36. },
  37. getData(id) {
  38. wx.request({
  39. url: host + '/api/wx/player/match/record/list',
  40. data: { id: id },
  41. header: {
  42. 'Authorization': this.data.userInfo.token
  43. },
  44. success: res => {
  45. console.log(res)
  46. this.setData({
  47. datas: res.data.data
  48. })
  49. wx.hideNavigationBarLoading()
  50. },
  51. fail: error => {
  52. //跳转到登陆页面
  53. wx.switchTab({
  54. url: '../user/user',
  55. })
  56. }
  57. })
  58. },
  59. /**
  60. * 生命周期函数--监听页面初次渲染完成
  61. */
  62. onReady: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面显示
  66. */
  67. onShow: function () {
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面卸载
  76. */
  77. onUnload: function () {
  78. },
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh: function () {
  83. },
  84. /**
  85. * 页面上拉触底事件的处理函数
  86. */
  87. onReachBottom: function () {
  88. },
  89. /**
  90. * 用户点击右上角分享
  91. */
  92. onShareAppMessage: function () {
  93. }
  94. })