|
|
@ -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> |