Kaynağa Gözat

小程序开发~

release/210823_需求对对碰
王饶冀 3 yıl önce
ebeveyn
işleme
43660b2a6d

+ 15
- 1
pages/myModule/components/myRelease/myRelease.js Dosyayı Görüntüle

@@ -164,7 +164,7 @@ Page({
}
})
this.setData({
listData
listData
})
}
}).catch(error => {
@@ -217,6 +217,18 @@ Page({
wx.hideLoading()
})
},
// 修改需求
productEdit(e){
let item = e.currentTarget.dataset.item;
let that = this;
wx.navigateTo({
url: '/pages/releaseModule/index',
success: function (res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('acceptDataFromOpenerPage', { listDetail: item })
}
})
},
// 数据加载提示
showLoading(title) {
wx.showLoading({
@@ -224,6 +236,8 @@ Page({
mask: true
})
},

getListData() {
let { page, size, customerId, keyword, currentTab } = this.data;
$request.get('/businessCommunicationDemand/getDemandByStateAndCustomerId.action',

+ 1
- 1
pages/myModule/components/myRelease/myRelease.wxml Dosyayı Görüntüle

@@ -41,7 +41,7 @@
>
{{ item.isOnTop ? '取消置顶' : '置顶' }}
</van-button>
<van-button plain type="info" size="small" round class="foot-van-btn">修改</van-button>
<van-button plain type="info" size="small" round class="foot-van-btn" data-item="{{ item }}" bindtap="productEdit">修改</van-button>
<van-button plain type="info" size="small" round class="foot-van-btn" data-item="{{ item }}" bindtap="productRelease">
{{ item.state == 0 ? '下架' : '上架' }}
</van-button>

+ 60
- 27
pages/releaseModule/index.js Dosyayı Görüntüle

@@ -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,

+ 1
- 1
pages/releaseModule/index.wxml Dosyayı Görüntüle

@@ -6,7 +6,7 @@
<view wx:else>
<!-- 顶部 -->
<view class="section">
<textarea class="section-textarea" bindinput="textareaInput" maxlength="{{ max }}" placeholder="请输入你的需求详情~ " />
<textarea class="section-textarea" value="{{ detailValue }}" bindinput="textareaInput" maxlength="{{ max }}" placeholder="请输入你的需求详情~ " />
<view class="limit">{{min}}/{{max}}</view>
</view>
<view class="tags-view">

Loading…
İptal
Kaydet