ceshi3.js 5.14 KB
//index.js
//获取应用实例
const app = getApp()
Page({
  data: {
    limit: 0,
    show: 0,
    limitto: 5,
    loadHidden: true,
    datalaiy: '中国福利彩票官网',
    newstitle: '彩经新闻',
    lists: [
      {
        'id': '1',
        'image': 'http://img1.huiyijingling.cn/UploadImage/Meet/20161010/4ntia7d5/636117184529372567.png',
        'title': '双色球17102期开奖结果',
        'num': '304',
        'state': '进行中',
        'time': '2017-03-28',
        'keywords': '双色球17102期开奖结果'
      }
    ],
    list: [
      {
        'id': '1',
        'image': 'http://img1.huiyijingling.cn/UploadImage/Meet/20161010/4ntia7d5/636117185105463337.png',
        'title': '福彩3D开奖结果',
        'num': '150',
        'state': '已结束',
        'time': '2017-03-28',
        'keywords': '福彩3D开奖结果'
      }
    ],
    kjlist: [
      {
        'id': '1', 'name': '双色球',
        'bid': '0', 'caipiaoid': '13',
        'ball': [{ id: 1, num: '2', tp: 1 }, { id: 2, num: '3', tp: 1 }, { id: 3, num: '4', tp: 1 }, { id: 4, num: '8', tp: 1 },
        { id: 5, num: '12', tp: 1 },
        { id: 6, num: '17', tp: 1 },
        { id: 7, num: '7', tp: 2 }
        ],
        'issueno': '17031',
        'opendate': '2017-03-28'
      }
    ],
    imgUrls: [
      '/images/1.jpg',
      '/images/2.jpg'
    ],
    //配置tabBar  
    tabBar: {
      "color": "#9E9E9E",
      "selectedColor": "#f00",
      "backgroundColor": "#fff",
      "borderStyle": "#ccc",
      "num": 4,
      "list": [
        {
          "pagePath": "/page/index/index",
          "text": "主页",
          "iconPath": "../../images/1.png",
          "selectedIconPath": "../../images/1-2.png",
          //"selectedColor": "#4EDF80",  
          active: true
        },
        {
          "pagePath": "/page/kj/list",
          "text": "开奖查询",
          "iconPath": "../../images/2.png",
          "selectedIconPath": "../../images/2-2.png",
          active: false
        },
        {
          "pagePath": "/page/news/index",
          "text": "彩经新闻",
          "iconPath": "../../images/3.png",
          "selectedIconPath": "../../images/3-2.png",
          active: false
        },
        {
          "pagePath": "/page/line/index",
          "text": "预测分析",
          "iconPath": "../../images/4.png",
          "selectedIconPath": "../../images/4-2.png",
          active: false
        }
      ],
      "position": "bottom"
    }
  },
  scrollR: function (e) {
    var that = this;
    that.setData({ loadHidden: false })
    wx.request({
      //主页信息
      url: app.url + '/apiArticleIndex.php', //首页接口地址
      data: { limit: that.data.limit, limitto: that.data.limitto },
      header: { 'Content-Type': 'application/json' },
      success: function (res) {
        that.setData({
          list: res.data.aarr
        })
        that.setData({ limit: that.data.limit + 3 })
        that.setData({ limitto: that.data.limitto + 3 })

        that.setData({
          lists: that.data.lists.concat(that.data.list),
        });
      },
      fail: function (res) {
        console.log('失败')
      },
      complete: function () {
        //隐藏 加载中的提示
        that.setData({ loadHidden: true })
      },
    })
  },
  getDatas: function (e) {
    var that = this;
    wx.request({
      //主页信息
      url: app.url + '/apiIndex.php', //首页接口地址
      data: {},
      success: function (res) {
        that.setData({
          kjlist: res.data.kjlist
        })
        that.setData({
          datalaiy: res.data.datalaiy
        })
        that.setData({
          newstitle: res.data.newstitle
        })
      },
      fail: function (res) {
        console.log('失败')
      }
    })
  },
  getArticleDatas: function (e) {
    var that = this;
    that.setData({ loadHidden: false })
    wx.request({
      //主页信息
      url: app.url + '/apiArticleIndex.php', //首页接口地址
      data: { limit: that.data.limit, limitto: that.data.limitto },
      header: { 'Content-Type': 'application/json' },
      success: function (res) {
        that.setData({
          lists: res.data.aarr
        })
        that.setData({ limit: that.data.limit + 3 })
        that.setData({ limitto: that.data.limitto + 3 })
        console.log('limit数据' + that.data.limit)
      },
      fail: function (res) {
        console.log('失败')
      },
      complete: function () {
        //隐藏 加载中的提示
        that.setData({ loadHidden: true })
      },
    })
  },
  onLoad: function (e) {
    // this.scrollR(e);
    this.getDatas();
    this.getArticleDatas();
  },
  //事件处理函数
  bindViewTap: function () {
    wx.navigateTo({
      url: '../kjdetail/index',
      success: function (res) {
        console.log('跳转到news页面成功')// success
      },
      fail: function () {
        console.log('跳转到news页面失败')  // fail
      },
      complete: function () {
        console.log('跳转到news页面完成') // complete
      }
    })
  },

  scroll: function (e) {
    console.log('首页加载了scroll')
    this.scrollR();
  },
  onShareAppMessage: function () {

  }
})