myCollection.js 2.8 KB

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