当前位置:   article > 正文

微信小程序——上拉、下拉实现_微信小程序上拉菜单

微信小程序上拉菜单

下拉

1. json配置 下拉操作

  1. {
  2. "enablePullDownRefresh": true
  3. }

2. 下拉代码 onPullDownRefresh

  1. async onPullDownRefresh() {
  2. //在当前页面显示导航条加载动画
  3. wx.showNavigationBarLoading();
  4. //显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
  5. wx.showLoading({
  6. title: '刷新中...',
  7. })
  8. await this.onLoad()
  9. //隐藏loading 提示框
  10. wx.hideLoading();
  11. //隐藏导航条加载动画
  12. wx.hideNavigationBarLoading();
  13. //停止下拉刷新
  14. wx.stopPullDownRefresh();
  15. },

上拉 

主要是分页操作

  1. data: {
  2. filesArr: [],
  3. pageSize: 10,
  4. currentPage: 1,
  5. total_count: 0,
  6. },
  7. //底部加载
  8. async onReachBottom() {
  9. //console.log("触底上滑")
  10. if (this.data.currentPage * this.data.pageSize >= this.data.total_count) {
  11. asyncWx.showToast({
  12. title: "已经到底了!!!"
  13. })
  14. } else {
  15. this.setData({
  16. currentPage: this.data.currentPage + 1
  17. })
  18. await this.getFilesHis()
  19. }
  20. },
  21. async getFilesHis() {
  22. if (!userInfo.uNo || this.data.total_count <= 0) {
  23. return
  24. }
  25. wx.showLoading({
  26. title: '加载中...',
  27. mask: true
  28. })
  29. res = await asyncWx.request({
  30. url: appInstance.globalData.host + "/loadFilesRecord",
  31. header: {
  32. 'content-type': 'application/json' // 默认值
  33. },
  34. method: 'POST',
  35. data: {
  36. uNo: userInfo.uNo,
  37. sPage: this.data.currentPage,
  38. pageCount: this.data.pageSize
  39. },
  40. })
  41. console.log("历史文件记录", res)
  42. res = res.data.recordset
  43. this.setData({
  44. filesArr: this.data.filesArr.concat(res)
  45. })
  46. wx.hideLoading({
  47. success: (res) => {},
  48. })
  49. return
  50. },

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/725952
推荐阅读
相关标签
  

闽ICP备14008679号