ok
This commit is contained in:
@@ -3,179 +3,178 @@ const request = require('../../utils/request')
|
||||
const ui = require('../../utils/ui')
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
categoryName: "",
|
||||
categoryId: 0,
|
||||
total_count: 0,
|
||||
total_pages: 0,
|
||||
has_next: false,
|
||||
has_next: false,
|
||||
current_page: 1,
|
||||
list: []
|
||||
},
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
categoryName: "",
|
||||
categoryId: 0,
|
||||
total_count: 0,
|
||||
total_pages: 0,
|
||||
has_next: false,
|
||||
has_next: false,
|
||||
current_page: 1,
|
||||
list: [],
|
||||
scrollHeight:0
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
let that = this;
|
||||
if (!options.cid) {
|
||||
wx.navigateBack()
|
||||
this.triggerEvent('onBack')
|
||||
}
|
||||
that.setData({
|
||||
categoryId: options.cid
|
||||
})
|
||||
that.GetCategoryInfo()
|
||||
that.GetList()
|
||||
},
|
||||
|
||||
|
||||
GetCategoryInfo() {
|
||||
let that = this;
|
||||
request.request({
|
||||
method: "GET",
|
||||
url: "/api.php/doc/category_info?cid=" + that.data.categoryId
|
||||
}).then(res => {
|
||||
if (res.data.code === 1) {
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
let that = this;
|
||||
if (!options.cid) {
|
||||
wx.navigateBack()
|
||||
this.triggerEvent('onBack')
|
||||
}
|
||||
that.setListHeight()
|
||||
that.setData({
|
||||
categoryName: res.data.data.data.name,
|
||||
categoryId: res.data.data.data.scode,
|
||||
categoryId: options.cid
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log('ERROR')
|
||||
});
|
||||
},
|
||||
GetList() {
|
||||
let that = this;
|
||||
request.request({
|
||||
method: "GET",
|
||||
url: "/api.php/doc/list?cid=" + that.data.categoryId + "&pageSize=16"
|
||||
}).then(res => {
|
||||
if (res.data.code === 1) {
|
||||
that.GetCategoryInfo()
|
||||
that.GetList()
|
||||
},
|
||||
/**
|
||||
* 设置列表高度
|
||||
*/
|
||||
setListHeight: function () {
|
||||
let that = this;
|
||||
const windowInfo = wx.getWindowInfo()
|
||||
that.setData({
|
||||
list: res.data.data.data,
|
||||
current_page: res.data.data.current_page,
|
||||
has_next: res.data.data.has_next,
|
||||
has_prev: res.data.data.has_prev,
|
||||
total_count: res.data.data.total_count,
|
||||
total_pages: res.data.data.total_pages,
|
||||
})
|
||||
}
|
||||
// ui.showToast(res.data.errorMsg)
|
||||
}).catch(err => {
|
||||
console.log('ERROR')
|
||||
});
|
||||
},
|
||||
scrollHeight: windowInfo.windowHeight - 90,
|
||||
});
|
||||
// wx.getSystemInfo({
|
||||
// success: function (res) {
|
||||
// that.setData({
|
||||
// scrollHeight: res.windowHeight - 90,
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
},
|
||||
|
||||
|
||||
jumpPage(e) {
|
||||
let jumpType = e.currentTarget.dataset.jumptype;
|
||||
console.log(jumpType == 2);
|
||||
if (jumpType == 2) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/details/details?id=1"
|
||||
})
|
||||
/**
|
||||
* 下拉到底加载数据
|
||||
*/
|
||||
bindDownLoad() {
|
||||
let that = this;
|
||||
// 已经是最后一页
|
||||
if (that.data.has_next) {
|
||||
that.setData({
|
||||
current_page: that.data.current_page + 1
|
||||
});
|
||||
this.GetList();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
GetCategoryInfo() {
|
||||
let that = this;
|
||||
request.request({
|
||||
method: "GET",
|
||||
url: "/api.php/doc/category_info?cid=" + that.data.categoryId
|
||||
}).then(res => {
|
||||
if (res.data.code === 1) {
|
||||
that.setData({
|
||||
categoryName: res.data.data.data.name,
|
||||
categoryId: res.data.data.data.scode,
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log('ERROR')
|
||||
});
|
||||
},
|
||||
GetList() {
|
||||
let that = this;
|
||||
request.request({
|
||||
method: "GET",
|
||||
url: "/api.php/doc/list?cid=" + that.data.categoryId + "&pageSize=16&page=" + that.data.current_page
|
||||
}).then(res => {
|
||||
if (res.data.code === 1) {
|
||||
that.setData({
|
||||
list: that.data.list.concat(res.data.data.data),
|
||||
current_page: res.data.data.current_page,
|
||||
has_next: res.data.data.has_next,
|
||||
has_prev: res.data.data.has_prev,
|
||||
total_count: res.data.data.total_count,
|
||||
total_pages: res.data.data.total_pages,
|
||||
})
|
||||
}
|
||||
// ui.showToast(res.data.errorMsg)
|
||||
}).catch(err => {
|
||||
console.log('ERROR')
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
jumpPage(e) {
|
||||
let jumpType = e.currentTarget.dataset.jumptype;
|
||||
// 文章id
|
||||
let aid = e.currentTarget.dataset.aid;
|
||||
console.log(jumpType == 2);
|
||||
if (jumpType == 2 && aid) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/details/details?aid="+aid
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
console.log(111);
|
||||
// if (this.data.has_next) {
|
||||
// that.setData({
|
||||
// current_page: this.current_page + 1
|
||||
// })
|
||||
// //加载下一页
|
||||
// this.GetList();
|
||||
// } else {
|
||||
// ui.showToast({
|
||||
// icon: "none",
|
||||
// title: '没有更多数据了'
|
||||
// })
|
||||
// }
|
||||
},
|
||||
|
||||
loadData: function () {
|
||||
wx.request({
|
||||
url: 'http://test.com', //假的后台接口
|
||||
method: 'POST',
|
||||
data: {
|
||||
pageSize: this.pageSize,
|
||||
pageNum: this.pageNum,
|
||||
},
|
||||
success: function (res) {
|
||||
this.pageNum = res.data.content.pageNum;
|
||||
this.totalPage = res.data.content.totalPageNum;
|
||||
this.resultData = res.data.content.rows;
|
||||
},
|
||||
fail: function (res) {
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user