competition.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // pages/competition/competition.js
  2. const app = getApp()
  3. const util = require('../../utils/util.js');
  4. const APIClient = require('../../utils/APIClient.js');
  5. const login = require('../../utils/loginSchedule.js');
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. friendsData: {},
  12. friendsThreeData: {},
  13. myData: {},
  14. height: ''
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. wx.setNavigationBarTitle({
  21. title: '好友比一比'
  22. });
  23. wx.showShareMenu({
  24. withShareTicket: true
  25. })
  26. },
  27. /**
  28. * 生命周期函数--监听页面初次渲染完成
  29. */
  30. onReady: function () {
  31. },
  32. /**
  33. * 生命周期函数--监听页面显示
  34. */
  35. onShow: function () {
  36. //登录页信息
  37. login.getOpenidSessionKey(res => {
  38. APIClient.getFriendSchedule('wx/friendsRank/friends', {
  39. uid: res.data.data.uid
  40. }).success(res => {
  41. console.log(res)
  42. this.setData({
  43. friendsThreeData: util.topThree(res.data.data.friendsRankVoList),
  44. friendsData: res.data.data.friendsRankVoList.slice(3,),
  45. myData: res.data.data
  46. })
  47. const length = this.data.friendsData.length;
  48. if(length > 7){
  49. this.setData({
  50. height: 560
  51. })
  52. }
  53. })
  54. }, function() {
  55. wx.showModal({
  56. title: '提示',
  57. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除勋章战士后再次扫码进入,允许授权后可正常使用',
  58. showCancel: false,
  59. success: function (res) {
  60. if (res.confirm) {
  61. console.log('用户点击确定')
  62. } else if (res.cancel) {
  63. console.log('用户点击取消')
  64. }
  65. }
  66. })
  67. });
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面卸载
  76. */
  77. onUnload: function () {
  78. },
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh: function () {
  83. },
  84. /**
  85. * 页面上拉触底事件的处理函数
  86. */
  87. onReachBottom: function () {
  88. },
  89. /**
  90. * 用户点击右上角分享
  91. */
  92. onShareAppMessage: function () {
  93. }
  94. })