myCollection.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // pages/my/myTimejob/myTimejob.js
  2. let app = getApp();
  3. let util = require('../../../utils/util.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. appAssetsUrl: app.appAssetsUrl,
  10. appAssetsUrl3: app.appAssetsUrl3,
  11. typeList: [{
  12. name: '收藏的兼职',
  13. value: '01'
  14. }, {
  15. name: '收藏的活动',
  16. value: '02'
  17. },
  18. ],
  19. typeListIndex: 0,
  20. nodata: util.nodata(),
  21. params: {
  22. page: 1,
  23. limit: 10,
  24. vipid: '',
  25. type: ''
  26. },
  27. total: {
  28. currPage: 0,
  29. totalPage: 0
  30. },
  31. noMore: false,
  32. listData: [],
  33. },
  34. switchType (e) {
  35. if (e) {
  36. let typeListIndex = e.currentTarget.dataset.index;
  37. this.setData({
  38. typeListIndex
  39. })
  40. this.loadList(true);
  41. }
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad: function (options) {
  47. if (util.getUserId()) {
  48. this.data.params.sid = util.getUserId()
  49. } else {
  50. return;
  51. }
  52. this.loadList(true);
  53. },
  54. seeDetails (e) {
  55. if (this.data.typeListIndex == 0) {
  56. wx.navigateTo({
  57. url: '/pages/home/index/partDetail/partDetail?id=' + e.currentTarget.dataset.id,
  58. })
  59. } else {
  60. wx.navigateTo({
  61. url: '/pages/home/index/activityDetail/activityDetail?id=' + e.currentTarget.dataset.id
  62. })
  63. }
  64. },
  65. loadList (isRefresh) {
  66. let that = this;
  67. if (!isRefresh && this.data.noMore) {
  68. wx.showToast({
  69. title: '没有更多了~',
  70. icon: 'none'
  71. })
  72. return false;
  73. }
  74. this.setData({
  75. listData: isRefresh ? [] : this.data.listData,
  76. noMore: isRefresh ? false : this.data.noMore,
  77. params: {
  78. ...this.data.params,
  79. page: isRefresh ? 1 : this.data.params.page + 1,
  80. type: this.data.typeListIndex + 1
  81. }
  82. })
  83. wx.showLoading({
  84. title: '努力加载中...',
  85. })
  86. app._post_form('favorite/getFavoriteByVipid', '', this.data.params,
  87. function (res) {
  88. if (res.code == 0) {
  89. if (res.page.list.length > 0 && that.data.listData.length > 0 && res.page.list[0].id == that.data.listData[0].id) {
  90. return;
  91. }
  92. let listData = that.data.listData;
  93. listData.push(...res.page.list);
  94. that.setData({
  95. listData,
  96. currPage: res.page.currPage,
  97. totalPage: res.page.totalPage,
  98. noMore: res.page.totalPage == res.page.currPage
  99. })
  100. }
  101. },
  102. function (res) {
  103. wx.hideLoading()
  104. })
  105. },
  106. /**
  107. * 生命周期函数--监听页面初次渲染完成
  108. */
  109. onReady: function () {
  110. },
  111. /**
  112. * 生命周期函数--监听页面显示
  113. */
  114. onShow: function () {
  115. },
  116. /**
  117. * 生命周期函数--监听页面隐藏
  118. */
  119. onHide: function () {
  120. },
  121. /**
  122. * 生命周期函数--监听页面卸载
  123. */
  124. onUnload: function () {
  125. },
  126. /**
  127. * 页面相关事件处理函数--监听用户下拉动作
  128. */
  129. onPullDownRefresh: function () {
  130. },
  131. /**
  132. * 页面上拉触底事件的处理函数
  133. */
  134. onReachBottom: function () {
  135. this.loadList();
  136. },
  137. /**
  138. * 用户点击右上角分享
  139. */
  140. onShareAppMessage: function () {
  141. }
  142. })