index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. })
  71. this.setData({alllistContent:this.data.alllistContent.concat(res.content)});
  72. }else{
  73. Toast('暂无更多')
  74. }
  75. })
  76. },
  77. // 搜索
  78. spaceSearch(e){
  79. this.setData({seachValue:e.detail,currtPage:0,alllistContent:[]},()=>{
  80. this.getallList(e.detail);
  81. });
  82. },
  83. listClick(e){
  84. let data = e.detail.cardDate;
  85. data.outLine&&(data.outLine="");
  86. router.push("adjust",data);
  87. },
  88. /**
  89. * 页面上拉触底事件的处理函数
  90. */
  91. onReachBottom: function () {
  92. if(this.data.allListnum!=this.data.alllistContent.length){
  93. // this.setData({currtPage:this.data.currtPage+1})
  94. this.getallList();
  95. }else{
  96. Toast('暂无更多')
  97. }
  98. },
  99. })