|
|
@ -3,9 +3,10 @@ |
|
|
|
<navbar title="购物车" leftClick @leftClick="$utils.navigateBack" /> |
|
|
|
|
|
|
|
<view class="user"> |
|
|
|
<uv-checkbox-group |
|
|
|
<!-- <uv-checkbox-group |
|
|
|
shape="circle" |
|
|
|
v-model="cartCheckboxValue"> |
|
|
|
v-model="cartCheckboxValue"> --> |
|
|
|
<uv-radio-group v-model="radiovalue"> |
|
|
|
|
|
|
|
<uv-swipe-action> |
|
|
|
<view |
|
|
@ -17,12 +18,19 @@ |
|
|
|
@click="delCart(item, index)"> |
|
|
|
<view class="item"> |
|
|
|
<view class="checkbox"> |
|
|
|
<uv-checkbox |
|
|
|
<!-- <uv-checkbox |
|
|
|
:name="item.shopcar.id" |
|
|
|
activeColor="#FA5A0A" |
|
|
|
size="40rpx" |
|
|
|
icon-size="35rpx" |
|
|
|
></uv-checkbox> |
|
|
|
></uv-checkbox> --> |
|
|
|
|
|
|
|
<uv-radio |
|
|
|
:name="item.shopcar.id" |
|
|
|
activeColor="#FA5A0A" |
|
|
|
size="40rpx" |
|
|
|
icon-size="35rpx"> |
|
|
|
</uv-radio> |
|
|
|
</view> |
|
|
|
|
|
|
|
<image |
|
|
@ -52,10 +60,19 @@ |
|
|
|
</uv-swipe-action-item> |
|
|
|
</view> |
|
|
|
</uv-swipe-action> |
|
|
|
</uv-checkbox-group> |
|
|
|
<!-- </uv-checkbox-group> --> |
|
|
|
</uv-radio-group> |
|
|
|
|
|
|
|
<cartAction/> |
|
|
|
<cartAction |
|
|
|
:price="totalPrice" |
|
|
|
:num="num" |
|
|
|
@submit="$refs.addressPopup.open('bottom')"/> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 地址弹框 --> |
|
|
|
<uv-popup ref="addressPopup" :round="30"> |
|
|
|
<addressList ref="addressList" height="60vh" @select="selectAddress" /> |
|
|
|
</uv-popup> |
|
|
|
|
|
|
|
<tabber select="3" /> |
|
|
|
</view> |
|
|
@ -64,12 +81,15 @@ |
|
|
|
<script> |
|
|
|
import cartAction from '../components/product/cartAction.vue' |
|
|
|
import { mapState } from 'vuex' |
|
|
|
import addressList from '../components/address/addressList.vue' |
|
|
|
export default { |
|
|
|
components: { |
|
|
|
cartAction |
|
|
|
cartAction, |
|
|
|
addressList, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
radiovalue : 0, |
|
|
|
options: [ |
|
|
|
{ |
|
|
|
text: '删除', |
|
|
@ -78,15 +98,60 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
], |
|
|
|
addressTotal: 0, |
|
|
|
address: { |
|
|
|
name: '请选择联系人', |
|
|
|
addressDetail: '' |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
...mapState(['cartList', 'cartCheckboxValue']), |
|
|
|
totalPrice() { |
|
|
|
if (!this.radiovalue) { |
|
|
|
return '0' |
|
|
|
} |
|
|
|
let price = 0 |
|
|
|
this.cartList.forEach(n => { |
|
|
|
if (this.radiovalue == n.shopcar.id) { |
|
|
|
price += n.wares.waresPrice * (n.shopcar.shopcarNumber || 1) |
|
|
|
} |
|
|
|
}) |
|
|
|
return price |
|
|
|
}, |
|
|
|
num(){ |
|
|
|
if (!this.radiovalue) { |
|
|
|
return '0' |
|
|
|
} |
|
|
|
let num = 0 |
|
|
|
this.cartList.forEach(n => { |
|
|
|
if (this.radiovalue == n.shopcar.id) { |
|
|
|
num += (n.shopcar.shopcarNumber || 1) |
|
|
|
} |
|
|
|
}) |
|
|
|
return num |
|
|
|
}, |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
this.$store.commit('getCartList') |
|
|
|
this.getAddressListA() |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 选择地址 |
|
|
|
selectAddress(e) { |
|
|
|
this.address = e |
|
|
|
this.$refs.addressPopup.close() |
|
|
|
this.submit() |
|
|
|
}, |
|
|
|
// 获取地址列表 |
|
|
|
getAddressListA() { |
|
|
|
this.$refs.addressList.getAddressList().then(res => { |
|
|
|
this.addressTotal = res.total |
|
|
|
if (this.addressTotal != 0) { |
|
|
|
this.address = res.records[0] |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
valChange(item, e){ |
|
|
|
this.$api('updateShopcar', { |
|
|
|
id : item.shopcar.id, |
|
|
@ -106,6 +171,57 @@ |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
submit(){ |
|
|
|
|
|
|
|
let data = {} |
|
|
|
|
|
|
|
this.cartList.forEach(n => { |
|
|
|
if (this.radiovalue == n.shopcar.id) { |
|
|
|
data.waresId = n.shopcar.waresId |
|
|
|
data.number = n.shopcar.shopcarNumber |
|
|
|
data.addressId = this.address.id |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
if(this.$utils.verificationAll(data, { |
|
|
|
addressId : '请选择地址', |
|
|
|
waresId : '请选择商品', |
|
|
|
number : '请选择数量', |
|
|
|
})){ |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
this.$api('addWaresOrder', data, res => { |
|
|
|
if(res.code == 200){ |
|
|
|
|
|
|
|
uni.redirectTo({ |
|
|
|
url: '/pages_order/order/order' |
|
|
|
}) |
|
|
|
|
|
|
|
// uni.requestPayment({ |
|
|
|
// provider: 'wxpay', // 服务提提供商 |
|
|
|
// timeStamp: res.result.timeStamp, // 时间戳 |
|
|
|
// nonceStr: res.result.nonceStr, // 随机字符串 |
|
|
|
// package: res.result.packageValue, |
|
|
|
// signType: res.result.signType, // 签名算法 |
|
|
|
// paySign: res.result.paySign, // 签名 |
|
|
|
// success: function (res) { |
|
|
|
// console.log('支付成功',res); |
|
|
|
// uni.redirectTo({ |
|
|
|
// url: '/pages/index/order' |
|
|
|
// }) |
|
|
|
// }, |
|
|
|
// fail: function (err) { |
|
|
|
// console.log('支付失败',err); |
|
|
|
// uni.showToast({ |
|
|
|
// icon:'none', |
|
|
|
// title:"支付失败" |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }); |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|