cartbox.vue
4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<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>