123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- // 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) {
- let projectId = $.store.get('projectId') ||$.storage.get('projectId');
- let tenantId = $.store.get('tenantId')||$.storage.get('tenantId');
- let userId = $.store.get('userId') || $.storage.get('userId');
-
- this.setData({
- currtPage:0,
- projectId:projectId,
- tenantId:tenantId,
- userId: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('暂无更多')
- }
- },
- })
|