?图一的页面重要的代码时下一步的事件,如下
handleGoodsReturn() {
if (this.data.checkedGoods.length) {
const { recycleOrderEntryList } = this.data.orderInfo;
let orderInfo = this.data.orderInfo;
let checkedGoods = this.data.checkedGoods;
let recycleOrderType = this.data.orderInfo.recycleOrderType;
let vendorIdByTran = this.data.orderInfo.vendorIdByTran;
let that = this;
if (this.data.checkedGoods.length === recycleOrderEntryList.length) {
wx.showModal({
title: "提示",
content: "是否全部退回,该订单采购流程将被终止!",
success(res) {
if (res.confirm) {
wx.navigateTo({
url: "pages/package-purchase/pages/purchase-things/return-goods/back/index",
success(e) {
e.eventChannel.emit("onApprove", orderInfo);
e.eventChannel.emit("checkedGoods", checkedGoods);
},
events: {},
});
}
},
});
} else {
wx.navigateTo({
url: "/pages/package-purchase/pages/purchase-things/return-goods/back/index",
success(e) {
e.eventChannel.emit("onApprove", orderInfo);
e.eventChannel.emit("checkedGoods", checkedGoods);
},
events: {},
});
}
} else {
Toast.error("请选择要退回的商品");
}
},
以上代码的重点在于传值,使用了e.eventChannel.emit,传送中,orderInfo为复杂对象
那看看图二页面是如何接收的
onLoad() {
const eventChannel = this.getOpenerEventChannel();
eventChannel.on("onApprove", (data) => {
this.setData(
{
orderInfo: data,
recycleOrderType: data.recycleOrderType,
suName: data.vendorIdByTran,
},
() => {
this.getParamsDictionary();
}
);
});
eventChannel.on("checkedGoods", (data) => {
this.setData({
checkedGoods: data,
});
});
},
既然能够接收到,那就再进行赋值就好了。就已经能够达到该需求了?
|