小程序
小游戏
企业微信
微信支付
扫描小程序码分享
怎么判断class=liable和class=cclist那个执行了下面的goto_counter这个方法
7 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
<!--抄送-->
<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 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}}"/> -->
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){
text1: '你要给的值'
}
else if(source==2){
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();
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
就是判断是哪个触发的这个方法,如果第一个,就将数据返回给第一个里的text,如果是第二个就将数据返回给第二个里的text
this.setData({
liableList:e.detail.value
var which = e.currentTarget.dataset.source
if(which==1){
XML:
<view class="cclist"><view data-type="{{item.type}}" class="goto_counter" data-source="1" bindtap="goto_counter">{{text}}
<view class="goto_counter" data-type="{{item.type}}" data-id="" bindtap="goto_counter">{{text}}
你先把代码粘出来,我改改,不想自己敲太麻烦,还有你判断完要干啥
@牛
我能说我就是你省略的那不会写吗
<view data-source="1".....
var which = e.currenTarget.dataset.source if(which==1){....}
...
这个具体要怎么写啊
加一个data-source="a" e.currenTarget.dataset.source来判断
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
<!--抄送-->
<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();
},
就是判断是哪个触发的这个方法,如果第一个,就将数据返回给第一个里的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>
你先把代码粘出来,我改改,不想自己敲太麻烦,还有你判断完要干啥
@牛
我能说我就是你省略的那不会写吗
<view data-source="1".....
goto_counter:function(e){
var which = e.currenTarget.dataset.source if(which==1){....}
...
}
这个具体要怎么写啊
加一个data-source="a" e.currenTarget.dataset.source来判断