mycollection.js 3.7 KB

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