// pages/user/needsOrder/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { tabActive: 1, list: [] }, toDemandHall(){ wx.switchTab({ url: '/pages/demandHall/index', }) }, tabClick(e){ let i = e.currentTarget.dataset.i this.setData({ tabActive: i }) if(i == 1){ this.getCommunicates() } else{ this.getProjectList() } }, // 获取 沟通中 getCommunicates(){ app.http('get','Communicate/demandCommunicates').then((res)=>{ if(res.data.success){ if(res.data.data.length > 0){ res.data.data.map((item)=>{ item.open = false }) res.data.data[0].open = true } console.log(res.data.data) this.setData({ list: res.data.data }) } }) }, //点击展开 openClick(e){ let idx = e.currentTarget.dataset.idx console.log(idx) let list = this.data.list list[idx].open = !list[idx].open this.setData({ list: list }) }, //获取进行中、已结束列表 getProjectList(){ app.http('get','Project/listProject',{projectState: this.data.tabActive -1, projectType: 2}).then((res)=>{ if(res.data.success){ res.data.data.map((item)=>{ item.stageResultsDtoList.map((stage)=>{ if(stage.state == 1){ item.showBtn = true } }) }) this.setData({ list: res.data.data }) } }) }, //同意开启下一阶段 agreenOpen(e){ let item = e.currentTarget.dataset.item console.log(item) const stage = item.stageResultsDtoList.filter((item)=>{ return item.state == 1 }) wx.showModal({ title: '提示!', content: '是否同意开启下阶段?', success(res){ if(res.confirm){ app.http('get','Project/startNextStage',{stageResultId: stage[0].id}).then((res)=>{ if(res.data.success){ wx.showToast({ title: '操作成功!', duration: 2000 }) this.getProjectList() } }) } } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getCommunicates() }, // 平台介入 toPlatform(e){ let code = e.currentTarget.dataset.item.projectCode wx.navigateTo({ url: '/pages/demandHall/platform/index?code=' + code, }) }, // 取消沟通 cancelCommunicate(e){ let info = e.currentTarget.dataset.info console.log(info) let that = this; wx.showModal({ title: '提示!', content:'是否取消沟通?', success(res){ if(res.confirm){ app.http('get','Communicate/cancelCommunicates',{communicateId: info.communicateId}).then((res)=>{ if(res.data.success){ wx.showToast({ title: '操作成功!', duration: 1500 }) setTimeout(()=>{ that.getCommunicates() },1500) } }) } } }) }, //查看立项书 toCreateProject(e){ let item = e.currentTarget.dataset.item wx.navigateTo({ url: '/pages/demandHall/createProject/index?state=' + item.comminuteState+ '&id=' + item.communicateId, }) }, confirm(e){ let item = e.currentTarget.dataset.item let communicateId = e.currentTarget.dataset.id let that = this; wx.showModal({ title: '提示!', content:'是否确认立项?', success(res){ if(res.confirm){ app.http('post','Communicate/aggreProject',{ communicateId: communicateId, partnerInfos: item.info }).then((res)=>{ if(res.data.success){ wx.showToast({ title: '操作成功!', duration: 2000 }) that.getCommunicates() } }) } } }) }, cancelProject(e){ let item = e.currentTarget.dataset.item let communicateId = e.currentTarget.dataset.id let that = this; wx.showModal({ title: '提示!', content:'是否确认取消立项?', success(res){ if(res.confirm){ app.http('post','Communicate/cancelProject',{ communicateId: communicateId, partnerInfos: item.partnerInfos }).then((res)=>{ if(res.data.success){ wx.showToast({ title: '操作成功!', duration: 2000 }) that.getCommunicates() } }) } } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })