minePush.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // pages/minePush/minePush.js
  2. const request = require("../../utils/request.js");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. handleStatus: true,
  9. contentList: [],
  10. contentId: null,
  11. },
  12. deleteConFun() {
  13. let that = this;
  14. request.postData(
  15. 'app/cont/content/del',
  16. {contentId: that.data.contentId},
  17. res => {
  18. that.getContentList();
  19. that.setData({
  20. contentId: null,
  21. handleStatus: true
  22. })
  23. wx.showToast({
  24. title: '删除成功',
  25. icon: 'none',
  26. duration: 2000
  27. })
  28. }
  29. )
  30. },
  31. getContentList() {
  32. let that = this;
  33. request.getData(
  34. 'app/cont/content/mine',
  35. {},
  36. res => {
  37. let arr = res.data.data;
  38. arr.forEach((item, index, array) => {
  39. let scale = request.getUrlKey(item.imgUrlList[0], 'scale');
  40. item.scale = scale ? scale : 1;
  41. })
  42. that.setData({
  43. contentList: arr
  44. })
  45. },
  46. res => {
  47. console.log(res)
  48. }
  49. )
  50. },
  51. handleShow(event) {
  52. // this.data.contentId = event.currentTarget.dataset.contentid;
  53. this.setData({
  54. contentId: event.currentTarget.dataset.cid,
  55. handleStatus: !this.data.handleStatus
  56. })
  57. },
  58. toCirclesDetail(event) {
  59. let contentId = event.currentTarget.dataset.cid;
  60. wx.navigateTo({
  61. url: '../circlesDetail/circlesDetail?contentId=' + contentId
  62. })
  63. },
  64. /**
  65. * 生命周期函数--监听页面加载
  66. */
  67. onLoad(options) {
  68. this.getContentList()
  69. },
  70. /**
  71. * 生命周期函数--监听页面初次渲染完成
  72. */
  73. onReady() {
  74. },
  75. /**
  76. * 生命周期函数--监听页面显示
  77. */
  78. onShow() {
  79. },
  80. /**
  81. * 生命周期函数--监听页面隐藏
  82. */
  83. onHide() {
  84. },
  85. /**
  86. * 生命周期函数--监听页面卸载
  87. */
  88. onUnload() {
  89. },
  90. /**
  91. * 页面相关事件处理函数--监听用户下拉动作
  92. */
  93. onPullDownRefresh() {
  94. },
  95. /**
  96. * 页面上拉触底事件的处理函数
  97. */
  98. onReachBottom() {
  99. let that = this;
  100. let lastContentId = Number(that.data.contentList[that.data.contentList.length-1].contentId);
  101. request.getData(
  102. 'app/cont/content/mine',
  103. {lastContentId: lastContentId},
  104. res => {
  105. if(res.data.data.length > 0) {
  106. let arr = res.data.data;
  107. arr.forEach((item, index, array) => {
  108. let scale = request.getUrlKey(item.imgUrlList[0], 'scale');
  109. item.scale = scale ? scale : 1;
  110. })
  111. that.setData({
  112. contentList: that.data.contentList.concat(arr)
  113. })
  114. }
  115. },
  116. res => {
  117. console.log(res)
  118. }
  119. )
  120. },
  121. /**
  122. * 用户点击右上角分享
  123. */
  124. onShareAppMessage() {
  125. if(Object.from == 'button') {
  126. let title = Object.target.dataset.item.content
  127. let contentId = Object.target.dataset.item.contentId
  128. let imageUrl = Object.target.dataset.item.imgUrlList[0]
  129. return {
  130. title: title,
  131. imageUrl: imageUrl,
  132. path: '/pages/circlesDetail/circlesDetail?contentId=' + contentId
  133. }
  134. }
  135. }
  136. })