groupFragmentsRecord.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // pages/groupFragmentsRecord/groupFragmentsRecord.js
  2. const app = getApp()
  3. var net = require('../../utils/net.js')
  4. var url = require('../../utils/url.js')
  5. var common = require('../../utils/common.js')
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. isFirstLoad: true,
  12. gameId: '',
  13. code: '',
  14. list: []
  15. },
  16. backHome: function () {
  17. wx.redirectTo({
  18. url: '../home/home',
  19. })
  20. },
  21. handleData: function (list) {
  22. var result = []
  23. for (var i = 0; i < list.length; i++) {
  24. var item = list[i]
  25. var f = common.starToFragment(app.server.config.rankDanList, item.starC)
  26. var fragment = app.server.config.rankDanList[f[0]].name
  27. var starNum = f[1]
  28. item['fragment'] = fragment
  29. item['starNum'] = starNum
  30. item['bg'] = item.userId == app.server.userId ? 'self' : 'all'
  31. item['row'] = i
  32. result.push(item)
  33. }
  34. return result
  35. },
  36. joinGroupRecord: function () {
  37. wx.showLoading({
  38. title: '',
  39. })
  40. net.connect({
  41. url: url.host + url.join_group_record,
  42. data: { code: this.data.code },
  43. method: 'POST',
  44. success: res => {
  45. this.queryGroupRecord()
  46. },
  47. })
  48. },
  49. queryGroupRecord: function () {
  50. net.connect({
  51. url: url.host + url.group_record,
  52. data: { code: this.data.code },
  53. success: res => {
  54. this.data.list = this.handleData(res.data.data)
  55. this.setData({
  56. list: this.data.list
  57. })
  58. wx.hideLoading()
  59. },
  60. })
  61. },
  62. /**
  63. * 生命周期函数--监听页面加载
  64. */
  65. onLoad: function (options) {
  66. app.log(options)
  67. this.data.gameId = options.gameId
  68. this.data.code = app.globalData.identify.shareIdentify
  69. app.log(this.data.code)
  70. },
  71. /**
  72. * 生命周期函数--监听页面初次渲染完成
  73. */
  74. onReady: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面显示
  78. */
  79. onShow: function () {
  80. if (!this.data.isFirstLoad) {
  81. return
  82. }
  83. this.joinGroupRecord()
  84. this.data.isFirstLoad = false
  85. },
  86. /**
  87. * 生命周期函数--监听页面隐藏
  88. */
  89. onHide: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面卸载
  93. */
  94. onUnload: function () {
  95. },
  96. /**
  97. * 页面相关事件处理函数--监听用户下拉动作
  98. */
  99. onPullDownRefresh: function () {
  100. },
  101. /**
  102. * 页面上拉触底事件的处理函数
  103. */
  104. onReachBottom: function () {
  105. },
  106. /**
  107. * 用户点击右上角分享
  108. */
  109. onShareAppMessage: function () {
  110. var title = '用脑力征服世界,段位排行榜,你上榜了吗?'
  111. var path = '&gameId=' + this.data.gameId + '&page=groupFragmentsRecord'
  112. var t = 11
  113. var gameId = this.data.gameId
  114. return common.shareAction({
  115. path: path,
  116. title: title,
  117. type: t,
  118. gameId: gameId,
  119. success: res => {
  120. }
  121. }, this.data.code)
  122. }
  123. })