Today, I made an order sharing function, but I couldn’t transfer data

\

The initial code is written as follows

<van-button wx:if="{{order.statusName === 'to be given '}}" class="btn-font" plain data-order-id="{{order.id}}" Catchtap ="shareGoods" open-type="share" > </van-button>Copy the code

At this point, I found that the shareGoods method could get the orderId, but the onShareAppMessage method could not get the orderId

Search a lot of data, all native button can pass in this way

So I changed it to a native button. Boy, it could be implemented, but the style had to be reworked. I went back to the API in Ant-Weap and suddenly saw the following:

There is already a solution in ant- WEap, modify the code as follows:

<van-button wx:if="{{order.statusName === 'to be saved '}}" class="btn-font" plain round dataset="{{order.id}}" Catchtap ="shareGoods" open-type="share" > </van-button>Copy the code
/** * onShareAppMessage(res) {var that = this; If (res.from === 'button') {//console.log(' from the page forward button'); return { title: 'XXXXXX', path: '/pages/common/pay/pay? OrderId = '+ res. Target. The dataset. The detail of success: function (res) {}, fail: function (res) {/ / forward failure}}; } else if (res.from === 'menu') { } }Copy the code