mycollection.js 4.2 KB

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