index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // pages/my/postJob/index.js
  2. const App = getApp()
  3. var util = require("../../utils/util.js")
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. nodata: util.nodata(),
  10. tabs: [{
  11. i: '01',
  12. label: '进行中'
  13. },
  14. {
  15. i: '02',
  16. label: '已完成'
  17. }
  18. ],
  19. currentTab: 0,
  20. queryParams: {
  21. page: 1,
  22. limit: 10
  23. },
  24. type: '01',
  25. list: [],
  26. total: 0,
  27. currPage: null,
  28. totalPage: null,
  29. user: wx.getStorageSync('USER'),
  30. cityInfo: wx.getStorageSync('CHOOSECITY'),
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad(options) {
  36. },
  37. /**
  38. * 生命周期函数--监听页面初次渲染完成
  39. */
  40. onReady() {
  41. },
  42. /**
  43. * 生命周期函数--监听页面显示
  44. */
  45. onShow() {
  46. this.getlist()
  47. },
  48. getlist() {
  49. if (this.data.total > 0) {
  50. if (this.data.currPage == this.data.totalPage) {
  51. wx.showToast({
  52. title: '没有更多了哦~',
  53. icon: 'none'
  54. })
  55. return false
  56. }
  57. }
  58. wx.showLoading({
  59. title: '努力加载中...',
  60. })
  61. // 全部 ''
  62. App._post_form('work/myReleaseListNew', '', {
  63. ...this.data.queryParams,
  64. type: this.data.type,
  65. sid: this.data.user.id,
  66. city: this.data.cityInfo.cityId,
  67. }, res => {
  68. if (res.code === 0) {
  69. this.setData({
  70. list: [...this.data.list, ...res.data.list],
  71. total: res.data.totalCount,
  72. currPage: res.data.currPage,
  73. totalPage: res.data.totalPage
  74. })
  75. console.log(this.data.list, 111)
  76. }
  77. }, err => {}, complete => {
  78. setTimeout(() => {
  79. wx.hideLoading()
  80. })
  81. })
  82. },
  83. tabChange(e) {
  84. console.log(e)
  85. if (this.data.currentTab == e.currentTarget.dataset.index) {
  86. return
  87. }
  88. this.setData({
  89. currentTab: e.currentTarget.dataset.index,
  90. type: e.currentTarget.dataset.type
  91. })
  92. this.init()
  93. },
  94. init() {
  95. this.setData({
  96. queryParams: {
  97. page: 1,
  98. limit: 10
  99. },
  100. total: 0,
  101. list: []
  102. })
  103. this.getlist()
  104. },
  105. addJob() {
  106. wx.navigateTo({
  107. url: '/job/postJob/postJob',
  108. })
  109. },
  110. /**
  111. * 生命周期函数--监听页面隐藏
  112. */
  113. onHide() {
  114. },
  115. /**
  116. * 生命周期函数--监听页面卸载
  117. */
  118. onUnload() {
  119. },
  120. /**
  121. * 页面相关事件处理函数--监听用户下拉动作
  122. */
  123. onPullDownRefresh() {
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom() {
  129. this.setData({
  130. queryParams: {
  131. page: ++this.data.queryParams.page,
  132. limit: 10
  133. }
  134. })
  135. this.getlist()
  136. },
  137. /**
  138. * 用户点击右上角分享
  139. */
  140. onShareAppMessage() {
  141. }
  142. })