110 lines
1.8 KiB
JavaScript
110 lines
1.8 KiB
JavaScript
// pages/index.js
|
|
var urlPath = require('../../config.js');
|
|
const app = getApp();
|
|
Page({
|
|
goDetails(e) {
|
|
wx.navigateTo({
|
|
url: '../details/details?id=' + e.mark.id
|
|
});
|
|
},
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
//列表
|
|
host: urlPath.host,
|
|
works_list: [],
|
|
page: 1,
|
|
},
|
|
|
|
getNewsData: function() {
|
|
var that = this
|
|
wx.request({
|
|
url: urlPath.newsList,
|
|
header: {
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
},
|
|
dataType: 'json', // 添加这个配置
|
|
method: 'post',
|
|
data: {
|
|
page: that.data.page,
|
|
size: '10'
|
|
},
|
|
success(res) {
|
|
if (res.data.result == 'success') {
|
|
// console.log(JSON.parse(res.data.data))
|
|
that.setData({
|
|
works_list: that.data.works_list.concat(JSON.parse(res.data.data).list),
|
|
page: that.data.page + 1
|
|
})
|
|
} else {
|
|
console.log(res.msg); //失败
|
|
}
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
|
|
this.getNewsData()
|
|
|
|
//that.countDown()//倒计时监听
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {
|
|
if (typeof this.getTabBar === 'function' &&
|
|
this.getTabBar()) {
|
|
this.getTabBar().setData({
|
|
selected: 0
|
|
})
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function() {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function() {
|
|
this.setData({
|
|
page: this.data.page + 1
|
|
})
|
|
this.getNewsData()
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function() {
|
|
|
|
},
|
|
|
|
})
|