ranking.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. },
  49. /**
  50. * 组件的方法列表
  51. */
  52. methods: {
  53. /*展开更多*/
  54. more (e) {
  55. let height = this.properties.friendsData.length * 80.3;
  56. this.util(height+'rpx')
  57. },
  58. /* 创建动画并执行 */
  59. util (height) {
  60. // 创建动画实例
  61. var animation = wx.createAnimation({
  62. duration: 200, //动画时长
  63. timingFunction: "linear", //线性
  64. delay: 0 //0则不延迟
  65. });
  66. this.animation = animation;
  67. animation.height(height).step();
  68. this.setData({
  69. animationData: animation.export()
  70. })
  71. },
  72. },
  73. ready: function () {
  74. let options = util.getUrl();
  75. console.log(options)
  76. this.setData({
  77. indexs: options.ind
  78. })
  79. //获取排名
  80. login.getOpenidSessionKey(res => {
  81. //获取排名
  82. APIClient.getFriendSchedule('wx/friendsRank/user', {
  83. uid: res.data.data.uid
  84. }).success(res => {
  85. console.log(res)
  86. this.setData({
  87. rankData: res.data.data,
  88. })
  89. })
  90. }, () => {
  91. });
  92. }
  93. })