ok
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
// pages/list/list.js
|
||||
|
||||
const request = require('../../utils/request')
|
||||
const ui = require('../../utils/ui')
|
||||
Page({
|
||||
|
||||
/**
|
||||
@@ -6,15 +9,25 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
searchName : "",
|
||||
title:"搜索",
|
||||
total_count: 0,
|
||||
total_pages: 0,
|
||||
has_next: false,
|
||||
has_next: false,
|
||||
current_page: 1,
|
||||
list: [],
|
||||
|
||||
scrollHeight:0
|
||||
},
|
||||
|
||||
|
||||
jumpPage(e) {
|
||||
let jumpType = e.currentTarget.dataset.jumptype;
|
||||
let aid = e.currentTarget.dataset.aid;
|
||||
console.log(jumpType == 2);
|
||||
if (jumpType == 2) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/details/details?id=1"
|
||||
url: "/pages/details/details?aid=" +aid
|
||||
})
|
||||
}
|
||||
// wx.navigateTo({
|
||||
@@ -23,13 +36,78 @@ Page({
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
GetList() {
|
||||
let that = this;
|
||||
request.request({
|
||||
method: "GET",
|
||||
url: "/api.php/doc/list?keyword=" + that.data.searchName + "&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')
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置列表高度
|
||||
*/
|
||||
setListHeight: function () {
|
||||
let that = this;
|
||||
const windowInfo = wx.getWindowInfo()
|
||||
that.setData({
|
||||
scrollHeight: windowInfo.windowHeight - 90,
|
||||
});
|
||||
// wx.getSystemInfo({
|
||||
// success: function (res) {
|
||||
// that.setData({
|
||||
// scrollHeight: res.windowHeight - 90,
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 下拉到底加载数据
|
||||
*/
|
||||
bindDownLoad() {
|
||||
let that = this;
|
||||
// 已经是最后一页
|
||||
if (that.data.has_next) {
|
||||
that.setData({
|
||||
current_page: that.data.current_page + 1
|
||||
});
|
||||
this.GetList();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
let that = this;
|
||||
if (!options.search) {
|
||||
wx.navigateBack()
|
||||
this.triggerEvent('onBack')
|
||||
}
|
||||
console.log(options);
|
||||
that.setData({searchName:options.search})
|
||||
that.setListHeight()
|
||||
that.GetList()
|
||||
// that.data.searchName = options.search;
|
||||
// if (that.sea)
|
||||
// console.log(options);
|
||||
|
||||
Reference in New Issue
Block a user