|
|
@@ -18,12 +18,25 @@ Page({ |
|
|
|
selectedTag: [], |
|
|
|
detailValue: "", |
|
|
|
saveLoading:false, |
|
|
|
businessCommunicationDemandId:null, |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad() { |
|
|
|
const eventChannel = this.getOpenerEventChannel() |
|
|
|
if(eventChannel.on){ |
|
|
|
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 |
|
|
|
eventChannel.on('acceptDataFromOpenerPage', data => { |
|
|
|
let listDetail = data.listDetail; |
|
|
|
this.setData({ |
|
|
|
detailValue: listDetail.info, |
|
|
|
selectedTag: listDetail.type, |
|
|
|
businessCommunicationDemandId:listDetail.businessCommunicationDemandId |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
this.getTags(); |
|
|
|
}, |
|
|
|
// 输入框输入 |
|
|
@@ -64,7 +77,6 @@ Page({ |
|
|
|
el.isActive = 'active' + selectedTag.indexOf(el.typeName); |
|
|
|
} |
|
|
|
}) |
|
|
|
console.log(tags) |
|
|
|
this.setData({ |
|
|
|
selectedTag, |
|
|
|
tags |
|
|
@@ -77,12 +89,12 @@ Page({ |
|
|
|
this.setData({ |
|
|
|
saveLoading:true |
|
|
|
}) |
|
|
|
let { selectedTag, detailValue } = this.data; |
|
|
|
let { selectedTag, detailValue,businessCommunicationDemandId } = this.data; |
|
|
|
let param = { |
|
|
|
customerId: 666967, |
|
|
|
info: this.trimRight(detailValue), |
|
|
|
type: selectedTag.join(','), |
|
|
|
businessCommunicationDemandId: null, |
|
|
|
businessCommunicationDemandId, |
|
|
|
}; |
|
|
|
$request.post('/businessCommunicationDemand/saveDemand.action', param).then(res => { |
|
|
|
this.setData({ |
|
|
@@ -90,31 +102,43 @@ Page({ |
|
|
|
}) |
|
|
|
let that = this; |
|
|
|
if (res.status == 0) { |
|
|
|
wx.showModal({ |
|
|
|
title: '发布成功', |
|
|
|
content: "请关注平台公众号,如有咨询,可及时接收消息通知!", |
|
|
|
confirmText: "去关注", |
|
|
|
cancelText:"关闭", |
|
|
|
success (res1) { |
|
|
|
if (res1.confirm) { |
|
|
|
that.clearData(); |
|
|
|
console.log('用户点击确定') |
|
|
|
} else if (res1.cancel) { |
|
|
|
let listDetail = res.data; |
|
|
|
if (typeof listDetail.type == 'string') { |
|
|
|
listDetail.type = listDetail.type.split(','); |
|
|
|
} |
|
|
|
that.clearData(); |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/index/components/listDetails/Details', |
|
|
|
success: function (res2) { |
|
|
|
// 通过eventChannel向被打开页面传送数据 |
|
|
|
res2.eventChannel.emit('acceptDataFromOpenerPage', { listDetail }) |
|
|
|
if(!businessCommunicationDemandId){ |
|
|
|
wx.showModal({ |
|
|
|
title: '发布成功', |
|
|
|
content: "请关注平台公众号,如有咨询,可及时接收消息通知!", |
|
|
|
confirmText: "去关注", |
|
|
|
cancelText:"关闭", |
|
|
|
success (res1) { |
|
|
|
if (res1.confirm) { |
|
|
|
that.clearData(); |
|
|
|
console.log('用户点击确定') |
|
|
|
} else if (res1.cancel) { |
|
|
|
let listDetail = res.data; |
|
|
|
if (typeof listDetail.type == 'string') { |
|
|
|
listDetail.type = listDetail.type.split(','); |
|
|
|
} |
|
|
|
}) |
|
|
|
that.clearData(); |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/index/components/listDetails/Details', |
|
|
|
success: function (res2) { |
|
|
|
// 通过eventChannel向被打开页面传送数据 |
|
|
|
res2.eventChannel.emit('acceptDataFromOpenerPage', { listDetail }) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
wx.showLoading({ |
|
|
|
title: '修改成功', |
|
|
|
mask: true |
|
|
|
}) |
|
|
|
setTimeout(() => { |
|
|
|
wx.hideLoading() |
|
|
|
// wx.navigateBack() |
|
|
|
}, 1000); |
|
|
|
} |
|
|
|
|
|
|
|
} else if (res.status == 501) { |
|
|
|
wx.showModal({ |
|
|
|
title: '发布失败', |
|
|
@@ -130,9 +154,14 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
clearData(){ |
|
|
|
let tags = this.data.tags; |
|
|
|
tags.forEach(el => { |
|
|
|
el.isActive = ''; |
|
|
|
}) |
|
|
|
this.setData({ |
|
|
|
selectedTag:[], |
|
|
|
detailValue:"", |
|
|
|
tags |
|
|
|
}) |
|
|
|
}, |
|
|
|
trimRight(s) { |
|
|
@@ -159,8 +188,12 @@ Page({ |
|
|
|
}) |
|
|
|
if (res.status == 0) { |
|
|
|
let datas = res.data; |
|
|
|
let selectedTag = this.data.selectedTag; |
|
|
|
datas.forEach(el => { |
|
|
|
el.isActive = false; |
|
|
|
el.isActive = ""; |
|
|
|
if (selectedTag.indexOf(el.typeName) != -1) { |
|
|
|
el.isActive = 'active' + selectedTag.indexOf(el.typeName); |
|
|
|
} |
|
|
|
}) |
|
|
|
this.setData({ |
|
|
|
tags: datas, |