{"size": 1922, "ext": "js", "max_stars_repo_path": "pages/index/detail.js", "max_stars_repo_name": "gg1122/WXBaiSi", "max_stars_repo_stars_event_min_datetime": "2016-12-01T02:24:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-16T03:01:20.000Z", "max_issues_repo_path": "pages/index/detail.js", "max_issues_repo_name": "gg1122/WXBaiSi", "max_issues_repo_issues_event_min_datetime": "2018-04-22T09:27:33.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-11T06:39:46.000Z", "max_forks_repo_path": "pages/index/detail.js", "max_forks_repo_name": "gg1122/WXBaiSi", "max_forks_repo_forks_event_min_datetime": "2016-12-03T15:47:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T22:40:39.000Z"}
{"max_stars_count": 163, "max_issues_count": 3, "max_forks_count": 81, "avg_line_length": 24.961038961, "max_line_length": 103, "alphanum_fraction": 0.5353798127}
const util = require("../../utils/util.js");

var data_id = 0;//帖子的ID
var page = 1;
var lastcid = 0;//最后一条评论的ID

Page({
  data:{
    item:{},
    hotcomemnt_hidden:false,
    dataList: []
  },
  onLoad:function(options){
    data_id = options.id;
    //页面初始化 options为页面跳转所带来的参数
    this.refreshNewData();

  },
  //刷新数据
  refreshNewData:function(){
    //加载提示框
    util.showLoading();
    var that = this;
    var parameters = 'a=dataList&c=comment&data_id='+data_id+"&hot=1";
    console.log("parameters = "+parameters);
    util.request(parameters,function(res){
        page = 1;
        console.log("最热");
        
        var newObj = res.data.hot[0];
        console.log(newObj);
        that.setData({
          hotcomemnt_hidden: newObj ? false : true,
          item:newObj ? newObj : {},
          dataList: res.data.data
        })
        if (res.data.data.length > 0) {
          lastcid = res.data.data[res.data.data.length-1].id;
        }
        
        setTimeout(function(){
            util.hideToast();
            wx.stopPullDownRefresh();
          },1000);
      });
  },
  refreshData:function(){
    console.log("刷新数据");
  },
  //加载更多操作
  onReachBottom:function(){
    console.log("加载更多");
    //加载提示框
    util.showLoading();

    var that = this;
    var parameters = 'a=dataList&c=comment&data_id='+data_id + "&page="+(page+1) + "&lastcid="+lastcid;
    console.log("parameters = "+parameters);
    util.request(parameters,function(res){
      
        if (res.data.data) {
            page += 1;
            that.setData({
              dataList: that.data.dataList.concat(res.data.data)
            });
            lastcid = res.data.data[res.data.data.length-1].id;
            setTimeout(function(){
              util.hideToast();
              wx.stopPullDownRefresh();
            },1000);
        } else {
            util.showSuccess("没有新数据了",300);
        }
      });
      
    }
})