mycollection.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import httpRequestApi from '../../utils/APIClient';
  2. import {
  3. formatDate
  4. } from '../../utils/util';
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. collection_data: [],
  11. line1: '您还没有收藏过哦',
  12. line2: '快去收藏自己喜欢的吧',
  13. videoList: [],
  14. commentShow: false,
  15. statusbarobj: {
  16. isshowbtn: false, //是否显示按钮
  17. title: "小学语文朗读配音", //标题
  18. },
  19. },
  20. toClass: function (e) {
  21. let targetCode = e.currentTarget.dataset.targetcode;
  22. let title = e.currentTarget.dataset.title;
  23. // wx.navigateTo({
  24. // url: `../../main/class/class?id=${targetCode}&title=${title}`
  25. // });
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (option) {
  31. console.log(option.title);
  32. if (option.title) {
  33. wx.setNavigationBarTitle({
  34. title: '我的收藏' //页面标题为路由参数
  35. });
  36. this.setData({
  37. title: option.title
  38. });
  39. }
  40. httpRequestApi.myFavorites().success(res => {
  41. this.formatWorksList(res.data.data.list)
  42. });
  43. },
  44. formatWorksList(list) {
  45. list.forEach(item => {
  46. const temp = {};
  47. temp.title = item.userRead.title;
  48. temp.summary = item.userRead.summary;
  49. temp.img = item.userRead.iconImg;
  50. temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
  51. temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
  52. temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
  53. temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
  54. temp.time = formatDate(item.userRead.gmtCreated, 3);
  55. temp.avatar = item.user.avatar;
  56. temp.profession = item.user.profession;
  57. temp.uid = item.user.uid;
  58. temp.url = item.userRead.videoPath ? item.userRead.videoPath : item.userRead.originVideo;
  59. temp.id = item.userRead.id;
  60. temp.type = item.userRead.type;
  61. temp.nickName = item.user.wechatName;
  62. temp.isLike = item.isLike;
  63. temp.isFans = true;
  64. temp.isFavorite = true;
  65. temp.coverImg = item.userRead.coverImg;
  66. temp.videoShow = false;
  67. this.data.videoList.push(temp);
  68. });
  69. this.setData({
  70. videoList: this.data.videoList
  71. }, () => {
  72. console.log(this.data.videoList)
  73. })
  74. },
  75. goToReading: function (e) {
  76. console.log('去朗读', e)
  77. const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
  78. wx.navigateTo({
  79. url: `../../pages/reading/reading?id=${id}`
  80. });
  81. },
  82. // 评论区点击
  83. commentTap: function (e) {
  84. console.log('点击评论区', e)
  85. if (e.target.dataset.type === 'blank') {
  86. this.setData({
  87. commentShow: false
  88. })
  89. }
  90. },
  91. // 打开评论
  92. openComment: function (e) {
  93. //
  94. console.log('id', e.detail.activeId)
  95. this.setData({
  96. commentShow: !this.data.commentShow,
  97. commentId: e.detail.activeId,
  98. // commentList: []
  99. });
  100. // this.getReply(e.detail.activeId);
  101. },
  102. // 发布回复
  103. sendReply: function (e) {
  104. console.log('triger', e.detail.content);
  105. let data = {
  106. columnId: this.data.commentId,
  107. colunmNames: 'what',
  108. detailDesc: e.detail.content,
  109. // productId: this.data.productId
  110. }
  111. httpRequestApi.postReply(this.uid, data).success(res => {
  112. console.log(res)
  113. this.setData({
  114. pageNo: 1,
  115. commentList: []
  116. }, () => {
  117. this.getReply(this.data.commentId);
  118. })
  119. });
  120. },
  121. commentTouchMove: function (e) {
  122. return;
  123. },
  124. /**
  125. * 生命周期函数--监听页面初次渲染完成
  126. */
  127. onReady: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面显示
  131. */
  132. onShow: function () {
  133. },
  134. /**
  135. * 生命周期函数--监听页面隐藏
  136. */
  137. onHide: function () {
  138. },
  139. /**
  140. * 生命周期函数--监听页面卸载
  141. */
  142. onUnload: function () {
  143. },
  144. /**
  145. * 页面相关事件处理函数--监听用户下拉动作
  146. */
  147. onPullDownRefresh: function () {
  148. },
  149. /**
  150. * 页面上拉触底事件的处理函数
  151. */
  152. onReachBottom: function () {
  153. },
  154. /**
  155. * 用户点击右上角分享
  156. */
  157. onShareAppMessage: function () {
  158. if (res.from === 'button') {
  159. return {
  160. title: '请欣赏我的课文朗读作品,点赞+评论。',
  161. path: `/pages/index/index?readId=${this.data.shareId}`,
  162. imageUrl: '../../static/index/share_icon.png'
  163. }
  164. } else {
  165. return {
  166. title: '课文朗读,从未如此有趣',
  167. path: '/pages/index/index',
  168. }
  169. }
  170. }
  171. })