1+ <script setup>
2+ import { useCartStore } from ' @/stores/cartStore' ;
3+ const cartStore = useCartStore ()
4+
5+ const cartList = cartStore .cartList
6+ </script >
7+
8+ <template >
9+ <div class =" xtx-cart-page" >
10+ <div class =" container m-top-20" >
11+ <div class =" cart" >
12+ <table >
13+ <thead >
14+ <tr >
15+ <th width =" 120" >
16+ <el-checkbox />
17+ </th >
18+ <th width =" 400" >商品信息</th >
19+ <th width =" 220" >单价</th >
20+ <th width =" 180" >数量</th >
21+ <th width =" 180" >小计</th >
22+ <th width =" 140" >操作</th >
23+ </tr >
24+ </thead >
25+ <!-- 商品列表 -->
26+ <tbody >
27+ <tr v-for =" i in cartStore.cartList" :key =" i.id" >
28+ <td >
29+ <el-checkbox />
30+ </td >
31+ <td >
32+ <div class =" goods" >
33+ <RouterLink to =" /" >
34+ <img :src =" i.picture" alt =" " />
35+ </RouterLink >
36+ <div >
37+ <p class =" name ellipsis" >
38+ {{ i.name }}
39+ </p >
40+ </div >
41+ </div >
42+ </td >
43+ <td class =" tc" >
44+ <p >¥{{ i.price }}</p >
45+ </td >
46+ <td class =" tc" >
47+ <el-input-number v-model =" i.count" />
48+ </td >
49+ <td class =" tc" >
50+ <p class =" f16 red" >¥{{ (i.price * i.count).toFixed(2) }}</p >
51+ </td >
52+ <td class =" tc" >
53+ <p >
54+ <el-popconfirm title =" 确认删除吗?" confirm-button-text =" 确认" cancel-button-text =" 取消"
55+ @confirm =" delCart(i)" >
56+ <template #reference >
57+ <a href =" javascript:;" >删除</a >
58+ </template >
59+ </el-popconfirm >
60+ </p >
61+ </td >
62+ </tr >
63+ <tr v-if =" cartStore.cartList.length === 0" >
64+ <td colspan =" 6" >
65+ <div class =" cart-none" >
66+ <el-empty description =" 购物车列表为空" >
67+ <el-button type =" primary" >随便逛逛</el-button >
68+ </el-empty >
69+ </div >
70+ </td >
71+ </tr >
72+ </tbody >
73+ </table >
74+ </div >
75+ <!-- 操作栏 -->
76+ <div class =" action" >
77+ <div class =" batch" >
78+ 共 10 件商品,已选择 2 件,商品合计:
79+ <span class =" red" >¥ 200.00 </span >
80+ </div >
81+ <div class =" total" >
82+ <el-button size =" large" type =" primary" >下单结算</el-button >
83+ </div >
84+ </div >
85+ </div >
86+ </div >
87+ </template >
88+
89+ <style scoped lang="scss">
90+ .xtx-cart-page {
91+ margin-top : 20px ;
92+
93+ .cart {
94+ background : #fff ;
95+ color : #666 ;
96+
97+ table {
98+ border-spacing : 0 ;
99+ border-collapse : collapse ;
100+ line-height : 24px ;
101+
102+ th ,
103+ td {
104+ padding : 10px ;
105+ border-bottom : 1px solid #f5f5f5 ;
106+
107+ & :first-child {
108+ text-align : left ;
109+ padding-left : 30px ;
110+ color : #999 ;
111+ }
112+ }
113+
114+ th {
115+ font-size : 16px ;
116+ font-weight : normal ;
117+ line-height : 50px ;
118+ }
119+ }
120+ }
121+
122+ .cart-none {
123+ text-align : center ;
124+ padding : 120px 0 ;
125+ background : #fff ;
126+
127+ p {
128+ color : #999 ;
129+ padding : 20px 0 ;
130+ }
131+ }
132+
133+ .tc {
134+ text-align : center ;
135+
136+ a {
137+ color : $xtxColor ;
138+ }
139+
140+ .xtx-numbox {
141+ margin : 0 auto ;
142+ width : 120px ;
143+ }
144+ }
145+
146+ .red {
147+ color : $priceColor ;
148+ }
149+
150+ .green {
151+ color : $xtxColor ;
152+ }
153+
154+ .f16 {
155+ font-size : 16px ;
156+ }
157+
158+ .goods {
159+ display : flex ;
160+ align-items : center ;
161+
162+ img {
163+ width : 100px ;
164+ height : 100px ;
165+ }
166+
167+ >div {
168+ width : 280px ;
169+ font-size : 16px ;
170+ padding-left : 10px ;
171+
172+ .attr {
173+ font-size : 14px ;
174+ color : #999 ;
175+ }
176+ }
177+ }
178+
179+ .action {
180+ display : flex ;
181+ background : #fff ;
182+ margin-top : 20px ;
183+ height : 80px ;
184+ align-items : center ;
185+ font-size : 16px ;
186+ justify-content : space-between ;
187+ padding : 0 30px ;
188+
189+ .xtx-checkbox {
190+ color : #999 ;
191+ }
192+
193+ .batch {
194+ a {
195+ margin-left : 20px ;
196+ }
197+ }
198+
199+ .red {
200+ font-size : 18px ;
201+ margin-right : 20px ;
202+ font-weight : bold ;
203+ }
204+ }
205+
206+ .tit {
207+ color : #666 ;
208+ font-size : 16px ;
209+ font-weight : normal ;
210+ line-height : 50px ;
211+ }
212+ }
213+ </style >
0 commit comments