Browse Source

购物车结算,修改商品规格,

master
chenkun 5 months ago
parent
commit
c66b767a95
1 changed files with 99 additions and 43 deletions
  1. +99
    -43
      pages/index/cart.vue

+ 99
- 43
pages/index/cart.vue View File

@ -10,7 +10,7 @@
<uv-swipe-action-item :options="options" @click="delCart(item, index)">
<view class="item">
<view class="checkbox">
<uv-checkbox :name="item.id" activeColor="#FA5A0A" size="40rpx"
<uv-checkbox :name="item.goodsId" activeColor="#FA5A0A" size="40rpx"
icon-size="35rpx"></uv-checkbox>
</view>
@ -26,15 +26,14 @@
@change="e => valChange(item, e)"></uv-number-box>
</view>
</view>
<!-- 规格下拉框 -->
<view class="unit" @click="toggleDropdown">
规格{{ selectedOption || item.title }}
<view class="unit" @click="toggleDropdown(item)">
规格{{ item.title }}
<uv-icon name="arrow-down"></uv-icon>
</view>
<view class="price">
<text>{{ item.price }}</text>
<text>{{ item.price }}</text>
</view>
</view>
</view>
@ -52,7 +51,8 @@
<view class="count">
合计
<view>
<text>{{ totalPrice }}</text>
<text>{{ totalPrice }}</text>
</view>
</view>
<view class="text">
@ -75,6 +75,7 @@
<script>
import tabber from '@/components/base/tabbar.vue'
import addressList from '@/components/address/addressList.vue'
export default {
components: {
tabber,
@ -83,16 +84,6 @@
data() {
return {
dropdownVisible: false,
value: 0,
checkboxValue: [],
options: [{
text: '删除',
style: {
backgroundColor: '#FA5A0A'
}
}],
queryParams: {
pageNo: 1,
pageSize: 10,
@ -103,6 +94,20 @@
name: '请选择联系人',
addressDetail: ''
},
skuList: [],
editSkuForm: {
id: '', //id
goodsId: '', //id
skuId: '', //id
},
value: 0,
checkboxValue: [],
options: [{
text: '删除',
style: {
backgroundColor: '#FA5A0A'
}
}, ],
}
},
computed: {
@ -133,41 +138,72 @@
},
methods: {
toggleDropdown() {
this.dropdownVisible = !this.dropdownVisible
//
toggleDropdown(item) {
this.editSkuForm.id = item.id
this.editSkuForm.goodsId = item.goodsId
// id
this.$api('goodsSku', {
id: item.goodsId
}, res => {
if (res.code == 200) {
this.skuList = res.result
// TODO
}
})
},
selectOption(option) {
//
changeCartProductSku(e) {
console.log(e, "e");
this.editSkuForm.skuId = e.aaa //TODO
return
this.$api('editSku', this.editSkuForm, res => {
if (res.code == 200) {
this.getData()
}
})
},
//
goCleaning() {
console.log("===");
if (this.checkboxValue.length < 1) {
uni.showToast({
title: "请勾选商品",
icon: 'none'
})
return
}
//
this.$refs.addressPopup.open('bottom')
},
//
selectAddress(e) {
this.address = e
this.$refs.addressPopup.close()
this.ordersPay()
},
//
//
ordersPay() {
let data = []
console.log(this.address, "this.address");
console.log(this.checkboxValue, "checkboxValue");
for (var i = 0; i < this.list.length; i++) {
if (this.checkboxValue.includes(this.list[i].id)) {
var deleteCartIds = this.checkboxValue.join(",") //id
let data = []
let records = this.list.records
for (var i = 0; i < records.length; i++) {
if (this.checkboxValue.includes(records[i].goodsId)) {
data.push({
id: this.list[i].id, //id
skuId: this.unit.id, //id
id: records[i].goodsId, //id
skuId: records[i].skuId, //id
addressId: this.address.id, //id
sku: this.unit.title, //
num: this.list[i],
sku: records[i].title, //
num: records[i].num,
})
}
}
return
this.$api('orderCreate', {
req: JSON.stringify(data)
}, res => {
@ -185,7 +221,18 @@
signType: res.result.signType, //
paySign: res.result.paySign, //
success: function(res) {
// console.log('', res);
console.log('支付成功', res);
//
this.$api('cartDel', {
id: deleteCartIds
}, res => {
if (res.code == 200) {
this.getData()
}
})
uni.redirectTo({
url: '/pages/index/order'
})
@ -227,12 +274,7 @@
})
},
//
selectAddress(e) {
this.address = e
this.$refs.addressPopup.close()
},
valChange(item, e) {
console.log(e.value);
@ -311,7 +353,6 @@
}
.price {
color: $uni-color;
font-size: 28rpx;
@ -412,4 +453,19 @@
padding: 20px 0px;
font-size: 16px;
}
.text {
font-size: 12px;
color: #666;
margin-top: 5px;
}
.uni-px-5 {
padding-left: 10px;
padding-right: 10px;
}
.uni-pb-5 {
padding-bottom: 10px;
}
</style>

Loading…
Cancel
Save