Skip to content

Commit

Permalink
add cart list
Browse files Browse the repository at this point in the history
  • Loading branch information
stark committed Oct 9, 2017
1 parent 209eb87 commit 31609d8
Show file tree
Hide file tree
Showing 8 changed files with 403 additions and 4 deletions.
5 changes: 5 additions & 0 deletions client/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Hello from '@/components/Hello'
import GoodsList from '@/view/GoodsList'
import User from '@/view/user/index'
import Cart from '@/view/cart'
import Address from '@/view/address'

Vue.use(Router)

Expand All @@ -17,6 +18,10 @@ export default new Router({
path: '/cart', //?代表可写,也可以不写 /user/1
component: Cart
},
{
path: '/address',
component: Address
},
{
path: '/user/:stark?/:xiaorong?', //?代表可写,也可以不写 /user/1
component: User
Expand Down
165 changes: 165 additions & 0 deletions client/src/view/Address.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<template>
<div>
<head-nav/>

<div class="checkout-page">
<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-add" viewBox="0 0 31 32">
<title>add</title>
<path class="path1" d="M30.745 15.152h-14.382v-14.596c0-0.308-0.243-0.557-0.543-0.557s-0.543 0.249-0.543 0.557v14.596h-14.665c-0.3 0-0.543 0.249-0.543 0.557s0.243 0.557 0.543 0.557h14.665v15.177c0 0.307 0.243 0.557 0.543 0.557s0.543-0.249 0.543-0.557v-15.177h14.382c0.3 0 0.543-0.249 0.543-0.557s-0.243-0.557-0.543-0.557z"></path>
</symbol>
<symbol id="icon-ok" viewBox="0 0 32 32">
<title>ok</title>
<path class="path1" d="M14.084 20.656l-7.845-9.282c-1.288-1.482-3.534-1.639-5.016-0.351s-1.639 3.534-0.351 5.016l10.697 12.306c1.451 1.669 4.057 1.623 5.448-0.096l18.168-22.456c1.235-1.527 0.999-3.765-0.528-5.001s-3.765-0.999-5.001 0.528l-15.573 19.337z"></path>
</symbol>
<symbol id="icon-edit" viewBox="0 0 32 32">
<title>edit</title>
<path class="path1" d="M28.287 8.51l-4.805-4.806 0.831-0.831c0.472-0.472 1.086-0.777 1.564-0.777 0.248 0 0.452 0.082 0.622 0.253l3.143 3.144c0.539 0.54 0.133 1.529-0.524 2.186l-0.831 0.831zM26.805 9.992l-1.138 1.138-4.805-4.806 1.138-1.138 4.805 4.806zM24.186 12.612l-14.758 14.762-4.805-4.806 14.758-14.762 4.805 4.806zM7.379 28.288l-4.892 1.224 1.223-4.894 3.669 3.67zM31.123 4.011l-3.143-3.144c-0.567-0.567-1.294-0.867-2.103-0.867-1.036 0-2.174 0.52-3.045 1.391l-20.429 20.436c-0.135 0.134-0.23 0.302-0.276 0.487l-2.095 8.385c-0.089 0.355 0.017 0.736 0.276 0.995 0.198 0.198 0.461 0.307 0.741 0.307 0.085 0 0.171-0.010 0.254-0.031l8.381-2.096c0.185-0.047 0.354-0.142 0.487-0.276l20.43-20.436c1.409-1.41 2.042-3.632 0.524-5.15v0z"></path>
</symbol>
<symbol id="icon-del" viewBox="0 0 32 32">
<title>delete</title>
<path class="path1" d="M11.355 4.129v-2.065h9.29v2.065h-9.29zM6.194 29.935v-23.742h19.613v23.742h-19.613zM30.968 4.129h-8.258v-3.097c0-0.569-0.463-1.032-1.032-1.032h-11.355c-0.569 0-1.032 0.463-1.032 1.032v3.097h-8.258c-0.569 0-1.032 0.463-1.032 1.032s0.463 1.032 1.032 1.032h3.097v24.774c0 0.569 0.463 1.032 1.032 1.032h21.677c0.569 0 1.032-0.463 1.032-1.032v-24.774h3.097c0.569 0 1.032-0.463 1.032-1.032s-0.463-1.032-1.032-1.032v0z"></path>
<path class="path2" d="M10.323 9.806c-0.569 0-1.032 0.463-1.032 1.032v14.452c0 0.569 0.463 1.032 1.032 1.032s1.032-0.463 1.032-1.032v-14.452c0-0.569-0.463-1.032-1.032-1.032z"></path>
<path class="path3" d="M16 9.806c-0.569 0-1.032 0.463-1.032 1.032v14.452c0 0.569 0.463 1.032 1.032 1.032s1.032-0.463 1.032-1.032v-14.452c0-0.569-0.463-1.032-1.032-1.032z"></path>
<path class="path4" d="M21.677 9.806c-0.569 0-1.032 0.463-1.032 1.032v14.452c0 0.569 0.463 1.032 1.032 1.032s1.032-0.463 1.032-1.032v-14.452c0-0.569-0.463-1.032-1.032-1.032z"></path>
</symbol>
<symbol id="icon-clock" viewBox="0 0 32 32">
<title>clock</title>
<path class="path1" d="M29.333 16c0-7.364-5.97-13.333-13.333-13.333s-13.333 5.97-13.333 13.333c0 7.364 5.97 13.333 13.333 13.333s13.333-5.97 13.333-13.333v0 0 0 0 0 0zM0 16c0-8.837 7.163-16 16-16s16 7.163 16 16c0 8.837-7.163 16-16 16s-16-7.163-16-16zM14.667 14.667v1.333h2.667v-10.667h-2.667v9.333zM24 18.667h1.333v-2.667h-10.667v2.667h9.333z"></path>
</symbol>
<symbol id="icon-question" viewBox="0 0 32 32">
<title>question</title>
<path class="path1" d="M16 2.56c7.411 0 13.44 6.029 13.44 13.44s-6.029 13.44-13.44 13.44c-7.411 0-13.44-6.029-13.44-13.44s6.029-13.44 13.44-13.44zM16 0c-8.822 0-16 7.178-16 16s7.178 16 16 16c8.822 0 16-7.178 16-16s-7.178-16-16-16z"></path>
<path class="path2" d="M16 22.080c-1.059 0-1.92 0.861-1.92 1.92s0.861 1.92 1.92 1.92c1.059 0 1.92-0.861 1.92-1.92s-0.861-1.92-1.92-1.92z"></path>
<path class="path3" d="M12.16 12.48c0.706 0 1.28-0.574 1.28-1.28 0-1.412 1.148-2.56 2.56-2.56s2.56 1.148 2.56 2.56c0 1.412-1.148 2.56-2.56 2.56-0.706 0-1.28 0.574-1.28 1.28v3.84c0 0.706 0.574 1.28 1.28 1.28s1.28-0.574 1.28-1.28v-2.723c2.224-0.575 3.84-2.616 3.84-4.957 0-2.823-2.297-5.12-5.12-5.12s-5.12 2.297-5.12 5.12c0 0.706 0.574 1.28 1.28 1.28z"></path>
</symbol>
</defs>
</svg>
<div class="container">
<div class="checkout-addr">
<div class="page-title-normal">
<h2 class="page-title-h2"><span>check out</span></h2>
</div>
<!-- process step -->
<div class="check-step">
<ul>
<li class="cur"><span>Confirm</span> address</li>
<li><span>View your</span> order</li>
<li><span>Make</span> payment</li>
<li><span>Order</span> confirmation</li>
</ul>
</div>

<!-- address list -->
<div class="page-title-normal checkout-title">
<h2><span>Shipping address</span></h2>
</div>
<div class="addr-list-wrap">
<div class="addr-list">
<ul>


<li v-for="(item,index) in addressList" :key="index">
<dl>
<dt>{{item.userName}}</dt>
<dd class="address">{{item.streetName}}</dd>
<dd class="tel">{{item.tel}}</dd>
</dl>
<div class="addr-opration addr-del">
<a href="javascript:;" class="addr-del-btn">
<svg class="icon icon-del"><use xlink:href="#icon-del"></use></svg>
</a>
</div>
<div class="addr-opration addr-set-default">
<a href="javascript:;" class="addr-set-default-btn"><i>Set default</i></a>
</div>
<div class="addr-opration addr-default">Default address</div>
</li>



<li class="addr-new">
<div class="add-new-inner">
<i class="icon-add">
<svg class="icon icon-add"><use xlink:href="#icon-add"></use></svg>
</i>
<p>Add new address</p>
</div>
</li>
</ul>
</div>

<div class="shipping-addr-more">
<a class="addr-more-btn up-down-btn" href="javascript:;">
more
<i class="i-up-down">
<i class="i-up-down-l"></i>
<i class="i-up-down-r"></i>
</i>
</a>
</div>
</div>

<!-- shipping method-->
<div class="page-title-normal checkout-title">
<h2><span>Shipping method</span></h2>
</div>
<div class="lemall-msg-info hidden">
<span>The region you selected is not within our delivery area. Please select another shipping address within our delivery areas.</span>
</div>
<div class="shipping-method-wrap">
<div class="shipping-method">
<ul>
<li class="check">
<div class="name">Standard shipping</div>
<div class="price">Free</div>
<div class="shipping-tips">
<p>Once shipped,Order should arrive in the destination in 1-7 business days</p>
</div>
</li>
</ul>
</div>
</div>
<div class="next-btn-wrap">
<a class="btn btn--m btn--red">Next</a>
</div>
</div>
</div>
</div>
<footer-nav/>
</div>
</template>
<script>
import HeadNav from '@/components/Head'
import NavBread from '@/components/NavBread'
import FooterNav from '@/components/Footer'
import Modal from '@/components/Modal'
export default {
data(){
return{
addressList:[]
}
},
mounted(){
this.init();
},
methods:{
init(){
this.$http.get('/users/addressList').then((result) =>{
let res = result.data;
console.log(res);
this.addressList = res.result;
} )
}
},
components:{
HeadNav,
NavBread,
FooterNav,
Modal
},
}
</script>

79 changes: 75 additions & 4 deletions client/src/view/Cart.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
<template>
<div>
<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-add" viewBox="0 0 32 32">
<title>add2</title>
<path class="path1"
d="M15 17h-13.664c-0.554 0-1.002-0.446-1.002-1 0-0.552 0.452-1 1.002-1h13.664v-13.664c0-0.554 0.446-1.002 1-1.002 0.552 0 1 0.452 1 1.002v13.664h13.664c0.554 0 1.002 0.446 1.002 1 0 0.552-0.452 1-1.002 1h-13.664v13.664c0 0.554-0.446 1.002-1 1.002-0.552 0-1-0.452-1-1.002v-13.664z"></path>
</symbol>
<symbol id="icon-ok" viewBox="0 0 32 32">
<title>ok</title>
<path class="path1"
d="M31.020 0.438c-0.512-0.363-1.135-0.507-1.757-0.406s-1.166 0.435-1.529 0.937l-17.965 24.679-5.753-5.67c-0.445-0.438-1.035-0.679-1.664-0.679s-1.219 0.241-1.664 0.679c-0.917 0.904-0.917 2.375 0 3.279l7.712 7.6c0.438 0.432 1.045 0.681 1.665 0.681l0.195-0.008c0.688-0.057 1.314-0.406 1.717-0.959l19.582-26.9c0.754-1.038 0.512-2.488-0.538-3.233z"></path>
</symbol>
<symbol id="icon-edit" viewBox="0 0 32 32">
<title>edit</title>
<path class="path1"
d="M28.287 8.51l-4.805-4.806 0.831-0.831c0.472-0.472 1.086-0.777 1.564-0.777 0.248 0 0.452 0.082 0.622 0.253l3.143 3.144c0.539 0.54 0.133 1.529-0.524 2.186l-0.831 0.831zM26.805 9.992l-1.138 1.138-4.805-4.806 1.138-1.138 4.805 4.806zM24.186 12.612l-14.758 14.762-4.805-4.806 14.758-14.762 4.805 4.806zM7.379 28.288l-4.892 1.224 1.223-4.894 3.669 3.67zM31.123 4.011l-3.143-3.144c-0.567-0.567-1.294-0.867-2.103-0.867-1.036 0-2.174 0.52-3.045 1.391l-20.429 20.436c-0.135 0.134-0.23 0.302-0.276 0.487l-2.095 8.385c-0.089 0.355 0.017 0.736 0.276 0.995 0.198 0.198 0.461 0.307 0.741 0.307 0.085 0 0.171-0.010 0.254-0.031l8.381-2.096c0.185-0.047 0.354-0.142 0.487-0.276l20.43-20.436c1.409-1.41 2.042-3.632 0.524-5.15v0z"></path>
</symbol>
<symbol id="icon-del" viewBox="0 0 32 32">
<title>delete</title>
<path class="path1"
d="M11.355 4.129v-2.065h9.29v2.065h-9.29zM6.194 29.935v-23.742h19.613v23.742h-19.613zM30.968 4.129h-8.258v-3.097c0-0.569-0.463-1.032-1.032-1.032h-11.355c-0.569 0-1.032 0.463-1.032 1.032v3.097h-8.258c-0.569 0-1.032 0.463-1.032 1.032s0.463 1.032 1.032 1.032h3.097v24.774c0 0.569 0.463 1.032 1.032 1.032h21.677c0.569 0 1.032-0.463 1.032-1.032v-24.774h3.097c0.569 0 1.032-0.463 1.032-1.032s-0.463-1.032-1.032-1.032v0z"></path>
<path class="path2"
d="M10.323 9.806c-0.569 0-1.032 0.463-1.032 1.032v14.452c0 0.569 0.463 1.032 1.032 1.032s1.032-0.463 1.032-1.032v-14.452c0-0.569-0.463-1.032-1.032-1.032z"></path>
<path class="path3"
d="M16 9.806c-0.569 0-1.032 0.463-1.032 1.032v14.452c0 0.569 0.463 1.032 1.032 1.032s1.032-0.463 1.032-1.032v-14.452c0-0.569-0.463-1.032-1.032-1.032z"></path>
<path class="path4"
d="M21.677 9.806c-0.569 0-1.032 0.463-1.032 1.032v14.452c0 0.569 0.463 1.032 1.032 1.032s1.032-0.463 1.032-1.032v-14.452c0-0.569-0.463-1.032-1.032-1.032z"></path>
</symbol>
<symbol id="icon-clock" viewBox="0 0 32 32">
<title>clock</title>
<path class="path1" fill="#605f5f"
d="M16 29c-7.168 0-13-5.831-13-13s5.832-13 13-13c7.168 0 13 5.832 13 13s-5.832 13-13 13zM16 0c-8.822 0-16 7.178-16 16s7.178 16 16 16c8.822 0 16-7.178 16-16s-7.178-16-16-16z"></path>
<path class="path2" fill="#605f5f"
d="M23.958 21.837l-6.958-6.489v-6.282c0-0.827-0.673-1.5-1.5-1.5s-1.5 0.673-1.5 1.5v6.934c0 0.414 0.174 0.814 0.477 1.098l7.435 6.934c0.279 0.259 0.642 0.402 1.023 0.402 0.415 0 0.814-0.174 1.096-0.477 0.564-0.605 0.532-1.555-0.073-2.12z"></path>
</symbol>
</defs>
</svg>
<head-nav/>
<nav-bread> <span>购物车列表</span></nav-bread>
<div class="container">
Expand Down Expand Up @@ -54,7 +91,7 @@
</div>
<div class="cart-tab-5">
<div class="cart-item-opration">
<a href="javascript:;" class="item-edit-btn">
<a href="javascript:;" class="item-edit-btn" @click="delCartConfirm(item.productId)">
<svg class="icon icon-del">
<use xlink:href="#icon-del"></use>
</svg>
Expand Down Expand Up @@ -82,14 +119,23 @@
Item total: <span class="total-price">{{totalPrice}}</span>
</div>
<div class="btn-wrap">
<a class="btn btn--red">Checkout</a>
<a class="btn btn--red" @click="checkOut">结账</a>
</div>
</div>
</div>
</div>
</div>
</div>
<footer-nav/>
<modal :mdShow="modalConfirm">
<a href="" slot="message">
你确要删除这个商品吗?
</a>
<div slot="btnGroup">
<a href="javascript:;" class="btn btn--m" @click="delCart">确定</a>
<a href="javascript:;" class="btn btn--m" @click="modalConfirm = false">关闭</a>
</div>
</modal>
</div>
</template>
<script>
Expand All @@ -102,7 +148,9 @@ export default {
data(){
return{
cartList:'',
checked:''
checked:'',
modalConfirm:false,
productId:''
}
},
computed:{
Expand Down Expand Up @@ -166,6 +214,20 @@ export default {
let res = result.data.result;
})
},
delCartConfirm(productId){
this.modalConfirm = true;
this.productId = productId;
},
delCart(){
this.$http.post('/users/cartDel',{
productId:this.productId
}).then((res)=>{
// 模态框关闭
this.modalConfirm = false;
// 重新渲染
this.getCarList();
})
},
toggleCheckAll(){
let flag = !this.checkAllFlag;
this.cartList.forEach((item)=>{
Expand All @@ -178,7 +240,16 @@ export default {
let res = response.data;
})
}
},
checkOut(){
if(this.checkedCount > 0){
this.$router.push({
path:"/address"
})
}else{
alert('购物车,必须有选中的商品!')
}
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions note/01.技术栈.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,29 @@ docker
五天就放假了
十一回来五天

购物车删除
地址
订单

周三,周四
上线(操作性挺强)
需要每个人买一台服务器
ubuntu
centos
搭建
mongodb
nodejs
vuejs

docker

vuex 周二

讲一下简历 周五
项目方面
工作流程

模拟面试
面试题串讲


Loading

0 comments on commit 31609d8

Please sign in to comment.