ranking.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // compontents/ranking/ranking.js
  2. const util = require('../../utils/util.js');
  3. const APIClient = require('../../utils/APIClient.js');
  4. const login = require('../../utils/loginSchedule.js');
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. * friendsData除了前三名的数据
  9. * friendsThreeData前三名的数据
  10. * myData总的数据
  11. * str 传过来的排名
  12. * title 头部标题
  13. * height是否显示展开
  14. */
  15. properties: {
  16. friendsData: {
  17. type: Array,
  18. value: []
  19. },
  20. friendsThreeData: {
  21. type: Array,
  22. value: []
  23. },
  24. myData: {
  25. type: Object,
  26. value: {}
  27. },
  28. str: {
  29. type: String,
  30. value: ''
  31. },
  32. title: {
  33. type: String,
  34. value: ''
  35. },
  36. height: {
  37. type: String,
  38. value: ''
  39. }
  40. },
  41. /**
  42. * 组件的初始数据
  43. */
  44. data: {
  45. animationData: {},
  46. rankData: {},
  47. indexs: 0,
  48. flag: true
  49. },
  50. /**
  51. * 组件的方法列表
  52. */
  53. methods: {
  54. /*展开更多*/
  55. more (e) {
  56. let height = this.properties.friendsData.length * 79.9;
  57. this.util(height+'rpx')
  58. this.setData({
  59. flag: false
  60. })
  61. },
  62. /* 创建动画并执行 */
  63. util (height) {
  64. // 创建动画实例
  65. var animation = wx.createAnimation({
  66. duration: 200, //动画时长
  67. timingFunction: "linear", //线性
  68. delay: 0 //0则不延迟
  69. });
  70. this.animation = animation;
  71. animation.height(height).step();
  72. this.setData({
  73. animationData: animation.export()
  74. })
  75. },
  76. },
  77. ready: function () {
  78. let options = util.getUrl();
  79. console.log(options)
  80. this.setData({
  81. indexs: options.ind
  82. })
  83. //获取排名
  84. login.getOpenidSessionKey(res => {
  85. //获取排名
  86. APIClient.getFriendSchedule('wx/friendsRank/user', {
  87. uid: res.data.data.uid
  88. }).success(res => {
  89. console.log(res)
  90. this.setData({
  91. rankData: res.data.data,
  92. })
  93. })
  94. }, () => {
  95. });
  96. }
  97. })