Commit 55e30a3a by 赵雅纹

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

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