75 lines
1.5 KiB
JavaScript
75 lines
1.5 KiB
JavaScript
// pages/companyOrder/companyOrder.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
state: 'unstart', //未开始 unstart 进行中start 已结束end
|
|
lists: [],
|
|
page: 1,
|
|
has_more: true,
|
|
},
|
|
|
|
onLoad() {
|
|
this.userActives();
|
|
},
|
|
|
|
/**
|
|
* 点击按钮触发事件
|
|
*/
|
|
menuSelect: function (e) {
|
|
if (this.data.state != e.currentTarget.dataset.state) {
|
|
wx.showLoading({
|
|
title: '请求中...',
|
|
mask: true
|
|
})
|
|
this.setData({
|
|
state: e.currentTarget.dataset.state,
|
|
page: 1,
|
|
lists: [],
|
|
has_more: true
|
|
})
|
|
}
|
|
this.userActives();
|
|
},
|
|
// 获取活动列表
|
|
userActives() {
|
|
wx.$api.companyModule.userActives(this.data.state, this.data.page).then(res => {
|
|
setTimeout(() => {
|
|
wx.hideLoading({})
|
|
}, 1000);
|
|
var lists = this.data.lists.concat(res.data)
|
|
if (res.page.has_more) {
|
|
this.setData({
|
|
has_more: res.page.has_more,
|
|
page: page + 1,
|
|
lists: lists
|
|
})
|
|
} else {
|
|
this.setData({
|
|
has_more: res.page.has_more,
|
|
lists: lists
|
|
})
|
|
}
|
|
})
|
|
},
|
|
// 触底加载更多
|
|
onReachBottom() {
|
|
console.log('触底')
|
|
if (this.data.has_more) {
|
|
this.userActives();
|
|
} else {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '没有更多',
|
|
})
|
|
}
|
|
},
|
|
//跳转到详情页
|
|
goUrl(e) {
|
|
wx.navigateTo({
|
|
url: '/pages/companyModule/activeDetail/activeDetail?id=' + e.currentTarget.dataset.id,
|
|
})
|
|
}
|
|
}) |