Explorar o código

fix 搜索界面

anxiaoxia %!s(int64=3) %!d(string=hai) anos
pai
achega
d369bae984
Modificáronse 2 ficheiros con 116 adicións e 103 borrados
  1. 1 1
      pages/projectlist/index.wxml
  2. 115 102
      pages/spacelist/index.js

+ 1 - 1
pages/projectlist/index.wxml

@@ -2,7 +2,7 @@
   <block wx:for="{{projectList}}" wx:key="{{index}}">
     <view class="proname">{{item.projectName}}</view>
     <block wx:for="{{item.children}}" wx:for-item="items"  wx:key="{{items.tenantId}}">
-      <view class="children children{{items.tenantId===tenantId?'active':''}}" data-index="{{items}}"  bindtap="chooseTenant">{{items.tenantName}}</view>
+      <view wx:if="{{items.tenantName}}" class="children children{{items.tenantId===tenantId?'active':''}}" data-index="{{items}}"  bindtap="chooseTenant">{{items.tenantName}}</view>
     </block>
   </block>
 </view>

+ 115 - 102
pages/spacelist/index.js

@@ -1,108 +1,121 @@
 // 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'
+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,
-  },
+    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');
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    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);
-          if(typeof item.isPassengerPass==="undefined"){
-            item.isPassengerPassShow=false;
-          }else{
-            item.isPassengerPassShow=true;
-            item.isPassengerPass=item.isPassengerPass?'有人':'无人'
-          }
-        })
-        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('暂无更多')
-    }
-  },
-})
+        this.setData({
+            currtPage: 0,
+            projectId: projectId,
+            tenantId: tenantId,
+            userId: userId,
+        });
+        this.getallList();
+    },
+    onShow() {
+        if (this.data.seachValue) { // 搜索条件下
+            this.spaceSearch();
+        }
+    },
+    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);
+                    if (typeof item.isPassengerPass === "undefined") {
+                        item.isPassengerPassShow = false;
+                    } else {
+                        item.isPassengerPassShow = true;
+                        item.isPassengerPass = item.isPassengerPass
+                            ? "有人"
+                            : "无人";
+                    }
+                });
+                this.setData({
+                    alllistContent: this.data.alllistContent.concat(
+                        res.content
+                    ),
+                });
+            } else {
+                Toast("暂无更多");
+            }
+        });
+    },
+    // 搜索
+    spaceSearch(e) {
+        let val = e ? e.detail : this.data.seachValue;
+        this.setData(
+            { seachValue: val, currtPage: 0, alllistContent: [] },
+            () => {
+                this.getallList(val);
+            }
+        );
+    },
+    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("暂无更多");
+        }
+    },
+});