detail.js 1.9 KB

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