<template>
	<view>
		<navigation-bar title="购物车" background-color="#0081ff" front-color="#ffffff" :left-button="null" />
		<u-tabs lineWidth="50" :list="list" itemStyle="height:90rpx;width: 100rpx;" :is-scroll="false"
			:current="current" @change="change"></u-tabs>
		<u-list style="margin-top: 10rpx;padding: 15rpx;" @scrolltolower="scrolltolower">
			<u-list-item v-for="(item, index) in cartList" :key="index">
				<view class="item-box">
					<view class="goods-item">
						<view class="good-row">
							<view>
								<u--image radius="10" :showLoading="true" :src="item.goodsImg" width="250rpx"
									height="210rpx"></u--image>
							</view>
							<view class="des">
								<view style="font-size: 34rpx; height: 100rpx; display: flex;">
									<view style="width: 300rpx;">
										{{item.goodsName}}
									</view>
									<view class="status" @click="cleanCart(item.id)">
										<uni-icons type="trash" color="grey" size="30"></uni-icons>
									</view>
								</view>
								<!-- <view style="font-size: 34rpx;">[老板力荐]鲜活小龙虾(帮剪头去虾线)约250g/份</view> -->
								<view class="subtit">
									<view class="price">￥{{item.totalPrice}}</view>
								</view>
								
							</view>
						</view>
					</view>
					<view class="goods-item">
						<view class="footer-item">
							<view style="margin: 15rpx 0rpx;"><button size="mini"
									:plain="true">立即购买</button></view>
						</view>
					</view>
				</view>
			</u-list-item>
		</u-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cartList: [],
			}
		},
		onLoad() {
			this.getCartList()
		},
		methods: {
			getCartList() {
				this.http.request({
					url: '/level-one-server/TbGoodsCart/getList',
					success: res => {
						this.cartList = res.data.data;
					}
				});
			},
			scrolltolower() {
				this.getCartList()
			},
			// 
			cleanCart(id) {
				this.http.request({
					url: '/level-one-server/app/TbGoodsCart/cleanCart',
					data: {id: 1460500735619366940},
					contentType: 'application/json; charset=utf-8',
					method: 'POST',
					success: res => {
						setTimeout(function() {
							uni.showToast({
								title: res.data.msg
							});
						}, 1000)
					}
				});
				console.log( id + "类型"+ typeof id)
			}
		}
	}
</script>

<style lang="scss">
	.goods-item {
		margin-bottom: 15rpx;
	}

	.good-row {
		display: flex;
		align-items: center;
	}

	.shop {
		display: flex;
		align-items: center;
		width: 480rpx;
	}

	.shop-icon {
		width: 60rpx;
		height: 60rpx;
		border-radius: 30rpx;
		background-color: #eaf1fe;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.status {
		width: 100rpx;
		display: flex;
		align-items: center;
		// justify-content: flex-end;
	}

	.des {
		margin-left: 20rpx;
		position: relative;
		top: 1rpx;
		height: 200rpx;
	}

	.subtit {
		font-size: 28rpx;
		color: #9C9C9C;
		margin: 20rpx 10rpx;
	}

	.footer-item {
		display: flex;
		justify-content: flex-end;
		margin-top: -15rpx;
		margin-bottom: 5rpx;
	}

	.price {
		font-size: 30rpx;
	}

	.item-box {
		height: 280rpx;
		width: 85%;
		padding: 30rpx;
		border: 1rpx #888 solid;
		margin: 10rpx 15rpx;
		border-radius: 10rpx;
	}
</style>