榆山居民端
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.
 

104 lines
2.8 KiB

const api = require('../../utils/mediateHypermarket')
Page({
/**
* 页面的初始数据
*/
data: {
pageIndex: 1,
pageSize: 10,
nodata: false,
loadMoreType: 'none',
loadMoreVisible: false,
isLoadMore: false,
modulelist: [],
pid: '1438320938730868737',
typeCode: 'MTCS'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// this.modulelist()
// wx.setNavigationBarTitle({
// title: options.title
// })
this.getModuleList()
},
// modulelist() {
// let that = this;
// api.modulelist(that.data.moduleCategory).then(function (res) {
// that.setData({
// modulelist: res.data,
// })
// console.log(that.data.modulelist)
// })
// },
getModuleList() {
let params = {
pageIndex: this.data.pageIndex,
pageSize: this.data.pageSize,
// pid: this.data.pid
typeCode: this.data.typeCode
}
api.getModuleList(params).then(res => {
const customOrder = ["有话说", "点将台", "联动轴", "闪光灯"];
res.data.sort((a, b) => {
return customOrder.indexOf(a.name) - customOrder.indexOf(b.name);
});
this.setData({
modulelist: this.data.modulelist.concat(res.data),
loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none',
loadMoreVisible: res.data.length === this.data.pageSize ? false : true
})
if (this.data.modulelist.length == 0) {//没有值
this.setData({
nodata: true,
loadMoreType: 'none',
loadMoreVisible: false,
})
}
}).catch(err => {
this.setData({
modulelist: [],
nodata: true,
loadMoreType: 'none',
loadMoreVisible: false,
})
console.log(err)
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.setData({
loadMoreVisible: true
})
if (this.data.loadMoreType === 'loading') {
this.setData({
pageIndex: this.data.pageIndex + 1,
pageSize: this.data.pageSize,
})
this.getModuleList()
}
},
goDetails (e) {
console.log(e);
if(e.currentTarget.dataset.module.typeCode == '01'){
wx.redirectTo({
url: '/pages/discussion/discussion',
})
return
}else if(e.currentTarget.dataset.module.typeCode == 'DJT'){
wx.navigateTo({
url: '/subpages/mediateHypermarket/page/dotGeneral/dotGeneral',
})
return
}
wx.navigateTo({
url: `/subpages/workTodo/pages/moduleList/moduleList?pid=${e.currentTarget.dataset.module.id}&typeCode=${e.currentTarget.dataset.module.typeCode}&name=${e.currentTarget.dataset.module.name}&style=${e.currentTarget.dataset.module.moduleStyle}`,
})
}
})