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