怎么判断class=liable和class=cclist那个执行了下面的goto_counter这个方法
<!--抄送-->
<view class="page_one">
<view class="page_two">
<view class="section_title">抄送<text style="color:red;">*</text></view>
<view wx:key="{{nameData}}">
<form style="width:70px;height:80px" src="{item.plan_person_liable}"></form>
</view>
<view class="cclist"><view data-type="{{item.type}}" class="goto_counter" data-source="1" bindtap="goto_counter">{{text1}}
<image src="../../images/blue.png" style="width:15px;height:15px"></image>
</view>
</view>
</view>
</view>
<view class="page_one">
<view class="page_two">
<view class="section_title">责任人<text style="color:red;">*</text></view>
<!-- <view wx:key="{nameData}">
<form style="width:70px;height:80px" src="{item.leader_list}"></form>
</view> -->
<view class="liableName">
<view class="goto_counter" data-type="{{item.type}}" data-source="2" data-id="" bindtap="goto_counter">{{text2}}
<!-- <template is="item" data="{{text}}"/> -->
<image src="../../images/blue.png" style="width:15px;height:15px"></image>
</view>
</view>
</view>
</view>
JS:
//责任人:调用接口取出责任人的列表
goto_counter:function(e){
var that = this
that.setData({
liableList:e.detail.value //这个value哪来的?
})
wx.showToast({
title:'加载中',
icon:'loading',
});
var acc=wx.getStorageSync('account');
const _this = this;
var source = e.currentTarget.dataset.source
if(source==1){
that.setData({
text1: '你要给的值'
})
}
else if(source==2){
that.setData({
text2: '你要给的值'
})
}
wx.request({
url: 'https://plan_contract.php',
data: {
account_no: acc,
type:e.currentTarget.dataset.type,
source:e.currentTarget.dataset.source
},
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
method:'POST',
dataType:'json',
success: function (res) {
console.log(res.data.leader_list);
console.log(res.data);
wx.redirectTo({
url:'../contacts/contacts?leader_list='+JSON.stringify(res.data.leader_list)
+'&contract_list='+JSON.stringify(res.data.contract_list)
// +'&leader_selected'+
// JSON.stringify(res.data.contract_list.selected)
})
}
});
console.log(e.currentTarget.dataset.id);
wx.hideToast();
},
<view data-source=“1”…
goto_counter:function(e){
var which = e.currenTarget.dataset.sourceif(which==1){…}
…
}
就是判断是哪个触发的这个方法,如果第一个,就将数据返回给第一个里的text,如果是第二个就将数据返回给第二个里的text
JS:
//责任人:调用接口取出责任人的列表
goto_counter:function(e){
this.setData({
liableList:e.detail.value
})
wx.showToast({
title:‘加载中’,
icon:‘loading’,
});
var acc=wx.getStorageSync(‘account’);
const _this = this;
var which = e.currentTarget.dataset.source
if(which==1){
}
wx.request({
url: ‘https://plan_contract.php’,
data: {
account_no: acc,
type:e.currentTarget.dataset.type,
source:e.currentTarget.dataset.source
},
header: {
“Content-Type”: “application/x-www-form-urlencoded”
},
method:‘POST’,
dataType:‘json’,
success: function (res) {
console.log(res.data.leader_list);
console.log(res.data);
wx.redirectTo({
url:’…/contacts/contacts?leader_list=’+JSON.stringify(res.data.leader_list)
+’&contract_list=’+JSON.stringify(res.data.contract_list)
// +’&leader_selected’+
// JSON.stringify(res.data.contract_list.selected)
})
}
});
console.log(e.currentTarget.dataset.id);
wx.hideToast();
},
XML:
<!–抄送–>
<view class=“page_one”>
<view class=“page_two”>
<view class=“section_title”>抄送<text style=“color:red;”>*</text></view>
<view wx:key="{{nameData}}">
<form style=“width:70px;height:80px” src="{item.plan_person_liable}"></form>
</view>
<view class=“cclist”><view data-type="{{item.type}}" class=“goto_counter” data-source=“1” bindtap=“goto_counter”>{{text}}
<image src="…/…/images/blue.png" style=“width:15px;height:15px”></image>
</view>
</view>
</view>
</view>
<view class=“page_one”>
<view class=“page_two”>
<view class=“section_title”>责任人<text style=“color:red;”>*</text></view>
<!-- <view wx:key="{nameData}">
<form style=“width:70px;height:80px” src="{item.leader_list}"></form>
</view> -->
<view class=“liableName”>
<view class=“goto_counter” data-type="{{item.type}}" data-id="" bindtap=“goto_counter”>{{text}}
<!-- <template is=“item” data="{{text}}"/> -->
<image src="…/…/images/blue.png" style=“width:15px;height:15px”></image>
</view>
</view>
</view>
</view>