|
|
|
// subpages/heart/pages/groupBuyList/groupBuyList.js
|
|
|
|
const api = require("../../utils/api")
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
pageIndex: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
nodata: false,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
groupbuylist: [],
|
|
|
|
dialogVisible: false,
|
|
|
|
dialogTitle: "",
|
|
|
|
dialogContent: "",
|
|
|
|
dialogConfirmText: "",
|
|
|
|
dialogCancelText: "",
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
wx.setNavigationBarTitle({
|
|
|
|
title: options.title
|
|
|
|
})
|
|
|
|
// this.getGroupBuyList()
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
this.setData({
|
|
|
|
pageIndex: 1,
|
|
|
|
groupbuylist: []
|
|
|
|
})
|
|
|
|
this.getGroupBuyList()
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
// onShareAppMessage: function () {
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function () {
|
|
|
|
this.setData({
|
|
|
|
loadMoreVisible: true
|
|
|
|
})
|
|
|
|
if (this.data.loadMoreType === "loading") {
|
|
|
|
this.setData({
|
|
|
|
pageIndex: this.data.pageIndex + 1
|
|
|
|
})
|
|
|
|
this.getGroupBuyList()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getGroupBuyList () {
|
|
|
|
const para = {
|
|
|
|
isMe: '0',
|
|
|
|
pageIndex: this.data.pageIndex,
|
|
|
|
pageSize: this.data.pageSize
|
|
|
|
}
|
|
|
|
api.getGroupBuyList(para).then(res => {
|
|
|
|
console.log(res)
|
|
|
|
this.setData({
|
|
|
|
groupbuylist: [...this.data.groupbuylist,...res.data],
|
|
|
|
loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none',
|
|
|
|
loadMoreVisible: res.data.length === this.data.pageSize ? false : true,
|
|
|
|
nodata: false,
|
|
|
|
})
|
|
|
|
if (this.data.groupbuylist.length == 0) {
|
|
|
|
this.setData({
|
|
|
|
nodata: true,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
this.setData({
|
|
|
|
groupbuylist: [],
|
|
|
|
nodata: true,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
})
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 跳转发布
|
|
|
|
toPublish () {
|
|
|
|
console.log('发布')
|
|
|
|
api.getVolunteerVerify().then(res => {
|
|
|
|
if (res.code == 0) {
|
|
|
|
if (res.data && res.data.id) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/subpages/heart/pages/groupBuyPublish/groupBuyPublish`
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
dialogVisible: !this.data.dialogVisible,
|
|
|
|
dialogTitle: "志愿者认证",
|
|
|
|
dialogContent: ["是否认证志愿者,完成发布"],
|
|
|
|
dialogConfirmText: "是",
|
|
|
|
dialogCancelText: "否"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 跳转我的发布
|
|
|
|
toNoticeNewList () {
|
|
|
|
console.log('我的发布')
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/subpages/heart/pages/noticeNewList/noticeNewList?type=1`
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
//志愿者认证
|
|
|
|
confirmDialog () {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: "/subpages/heart/pages/volunteer/volunteer"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|