From eb008c80b55193240b28ee9faf3914b94296d04e Mon Sep 17 00:00:00 2001 From: Chad Wuo Date: Sat, 10 Feb 2024 22:46:42 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/pages/book/details/index.js | 23 ++++++----------- miniprogram/pages/friend/index.js | 2 +- miniprogram/pages/giftOut/index.js | 33 ++++++++++++++----------- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/miniprogram/pages/book/details/index.js b/miniprogram/pages/book/details/index.js index ca111ebf..d50f6574 100644 --- a/miniprogram/pages/book/details/index.js +++ b/miniprogram/pages/book/details/index.js @@ -10,15 +10,7 @@ Page({ }, onSearch(e) { const searchVal = e.detail - if (!searchVal) { - this.loadData(1); - return; - } - this.setData({ - giftList: this.data.giftList.filter((i) => - i.friendInfo.name.includes(searchVal) - ), - }); + this.loadData(1, searchVal); }, onAddGift() { let that = this; @@ -80,10 +72,11 @@ Page({ }, }); }, - async loadData(page) { + async loadData(page, keyword) { const res = await giftReceiveService.getGiftReceivePage({ bookId: this.data.book._id, page, + keyword }); if (res.success) { this.setData({ @@ -110,27 +103,27 @@ Page({ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady: function () {}, + onReady: function () { }, /** * 生命周期函数--监听页面显示 */ - onShow: function () {}, + onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ - onHide: function () {}, + onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ - onUnload: function () {}, + onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ - async onPullDownRefresh() {}, + async onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 diff --git a/miniprogram/pages/friend/index.js b/miniprogram/pages/friend/index.js index de8e73a6..867271dc 100644 --- a/miniprogram/pages/friend/index.js +++ b/miniprogram/pages/friend/index.js @@ -1,7 +1,7 @@ // pages/friend/index.js const friendService = require("@/alicloud/services/friend"); const app = getApp(); -const app = getApp(); + Page({ /** * 页面的初始数据 diff --git a/miniprogram/pages/giftOut/index.js b/miniprogram/pages/giftOut/index.js index f756cd5f..c3eaefdb 100644 --- a/miniprogram/pages/giftOut/index.js +++ b/miniprogram/pages/giftOut/index.js @@ -1,7 +1,6 @@ // pages/giftOut/index.js const giftOutService = require('@/alicloud/services/giftOut'); const app = getApp(); -const app = getApp(); Page({ /** * 页面的初始数据 @@ -24,15 +23,18 @@ Page({ }, onSearch(e) { const searchVal = e.detail - if (!searchVal) { - this.loadData(1); - return; - } - this.setData({ - giftList: this.data.giftList.filter((i) => - i.friendInfo.name.includes(searchVal) - ), - }); + + this.loadData(1, searchVal); + + // if (!searchVal) { + // this.loadData(1); + // return; + // } + // this.setData({ + // giftList: this.data.giftList.filter((i) => + // i.friendInfo.name.includes(searchVal) + // ), + // }); }, onGiftClick(e) { wx.navigateTo({ @@ -61,9 +63,10 @@ Page({ }, }); }, - async loadData(page) { + async loadData(page, keyword) { const res = await giftOutService.getGiftOutPage({ page, + keyword }); if (res.success) { this.setData({ @@ -81,7 +84,7 @@ Page({ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady: function () {}, + onReady: function () { }, /** * 生命周期函数--监听页面显示 @@ -95,17 +98,17 @@ Page({ /** * 生命周期函数--监听页面隐藏 */ - onHide: function () {}, + onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ - onUnload: function () {}, + onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ - onPullDownRefresh: function () {}, + onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数