123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- // pages/groupFragmentsRecord/groupFragmentsRecord.js
- const app = getApp()
- var net = require('../../utils/net.js')
- var url = require('../../utils/url.js')
- var common = require('../../utils/common.js')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- rankType: '1',
- isFirstLoad: true,
- gameId: '',
- code: '',
- list: []
- },
- backHome: function () {
- wx.redirectTo({
- url: '../home/home',
- })
- },
- handleData: function (list) {
- var result = []
- for (var i = 0; i < list.length; i++) {
- var item = list[i]
- var f = common.starToFragment(app.server.config.rankDanList, item.starC)
- var fragment = app.server.config.rankDanList[f[0]].name
- var starNum = f[1]
- item['fragment'] = fragment
- item['starNum'] = starNum
- item['bg'] = item.userId == app.server.userId ? 'self' : 'all'
- item['row'] = i
- result.push(item)
- }
- return result
- },
- joinGroupRecord: function () {
- wx.showLoading({
- title: '',
- })
-
- net.connect({
- url: url.host + url.join_group_record,
- data: { code: this.data.code },
- method: 'POST',
- success: res => {
- this.queryGroupRecord()
- },
- })
- },
- queryGroupRecord: function () {
- net.connect({
- url: url.host + url.group_record,
- data: { code: this.data.code },
- success: res => {
- this.data.list = this.handleData(res.data.data)
- this.setData({
- list: this.data.list
- })
- wx.hideLoading()
- },
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- app.log(options)
- this.data.gameId = options.gameId
- this.data.code = app.globalData.identify.shareIdentify
- app.log(this.data.code)
- if (options.rankType) {
- this.data.rankType = options.rankType
- }
- var title
- switch (this.data.rankType) {
- case '1': {
- title = '脑力排行榜'
- break
- }
- case '2': {
- title = '专场脑力排行榜'
- break
- }
- default: break
- }
- wx.setNavigationBarTitle({
- title: title,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- if (!this.data.isFirstLoad) {
- return
- }
- this.joinGroupRecord()
- this.data.isFirstLoad = false
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- var title = '用脑力征服世界,段位排行榜,你上榜了吗?'
- var path = '&gameId=' + this.data.gameId + '&page=groupFragmentsRecord'
- var t = 11
- var gameId = this.data.gameId
- return common.shareAction({
- path: path,
- title: title,
- type: t,
- gameId: gameId,
- success: res => {
- }
- }, this.data.code)
- }
- })
|