6
0
Fork 0

'展示所有商品'

hui.zhou
H 2022-07-26 17:08:40 +08:00
parent 2fc2c82b50
commit ee5a00e867
1 changed files with 23 additions and 9 deletions

View File

@ -1,6 +1,6 @@
<template>
<view class="">
<view class="flex items-center px-40rpx text-32rpx bg-white py-30rpx">
<view class="flex items-center px-40rpx text-32rpx bg-white py-30rpx sticky top-0 z-99">
<view class="mr-15rpx">商品信息</view>
<u-search @search="searchGoods" class="flex-1" placeholder="货号或名称" v-model="keyword" :show-action="false">
</u-search>
@ -9,8 +9,10 @@
<!-- 有商品时 -->
<block v-if="!isShow">
<!-- 搜索的商品列表 -->
<view class="px-30rpx bg-white" v-if="goodItem.id">
<GoodsItem :isAdd="true" :goods="goodItem" @addGood="addGood" />
<view class="px-30rpx bg-white" v-if="goodsList.length">
<block v-for="(item,index) in goodsList" :key="index">
<GoodsItem :isAdd="true" :goods="item" @addGood="addGood" />
</block>
</view>
<view v-if="chooseList.length>0" class="py-20rpx text-40rpx font-extrabold text-center"></view>
<!-- 提货数量 -->
@ -101,6 +103,15 @@
return pr + cu.vip_price * cu.num
}, 0)
return total
},
goodsList(){
return this.list?.map(e=>{
return {
...e,
defaultNum:1,
num:1
}
})
}
},
methods: {
@ -129,16 +140,19 @@
return this.$u.toast('暂未搜索到该商品')
}
this.isShow = false
let goodsObj = resDate.data.length > 0 ? resDate.data[0] : {}
goodsObj.defaultNum = 1
goodsObj.num = 1
this.goodItem = goodsObj
// this.goodList=
// let goodsObj = resDate.data.length > 0 ? resDate.data[0] : {}
// goodsObj.defaultNum = 1
// goodsObj.num = 1
// this.goodItem = goodsObj
},
//
addGood(e) {
console.log(e,'2222');
const result = this.chooseList.findIndex(item => item.id == e)
if (result == -1) {
this.chooseList.unshift(this.goodItem)
const goodsItem=this.goodsList?.find(el=>el.id==e)
this.chooseList.unshift(goodsItem)
} else {
const num = this.chooseList[result].num + 1
this.getUpdate(result, num)
@ -193,7 +207,7 @@
this.isShow = true
uni.hideLoading()
} catch (err) {}finally{
}
}
}