This commit is contained in:
2024-03-31 18:24:22 +08:00
parent 60cb832b02
commit a06d74934f

View File

@@ -14,20 +14,23 @@
<image class='goods-image' :src='item.images' /> <image class='goods-image' :src='item.images' />
<text class='goods-name'>{{ item.goodsName }}</text> <text class='goods-name'>{{ item.goodsName }}</text>
<text class='goods-price'>¥{{ item.price }}</text> <text class='goods-price'>¥{{ item.price }}</text>
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart' /> <image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart(item)' />
</view> </view>
</grid-view> </grid-view>
</scroll-view> </scroll-view>
</view> </view>
<sku-dialog ref='skuDialogRef' />
</template> </template>
<script lang='ts' setup> <script lang='ts' setup>
import SkuDialog from '@/components/sku-dialog.vue';
import { assetsUrl } from '@/utils/assets'; import { assetsUrl } from '@/utils/assets';
import { goPath } from '@/utils'; import { goPath } from '@/utils';
import { getGoodsList } from '@/api/goods'; import { getGoodsList } from '@/api/goods';
import useShoppingCartStore from '@/store/modules/shoppingcart'; import useShoppingCartStore from '@/store/modules/shoppingcart';
import { GoodsBean } from '@/api/goods/types'; import { GoodsBean } from '@/api/goods/types';
const skuDialogRef = ref();
const shoppingCartStore = useShoppingCartStore(); const shoppingCartStore = useShoppingCartStore();
const goodsList = ref<GoodsBean[]>([]); const goodsList = ref<GoodsBean[]>([]);
@@ -50,8 +53,10 @@ const bindInput = async (e: any) => {
goodsList.value = rows; goodsList.value = rows;
}; };
const addShoppingCart = (item: GoodsBean) => { const addShoppingCart = (goodsBean: GoodsBean) => {
shoppingCartStore.save(item); skuDialogRef.value.show(goodsBean.goodsId, (e: GoodsBean) => {
shoppingCartStore.save(e);
});
}; };
</script> </script>