-
Notifications
You must be signed in to change notification settings - Fork 0
/
car.php
421 lines (379 loc) · 17.1 KB
/
car.php
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./lib/element-ui.css">
<link rel="stylesheet" href="./lib/element-icons.css">
<link rel="stylesheet" href="./css/index.css">
<link rel="stylesheet" href="./css/car.css">
</head>
<body>
<div id="app">
<div class="duola-top">
<div class="w">
<div class="top_main">
<el-link class="top_main_a" @click="denglu" type="info" v-if="huanying">hi~请登录</el-link>
<el-link class="top_main_a" type="info" v-else>你好,会员{{uname}}!</el-link>
<el-link class="top_main_a" @click="zhuce" type="info">注册</el-link>
</div>
</div>
</div>
<!-- 顶部 -->
<div class="w">
<div class="top">
<div class="top_left">
<img src="./images/logo.png" alt="" srcset="">
</div>
<div class="top_right">
<el-input v-model="sousuovalue" placeholder="请输入搜索商品"></el-input>
<el-dropdown @command="sousuoCommand" style="width:100px;height:38px;border-radius: 0 0 0 0;border: 1px solid #DCDFE6;padding-left: 25px;" trigger="click">
<span class="el-dropdown-link" style="text-align: center;color: #ccc;line-height: 40px;">
{{leibie}}<i class="el-icon-arrow-down el-icon--right "></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="毛绒玩具">毛绒玩具</el-dropdown-item>
<el-dropdown-item command="金属玩具">金属玩具</el-dropdown-item>
<el-dropdown-item command="塑料玩具">塑料玩具</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button style="border-radius: 0 4px 4px 0;" type="primary" icon="el-icon-search" @click="getsousuo()"></el-button>
</div>
<div class="user" v-if="xxshow">
<div class="top_car">
<el-badge :value=cartlength class="item">
<el-button size="small" icon="el-icon-shopping-cart-full" @click="gotocar()">购物车</el-button>
</el-badge>
</div>
<div>
<el-dropdown trigger="hover" placement="bottom" @command="handleCommand">
<span class="el-dropdown-link">
<!-- 下拉菜单<i class="el-icon-arrow-down el-icon--right"></i> -->
<el-avatar :src="nodengluurl"></el-avatar>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-user" command="geren">个人中心</el-dropdown-item>
<!-- <el-dropdown-item icon="el-icon-edit-outline" command="xiugai">修改密码</el-dropdown-item> -->
<el-dropdown-item icon="el-icon-switch-button" command="tuichu">退出账号</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
<!-- 修改密码
<el-dialog title="修改密码" :visible.sync="xiugaimimashow" width="30%" center>
<el-input v-model="mima" placeholder="密码"></el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="xiugaimimashow = false">取 消</el-button>
<el-button type="primary" @click="getmima()">确 定</el-button>
</span>
</el-dialog> -->
</div>
</div>
<!-- 导航栏 -->
<div class="nav">
<div class="w">
<div style="display: flex; justify-content: space-between; min-width: 1000px;">
<div class="nav-left" @click="mouseOver" @mouseleave="mouseLeave">
<span class="before">
<span class="before1"></span>
<span class="before2"></span>
<span class="before3"></span>
</span>
<span style="height: 60px;line-height: 60px;display: inline-block;vertical-align: middle;">SHOP BY CATEGORIES</span>
<div class="nav-down" v-if="xiala">
<p> <a href="./allgoods.php">毛绒玩具</a> </p>
<p> <a href="./allgoods.php">金属玩具</a> </p>
<p> <a href="./allgoods.php">塑料玩具</a> </p>
</div>
</div>
<div class="top_nav">
<el-link class="top_nav_size" href="./index.php">主页</el-link>
<el-link class="top_nav_size" href="./allgoods.php">玩具</el-link>
<el-link class="top_nav_size" href="./about.php">关于</el-link>
</div>
<div style="margin-left:70px;font-size:20px; color:#606266; font-weight: 400;">
<i class="el-icon-box"></i>
<span>注册会员免运费</span>
</div>
</div>
</div>
</div>
<!-- 购物车 -->
<div class="car">
<div class="w">
<template>
<el-table :data="cart" style="width: 100%">
<!-- <el-table-column type="selection" width="100">
</el-table-column> -->
<el-table-column prop="picture" label="商品图片" width="180">
<template slot-scope="scope">
<img :src="scope.row.picture" alt="" style="height: 100px;">
</template>
</el-table-column>
<el-table-column label="商品名称" prop="goods_name" label="ID">
</el-table-column>
<el-table-column prop="price" label="单价" width="120">
</el-table-column>
<el-table-column prop="nums" label="数量" width="170">
<!-- <template slot-scope="scope">
<el-input-number size="small" v-model="num" @change="Changenum" :min=1 :max="10000"></el-input-number>
</template> -->
</el-table-column>
<el-table-column label="操作" width="120">
<template slot-scope="scope">
<el-button size="mini" type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
</template>
<div style="float: right;margin-top:20px">
<el-button type="success" @click="getorders()">结算</el-button>
</div>
</div>
</div>
<!-- 底部版权 -->
<div class="foot-box">
<div class="foot-top">
<div class="foot-ul">
<ul>
<li class="ft-1">严格准入标准</li>
<li class="ft-2">七天无理由退货</li>
<li class="ft-3">15天免费换货</li>
<li class="ft-4">全场包邮</li>
</ul>
</div>
</div>
<div class="foot-bottom">
<div class="foot-left">
<div class="lt">
售后服务电话 :
<a href="javascript:;">400-3320050225</a>
<span>(周一至周五9:00-18:00)</span>
</div>
<div class="lb">
<span>©2021信管二班</span>
<a href="javascript:;">使用前必读</a>
<a href="javascript:;">关于我们</a>
<a href="javascript:;">服务条款</a>
<a href="javascript:;">意见反馈</a>
<a href="javascript:;">售后政策</a>
<a href="javascript:;">合作咨询</a>
</div>
</div>
<div class="foot-right">
<div class="content-info">
<div class="info-right">
<img src="./images/wx.jpg" alt="">
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="./lib/vue.js"></script>
<script src="./lib/vue-resource.min.js"></script>
<script src="./lib/element-ui.js"></script>
<script src="./lib/jquery-3.5.1.min.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
leibie: "选择类别",
uname:"",
xiugaimimashow: false, //修改密码弹出框
nodengluurl: "./images/nodenglu.jpg", //登录图片
xxshow: false,
cart: [], //购物车数据
cartlength: 0,
huanying: true,
num: 1, //数量
carts: "",
multipleSelection: [], //选择的id
sousuovalue: "", //搜索
userid: "", //userid
xiala: false,
},
mounted() {
this.getshow()
this.getuser()
this.getcar()
// this.getGoods()
},
methods: {
sousuoCommand(command) {
switch (command) {
case "毛绒玩具":
this.leibie = "毛绒玩具"
break;
case "金属玩具":
this.leibie = "金属玩具"
break;
case "塑料玩具":
this.leibie = "塑料玩具"
break;
default:
break;
}
},
// 搜索
getsousuo: function() {
if (this.sousuovalue == "") {
this.$message({
message: '请输入搜索的商品名!',
type: 'warning'
});
} else {
var param = encodeURI(encodeURI(this.sousuovalue));
window.location.href = './allgoods.php?key='+ param
}
},
getshow() {
var lastname = localStorage.getItem("xxshow");
this.userid = localStorage.getItem("userid");
console.log(this.userid, 'ssssssss');
if (this.userid != null) {
this.xxshow = true
console.log(this.xxshow);
this.huanying = false
} else {
this.xxshow = false
console.log(this.xxshow);
}
},
// 获取购物车
// getcar: function() {
// this.$http.post('./getcar.php', {
// userid: this.userid
// }, {
// emulateJSON: true
// }).then(response => {
// var cartObj = eval("(" + response.bodyText + ")");
// // this.cart = cartObj
// this.cartlength = cartObj.length
// console.log(this.cartlength, '[ this.cartlength ] >')
// }, function() {
// console.log('获取商品请求失败处理');
// });
// },
// 下拉菜单操作
handleCommand(command) {
console.log(command, 'command');
switch (command) {
case 'geren':
window.location.href = "./my.php";
break;
case 'xiugai':
this.xiugaimimashow = true
break;
case 'tuichu':
localStorage.removeItem("userid");
console.log("清除缓存");
this.$message({
message: '退出账号成功!',
type: 'success'
});
setTimeout(function() {
location.reload()
}, 1200);
break;
default:
break;
}
},
Changenum: function(el) {
console.log('[ ] >', el)
this.num = el
},
//获取user
getuser: function() {
this.userid = localStorage.getItem("userid");
this.$http.post('./getuser.php', {
id: this.userid
}, {
emulateJSON: true
}).then(response => {
var userObj = eval("(" + response.bodyText + ")");
for (let i = 0; i < userObj.length; i++) {
this.uname = userObj[i].uname;
}
console.log(this.uname, '[ this.user] >')
}, function() {
console.log('获取user请求失败处理');
});
},
// 获取购物车
getcar: function() {
this.$http.post('./getcar.php', {
userid: this.userid
}, {
emulateJSON: true
}).then(response => {
var cartObj = eval("(" + response.bodyText + ")");
this.cart = cartObj
console.log(this.cart, '[ this.cart ] >')
this.cartlength = cartObj.length
for (var i = 0; i < cartObj.length; i++) {
this.carts = cartObj[i]; //数组的索引是从0开始的
console.log(this.carts); //把取出的值打印在控制台上
console.log(this.carts.nums, 'carts')
}
this.num = this.carts.nums
}, function() {
console.log('获取购物车商品请求失败处理');
});
},
mouseOver: function() {
this.xiala = true
},
mouseLeave: function() {
this.xiala = false
},
// 删除购物车商品
handleDelete: function(val) {
console.log('[ ] >', val)
this.$http.post('./delcargoods.php', {
id: val
}, {
emulateJSON: true
}).then(response => {
if (response.body == 1) {
this.$message({
message: '删除成功!',
type: 'success'
});
setTimeout(function() {
location.reload()
}, 1200);
} else {
this.$message({
message: '删除失败!',
type: 'warning'
});
}
}, function() {
console.log(' 删除购物车商请求失败处理');
});
},
// 结算
getorders: function() {
window.location.href = "./orders.php";
},
// 购物车
gotocar: function() {
window.location.href = "./car.php";
},
//登录跳转
denglu: function() {
window.location.href = "./login.php";
},
// 注册跳转
zhuce: function() {
window.location.href = "./register.php";
},
}
})
</script>
</html>