From 6ead2fce4447cf95bc2ddc450331430a1c0256aa Mon Sep 17 00:00:00 2001 From: A1300399510 Date: Wed, 10 May 2023 01:50:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.js | 51 ++++----- pages/index/index.json | 5 +- pages/index/index.wxml | 240 ++++++++++++++++++++--------------------- pages/index/index.wxss | 6 +- 4 files changed, 150 insertions(+), 152 deletions(-) diff --git a/pages/index/index.js b/pages/index/index.js index 65187cb..8c0f88b 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -35,6 +35,7 @@ Page({ getLocationList: [], // 地区选项 配置数据 listData: [], // 列表数据 + listPage: 1, // 列表数据 页数 listDataLeft: [], // 列表数据 listDataRight: [], // 列表数据 }, @@ -398,16 +399,20 @@ Page({ // 获取列表数据 getListData() { miucms.wxget(app.globalData.baseURL + "/tenement/v2/api/home/recommendList", { - page: 1 + page: this.data.listPage, + limit: 10 }).then(res => { if (res.code != 200) return let data = res.data.data + let listData = this.data.listData + listData.push(...data) this.setData({ + listPage: this.data.listPage + 1, listData: data }) - this.query = wx.createSelectorQuery(); + this.listDataIndex = 0 this.calculateProcessingCenter() }) }, @@ -416,38 +421,26 @@ Page({ leftHeight: 0, // px 单位 rightHeight: 0, ratio: 0, - query: null, + // 计算 calculateProcessingCenter() { - if (this.listDataIndex >= this.data.listData.length) { - - this.setData({ - listDataLeft: this.data.listDataLeft, - listDataRight: this.data.listDataRight - }) - return - } - - let ratio = this.ratio - if (this.ratio) this.ratio = this.data.screen_data['windowWidth'] / 750 let targetData = this.data.listData[this.listDataIndex] + if (!targetData) return let type = targetData['type'] if (type == 'adv') { this.getPictureHeight(targetData.image).then(res => { this.whichSide(res, targetData) + return }) } else { let altitude = 0 // rpx - if (type == 'apartment') { altitude = 105 if (targetData['specifications'].length > 2) altitude += 100 else altitude += 64 * targetData['specifications'].length - } else { - altitude = 141 - } + } else altitude = 141 altitude = altitude * ratio // 转 px @@ -459,21 +452,22 @@ Page({ altitude += res let select = type == 'apartment' ? '#apartment' : '#general' - this.query.select(select).boundingClientRect(rect => { + let query = wx.createSelectorQuery(); + query.select(select).boundingClientRect(rect => { let height = rect.height; altitude += height this.whichSide(altitude, targetData) + return }).exec(); }) } - console.log(this.data.listDataLeft, this.data.listDataRight); }, // 判断在哪边的 whichSide(res, targetData) { - console.log(this.leftHeight <= this.rightHeight, this.leftHeight, this.rightHeight); + console.log(this.leftHeight, this.rightHeight, this.leftHeight <= this.rightHeight); if (this.leftHeight <= this.rightHeight) { this.leftHeight = this.leftHeight + res this.data.listDataLeft.push(targetData) @@ -483,10 +477,14 @@ Page({ } this.setData({ - targetData: null + listDataLeft: this.data.listDataLeft, + listDataRight: this.data.listDataRight }) - this.listDataIndex++ - this.calculateProcessingCenter() + + if (this.data.listData[this.listDataIndex]) { + this.listDataIndex++ + this.calculateProcessingCenter() + } }, // 获取图片高度 @@ -504,6 +502,9 @@ Page({ } }) }) - } + }, + onReachBottom() { + this.getListData() + }, }) \ No newline at end of file diff --git a/pages/index/index.json b/pages/index/index.json index a79a9ad..cd8242a 100644 --- a/pages/index/index.json +++ b/pages/index/index.json @@ -10,9 +10,6 @@ "card-person": "./cardPerson/cardPerson", "card-brands": "./cardBrands/cardBrands", "fix-footer": "../../template/fixFooter/fixFooter", - "announcement-popup": "../../template/announcementPopup/announcementPopup", - "me-waterfall": "/lib/waterfall/index", - "me-waterfall-item": "/lib/waterfall-item/index" - + "announcement-popup": "../../template/announcementPopup/announcementPopup" } } \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index be81788..630ac78 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -1,18 +1,16 @@ - - + + + {{ targetData['title'] }} + {{ targetData['propaganda'] }} + + {{ targetData['title'] }} - - {{ targetData['title'] }} - {{ targetData['propaganda'] }} - - {{ targetData['title'] }} - {{ topTitle }} - + @@ -93,7 +91,7 @@ - + @@ -185,126 +183,128 @@ - - - - 个人房源 - - more - - - - - - - - - - - - - - - - - - - + + + + + 个人房源 + + more + + + + + + + + + + + + + + + + + + + + + - - - - - - - - 查看更多 - - - - - - - - - - - - - 品牌公寓 - - more - - - - - - - + - + + + + 查看更多 + + - - - - - - - 查看更多 - - - - - - - - + + + + - - - - - 求房源 - - more - - - - - - - - - - + + + + 品牌公寓 + + more + + + + + + + - - - - - - - + - - - - - - - - 查看更多 - + + + - - - - - - + + 查看更多 + + + + + + + + + + + + + + 求房源 + + more + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 查看更多 + + + + + + + + + diff --git a/pages/index/index.wxss b/pages/index/index.wxss index cd4a0cb..244fdd6 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -954,20 +954,20 @@ .apartment1-name { font-size: 27rpx; - color: #000000; + color: transparent; font-weight: 650; padding: 13.5rpx 15rpx; } .apartment1-introduce { - color: #aaaaaa; + color: transparent; font-size: 21rpx; padding: 0 15rpx; } .general-name1 { font-size: 27rpx; - color: #000000; + color: transparent; line-height: 48rpx; padding: 0 15rpx; display: -webkit-box;