循环生成的button分享无法获取对应参数,从而达到实现分享不同内容?
<view class="item-info" wx:for="{{display_all_list}}" wx:for-index="index" wx:key="index">
<view class="item-into-name-share">
<view class="item-into-name" bindtap="editRecord" data-index="{{index}}">
{{item.sup_name}}
</view>
<button style="border:none;position: inherit;padding:0rpx;" id="{{index}}" bindtap="onShareAppMessage"
class="share" open-type="share" data-cust-index="{{index}}" data-no="{{item.supcust_no}}">
<image src="{{share_logo}}" class="share-image">
</image>
分享
</button>
</view>
<view class="item-into-detail" bindtap="editRecord" data-index="{{index}}">
客户编码: {{item.supcust_no}}
</view>
<view class="item-into-detail" bindtap="editRecord" data-index="{{index}}">
冻结业务:{{item.order_flag==='0'?'正常':'冻结'}}
</view>
</view>
js 事件
onShareAppMessage: function (e) {
console.log(e)
console.log(app.globalData.wxgh_oauth_url + '/Image/sygj-logo.png')
let _this = this;
if (e.from && e.from === 'button') {
console.log(e.target.dataset.custIndex)
let custInfo = _this.data.display_all_list[Number(e.target.dataset.custIndex)];
return {
title: custInfo.sup_name,
imageUrl: app.globalData.wxgh_oauth_url + '/Image/sygj-logo.png'
};
for 循环遍历后 data-cust-index 属性的值是不同的
console 打印的数据,都为for 循环数组的最后一条记录