index.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. const app = getApp()
  2. Page({
  3. data: {
  4. frameStyle: { useTop: true, name: '俱乐部', leftArrow: false, useBar: true },
  5. src: '/image/club.png',
  6. list: [
  7. { name: '宝藏俱乐部', founder: '宝藏', add: '长春市朝阳区前进大街1244号', project: '羽毛球', time: '2000-02-01', tel: '0431-800-800-8800' },
  8. { name: '英语俱乐部', founder: '英语', time: '2000-02-01', add: '长春市朝阳区前进大街1244号', project: '羽毛球', tel: '0431-800-800-8800' },
  9. { name: '宝藏俱乐部', founder: '宝藏', add: '长春市朝阳区前进大街1244号', project: '羽毛球', time: '2000-02-01', tel: '0431-800-800-8800' },
  10. { name: '英语俱乐部', founder: '英语', time: '2000-02-01', add: '长春市朝阳区前进大街1244号', project: '羽毛球', tel: '0431-800-800-8800' },
  11. ],
  12. total: 0,
  13. page: 0,
  14. skip: 0,
  15. limit: 5,
  16. },
  17. // 跳转菜单
  18. tabPath(e) {
  19. let { route } = e.detail.detail;
  20. if (route) wx.redirectTo({ url: `/${route}` })
  21. },
  22. // 分页
  23. toPage: function () {
  24. const that = this;
  25. let list = that.data.list;
  26. let limit = that.data.limit;
  27. if (that.data.total > list.length) {
  28. wx.showLoading({ title: '加载中', mask: true })
  29. let page = that.data.page + 1;
  30. that.setData({ page: page })
  31. let skip = page * limit;
  32. that.setData({ skip: skip })
  33. that.watchLogin();
  34. wx.hideLoading()
  35. } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
  36. },
  37. /**
  38. * 生命周期函数--监听页面加载
  39. */
  40. onLoad: function (options) { },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady: function () { },
  45. /**
  46. * 生命周期函数--监听页面显示
  47. */
  48. onShow: function () {
  49. const that = this;
  50. // 监听用户是否登录
  51. that.watchLogin();
  52. },
  53. // 监听用户是否登录
  54. watchLogin: async function () {
  55. const that = this;
  56. wx.getStorage({
  57. key: 'user',
  58. success: async res => { },
  59. fail: async res => {
  60. // wx.redirectTo({ url: '/pages/index/index' })
  61. }
  62. })
  63. },
  64. /**
  65. * 页面上拉触底事件的处理函数
  66. */
  67. /**
  68. * 生命周期函数--监听页面隐藏
  69. */
  70. onHide: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面卸载
  74. */
  75. onUnload: function () {
  76. },
  77. /**
  78. * 页面相关事件处理函数--监听用户下拉动作
  79. */
  80. onPullDownRefresh: function () {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage: function () {
  86. }
  87. })