Commit 833943ae22d6d7534effb7b8d55725bd3bc9e79c

Authored by liuxuqinfhp1220
1 parent 3d3a630c

人数组件修改

Component({
properties:{
seller:Object,
count:{
type:Number,
value:4
}
},
data:{
},
... ... @@ -15,25 +22,29 @@ Component({
peoplelist:peoplelist
})
},
ready(){
this.editpeoplelist(this.data.count);
},
methods:{
selectpeople(e){
console.log(e)
const target=e.currentTarget.dataset;
console.log(target)
this.editpeoplelist(target.count);
this.triggerEvent('selectpeople',target.count);
},
editpeoplelist(count){
let peoplelist=this.data.peoplelist,setdata={};
peoplelist.forEach((v,i)=>{
if(v.isactive){
v.isactive=false;
let setprevkey='peoplelist['+i+'].isactive';
setdata[setprevkey]=false
setdata[setprevkey]=false;
}
if(i==target.index && !v.isactive){
if(v.count==count && !v.isactive){
let setcurrentkey='peoplelist['+i+'].isactive';
setdata[setcurrentkey]=true
setdata[setcurrentkey]=true;
}
})
this.setData(setdata)
console.log(this.data.peoplelist)
}
}
})
\ No newline at end of file
... ...
<swiper class="people-list" display-multiple-items="5" next-margin="46rpx">
<block wx:for="{{peoplelist}}" wx:key="{{index}}">
<swiper-item>
<view class="people {{item.isactive ? 'white-font active' : 'black-font'}} font30r font-bold flex-cc" catchtap="selectpeople" data-index="{{index}}" data-count="{{item.count}}">{{item.count}}位</view>
<view class="people {{item.isactive ? 'white-font active' : 'black-font'}} font30r font-bold flex-cc" catchtap="selectpeople" data-count="{{item.count}}">{{item.count}}位</view>
</swiper-item>
</block>
</swiper>
\ No newline at end of file
... ...