6
0
Fork 0

添加删除商品滑动

hui.zhou
H 2022-07-29 17:01:10 +08:00
parent 7b1cc19c89
commit d706faef50
1 changed files with 31 additions and 5 deletions

View File

@ -16,8 +16,10 @@
</view>
<view v-if="chooseList.length>0" class="py-20rpx text-40rpx font-extrabold text-center"></view>
<!-- 提货数量 -->
<view class="px-30rpx bg-white">
<view class="py-20rpx flex w-full items-start" v-for="(item,index) in chooseList" :key="index">
<view class=" bg-white">
<u-swipe-action v-for="(item, index) in chooseList" :key="item.id" :show="item.show" :index="index" @click="click" @open="open" :options="options"
>
<view class="py-20rpx flex w-full items-start px-30rpx" >
<view
class="w-38rpx mt-8rpx h-38rpx rounded-full border border-hex-ef4444 border-solid text-center leading-38rpx text-hex-ef4444">
{{index+1}}
@ -33,9 +35,11 @@
</view>
</view>
<GoodsItem class="px-0" :goods="item" @numChange="numChange" />
<u-line v-if="chooseList.length-1!=index" :hair-line="false" color="#c8c9cc"></u-line>
</view>
</view>
<u-line v-if="chooseList.length-1!=index" :hair-line="false" color="#c8c9cc"></u-line>
</u-swipe-action>
</view>
<view class="h-180rpx"></view>
<!-- 底部按钮 -->
@ -82,6 +86,14 @@
list: [], //
chooseList: [], //
goodItem: {},
options: [
{
text: '删除',
style: {
backgroundColor: '#ef4444'
}
}
]
};
},
onLoad({
@ -115,6 +127,21 @@
}
},
methods: {
click(index,index1) {
if(index1==0){
this.$nextTick(()=>{
this.chooseList.splice(index, 1)
this.chooseList[index].show = false;
})
}
},
open(index) {
this.chooseList[index].show = true;
this.chooseList.forEach((val, idx) => {
if(index != idx) this.chooseList[idx].show = false;
})
},
//
onQR(){
uni.scanCode({
@ -148,11 +175,10 @@
},
//
addGood(e) {
console.log(e,'2222');
const result = this.chooseList.findIndex(item => item.id == e)
if (result == -1) {
const goodsItem=this.goodsList?.find(el=>el.id==e)
this.chooseList.unshift(goodsItem)
this.chooseList.push(Object.assign(goodsItem,{show:false}))
} else {
const num = this.chooseList[result].num + 1
this.getUpdate(result, num)