Commit 55e30a3a by 赵雅纹

Merge branch 'dev_7.1.0' into feature-zyw-sc

parents 8e72dd3c 69ddb7ad
......@@ -14,7 +14,9 @@ wxService.page({
startX: '',
delBtnWidth: 66,//删除按钮宽度单位(rpx)
cartList: [],
outGoods: []
outGoods: [],
checkAll: false,
checkedColor: 'rgb(203, 60, 60)'
},
/**
......@@ -46,9 +48,11 @@ wxService.page({
wx.showLoading({
title: '加载中'
})
// 1556108807316001
// 1556108807316000
const trolleySku = {
count: 1,
skuId: '1556108807316000'
skuId: '1556108807316001'
}
// 加入购物车
wxService.post('/sale/trolley/put', trolleySku).then(res => {
......@@ -67,30 +71,20 @@ wxService.page({
title: '加载中'
})
wxService.get('/sale/trolley/query').then(res => {
console.log('query', res)
if (res) {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
// item.checked
data.skuVOList.forEach(item=>{
item.checked = false
})
this.setData({
cartList: data.skuVOList
})
}
}
// let promotionIds = res.data.data.shopCartItems.map(function (item) { // 获取购物车中商品库存信息
// return item.promotionId
// }).join(',')
// if (promotionIds === '') {
// this.setData({
// cartList: [],
// })
// wx.hideLoading()
// return false
// }
})
},
minusNum: function (e) { // 减少数量
let cartList = this.data.cartList
......@@ -212,8 +206,27 @@ wxService.page({
},
goBuy() {
let goodsIds = []
let specIds = []
let quantitys = []
let redemptionSpecIds = []
let cartListData = this.data.cartList || []
if (!cartListData) return false
cartListData.filter(item => { // 选中的商品信息
return item.checked
}).map(function (item) {
goodsIds.push(item.skuId)
quantitys.push(item.count)
})
if (goodsIds.length == 0) {
wx.showToast({
title: '请选择商品',
icon: 'none'
})
return false
}
// 去下单页
this.handleGoBuy()
},
handleGoBuy() {
......@@ -221,31 +234,31 @@ wxService.page({
wx.showLoading({
title: '加载中'
})
wxService.post(`/sale/trade/buyer/create`).then(res => {
if (!res) return false;
const { result, data } = res && res.data || res && res.result
if (result == 0) {
delete data.appId
wx.requestPayment(Object.assign({
success(res) {
wx.hideLoading()
wx.showToast({
title: '支付成功',
icon: 'none',
mask: true
})
},
fail(res) {
wx.hideLoading()
wx.showToast({
title: '支付失败',
icon: 'none',
mask: true
})
}
}, data))
}
})
// wxService.post(`/sale/trade/buyer/create`).then(res => {
// if (!res) return false;
// const { result, data } = res && res.data || res && res.result
// if (result == 0) {
// delete data.appId
// wx.requestPayment(Object.assign({
// success(res) {
// wx.hideLoading()
// wx.showToast({
// title: '支付成功',
// icon: 'none',
// mask: true
// })
// },
// fail(res) {
// wx.hideLoading()
// wx.showToast({
// title: '支付失败',
// icon: 'none',
// mask: true
// })
// }
// }, data))
// }
// })
},
// 调整商品 /trolley/add
editOk() {
......@@ -270,33 +283,57 @@ wxService.page({
}
})
},
//选择商品
selectPro(e) {
var index = e.currentTarget.dataset.index;
this.data.cartList[index].isSelect = !this.data.cartList[index].isSelect;
this.setData({
cartList: this.data.cartList
})
checkPro: function (e) { // 选中商品
var cartList = this.data.cartList
var index = e.currentTarget.dataset.index
var checkAll = false
if (cartList[index].checked) {
cartList[index].checked = false
} else {
cartList[index].checked = true
}
if (cartList.length === cartList.filter(function (item) {
return item.checked
}).length ) {
checkAll = true
}else {
checkAll = false
}
this.setData({
cartList: cartList,
checkAll: checkAll
}, function () {
// this.setTotalFee()
})
},
checkAll: function () { // 全选
var cartList = this.data.cartList || []
if(!cartList.length) return false
//全选
allSelect() {
this.setData({
isAllSelect: !this.data.isAllSelect
})
if (this.data.isAllSelect) {
if (this.data.checkAll) {
this.setData({
cartList: this.data.cartList.map((item) => {
item.isSelect = true
cartList: cartList.map(function (item) {
item.checked = false
return item
})
}),
checkAll: false
}, function () {
// this.setTotalFee()
})
} else {
this.setData({
cartList: this.data.cartList.map((item) => {
item.isSelect = false
return item
})
cartList: cartList.map(function (item) {
// 区分失效商品
item.checked = true
return item
}),
checkAll: true
}, function () {
// this.setTotalFee()
})
}
},
......
......@@ -16,10 +16,8 @@
<view class="cart-content" wx:if="{{cartList.length}}">
<view class="cart-item" wx:for="{{cartList}}" wx:key="{{index}}">
<view class="cart-list" bindtouchstart="touchS" bindtouchmove="touchM" bindtouchend="touchE" style="{{item.shows}}" data-index="{{index}}">
<view class="select-radio" catchtap="selectPro" data-index="{{index}}">
<view class="{{item.isSelect ? 'theme-color' : ''}} circle-radio" >
<image wx:if="{{item.isSelect}}" class="tick-success" src="/assets/imgs/7_1_0/tick-success.png" mode="widthFix"></image>
</view>
<view class="select-radio" data-index="{{index}}">
<icon size="16" type="{{item.checked ? 'success' : 'circle'}}" color="{{checkedColor}}" data-index="{{index}}" catchtap="checkPro"></icon>
</view>
<view class="pro-info">
<image class="pro-img" src="/assets/imgs/7_1_0/icon.png" mode="widthFix"></image>
......@@ -29,9 +27,9 @@
<view class="pro-price">
<view class="price">¥{{item.price}}</view>
<view class="pro-num-edit">
<button class="redus-num" data-index="{{j}}" catchtap="minusNum">-</button>
<input class="pro-num-edit-input" type="number" data-index="{{j}}" catchtap bindblur="blurNum" bindinput="inputNum" value="{{item.count}}"></input>
<button class="add-num" data-index="{{j}}" catchtap="addNum">+</button>
<button class="redus-num" data-index="{{index}}" catchtap="minusNum">-</button>
<input class="pro-num-edit-input" type="number" data-index="{{index}}" catchtap bindblur="blurNum" bindinput="inputNum" value="{{item.count}}"></input>
<button class="add-num" data-index="{{index}}" catchtap="addNum">+</button>
</view>
</view>
</view>
......@@ -64,10 +62,8 @@
<!-- 底部 -->
<view class="cart-bottom" style="bottom:{{currentHeight}}px">
<view class="total">
<view class="select-radio all-radio" bindtap="allSelect">
<view class="{{isAllSelect ? 'theme-color' : ''}} circle-radio " >
<image wx:if="{{isAllSelect}}" class="tick-success" src="/assets/imgs/7_1_0/tick-success.png" mode="widthFix"></image>
</view>
<view class="select-radio all-radio" bindtap="checkAll">
<icon type="{{checkAll ? 'success' : 'circle'}}" color="{{checkedColor}}" size="16" ></icon>
<text class="all" >全选</text>
</view>
<view class="total-amount">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment