index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // pages/search/index.js
  2. import utils from "../../utils/util";
  3. import {queryAllspace} from "../../requests/api";
  4. import Toast from '../../vant-weapp/dist/toast/toast';
  5. import $ from './../../utils/Tool'
  6. import router from './../../utils/router'
  7. const app = getApp();
  8. Page({
  9. data: {
  10. alllistContent:[],
  11. projectId:"",
  12. tenantId:"",
  13. userId:"",
  14. currtPage:0,
  15. allListnum:0,
  16. seachValue:'',
  17. imgShow:false,
  18. noSpace:false,
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. let projectId = $.store.get('projectId') ||$.storage.get('projectId');
  25. let tenantId = $.store.get('tenantId')||$.storage.get('tenantId');
  26. let userId = $.store.get('userId') || $.storage.get('userId');
  27. this.setData({
  28. currtPage:0,
  29. projectId:projectId,
  30. tenantId:tenantId,
  31. userId:userId,
  32. })
  33. this.getallList();
  34. },
  35. onShow(){
  36. // this.setData({currtPage:1});
  37. },
  38. getallList(value){
  39. this.setData({currtPage:this.data.currtPage + 1},async ()=>{
  40. let data={
  41. "criteria": {
  42. "userId":this.data.userId,
  43. "projectId": this.data.projectId,
  44. "tenantId": this.data.tenantId
  45. },
  46. page:this.data.currtPage,
  47. size:15,
  48. orders:[
  49. {
  50. column:"localName",
  51. asc:"true"
  52. }
  53. ]
  54. }
  55. if(this.data.seachValue){
  56. data.criteria.localName={$like: `%${this.data.seachValue}%`}
  57. }
  58. wx.showLoading({
  59. title:"加载中",
  60. mask:true
  61. })
  62. // $.loading();
  63. let res =await queryAllspace(data);
  64. // $.hideLoading();
  65. wx.hideLoading();
  66. this.setData({allListnum:res.count});
  67. if(res.count&&res.content){
  68. res.content.map(item=>{
  69. item.picInit=utils.picInit(item.roomFuncType);
  70. if(typeof item.isPassengerPass==="undefined"){
  71. item.isPassengerPassShow=false;
  72. }else{
  73. item.isPassengerPassShow=true;
  74. item.isPassengerPass=item.isPassengerPass?'有人':'无人'
  75. }
  76. })
  77. this.setData({alllistContent:this.data.alllistContent.concat(res.content)});
  78. }else{
  79. Toast('暂无更多')
  80. }
  81. })
  82. },
  83. // 搜索
  84. spaceSearch(e){
  85. this.setData({seachValue:e.detail,currtPage:0,alllistContent:[]},()=>{
  86. this.getallList(e.detail);
  87. });
  88. },
  89. listClick(e){
  90. let data = e.detail.cardDate;
  91. data.outLine&&(data.outLine="");
  92. router.push("adjust",data);
  93. },
  94. /**
  95. * 页面上拉触底事件的处理函数
  96. */
  97. onReachBottom: function () {
  98. if(this.data.allListnum!=this.data.alllistContent.length){
  99. // this.setData({currtPage:this.data.currtPage+1})
  100. this.getallList();
  101. }else{
  102. Toast('暂无更多')
  103. }
  104. },
  105. })