myworks.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. // pages/user/myworks/myworks.js
  2. import APIClient from '../../../utils/APIClient.js'
  3. import { formatDate } from '../../../utils/util.js'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. wareCards: [
  10. {
  11. title: "古诗词诵读(一)江南",
  12. grade: "一年级(上学期)",
  13. avatarUrl: '../../../static/image/timg.jpg',
  14. previewUrl: "../../../static/image/timg.jpg",
  15. plays: "17230",
  16. likes: "71230",
  17. classId: "1",
  18. avatar: '../../static/image/timg.jpg',
  19. nickName: '喔喔',
  20. time: '10-18 09:56'
  21. },
  22. {
  23. title: "古诗词诵读(一)江南",
  24. grade: "一年级(上学期)",
  25. avatarUrl: '../../../static/image/timg.jpg',
  26. previewUrl: "../../../static/image/timg.jpg",
  27. plays: "17230",
  28. likes: "71230",
  29. classId: "2",
  30. avatar: '../../static/image/timg.jpg',
  31. nickName: '喔喔',
  32. time: '10-18 09:56'
  33. },
  34. {
  35. title: "古诗词诵读(一)江南",
  36. grade: "一年级(上学期)",
  37. avatarUrl: '../../../static/image/timg.jpg',
  38. previewUrl: "../../../static/image/timg.jpg",
  39. plays: "17230",
  40. likes: "71230",
  41. classId: "3",
  42. avatar: '../../static/image/timg.jpg',
  43. nickName: '喔喔',
  44. time: '10-18 09:56'
  45. },
  46. {
  47. title: "古诗词诵读(一)江南",
  48. grade: "一年级(上学期)",
  49. avatarUrl: '../../../static/image/timg.jpg',
  50. previewUrl: "../../../static/image/timg.jpg",
  51. plays: "17230",
  52. likes: "71230",
  53. classId: "4",
  54. avatar: '../../static/image/timg.jpg',
  55. nickName: '喔喔',
  56. time: '10-18 09:56'
  57. },
  58. {
  59. title: "古诗词诵读(一)江南",
  60. grade: "一年级(上学期)",
  61. avatarUrl: '../../../static/image/timg.jpg',
  62. previewUrl: "../../../static/image/timg.jpg",
  63. plays: "17230",
  64. likes: "71230",
  65. classId: "5",
  66. avatar: '../../static/image/timg.jpg',
  67. nickName: '喔喔',
  68. time: '10-18 09:56'
  69. },
  70. {
  71. title: "古诗词诵读(一)江南",
  72. grade: "一年级(上学期)",
  73. avatarUrl: '../../../static/image/timg.jpg',
  74. previewUrl: "../../../static/image/timg.jpg",
  75. plays: "17230",
  76. likes: "71230",
  77. classId: "6",
  78. avatar: '../../static/image/timg.jpg',
  79. nickName: '喔喔',
  80. time: '10-18 09:56'
  81. }
  82. ],
  83. pageNo: 1,
  84. totalNo: 0,
  85. uid: ''
  86. },
  87. toMyWorks: function(e){
  88. let id = e.currentTarget.dataset.id;
  89. let title = e.currentTarget.dataset.title;
  90. wx.navigateTo({
  91. url: `../../social/works/works?id=${id}&title=${title}`
  92. });
  93. },
  94. getResults(){
  95. let pageNo = this.data.pageNo;
  96. let pageSize = 3;
  97. let uid = this.data.uid;
  98. console.log('用户身份',uid);
  99. APIClient.userWorks(uid, pageNo, pageSize).success(res => {
  100. // debugger;
  101. this.setData({
  102. wareCards: res.data.data.list
  103. });
  104. }).fail(err => {
  105. console.log(err);
  106. });
  107. },
  108. /**
  109. * 生命周期函数--监听页面加载
  110. */
  111. onLoad: function (options) {
  112. this.setData({
  113. uid: options.uid
  114. },() => {
  115. console.log(options.uid);
  116. });
  117. this.getResults();
  118. },
  119. /**
  120. * 生命周期函数--监听页面初次渲染完成
  121. */
  122. onReady: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面显示
  126. */
  127. onShow: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面隐藏
  131. */
  132. onHide: function () {
  133. },
  134. /**
  135. * 生命周期函数--监听页面卸载
  136. */
  137. onUnload: function () {
  138. },
  139. /**
  140. * 页面相关事件处理函数--监听用户下拉动作
  141. */
  142. onPullDownRefresh: function () {
  143. },
  144. /**
  145. * 页面上拉触底事件的处理函数
  146. */
  147. onReachBottom: function () {
  148. this.setData({
  149. pageNo: this.data.pageNo + 1
  150. })
  151. if (this.data.pageNo <= this.data.totalNo) {
  152. this.getResults();
  153. }
  154. },
  155. /**
  156. * 用户点击右上角分享
  157. */
  158. onShareAppMessage: function () {
  159. }
  160. })