123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- // pages/rank/rank.js
- const $api = require('../../utils/api.js').API;
- const $push = require('../../utils/api.js').PUSH;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- datas:{},
- date:'',
- match:[],
- index:0,
- match_id:'',
- match_day:0,
- matchData:{},
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // var y = new Date().getFullYear(), m = (new Date().getMonth() + 1), d = new Date().getDate();
- // m = m > 9 ? m : '0' + m;
- // d = d > 9 ? d : '0' + d;
- // this.setData({
- // date: y + '-' + m + '-' + d
- // })
-
- $api.getMatchList().then(res=>{
- this.setData({
- match:res.data.data,
- index: 0,
- match_id: res.data.data[0].id,
- matchData:res.data.data[0],
- })
- this.getDate()
- })
-
- },
- getDate(){
- $api.getDate({ match_id: this.data.match_id }).then(res => {
- this.setData({
- date: res.data.data,
- })
- this.getData()
- })
- },
- getData() {
- wx.showNavigationBarLoading()
-
- let day = this.data.matchData.valid_dates.indexOf(this.data.date)
- this.setData({
- match_day:day
- })
- if (!this.data.match_id){
- return
- }
- $api.getRank({ stock_date: this.data.date, match_id: this.data.match_id}).then(res => {
- wx.hideNavigationBarLoading()
-
- this.setData({
- datas:res.data.data,
- })
- })
- .catch(err=>{
- wx.hideNavigationBarLoading()
- })
- },
- bindChange(e) {
- let match=this.data.match;
- this.setData({
- index: e.detail.value,
- match_id: match[e.detail.value].id,
- matchData:match[e.detail.value],
- })
- this.getDate()
- },
- bindDateChange(e) {
- this.setData({
- date: e.detail.value
- })
- this.getData()
- },
- pushToday(e){
- $push.pushToday(e.currentTarget.dataset)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- $api.initUser()
-
- $api.getsignup().then(res => {
- this.setData({
- info: res.data.data
- })
- })
- wx.hideNavigationBarLoading()
-
- if (!this.data.datas.groups){
- $api.getMatchList().then(res => {
- this.setData({
- match: res.data.data,
- index: 0,
- match_id: res.data.data[0].id
- })
- this.getDate()
- })
- }else{
- wx.showNavigationBarLoading()
- this.getData()
- }
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|