ranking.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. var app = getApp();
  2. var status = require('../../utils/index.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. type: 1, // 1:今日,2:昨日,3:上周,4:上月
  9. list: []
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. let that = this;
  16. status.setGroupInfo().then((groupInfo) => {
  17. let owner_name = groupInfo && groupInfo.owner_name || '团长';
  18. wx.setNavigationBarTitle({
  19. title: `${owner_name}排行`,
  20. })
  21. that.setData({ groupInfo })
  22. });
  23. },
  24. /**
  25. * 生命周期函数--监听页面显示
  26. */
  27. onShow: function () {
  28. this.getData();
  29. },
  30. getData: function () {
  31. let token = wx.getStorageSync('token');
  32. wx.showLoading();
  33. app.util.ProReq('community.community_ranking_list', { token, type: this.data.type }).then(res => {
  34. wx.hideLoading();
  35. if(res.is_show_community_ranking!=1) {
  36. return app.util.message('访问页面不存在或已关闭', 'redirect:/lionfish_comshop/moduleA/groupCenter/index', 'error');
  37. }
  38. this.setData({
  39. list: res.data
  40. })
  41. })
  42. },
  43. changeType: function(e) {
  44. let type = e.currentTarget.dataset.type || 1;
  45. this.setData({
  46. type
  47. }, ()=>{
  48. this.getData();
  49. })
  50. },
  51. /**
  52. * 页面相关事件处理函数--监听用户下拉动作
  53. */
  54. onPullDownRefresh: function () {
  55. }
  56. })