myCollection.js 2.8 KB

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