index.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. this.setData({
  25. currtPage:0,
  26. projectId:$.store.get('projectId'),
  27. tenantId:$.store.get('tenantId'),
  28. userId:$.store.get('userId'),
  29. })
  30. this.getallList();
  31. },
  32. onShow(){
  33. // this.setData({currtPage:1});
  34. },
  35. getallList(value){
  36. this.setData({currtPage:this.data.currtPage + 1},async ()=>{
  37. let data={
  38. "criteria": {
  39. "userId":this.data.userId,
  40. "projectId": this.data.projectId,
  41. "tenantId": this.data.tenantId
  42. },
  43. page:this.data.currtPage,
  44. size:15,
  45. orders:[
  46. {
  47. column:"localName",
  48. asc:"true"
  49. }
  50. ]
  51. }
  52. if(this.data.seachValue){
  53. data.criteria.localName={$like: `%${this.data.seachValue}%`}
  54. }
  55. wx.showLoading({
  56. title:"加载中",
  57. mask:true
  58. })
  59. // $.loading();
  60. let res =await queryAllspace(data);
  61. // $.hideLoading();
  62. wx.hideLoading();
  63. this.setData({allListnum:res.count});
  64. if(res.count&&res.content){
  65. res.content.map(item=>{
  66. item.picInit=utils.picInit(item.roomFuncType);
  67. })
  68. this.setData({alllistContent:this.data.alllistContent.concat(res.content)});
  69. }else{
  70. Toast('暂无更多')
  71. }
  72. })
  73. },
  74. // 搜索
  75. spaceSearch(e){
  76. this.setData({seachValue:e.detail,currtPage:0,alllistContent:[]},()=>{
  77. this.getallList(e.detail);
  78. });
  79. },
  80. listClick(e){
  81. let data = e.detail.cardDate;
  82. data.outLine&&(data.outLine="");
  83. router.push("adjust",data);
  84. },
  85. /**
  86. * 页面上拉触底事件的处理函数
  87. */
  88. onReachBottom: function () {
  89. if(this.data.allListnum!=this.data.alllistContent.length){
  90. // this.setData({currtPage:this.data.currtPage+1})
  91. this.getallList();
  92. }else{
  93. Toast('暂无更多')
  94. }
  95. },
  96. })