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.

195 lines
4.0 KiB

3 years ago
// pages/demandHall/index.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
tabbar: {},
3 years ago
active: '1', // 1资源供应,2需求广场
tabActive: '1', // 1资源列表,2企业列表
list: [],
showScreenDialog: false,
companyList: [],
pagesize: 10,
page: 1,
loading: true, //是否加载更多
cagetoryList: [] , // 分类列表
cName:'', //筛选企业/个人
resourceCagetoryId: '' //筛选分类
3 years ago
},
topTabClick(e){
this.setData({
3 years ago
active: e.currentTarget.dataset.i,
loading: true,
pagesize: 10,
page: 1,
list: []
3 years ago
})
3 years ago
this.getPageData()
3 years ago
},
tabClick(e){
this.setData({
tabActive: e.currentTarget.dataset.i,
loading: true,
page: 1,
size: 10
3 years ago
})
3 years ago
if(e.currentTarget.dataset.i == 2){
this.getCompanyList()
} else{
this.getPageData()
3 years ago
}
3 years ago
},
showDialog(){
this.setData({
showScreenDialog: true
})
},
3 years ago
toResourceDetail(e){
let id = e.currentTarget.dataset.id;
wx.navigateTo({
url: '/pages/demandHall/resourcesDetail/index?id='+id,
})
},
toCompanyDetail(e){
let id = e.currentTarget.dataset.id;
wx.navigateTo({
url: '/pages/demandHall/companyDetail/index?id='+id,
})
},
toNeedsDetail(e){
let id = e.currentTarget.dataset.id;
wx.navigateTo({
url: '/pages/demandHall/needsDetail/index?id='+id,
})
},
3 years ago
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
3 years ago
app.editTabbar()
// this.getPageData()
3 years ago
this.getCagetoryList()
},
getCagetoryList(){
app.http('get','ResourcesCagetory/listResourcesCagetory').then((res)=>{
if(res.data.success){
this.setData({
cagetoryList: res.data.data
})
}
})
},
cagetoryClick(e){
let item = e.currentTarget.dataset.item
let i = e.currentTarget.dataset.i
this.setData({
cagetoryActive: i,
resourceCagetoryId: item.id
})
},
businessChange(e){
let type = e.currentTarget.dataset.type
this.setData({cName: type})
},
finishClick(){
this.setData({loading: true,page: 1, size: 10})
this.getPageData()
this.setData({
showScreenDialog: false
})
},
resetClick(){
this.setData({
cName: '',
cagetoryActive: null,
resourceCagetoryId:''
3 years ago
})
},
getPageData(){
if(this.data.loading){
app.http('post','Resources/listResources',{
resourceType: this.data.active,
page: this.data.page,
pagesize:this.data.pagesize,
resourceCagetoryId:this.data.resourceCagetoryId,
cName: this.data.cName,
3 years ago
}).then((res)=>{
if(res.data.success){
if(res.data.data.content.length < this.data.pagesize){
this.setData({
loading: false
})
}
if(this.data.page > 1){
this.setData({
list: this.data.list.concat(res.data.data.content)
})
} else{
this.setData({
list: res.data.data.content
})
}
3 years ago
}
})
}
},
getCompanyList(){
app.http('post','Enterprise/listEnterprise',{}).then((res)=>{
if(res.data.success){
this.setData({
companyList: res.data.data.content
})
}
})
3 years ago
},
/**
3 years ago
* 页面上拉触底事件的处理函数
3 years ago
*/
3 years ago
onReachBottom: function () {
this.setData({
page: this.data.page + 1
})
this.getPageData()
3 years ago
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getPageData()
3 years ago
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
3 years ago
3 years ago
},
3 years ago
3 years ago
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})