This commit is contained in:
2024-03-25 14:44:38 +08:00
parent 4fb648f003
commit 91af869899
10 changed files with 103 additions and 37 deletions

View File

@@ -55,7 +55,8 @@ onLoad(() => {
});
const fetchCategoryList = async () => {
categoryList.value = await getCategoryList();
const list = await getCategoryList();
categoryList.value.push(list);
await changeCategory(0);
};
@@ -78,11 +79,15 @@ const fetchGoodsList = async () => {
goodsList.value = rows;
};
const randomImageHeight = () => {
// return Math.random() * 100 + 'rpx';
return '300rpx';
};
const addShoppingCart = (goodsBean: GoodsBean) => {
shoppingCart.save({
...goodsBean,
name: goodsBean.goodsName,
count: 1
});
};

View File

@@ -3,7 +3,7 @@
<view class='search-view'>
<view class='search-input'>
<image :src='assetsUrl("ic_search.png")' />
<input placeholder='输入名称、款号搜索' />
<input placeholder='输入名称、款号搜索' @input='bindInput' />
</view>
</view>
@@ -14,7 +14,7 @@
<image class='goods-image' :src='item.images' />
<text class='goods-name'>{{ item.goodsName }}</text>
<text class='goods-price'>¥{{ item.price }}</text>
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' />
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart' />
</view>
</grid-view>
</scroll-view>
@@ -22,13 +22,37 @@
</template>
<script lang='ts' setup>
import { assetsUrl } from '@/utils/assets';
import { goPath } from '@/utils';
import { getGoodsList } from '@/api/goods';
import useShoppingCartStore from '@/store/modules/shoppingcart';
import { GoodsBean } from '@/api/goods/types';
const goodsList = ref<GoodsBean[]>([1, 2, 3, 4, 1, 2, 2, 2]);
const shoppingCartStore = useShoppingCartStore();
const goodsList = ref<GoodsBean[]>([]);
onLoad((e) => {
});
const bindInput = async (e: any) => {
const { rows } = await getGoodsList({
page: {
pageNum: 1,
pageSize: 100,
bean: {
keyword: e.detail.value,
typeIds: ['1724629185362591745']
}
}
});
goodsList.value = rows;
};
const addShoppingCart = (item: GoodsBean) => {
shoppingCartStore.save(item);
};
</script>
@@ -72,13 +96,12 @@ const goodsList = ref<GoodsBean[]>([1, 2, 3, 4, 1, 2, 2, 2]);
flex-direction: column;
position: relative;
padding: 10rpx 10rpx;
background: #333333;
flex: 1;
.goods-image {
border-radius: 10rpx;
width: 100%;
max-height: 200rpx;
max-height: 400rpx;
}
.goods-name {