From 230c0da617bed5093b3b2832d9b53962bb5c6781 Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期五, 22 三月 2024 10:46:39 +0800 Subject: [PATCH] 上拉刷新下拉加载 --- pages/cart/index.json | 9 + pages/cart/index.js | 50 ++++++++- pages/bibliographyList/index.wxml | 14 ++ pages/retrievalPage/index.json | 3 pages/bibliographyList/index.wxss | 9 + pages/bibliographyList/index.json | 9 + pages/retrievalPage/index.js | 26 ++++- pages/bibliographyList/index.js | 121 ++++++++++++++++++++++-- pages/cart/index.wxss | 9 + pages/cart/index.wxml | 5 10 files changed, 225 insertions(+), 30 deletions(-) diff --git a/pages/bibliographyList/index.js b/pages/bibliographyList/index.js index 4c3cd21..0a4cd71 100644 --- a/pages/bibliographyList/index.js +++ b/pages/bibliographyList/index.js @@ -7,6 +7,7 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { + isMore: null, higherList: [], vocationalList: [], teacherList: [], @@ -16,7 +17,8 @@ value: '', BarHeight: '', navBarHeight: '', - + start: 1, + tabValue: '' }, /** @@ -35,7 +37,12 @@ barHeight: systInfo.statusBarHeight, }) + let event = + { + detail: { value: "0" } + } + this.onTabsChange(event) @@ -92,12 +99,28 @@ }, onTabsChange(event) { - console.log(`Change tab, tab-panel value is ${event.detail.value}.`); + + const value = event.detail.value + + if (value === '0') { + console.log(value); + this.setData({ + tabValue: value + }) + } else if (value === '1') { + console.log(value); + this.setData({ + tabValue: value + }) + } else if (value === '2') { + console.log(value); + this.setData({ + tabValue: value + }) + } }, - onTabsClick(event) { - console.log(`Click tab, tab-panel value is ${event.detail.value}.`); - }, + //楂樼瓑鏁欒偛 higherGet(keyword) { let searchObj = { @@ -112,7 +135,7 @@ queryType: '*', paging: { start: '0', - size: '999' + size: this.data.start * 9 }, coverSize: { width: 260 @@ -139,7 +162,7 @@ }) console.log(this.data.higherList, '5555'); }) - + wx.stopPullDownRefresh() }, @@ -156,7 +179,7 @@ queryType: '*', paging: { start: '0', - size: '999' + size: this.data.start * 9 }, coverSize: { width: 260 @@ -181,6 +204,7 @@ }) }) + wx.stopPullDownRefresh() }, // 鑱屼笟鏁欒偛 teacherGet(keyword) { @@ -195,7 +219,7 @@ queryType: '*', paging: { start: '0', - size: '999' + size: this.data.start * 9 }, coverSize: { width: 260 @@ -220,7 +244,7 @@ }) }) - + wx.stopPullDownRefresh() }, downloadData(event) { @@ -267,5 +291,82 @@ goBack() { wx.navigateBack(); }, + onReachBottom(e) { + if (this.data.tabValue == 0) { + console.log(0); + if (this.data.higherList.length < this.data.higherTotal) { + this.setData({ + isMore: true, + start: this.data.start + 1 + }) + this.higherGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + + } + + } else if (this.data.tabValue == 1) { + + if (this.data.teacherList.length < this.data.teacherTotal) { + this.setData({ + isMore: true, + start: this.data.start + 1 + }) + this.teacherGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + + } + console.log(2); + } else if (this.data.tabValue == 2) { + + if (this.data.vocationalList.length < this.data.vocationalTotal && this.data.vocationalList.length > 9) { + this.setData({ + isMore: true, + start: this.data.start + 1 + }) + this.vocationalGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + + } + console.log(2); + } + + + + }, + onPullDownRefresh() { + + + this.setData({ + start: 1 + }) + this.vocationalGet() + this.higherGet() + this.teacherGet() + + }, }) \ No newline at end of file diff --git a/pages/bibliographyList/index.json b/pages/bibliographyList/index.json index a9c6aab..66d8036 100644 --- a/pages/bibliographyList/index.json +++ b/pages/bibliographyList/index.json @@ -4,7 +4,12 @@ "t-tabs": "tdesign-miniprogram/tabs/tabs", "t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel", "t-search": "tdesign-miniprogram/search/search", - "t-icon": "tdesign-miniprogram/icon/icon" + "t-icon": "tdesign-miniprogram/icon/icon", + "t-loading": "tdesign-miniprogram/loading/loading", + "t-image": "tdesign-miniprogram/image/image" }, - "navigationStyle": "custom" + "navigationStyle": "custom", + "enablePullDownRefresh": true, + "onReachBottomDistance": 200, + "backgroundTextStyle": "dark" } \ No newline at end of file diff --git a/pages/bibliographyList/index.wxml b/pages/bibliographyList/index.wxml index 3b9aa81..83c7d6b 100644 --- a/pages/bibliographyList/index.wxml +++ b/pages/bibliographyList/index.wxml @@ -49,7 +49,10 @@ </view> </view> - + <view class="bottom-box"> + <t-loading theme="circular" size="40rpx" class="wrapper" wx:if="{{isMore == true}}" /> + <text wx:if="{{isMore == false}}">娌℃湁鏇村浜�</text> + </view> </t-tab-panel> <t-tab-panel label="鑱屼笟鏁欒偛({{vocationalTotal}})" value="1"> <view class="outsideHigherBox"> @@ -67,7 +70,10 @@ </view> </view> - + <view class="bottom-box"> + <t-loading theme="circular" size="40rpx" class="wrapper" wx:if="{{isMore == true}}" /> + <text wx:if="{{isMore == false}}">娌℃湁鏇村浜�</text> + </view> </t-tab-panel> <t-tab-panel label="鏁欏笀鏁欒偛({{teacherTotal}})" value="2"> @@ -86,6 +92,10 @@ </view> </view> + <view class="bottom-box"> + <t-loading theme="circular" size="40rpx" class="wrapper" wx:if="{{isMore == true}}" /> + <text wx:if="{{isMore == false}}">娌℃湁鏇村浜�</text> + </view> </t-tab-panel> </t-tabs> \ No newline at end of file diff --git a/pages/bibliographyList/index.wxss b/pages/bibliographyList/index.wxss index a6426d2..8133f8a 100644 --- a/pages/bibliographyList/index.wxss +++ b/pages/bibliographyList/index.wxss @@ -119,4 +119,13 @@ .t-tabs__track { background-color: #FF6C00 !important; +} + +.bottom-box { + display: flex; + justify-content: center; + color: #999; + height: 80rpx; + font-size: 28rpx; + --td-loading-color: #ff6c00 } \ No newline at end of file diff --git a/pages/cart/index.js b/pages/cart/index.js index 7e52034..2abc176 100644 --- a/pages/cart/index.js +++ b/pages/cart/index.js @@ -11,10 +11,14 @@ checkedList: [], selectedCount: 0, totalPrice: 0.00, - type: '' + type: '', + start: 1, + totalSize: '', + isMore: null, }, onLoad(options) { + wx.setNavigationBarTitle({ title: '璐墿杞�' }); @@ -38,16 +42,19 @@ shoppingCartGet() { let query = { start: 0, - size: 999, + size: this.data.start * 4, filterList: [], searchList: [] }; app.MG.store.getShoppingCartProductList(query).then(res => { - console.log(res, 'res'); + + this.setData({ + totalSize: res.totalSize + }) + res.datas.forEach(item => { item.imgUrl = getPublicImage(item.productMonWithLinkDto.product.icon, '', '160'); - console.log(item); - console.log(item.saleMethod.type, 'item.saleMethod.type') + this.setData({ type: item.saleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product' }) @@ -58,6 +65,7 @@ shoppingCartData: res.datas }); }); + wx.stopPullDownRefresh() }, bottomChange(e) { @@ -134,5 +142,35 @@ wx.navigateTo({ url: '/pages/testLogin/index' }); - } + }, + //瑙﹀簳鍑芥暟 + onReachBottom() { + if (this.data.shoppingCartData.length < this.data.totalSize) { + this.setData({ + isMore: true, + start: this.data.start + 1 + }) + this.shoppingCartGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + + } + }, + // 涓嬫媺鍑芥暟 + onPullDownRefresh() { + + this.setData({ + start: 1 + }) + console.log(978); + this.shoppingCartGet() + }, + }); diff --git a/pages/cart/index.json b/pages/cart/index.json index e06cfaa..5c4b437 100644 --- a/pages/cart/index.json +++ b/pages/cart/index.json @@ -6,6 +6,11 @@ "t-cell": "tdesign-miniprogram/cell/cell", "t-button": "tdesign-miniprogram/button/button", "t-toast": "tdesign-miniprogram/toast/toast", - "t-empty": "tdesign-miniprogram/empty/empty" - } + "t-empty": "tdesign-miniprogram/empty/empty", + "t-loading": "tdesign-miniprogram/loading/loading", + "t-image": "tdesign-miniprogram/image/image" + }, + "enablePullDownRefresh": true, + "onReachBottomDistance": 200, + "backgroundTextStyle": "dark" } \ No newline at end of file diff --git a/pages/cart/index.wxml b/pages/cart/index.wxml index 7642960..5e42db6 100644 --- a/pages/cart/index.wxml +++ b/pages/cart/index.wxml @@ -46,7 +46,10 @@ </view> <view slot="right" class="btn delete-btn" bind:tap="onDelete" data-item="{{item}}">鍒犻櫎</view> </t-swipe-cell> - + <view class="bottom-box"> + <t-loading theme="circular" size="40rpx" class="wrapper" wx:if="{{isMore == true}}" /> + <text wx:if="{{isMore == false}}">娌℃湁鏇村浜�</text> + </view> </view> <view class="bottomBox"> diff --git a/pages/cart/index.wxss b/pages/cart/index.wxss index 4d47114..b802a96 100644 --- a/pages/cart/index.wxss +++ b/pages/cart/index.wxss @@ -249,4 +249,13 @@ color: #333333; /* margin: 10rpx 0; */ margin-bottom: 20rpx; +} + +.bottom-box { + display: flex; + justify-content: center; + color: #999; + height: 80rpx; + font-size: 28rpx; + --td-loading-color: #ff6c00 } \ No newline at end of file diff --git a/pages/retrievalPage/index.js b/pages/retrievalPage/index.js index 9039b9a..3524d4a 100644 --- a/pages/retrievalPage/index.js +++ b/pages/retrievalPage/index.js @@ -41,7 +41,6 @@ const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� this.setData({ - navBarHeight: navBarHeight, barHeight: systInfo.statusBarHeight, searchVal: options.searchVal @@ -492,7 +491,7 @@ }) - + wx.stopPullDownRefresh() }, bibliographyGet() { let bibliographyObj = {} @@ -533,6 +532,7 @@ }) }) + wx.stopPullDownRefresh() }, downloadData(event) { console.log(111); @@ -585,10 +585,7 @@ url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟 }); }, - //瑙﹀簳鍑芥暟 - onReachBottom() { - console.log("涓婃媺鍔犺浇...."); - }, + //涓婃媺鍑芥暟 onPullDownRefresh() { console.log("涓嬫媺鍒锋柊..."); @@ -717,5 +714,22 @@ }, + // 涓嬫媺鍑芥暟 + onPullDownRefresh() { + if (this.data.tabValue == 4) { + this.setData({ + "pageCount.page": 1 + }) + this.bibliographyGet() + } else { + this.setData({ + "pageCount.page": 1 + }) + this.retrievalPageGet() + } + + + + }, }) \ No newline at end of file diff --git a/pages/retrievalPage/index.json b/pages/retrievalPage/index.json index e01e033..a348276 100644 --- a/pages/retrievalPage/index.json +++ b/pages/retrievalPage/index.json @@ -12,5 +12,6 @@ }, "navigationStyle": "custom", "enablePullDownRefresh": true, - "onReachBottomDistance": 200 + "onReachBottomDistance": 200, + "backgroundTextStyle": "dark" } \ No newline at end of file -- Gitblit v1.9.1