servantList.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. scrollHeight: 0,
  10. page: 1,
  11. limit: 10,
  12. totalPages: 1,
  13. addressInfo:{},
  14. servantList:[
  15. ]
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. var addressInfo=wx.getStorageSync('addressInfo');
  22. if(addressInfo){
  23. this.setData({
  24. addressInfo:addressInfo
  25. })
  26. }
  27. this.getServantList();
  28. // wx.getSystemInfo({
  29. // success:res=>{
  30. // this.setData({
  31. // scrollHeight: res.windowHeight
  32. // });
  33. // }
  34. // });
  35. },
  36. viewMore(e){
  37. console.log(e);
  38. let workerNo=e.currentTarget.dataset.workerno;
  39. wx.navigateTo({
  40. url: '/pages/servant/servantDetail/servantDetail?workerNo='+workerNo,
  41. })
  42. },
  43. /**
  44. * 生命周期函数--监听页面初次渲染完成
  45. */
  46. onReady: function () {
  47. },
  48. /**
  49. * 生命周期函数--监听页面显示
  50. */
  51. onShow: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面隐藏
  55. */
  56. onHide: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面卸载
  60. */
  61. onUnload: function () {
  62. },
  63. /**
  64. * 页面相关事件处理函数--监听用户下拉动作
  65. */
  66. onPullDownRefresh: function () {
  67. },
  68. /**
  69. * 页面上拉触底事件的处理函数
  70. */
  71. onReachBottom: function () {
  72. if (this.data.totalPages > this.data.page) {
  73. this.setData({
  74. page: this.data.page + 1
  75. });
  76. this.getServantList();
  77. } else {
  78. wx.showToast({
  79. title: '没有更多了',
  80. icon: 'none',
  81. duration: 2000
  82. });
  83. return false;
  84. }
  85. },
  86. getServantList: function () {
  87. // this.setData({
  88. // servantList:this.data.servantList.concat(this.data.servantList),});
  89. util.request(api.getServantList, {
  90. page: this.data.page,
  91. limit: this.data.limit,
  92. shopId:this.data.addressInfo.shopId
  93. })
  94. .then(res=>{
  95. console.info(res);
  96. if (this.data.page == 1) {
  97. this.setData({
  98. servantList: res.data.dataList,
  99. totalPages: res.data.pages
  100. });
  101. } else{
  102. this.setData({
  103. servantList:this.data.servantList.concat(res.data.dataList),
  104. totalPages: res.data.pages
  105. });
  106. }
  107. });
  108. },
  109. /**
  110. * 用户点击右上角分享
  111. */
  112. onShareAppMessage: function () {
  113. }
  114. })