You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
2.6 KiB
140 lines
2.6 KiB
|
5 years ago
|
// pages/pbService/library/index.js
|
||
|
|
import commonApi from "../../../utils/https/common"
|
||
|
|
Page({
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面的初始数据
|
||
|
|
*/
|
||
|
|
data: {
|
||
|
|
type:1,
|
||
|
|
page_no:1,
|
||
|
|
total:1,
|
||
|
|
list:[],
|
||
|
|
keywords:'',
|
||
|
|
isSearch:false
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面加载
|
||
|
|
*/
|
||
|
|
onLoad: function (options) {
|
||
|
|
this.getList()
|
||
|
|
},
|
||
|
|
changeType:function(e){
|
||
|
|
let type = e.currentTarget.dataset.type;
|
||
|
|
this.setData({
|
||
|
|
type:type,
|
||
|
|
list:[],
|
||
|
|
page_no:1,
|
||
|
|
total:1,
|
||
|
|
isSearch:false
|
||
|
|
})
|
||
|
|
this.getList()
|
||
|
|
},
|
||
|
|
getList:function(){
|
||
|
|
let list = this.data.list;
|
||
|
|
if(list.length>=this.data.total) return;
|
||
|
|
let service = this.data.type==1?'pbservice/Booking/newBookList':'pbservice/Booking/recommendBookList'
|
||
|
|
commonApi._post(service,{
|
||
|
|
page_no:this.data.page_no,
|
||
|
|
page_num:20
|
||
|
|
}).then(res=>{
|
||
|
|
this.setData({
|
||
|
|
total:res.data.total,
|
||
|
|
list:list.concat(res.data.rows),
|
||
|
|
page_no:this.data.page_no+1
|
||
|
|
})
|
||
|
|
})
|
||
|
|
},
|
||
|
|
gotoInfo:function(e){
|
||
|
|
let item = e.currentTarget.dataset.item;
|
||
|
|
item = encodeURIComponent(JSON.stringify(item));
|
||
|
|
wx.navigateTo({
|
||
|
|
url: 'bookinfo/index?item='+item,
|
||
|
|
})
|
||
|
|
},
|
||
|
|
changeKeyword:function(e){
|
||
|
|
this.setData({
|
||
|
|
keywords:e.detail.value
|
||
|
|
})
|
||
|
|
},
|
||
|
|
search:function(){
|
||
|
|
this.setData({
|
||
|
|
isSearch:true,
|
||
|
|
page_no:1,
|
||
|
|
list:[],
|
||
|
|
total:1
|
||
|
|
})
|
||
|
|
this.getSearchList();
|
||
|
|
},
|
||
|
|
getSearchList:function(){
|
||
|
|
let list = this.data.list;
|
||
|
|
if(list.length>=this.data.total) return;
|
||
|
|
commonApi._post("pbservice/Booking/searchBook",{
|
||
|
|
page_no:this.data.page_no,
|
||
|
|
page_num:20,
|
||
|
|
keywords:this.data.keywords
|
||
|
|
}).then(res=>{
|
||
|
|
this.setData({
|
||
|
|
page_no:this.data.page_no+1,
|
||
|
|
total:res.data.total,
|
||
|
|
list:list.concat(res.data.rows)
|
||
|
|
})
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
|
*/
|
||
|
|
onReady: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面显示
|
||
|
|
*/
|
||
|
|
onShow: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面隐藏
|
||
|
|
*/
|
||
|
|
onHide: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面卸载
|
||
|
|
*/
|
||
|
|
onUnload: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
|
*/
|
||
|
|
onPullDownRefresh: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面上拉触底事件的处理函数
|
||
|
|
*/
|
||
|
|
onReachBottom: function () {
|
||
|
|
if(this.data.isSearch){
|
||
|
|
this.getSearchList()
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.getList()
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 用户点击右上角分享
|
||
|
|
*/
|
||
|
|
onShareAppMessage: function () {
|
||
|
|
|
||
|
|
}
|
||
|
|
})
|