Skip to content

Commit

Permalink
🐞 fix: 搜索功能优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Chadwuo committed Feb 10, 2024
1 parent 3f9ded3 commit eb008c8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 31 deletions.
23 changes: 8 additions & 15 deletions miniprogram/pages/book/details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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({
Expand All @@ -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() { },

/**
* 页面上拉触底事件的处理函数
Expand Down
2 changes: 1 addition & 1 deletion miniprogram/pages/friend/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// pages/friend/index.js
const friendService = require("@/alicloud/services/friend");
const app = getApp();
const app = getApp();

Page({
/**
* 页面的初始数据
Expand Down
33 changes: 18 additions & 15 deletions miniprogram/pages/giftOut/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// pages/giftOut/index.js
const giftOutService = require('@/alicloud/services/giftOut');
const app = getApp();
const app = getApp();
Page({
/**
* 页面的初始数据
Expand All @@ -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({
Expand Down Expand Up @@ -61,9 +63,10 @@ Page({
},
});
},
async loadData(page) {
async loadData(page, keyword) {
const res = await giftOutService.getGiftOutPage({
page,
keyword
});
if (res.success) {
this.setData({
Expand All @@ -81,7 +84,7 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
onReady: function () { },

/**
* 生命周期函数--监听页面显示
Expand All @@ -95,17 +98,17 @@ Page({
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
onHide: function () { },

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
onUnload: function () { },

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
onPullDownRefresh: function () { },

/**
* 页面上拉触底事件的处理函数
Expand Down

0 comments on commit eb008c8

Please sign in to comment.