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.

128 lines
2.3 KiB

// pages/quest/quest.js
import {http} from "../../utils/util"
Page({
/**
* 页面的初始数据
*/
data: {
questes: [],
maxpage: 1,
page: 1,
cdn: getApp().globalData.cdn,
month: '',
tagIdList: [],
brandIdList: [],
keyword: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.setNavigationBarTitle({
title: '素材中心',
success: function (res) {}
})
wx.setBackgroundColor({
backgroundColor: '#F9F9F9',
})
this.getdata()
},
to (e) {
wx.navigateTo({
url: e.currentTarget.dataset.url + '?id=' + e.currentTarget.dataset.id + '&name=' + e.currentTarget.dataset.name,
})
},
getdata(){
http("/referenceGroup/list", "post",{
pageNum: this.data.page,
month: this.data.month,
tagIdList: this.data.tagIdList[0]?this.data.tagIdList:[],
brandIdList: this.data.brandIdList[0]?this.data.brandIdList:[],
keyword: this.data.keyword
}).then(res=>{
this.setData({
questes:res.data.records
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
this.onRefresh()
},
onRefresh:function(){
//导航条加载动画
wx.showNavigationBarLoading()
//loading 提示框
wx.showLoading({
title: 'Loading...',
})
this.setData({
page: 1,
questes: []
})
this.getdata()
console.log("下拉刷新啦");
setTimeout(function () {
wx.hideLoading();
wx.hideNavigationBarLoading();
//停止下拉刷新
wx.stopPullDownRefresh();
}, 2000)
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
if (this.data.page === this.data.maxpage) {
wx.showToast({
title: '到底啦~',
icon: 'none',
duration: 2000
})
} else {
this.setData({
'page' : this.data.page + 1
})
this.getdata()
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})