cartbox.vue 4.2 KB
<template>
	<view class="content">
		<view class="sureshop">
			
			
			</view>
			<!-- 面坊商品 -->
			<view>
				<view class="sureorderbox flexone" @click="mianfang">
					<view class="sureimg">
						<image src="../../static/nearshop.png" mode=""></image>
					</view>
					<view class="sureshopname">面坊商品</view>
				</view>
				<view class='cartlist'>
					<view class="sureorderitem flexone" v-for="(item,index) in data2" :key="index">
						<view class="cartselimg" @click="selectcart(item)">
							<image src="../../static/cartnosel.png" mode="" v-if="item.sel==false"></image>
							<image src="../../static/cartsel.png" mode="" v-else></image>
						</view>
						<view class="sureorderitemleft">
							<image :src="item.flour_goods.flour_goods_spec.spec_image" mode=""></image>
						</view>
						<view class='shuright'>
							<view class="suregoodname">{{item.flour_goods.name}}{{item.sel}}
							</view>
							<view class="surebot flextwo">
								<view class="saleprice">¥{{item.flour_goods.price}}</view>
								<view class="weightnumk flexone">
									<view class="weightnumkleft leftk" @click="reducecart(item)">
										<image src="../../static/reduceimg.png" mode=""></image>
									</view>
									<view class="detailnum">{{item.number}}</view>
									<view class="weightnumkleft rightk" @click='addcart(item)'>
										<image src="../../static/addimg.png" mode=""></image>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			
		
		
		
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				data1: [], //店铺商品

				data3: [], //积分商品
				selall: false,
				sel: false,
				data2: [{
					"id": 12,
					"type": "1",
					"store_id": null,
					"goods_id": 2,
					"user_id": 5,
					"spec_sku_id": "",
					"number": 2,
					"createtime": 1586225601,
					"flour_goods": {
						"id": 2,
						"name": "商品名称(单规格)",
						"image": "http://zhongmian.w.brotop.cn",
						"images": null,
						"content": "详细描述详细描述",
						"spec_type": "1",
						"sales_initial": 20,
						"sales_actual": 0,
						"weigh": 2,
						"publishtime": 1584694198,
						"createtime": 1584694198,
						"updatetime": 1584694198,
						"status": "1",
						"is_seckill": "2",
						"is_sales": "2",
						"is_distribution": "2",
						"sales": 20,
						"flour_goods_spec": {
							"id": 5,
							"flour_goods_id": 2,
							"goods_no": "CH-56",
							"goods_price": "5.00",
							"seckill_price": "3.00",
							"stock_num": 20,
							"goods_sales": 0,
							"spec_sku_id": null,
							"spec_image": "http://zhongmian.w.brotop.cn",
							"createtime": 0,
							"updatetime": 0
						},
						"goods_price": "5.00",
						"seckill_price": "3.00",
						"spec": [],
						"price": "5.00"
					},
					"sel": 0
				}]
			}
		},

		methods: {
	//面坊商品选择购物车
			selectcart(item) {
				let that = this
				if (item.type == 2) {
					let newdata=that.data3
					newdata.forEach(function(value, index, array) {
						if (value.id == item.id) {
							value.sel =!value.sel
							
						}
					})
					console.log(newdata)
					that.data3 = newdata
				}else if(item.type==1){
					
					let newdata=that.data2
					newdata.forEach(function(value, index, array) {
						if (value.id == item.id) {
							value.sel =!value.sel
							
						}
					})
					that.data2 = newdata;
				}

			},
		}

	}
</script>

<style>
	@import url('../../base/nearshop');
	@import url('../../base/homepage');

	page {
		background: #F8F6F9;
	}

	.cartlist {
		/* padding-bottom: 120rpx; */
	}

	.cartselimg {
		width: 30rpx;
		height: 30rpx;
		font-size: 0;
		margin-right: 30rpx;
		flex: 0 0 auto;
	}

	.sureorderitem {
		padding-bottom: 30rpx;
		box-sizing: border-box;
	}

	.cartbottom {
		width: 750rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		padding: 38rpx 32rpx;
		box-sizing: border-box;
		background: #fff;
	}

	.totalnum {
		color: #3D454C;
		font-size: 28rpx;
		/* margin-left:12rpx; */
	}

	.totalmoney {
		color: #E26335;
		font-size: 28rpx;
		/* margin-left:12rpx; */
	}

	.jiesuan {
		width: 280rpx;
		height: 88rpx;
		background: rgba(194, 148, 69, 1);
		border-radius: 16rpx;
		color: #fff;
		font-size: 28rpx;
		text-align: center;
		line-height: 88rpx;
	}
</style>