92 lines
1.9 KiB
JavaScript
92 lines
1.9 KiB
JavaScript
/**
|
|
* Web二雪
|
|
* 趁时光不老 努力活成自己想要成为的样子
|
|
*/
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
lists: [],
|
|
page: 1,
|
|
has_more: true
|
|
},
|
|
onLoad() {
|
|
this.getList();
|
|
},
|
|
|
|
// 获取活动列表
|
|
getList() {
|
|
wx.$api.user.companySubscribesList(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: this.data.page + 1,
|
|
lists: lists
|
|
})
|
|
} else {
|
|
this.setData({
|
|
has_more: res.page.has_more,
|
|
lists: lists
|
|
})
|
|
}
|
|
})
|
|
},
|
|
// 触底加载更多
|
|
onReachBottom() {
|
|
if (this.data.has_more) {
|
|
this.getList();
|
|
} else {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '没有更多',
|
|
})
|
|
}
|
|
},
|
|
// 取消项目
|
|
crowdfundsUnLike(e) {
|
|
var id = e.currentTarget.dataset.id
|
|
var index = e.currentTarget.dataset.index
|
|
var arr = this.data.lists
|
|
var temp = []
|
|
for (var i = 0; i < arr.length; i++) {
|
|
if (i != index) {
|
|
temp.push(arr[i]);
|
|
}
|
|
}
|
|
console.log(temp)
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '确认取消关注么?',
|
|
success: res => {
|
|
if (res.confirm) {
|
|
wx.showLoading({
|
|
title: '取消中',
|
|
})
|
|
wx.$api.companyModule.companyLike(id).then(res => {
|
|
this.setData({
|
|
lists: temp
|
|
})
|
|
wx.showToast({
|
|
title: '取消成功',
|
|
icon: 'none'
|
|
})
|
|
wx.hideLoading({})
|
|
});
|
|
}
|
|
}
|
|
})
|
|
},
|
|
runIn(e) {
|
|
console.log(e.currentTarget.dataset.id)
|
|
wx.setStorageSync('company_id', e.currentTarget.dataset.id)
|
|
wx.navigateTo({
|
|
url: '/pages/home/index',
|
|
})
|
|
}
|
|
}) |