1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- // pages/search/index.js
- import utils from "../../utils/util";
- import {queryAllspace} from "../../requests/api";
- import Toast from '../../vant-weapp/dist/toast/toast';
- import $ from './../../utils/Tool'
- import router from './../../utils/router'
- const app = getApp();
- Page({
- data: {
- alllistContent:[],
- projectId:"",
- tenantId:"",
- userId:"",
- currtPage:0,
- allListnum:0,
- seachValue:'',
- imgShow:false,
- noSpace:false,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- currtPage:0,
- projectId:$.store.get('projectId'),
- tenantId:$.store.get('tenantId'),
- userId:$.store.get('userId'),
- })
- this.getallList();
- },
- onShow(){
- // this.setData({currtPage:1});
- },
- getallList(value){
- this.setData({currtPage:this.data.currtPage + 1},async ()=>{
- let data={
- "criteria": {
- "userId":this.data.userId,
- "projectId": this.data.projectId,
- "tenantId": this.data.tenantId
- },
- page:this.data.currtPage,
- size:15,
- orders:[
- {
- column:"localName",
- asc:"true"
- }
- ]
- }
- if(this.data.seachValue){
- data.criteria.localName={$like: `%${this.data.seachValue}%`}
- }
- wx.showLoading({
- title:"加载中",
- mask:true
- })
- // $.loading();
- let res =await queryAllspace(data);
- // $.hideLoading();
- wx.hideLoading();
- this.setData({allListnum:res.count});
- if(res.count&&res.content){
- res.content.map(item=>{
- item.picInit=utils.picInit(item.roomFuncType);
- })
- this.setData({alllistContent:this.data.alllistContent.concat(res.content)});
- }else{
- Toast('暂无更多')
- }
- })
- },
- // 搜索
- spaceSearch(e){
- this.setData({seachValue:e.detail,currtPage:0,alllistContent:[]},()=>{
- this.getallList(e.detail);
- });
- },
- listClick(e){
- let data = e.detail.cardDate;
- data.outLine&&(data.outLine="");
- router.push("adjust",data);
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- if(this.data.allListnum!=this.data.alllistContent.length){
- // this.setData({currtPage:this.data.currtPage+1})
- this.getallList();
- }else{
- Toast('暂无更多')
- }
- },
- })
|