myread.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import APIClient from '../../../utils/APIClient.js'
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. wareCards: [],
  8. user: {},
  9. line1: '您还没有朗读过哦',
  10. line2: '快去朗读吧'
  11. },
  12. toWork: function (e) {
  13. let lessonId = e.currentTarget.dataset.lessonid;
  14. let title = e.currentTarget.dataset.title;
  15. wx.navigateTo({
  16. url: `../../social/works/works?id=${lessonId}&title=${title}`
  17. });
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (option) {
  23. console.log(option.title);
  24. if (option.title) {
  25. wx.setNavigationBarTitle({
  26. title: option.title//页面标题为路由参数
  27. });
  28. this.setData({
  29. title: option.title
  30. });
  31. }
  32. APIClient.myRead().success(res => {
  33. console.log(res.data.data.list,'我的朗读');
  34. APIClient.getUserWorksInfo().success(res => {
  35. let user = res.data.data;
  36. this.setData({
  37. user: user,
  38. }, () => {
  39. console.log(this.data.user);
  40. });
  41. }).fail(error => {
  42. console.log(error);
  43. });
  44. this.setData({
  45. wareCards: res.data.data.list
  46. });
  47. }).fail(err => {
  48. console.log(err);
  49. });
  50. },
  51. /**
  52. * 生命周期函数--监听页面初次渲染完成
  53. */
  54. onReady: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面显示
  58. */
  59. onShow: function () {
  60. },
  61. /**
  62. * 生命周期函数--监听页面隐藏
  63. */
  64. onHide: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面卸载
  68. */
  69. onUnload: function () {
  70. },
  71. /**
  72. * 页面相关事件处理函数--监听用户下拉动作
  73. */
  74. onPullDownRefresh: function () {
  75. },
  76. /**
  77. * 页面上拉触底事件的处理函数
  78. */
  79. onReachBottom: function () {
  80. },
  81. /**
  82. * 用户点击右上角分享
  83. */
  84. onShareAppMessage: function () {
  85. }
  86. })