//teacher.js
//获取应用实例
var app = getApp()
var pages = 1
Page({
data:{
trimg:[]
},
onLoad:function(){
var that = this
wx.request({
url: 'https://interface.sina.cn/tech/gif/album.d.json?format=json&num=6&page=1',
dataType: 'jsonp',
jsonp: "callback",
jsonpCallback: "getDataJson",
header: {
'content-type': 'application/jsonp' // 默认值
},
success: function (res) {
var jsonstr = JSON.parse(res.data)
console.log(jsonstr)
that.setData({
trimg: jsonstr.data
})
}
})
},
onReachBottom: function (e) {
var that = this
pages++
wx.request({
url: 'https://interface.sina.cn/tech/gif/album.d.json?format=json&num=6',
dataType: 'jsonp',
data:{
page:pages
},
jsonp: "callback",
jsonpCallback: "getDataJson",
header: {
'content-type': 'application/jsonp' // 默认值
},
success: function (res) {
var jsonstr = JSON.parse(res.data)
var list = jsonstr.data;
var moment_list = that.data.trimg;
for (var i = 0; i < list.length; i++) {
moment_list.push(list[i]);
}
pages++
that.setData({
trimg: moment_list,
pages:pages
})
}
})
},
onPullDownRefresh: function () {
console.log('onPullDownRefresh')
},
})
网友评论