mycollection.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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.isFavorite = true;
  60. this.data.videoList.push(temp);
  61. });
  62. this.setData({
  63. videoList: this.data.videoList
  64. }, () => {
  65. console.log(this.data.videoList)
  66. })
  67. },
  68. goToReading: function (e) {
  69. console.log('去朗读', e)
  70. const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
  71. wx.navigateTo({
  72. url: `../../pages/reading/reading?id=${id}`
  73. });
  74. },
  75. // 评论区点击
  76. commentTap: function (e) {
  77. console.log('点击评论区', e)
  78. if (e.target.dataset.type === 'blank') {
  79. this.setData({
  80. commentShow: false
  81. })
  82. }
  83. },
  84. // 打开评论
  85. openComment: function (e) {
  86. //
  87. console.log('id', e.detail.activeId)
  88. this.setData({
  89. commentShow: !this.data.commentShow,
  90. commentId: e.detail.activeId,
  91. // commentList: []
  92. });
  93. // this.getReply(e.detail.activeId);
  94. },
  95. // 发布回复
  96. sendReply: function (e) {
  97. console.log('triger', e.detail.content);
  98. let data = {
  99. columnId: this.data.commentId,
  100. colunmNames: 'what',
  101. detailDesc: e.detail.content,
  102. // productId: this.data.productId
  103. }
  104. httpRequestApi.postReply(this.uid, data).success(res => {
  105. console.log(res)
  106. this.setData({
  107. pageNo: 1,
  108. commentList: []
  109. }, () => {
  110. this.getReply(this.data.commentId);
  111. })
  112. });
  113. },
  114. /**
  115. * 生命周期函数--监听页面初次渲染完成
  116. */
  117. onReady: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面显示
  121. */
  122. onShow: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面隐藏
  126. */
  127. onHide: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面卸载
  131. */
  132. onUnload: function () {
  133. },
  134. /**
  135. * 页面相关事件处理函数--监听用户下拉动作
  136. */
  137. onPullDownRefresh: function () {
  138. },
  139. /**
  140. * 页面上拉触底事件的处理函数
  141. */
  142. onReachBottom: function () {
  143. },
  144. /**
  145. * 用户点击右上角分享
  146. */
  147. onShareAppMessage: function () {
  148. }
  149. })