Files
AGuestSaas/pages/user/companyMine/focusedCompany/focusedCompany.js
2020-12-30 17:34:35 +08:00

89 lines
1.9 KiB
JavaScript

// pages/user/companyMine/focusedProject/focusedProject.js
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',
})
}
})