index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // pages/fulltime/index.js
  2. import {
  3. getFullList
  4. } from '../../services/index.js'
  5. import {
  6. imgServerUrl,
  7. imgServerUrl_new
  8. } from '../../config/config.js'
  9. var app = getApp();
  10. Page({
  11. /**
  12. * 页面的初始数据
  13. */
  14. data: {
  15. list: [],
  16. pageNo: 1, //当前分页
  17. isScroll: true, //是否可以滚动
  18. showNoMore: "没有更多信息...", //显示已无更多
  19. cityCode: '320200',
  20. cityName: '无锡',
  21. selectId: -1, //选中筛选的条件
  22. totalSalary: '', //薪资待遇排序(1:正序;2:倒序)
  23. sort: '', //距离排序(1:正序;2:倒序)
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function(options) {
  29. if (app.globalData.userInfo) {
  30. console.log('有info===', app.globalData)
  31. this.start();
  32. } else if (this.data.canIUse) {
  33. // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  34. // 所以此处加入 callback 以防止这种情况
  35. app.userInfoReadyCallback = res => {
  36. console.log('userInfoReadyCallback===', res.userInfo)
  37. app.globalData.userInfo = res.userInfo;
  38. this.start();
  39. }
  40. } else {
  41. // 在没有 open-type=getUserInfo 版本的兼容处理
  42. wx.getUserInfo({
  43. success: res => {
  44. app.globalData.userInfo = res.userInfo
  45. console.log('兼容处理===', app.globalData)
  46. this.start();
  47. }
  48. })
  49. }
  50. },
  51. /**
  52. * 生命周期函数--监听页面初次渲染完成
  53. */
  54. onReady: function() {
  55. },
  56. start() {
  57. this.fullList();
  58. },
  59. //获取全职列表数据
  60. fullList(params) {
  61. if (!this.data.isScroll) {
  62. return false
  63. }
  64. let paramsObj = {
  65. totalSalary: this.data.totalSalary,
  66. cityCode: this.data.cityCode,
  67. pageNo: this.data.pageNo,
  68. user_id: app.globalData.userId,
  69. user_token: app.globalData.userToken
  70. }
  71. Object.assign(paramsObj);
  72. getFullList(paramsObj).then(data => {
  73. var pageNo = data.data.pageNo;
  74. let setData = {}
  75. // 是否可以滚动加载数据
  76. if (data.data.isLast) {
  77. setData.isScroll = false
  78. }
  79. if (data.data.fullPosition.length != 0) {
  80. setData.list = this.data.list.concat(data.data.fullPosition)
  81. setData.pageNo = pageNo;
  82. } else {
  83. setData.list = this.data.list;
  84. }
  85. this.setData({
  86. ...setData
  87. })
  88. })
  89. },
  90. /**
  91. * 生命周期函数--监听页面显示
  92. */
  93. onShow: function() {
  94. },
  95. /**
  96. * 页面相关事件处理函数--监听用户下拉动作
  97. */
  98. onPullDownRefresh: function() {
  99. this.setData({
  100. pageNo: 1, //当前分页
  101. isScroll: true, //是否可以滚动
  102. list: [],
  103. selectId: -1, //选中筛选的条件
  104. totalSalary: '', //薪资待遇排序(1:正序;2:倒序)
  105. sort: '', //距离排序(1:正序;2:倒序)
  106. })
  107. this.start();
  108. wx.stopPullDownRefresh();
  109. },
  110. /**
  111. * 页面上拉触底事件的处理函数
  112. */
  113. onReachBottom: function() {
  114. var pageNo = this.data.pageNo + 1;
  115. this.setData({
  116. pageNo
  117. })
  118. this.fullList();
  119. },
  120. /**
  121. * 用户点击右上角分享
  122. */
  123. onShareAppMessage: function() {
  124. },
  125. doSalay: function(e) {
  126. var totalSalary;
  127. if (this.data.totalSalary == 1) {
  128. totalSalary = 2;
  129. } else {
  130. totalSalary = 1;
  131. }
  132. this.setData({
  133. selectId: 0,
  134. totalSalary: totalSalary,
  135. sort: '', //重置
  136. pageNo: 1, //当前分页
  137. isScroll: true, //是否可以滚动
  138. list: [],
  139. })
  140. console.log("totalSalary", this.data.totalSalary)
  141. this.start();
  142. },
  143. doDistince: function(e) {
  144. var sort;
  145. if (this.data.sort == 1) {
  146. sort = 2;
  147. } else {
  148. sort = 1;
  149. }
  150. this.setData({
  151. selectId: 1,
  152. sort: sort,
  153. totalSalary: '', //重置
  154. })
  155. console.log("sort", this.data.sort)
  156. }
  157. })