index.js 2.9 KB

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