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.
178 lines
3.6 KiB
178 lines
3.6 KiB
// subpages/heart/pages/noticeNewList/noticeNewList.js
|
|
const api = require("../../utils/api")
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
pageIndex: 1,
|
|
pageSize: 10,
|
|
nodata: false,
|
|
loadMoreType: 'none',
|
|
loadMoreVisible: false,
|
|
sdslist: [],
|
|
groupbuylist: [],
|
|
type: '0' //0 顺道捎 1 拼团购
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
type: options.type
|
|
})
|
|
this.getMyList()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
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.getMyList()
|
|
}
|
|
},
|
|
|
|
getMyList () {
|
|
if (this.data.type == '0') {
|
|
this.getSdsList()
|
|
} else {
|
|
this.getGroupBuyList()
|
|
}
|
|
},
|
|
getSdsList () {
|
|
const para = {
|
|
type: '2',
|
|
pageIndex: this.data.pageIndex,
|
|
pageSize: this.data.pageSize
|
|
}
|
|
api.getSdsList(para).then(res => {
|
|
console.log(res)
|
|
this.setData({
|
|
sdslist: [...this.data.sdslist,...res.data],
|
|
loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none',
|
|
loadMoreVisible: res.data.length === this.data.pageSize ? false : true
|
|
})
|
|
if (this.data.sdslist.length == 0) {
|
|
this.setData({
|
|
nodata: true,
|
|
loadMoreType: 'none',
|
|
loadMoreVisible: false,
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
this.setData({
|
|
sdslist: [],
|
|
nodata: true,
|
|
loadMoreType: 'none',
|
|
loadMoreVisible: false,
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
getGroupBuyList () {
|
|
const para = {
|
|
isMe: '1',
|
|
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
|
|
})
|
|
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)
|
|
})
|
|
},
|
|
|
|
deleteSds (e) {
|
|
console.log('删除', e.detail.id)
|
|
api.sdsDelete(e.detail.id).then(res => {
|
|
console.log(res.data)
|
|
this.setData({
|
|
pageIndex: 1,
|
|
sdslist: []
|
|
})
|
|
this.getMyList()
|
|
})
|
|
},
|
|
|
|
deleteGroupBuy (e) {
|
|
console.log('删除', e.detail.id)
|
|
api.groupBuyDelete(e.detail.id).then(res => {
|
|
console.log(res.data)
|
|
this.setData({
|
|
pageIndex: 1,
|
|
groupbuylist: []
|
|
})
|
|
this.getMyList()
|
|
})
|
|
}
|
|
})
|