Skip to content

Commit

Permalink
购物车 订单结算
Browse files Browse the repository at this point in the history
  • Loading branch information
chaijiamei committed Jun 13, 2018
1 parent 8232951 commit 15d2612
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 70 deletions.
14 changes: 13 additions & 1 deletion src/api/goods.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const addressDel = (params) => {
}
// 生成订单
export const submitOrder = (params) => {
return http.fetchPost('/member/addOrder', params)
return http.fetchPost('/terminalStatusMgr/addOrderAndOrderItem', params)
}
// 支付
export const payMent = (params) => {
Expand Down Expand Up @@ -101,3 +101,15 @@ export const getAddressList = (params) => {
export const addAddress = (params) => {
return http.fetchPost('/address/addAddress', params)
}
// 修改收货地址
export const modifyAddress = (params) => {
return http.fetchPost('/address/modifyAddress', params)
}
// 删除收货地址
export const deleteAddress = (params) => {
return http.fetchPost('/address/deleteAddress', params)
}
// 获取订单列表
export const getOrderList = (params) => {
return http.fetchPost('/terminalStatusMgr/queryOrderList', params)
}
3 changes: 1 addition & 2 deletions src/common/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@
let cartParams = {
cartDto :{
/*userId: getStore('userId')*/
userId: '1'
userId: getStore('userId')
}
}
getCartList(cartParams).then(res => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/mallGoods.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
cartDto :{
goodsNum: 1,
goodsId:'2018060201',
userId:'1',
userName:getStore('userId')
userId:getStore('userId'),
userName:getStore('userName')
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/page/Cart/cart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
let newChecked = checked === '1' ? '0' : '1'
let cartParams = {
cartDto : {
userId: '1',
userId: getStore('userId'),
goodsId: '2018060202',
goodsNum: goodsNum,
checked: newChecked
Expand All @@ -241,8 +241,7 @@
let cartParams = {
cartDto : {
/* userId: getStore('orgCode')*/
userId: '1',
userId: getStore('userId'),
goodsId: '2018060202',
goodsNum: goodsNum,
checked: checked
Expand All @@ -254,8 +253,8 @@
cartdel (goodsId) {
let cartDelParams = {
cartDto : {
userId: '1',
goodsId: '2018060201'
userId: getStore('userId'),
goodsId: goodsId
}
}
cartDel(cartDelParams).then(res => {
Expand Down
133 changes: 88 additions & 45 deletions src/page/Checkout/checkout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:key="i"
class="address pr"
:class="{checked:addressId === item.addressId}"
@click="chooseAddress(item.addressId, item.userName, item.tel, item.streetName)">
@click="chooseAddress(item.addressId, item.addressName, item.addressPhone, item.addressDetail)">
<span v-if="addressId === item.addressId" class="pa">
<svg viewBox="0 0 1473 1024" width="17.34375" height="12">
<path
Expand All @@ -27,7 +27,7 @@
<p>手机号码: {{item.addressPhone}}</p>
<div class="operation-section">
<span class="update-btn" style="font-size:12px" @click="update(item)">修改</span>
<span class="delete-btn" style="font-size:12px" :data-id="item.addressId" @click="del(item.addressId)">删除</span>
<span class="delete-btn" style="font-size:12px" :data-id="item.addressId" @click="del(item)">删除</span>
</div>
</li>

Expand Down Expand Up @@ -101,7 +101,7 @@
:classStyle="submit?'disabled-btn':'main-btn'"
style="margin: 0;width: 130px;height: 50px;line-height: 50px;font-size: 16px"
:text="submitOrder"
@btnClick="_submitOrder">
@btnClick="_submitOrder()">
</y-button>
</div>
</div>
Expand All @@ -127,7 +127,7 @@
<y-button text='保存'
class="btn"
:classStyle="btnHighlight?'main-btn':'disabled-btn'"
@btnClick="saveAddress({userId:userId,userName:msg.userName,tel:msg.tel,streetName:msg.streetName,isDefault:msg.isDefault})">
@btnClick="saveAddress({addressId:msg.addressId,userId:userId,userName:msg.userName,tel:msg.tel,streetName:msg.streetName,isDefault:msg.isDefault})">
</y-button>
</div>
</y-popup>
Expand All @@ -136,7 +136,7 @@
</div>
</template>
<script>
import { getCartList, productDet, submitOrder, addAddress, getAddressList } from '/api/goods'
import { getCartList, productDet, submitOrder, addAddress, getAddressList, modifyAddress, deleteAddress } from '/api/goods'
import YShelf from '/components/shelf'
import YButton from '/components/YButton'
import YPopup from '/components/popup'
Expand Down Expand Up @@ -247,7 +247,7 @@
_submitOrder () {
this.submitOrder = '提交订单中...'
this.submit = true
var array = []
if (this.addressId === '0') {
this.message('请选择收货地址')
this.submitOrder = '提交订单'
Expand All @@ -260,48 +260,65 @@
this.submit = false
return
}
var orderItems = []
for (var i = 0; i < this.cartList.length; i++) {
if (this.cartList[i].checked === '1') {
array.push(this.cartList[i])
}
var orderItem = new Object();
if (this.cartList[i].checked === '1') {
orderItem.goodsId = this.cartList[i].goodsId;
orderItem.goodsNum = this.cartList[i].goodsNum;
orderItem.goodsPrice = this.cartList[i].salePrice;
orderItem.totalPrice = this.cartList[i].salePrice * this.cartList[i].goodsNum;
// orderItem.venderId = this.cartList[i].venderId;
// orderItem.venderName = this.cartList[i].venderName;
orderItem.venderId =i
orderItem.venderName=i
orderItems.push(orderItem)
}
}
let params = {
userId: this.userId,
tel: this.tel,
userName: this.userName,
streetName: this.streetName,
goodsList: array,
orderTotal: this.orderTotal
orderDto:{
userId: this.userId,
addressId:this.addressId,
paymentMethod:'1',
buyOrgId:getStore('orgCode'),
comments:'',
linkPerson:this.userName,
linkPersonTelephone:this.tel,
},
orderItemDtos:orderItems
}
/* submitOrder(params).then(res => {
if (res.success === true) {
this.payment(res.result)
} else {
this.message(res.message)
this.submitOrder = '提交订单'
this.submit = false
}
})*/
submitOrder(params).then(res => {
if (res.result.resultCode === 200) {
if (res.code =='success' ) {
this.message('操作成功')
this.$router.push({path: '/user/orderList'})
// this.payment(res.result)
} else {
this.message(res.message)
this.message('操作失败')
this.submitOrder = '提交订单'
this.submit = false
}
})
// submitOrder(params).then(res => {
// if (res.result.resultCode === 200) {
// this.$router.push({path: '/user/orderList'})
// } else {
// this.message(res.message)
// this.submitOrder = '提交订单'
// this.submit = false
// }
// })
},
// 付款
/* payment (orderId) {
payment (orderId) {
// 需要拿到地址id
this.$router.push({
path: '/order/payment',
query: {
'orderId': orderId
}
})
},*/
},
// 选择地址
chooseAddress (addressId, userName, tel, streetName) {
this.addressId = addressId
Expand All @@ -314,9 +331,9 @@
this.popupOpen = true
if (item) {
this.popupTitle = '管理收货地址'
this.msg.userName = item.userName
this.msg.tel = item.tel
this.msg.streetName = item.streetName
this.msg.userName = item.addressName
this.msg.tel = item.addressPhone
this.msg.streetName = item.addressDetail
this.msg.isDefault = item.isDefault
this.msg.addressId = item.addressId
} else {
Expand All @@ -330,6 +347,26 @@
},
// 保存
saveAddress (add) {
this.popupOpen = false
if (add.addressId) {
console.log(add.addressId)
let params={
addressDto:{
isDefault:add.isDefault,
addressDetail:add.streetName,
addressPhone:add.tel,
userId:add.userId,
addressName:add.userName,
addressId:add.addressId
}
}
modifyAddress(params).then(res => {
if(res.code='"success"'){
this.message('修改成功')
this.getAddressList()
}
})
} else {
let params={
addressDto:{
isDefault:add.isDefault,
Expand All @@ -339,24 +376,30 @@
addressName:add.userName
}
}
addAddress(params).then(res => {
addAddress(params).then(res => {
if(res.code='"success"'){
this.message('添加成功')
this.getAddressList()
this.message('添加成功')
this.getAddressList()
}
console.log(res)
})
this.popupOpen = false
// if (p.addressId) {
// this._addressUpdate(p)
// } else {
// delete p.addressId
// this._addressAdd(p)
// }
})
// delete add.addressId
// this._addressAdd(add)
}
},
// 删除
del (addressId) {
this._addressDel({addressId})
del (item) {
let params={
addressDto:{
userId:item.userId,
addressId:item.addressId
}
}
deleteAddress(params).then(res => {
if(res.code='"success"'){
this.message('删除成功')
this.getAddressList()
}
})
},
_productDet (productId) {
productDet({params: {productId}}).then(res => {
Expand Down
2 changes: 1 addition & 1 deletion src/page/Home/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</div>
</template>
<script>
import { productHome,goodsDetails,getBanner,getPanel } from '/api/index.js'
import { productHome, goodsDetails, getBanner, getPanel } from '/api/index.js'
import YShelf from '/components/shelf'
import product from '/components/product'
import mallGoods from '/components/mallGoods'
Expand Down
1 change: 1 addition & 0 deletions src/page/Login/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export default {
this.logintxt = '登录'
}else{
setStore('userId', res.userId)
setStore('userName', res.userName)
setStore('orgCode', res.STAFF_ORG_CODE)
setStore('token', res.userToken)
// 登录后成功后存用户信息
Expand Down
27 changes: 13 additions & 14 deletions src/page/User/children/order.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="f-bc">
<span class="price">单价</span>
<span class="num">数量</span>
<span class="operation">商品操作</span>
<!--<span class="operation">商品操作</span>-->
</div>
</div>
<div class="last">
Expand All @@ -25,12 +25,12 @@
<div class="cart" v-for="(good,j) in item.goodsList" :key="j">
<div class="cart-l" :class="{bt:j>0}">
<div class="car-l-l">
<div class="img-box"><a @click="goodsDetails(good.productId)"><img :src="good.productImg" alt=""></a></div>
<div class="ellipsis"><a style="color: #626262;" @click="goodsDetails(good.productId)">{{good.productName}}</a></div>
<div class="img-box"><a @click="goodsDetails(good.goodsId)"><img :src="good.goodsImg" alt=""></a></div>
<div class="ellipsis"><a style="color: #626262;" @click="goodsDetails(good.goodsId)">{{good.goodsName}}</a></div>
</div>
<div class="cart-l-r">
<div>¥ {{good.salePrice.toFixed(2)}}</div>
<div class="num">{{good.productNum}}</div>
<div class="num">{{good.goodsNum}}</div>
<!-- <div class="type">
<el-button style="margin-left:20px" @click="_delOrder(item.orderId,i)" type="danger" size="small" v-if="j<1" class="del-order">删除此订单</el-button>
&lt;!&ndash; <a @click="_delOrder(item.orderId,i)" href="javascript:;" v-if="j<1" class="del-order">删除此订单</a> &ndash;&gt;
Expand Down Expand Up @@ -74,7 +74,7 @@
</div>
</template>
<script>
import { orderList, delOrder } from '/api/goods'
import { getOrderList, delOrder } from '/api/goods'
import YShelf from '/components/shelf'
import { getStore } from '/utils/storage'
export default {
Expand All @@ -83,7 +83,7 @@
orderList: [0],
userId: '',
orderStatus: '',
loading: true,
loading: false,
currentPage: 1,
pageSize: 5,
total: 0
Expand Down Expand Up @@ -137,18 +137,17 @@
},
_orderList () {
let params = {
params: {
userId: this.userId,
size: this.pageSize,
page: this.currentPage
orderDto: {
userId: this.userId
}
}
orderList(params).then(res => {
getOrderList(params).then(res => {
console.log(res)
/*this.orderList = res.result.data
this.total = res.result.total*/
this.orderList = res.result.data.data
this.total = res.result.data.total
this.loading = false
this.orderList = res.orderDtoList
// this.total = res.result.data.total
// this.loading = false
})
},
_delOrder (orderId, i) {
Expand Down

0 comments on commit 15d2612

Please sign in to comment.