锦水居民端小程序
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.
 

300 lines
6.8 KiB

// subpages/heart/pages/groupBuyListMy/groupBuyListMy.js
const api = require("../../utils/api")
Page({
/**
* 页面的初始数据
*/
data: {
pageIndex: 1,
pageSize: 10,
nodata: false,
loadMoreType: 'none',
loadMoreVisible: false,
groupbuylist: [],
selectedTab: "tab0",
dialogVisible: false,
dialogTitle: "",
dialogContent: "",
dialogConfirmText: "",
dialogCancelText: "",
noticeType: 3, //noticeNew 类型 3-我的参与 4-我的发布
cancelSignupVisible: false,
cancelSignupTipValue: "",
cancelSignupTipVisible: false,
selectNoticeId: '', //当前选中id 取消
noticeVisible: false, //提示框
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// this.getMyGroupBuyPublish()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.setData({
pageIndex: 1,
groupbuylist: []
})
this.getMyGroupBuyList()
},
/**
* 生命周期函数--监听页面隐藏
*/
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.getMyGroupBuyList()
}
},
// tab 切换
tabBarChange (e) {
this.setData({
loadMoreVisible: false,
loadMoreType: "none",
pageIndex: 1,
})
if (e.currentTarget.dataset.tab == "tab0") {
this.setData({
groupbuylist: []
})
this.getMyGroupBuyJoin()
} else if (e.currentTarget.dataset.tab == "tab1") {
this.setData({
groupbuylist: []
})
this.getMyGroupBuyPublish()
}
this.setData({
selectedTab: e.currentTarget.dataset.tab
})
},
getMyGroupBuyList () {
if (this.data.selectedTab == "tab0") {
this.getMyGroupBuyJoin()
} else {
this.getMyGroupBuyPublish()
}
},
getMyGroupBuyPublish () {
const para = {
pageIndex: this.data.pageIndex,
pageSize: this.data.pageSize
}
api.getMyGroupBuyPublish(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)
})
},
getMyGroupBuyJoin () {
const para = {
pageIndex: this.data.pageIndex,
pageSize: this.data.pageSize
}
api.getMyGroupBuyJoin(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)
})
},
//取消/结束接口函数
updateStatus () {
},
// 跳转发布
toPublish () {
console.log('发布')
api.getVolunteerVerify().then(res => {
if (res.code == 0) {
if (res.data && res.data.id) {
wx.navigateTo({
url: `/subpages/heart/pages/dropByPublish/dropByPublish`
})
} else {
this.setData({
dialogVisible: !this.data.dialogVisible,
dialogTitle: "志愿者认证",
dialogContent: ["是否认证志愿者,完成发布"],
dialogConfirmText: "是",
dialogCancelText: "否"
})
}
}
}).catch(err => {
console.log(err)
})
},
//志愿者认证
confirmDialog () {
wx.navigateTo({
url: "/subpages/heart/pages/volunteer/volunteer"
})
},
//前往评价
toEvaluate (e) {
const id = e.currentTarget.dataset.id
wx.navigateTo({
url: `/subpages/heart/pages/evaluate/evaluate?id=${id}`
})
},
//前往 详情
toNoticeDetail (e) {
const id = e.currentTarget.dataset.id
wx.navigateTo({
url: `/subpages/heart/pages/groupBuyDetail/groupBuyDetail?id=${id}`
})
},
//修改
toModify (e) {
if (e.currentTarget.dataset.edit == 0) {
return
}
const id = e.currentTarget.dataset.id
wx.navigateTo({
url: `/subpages/heart/pages/groupBuyPublish/groupBuyPublish?id=${id}`
})
},
//取消
toCancel (e) {
if (e.currentTarget.dataset.status == 5 || e.currentTarget.dataset.status == 10) {
return
}
this.setData({
cancelSignupVisible: !this.data.cancelSignupVisible,
cancelSignupTipValue: ``,
cancelSignupTipVisible: true,
selectNoticeId: e.currentTarget.dataset.id
})
},
cancelSignupCallback (e) {
const para = {
id: this.data.selectNoticeId,
status: '10',
cancelReason: e.detail.data
}
api.updateStatus(para).then(() => {
this.setData({
noticeVisible: !this.data.noticeVisible,
pageIndex: 1,
groupbuylist: []
})
this.getMyGroupBuyList()
}).catch(err => {
console.log(err)
})
},
// 关闭弹框
closeDialog () {
// wx.navigateBack()
},
//结束团购
toFinish (e) {
if (e.currentTarget.dataset.status == 5 || e.currentTarget.dataset.status == 10) {
return
}
const id = e.currentTarget.dataset.id
wx.navigateTo({
url: `/subpages/heart/pages/groupBuyDetail/groupBuyDetail?id=${id}&type=finish`
})
},
//确认交易
toConfirm (e) {
if (e.currentTarget.dataset.status == 10) {
return
}
const id = e.currentTarget.dataset.id
wx.navigateTo({
url: `/subpages/heart/pages/groupBuyConfirmList/groupBuyConfirmList?id=${id}`
})
}
})