锦水居民端小程序
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.

132 lines
3.0 KiB

6 years ago
const app = getApp()
Page({
data: {
discussionType: "issue",
6 years ago
completeInfoDialogVisible: false,
infoCompleted: 0,
gridName: "",
5 years ago
typeList: [{ //排名方式:0-周,1-月
type: "0",
name: "议题",
5 years ago
select: true
},
{
type: "1",
name: "项目",
5 years ago
select: false
}
],
6 years ago
},
onLoad () {
this.setData({
infoCompleted: app.globalData.infoCompleted
})
const gridName = wx.getStorageSync("topGridName")
6 years ago
this.setData({
gridName
})
},
onTabItemTap () {
if (this.data.discussionType === "issue") {
6 years ago
this.issuelist.getIssueList()
} else if (this.data.discussionType === "project") {
6 years ago
this.projectlist.getProjectList()
}
},
onPageScroll (e) {
if (this.data.discussionType === "issue") {
6 years ago
this.issuelist.onPageScroll(e)
} else if (this.data.discussionType === "project") {
6 years ago
this.projectlist.onPageScroll(e)
}
},
// 议题、项目切换
changeDiscussionType (e) {
if (e.currentTarget.dataset.type === "issue") {
6 years ago
this.setData({
discussionType: "issue"
6 years ago
})
} else if (e.currentTarget.dataset.type === "project") {
6 years ago
console.log(this.projectlist)
this.setData({
discussionType: "project"
6 years ago
})
}
},
5 years ago
// 议题、项目切换 v2
onButtonChange: function (e) {
5 years ago
const list = this.data.typeList
let that = this;
list.forEach(item => {
if (item.type === e.currentTarget.dataset.type) {
item.select = true
} else {
item.select = false
}
})
that.setData({
typeList: list,
})
if(e.currentTarget.dataset.type == 0){
this.setData({
discussionType: "issue"
5 years ago
})
}else{
this.setData({
discussionType: "project"
5 years ago
})
}
},
6 years ago
// 触底函数
onReachBottom () {
if (this.data.discussionType === "issue") {
6 years ago
this.issuelist.onReachBottom()
} else if (this.data.discussionType === "project") {
6 years ago
this.projectlist.onReachBottom()
}
},
// 跳转 我有事说
addIssue () {
if (this.verifyCompleteInfo()) {
return false
}
wx.navigateTo({
url: "/subpages/discussion/pages/addIssue/addIssue"
6 years ago
})
},
// 获取 项目组件实例
getProjectComponent () {
this.projectlist = this.selectComponent("#projectlist")
6 years ago
},
// 获取 议题组件实例
getIssueComponent () {
this.issuelist = this.selectComponent("#issuelist")
6 years ago
},
goProjectComponent () {
const list = this.data.typeList
list.forEach(item => {
if (item.type == '1') {
item.select = true
} else {
item.select = false
}
})
this.setData({
typeList: list,
discussionType: "project"
})
},
6 years ago
// 检查 是否完善信息
verifyCompleteInfo () {
if (this.data.infoCompleted == 0) {
this.setData({
completeInfoDialogVisible: !this.data.completeInfoDialogVisible
})
return true
} else {
return false
}
}
})