Files
AGuestSaas/components/company/projectRaise/projectRaise.js
2020-12-31 16:10:36 +08:00

96 lines
2.0 KiB
JavaScript

/**
* Web二雪
* 趁时光不老 努力活成自己想要成为的样子
*/
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
lists:[],//列表
categoryList:[],
category_id:'0',
company_id:wx.getStorageSync('company_id'),
page:1,
has_more:true,
},
/**
* 组件的方法列表
*/
methods: {
/**
* 跳转到详情
*/
toUrl(e){
wx.navigateTo({
url: '/pages/home/projectDetail/projectDetail?id='+e.currentTarget.dataset.id,
})
},
/**
* 点击按钮触发事件
*/
menuSelect: function (e) {
var category_id=e.currentTarget.dataset.id;
if(this.data.category_id!=category_id){
console.log(category_id);
this.setData({
category_id:category_id,
lists:[],
page:1,
has_more:true
})
this.crowdfunds();
}
},
/**
* 请求项目筹集分类接口
*/
crowdfundcategory(company_id){
wx.$api.companyModule.crowdfundcategory(wx.getStorageSync('company_id')).then(res=>{
console.log(res)
this.setData({
categoryList:res,
category_id:res[0].id
})
this.crowdfunds();
})
},
/**
* 请求根据分类获取列表
*/
crowdfunds(){
if(this.data.has_more){
wx.$api.companyModule.crowdfunds(wx.getStorageSync('company_id'),this.data.category_id,this.data.page).then(res=>{
console.log(res)
if(res.page.has_more){
this.setData({
has_more:true,
page:this.data.page+1,
})
}else{
this.setData({
has_more:false
})
}
var lists=this.data.lists.concat(res.data);
this.setData({
lists:lists
})
})
}
},
}
})