// 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: { 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) }, /** * 生命周期函数--监听页面初次渲染完成 */ 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) } })