<template>
	<view class="cardGoodsModel">
		<card v-for="(item, index) in list" :key="index" :data="item"></card>
	</view>
</template>

<script>
import card from '@/pages/mall/components/card.vue';
export default {
	name: 'card',
	components: {
		card
	},
	props: {
		list: {
			type: Array,
			default: () => {
				return [];
			}
		}
	},
	methods: {
		goGoodsDetail(item) {
			uni.navigateTo({
				url: '/pages-mall/pages/goods/detail?goodsId='+item.id
			});
		},
		addCart(item){
			this.$u.api.addCartAjax({
				goods_id:item.id,
				nums: 1,
				sku_id:1,//1是测试，应该传入skuId，外层没有返回，需要接口返回一下
			}).then(({code})=>{
				if(code==1){
					this.$u.toast('添加购物车成功')
				}
			})
		}
	}
};
</script>

<style lang="scss" scoped>
.cardGoodsModel{
	display: flex;
	padding: 0 30rpx;
	flex-wrap: wrap;
	justify-content: space-between;
}
</style>
