7.16
This commit is contained in:
@@ -37,17 +37,17 @@
|
||||
<view>
|
||||
<view class="title">优惠券折扣</view>
|
||||
<view class="value">
|
||||
<view>-¥10.00</view>
|
||||
<view>{{ index }}</view>
|
||||
<image src="../static/image/1.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view>
|
||||
<view class="title">支付方式</view>
|
||||
<view>
|
||||
<view class="title">运费</view>
|
||||
<view class="value">
|
||||
<view>微信</view>
|
||||
<image src="../static/image/1.png"></image>
|
||||
<view v-if="freight">¥{{ freight | setFreight(index) }}</view>
|
||||
<!-- <image src="../static/image/1.png"></image> -->
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -59,10 +59,10 @@
|
||||
<image src="../static/image/1.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view @click="showDelivery=true">
|
||||
<view class="title">配送方式</view>
|
||||
<view class="value">
|
||||
<view>快递</view>
|
||||
<view>{{ delivery.text }}</view>
|
||||
<image src="../static/image/1.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
@@ -70,36 +70,40 @@
|
||||
<view class="bottom">
|
||||
<view class="left">
|
||||
<view class="title">合计:</view>
|
||||
<view class="price">¥{{ orderInfo.store_goods_total | showTotalPrice }}</view>
|
||||
<view class="price">¥{{ totalPrice }}</view>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="num">共件{{ orderInfo.store_cart_list | setTotalNumber }}商品</view>
|
||||
<view class="btn" @click="sendOrder">结算</view>
|
||||
</view>
|
||||
</view>
|
||||
<u-action-sheet :list="deliveryList" @click="setDelivery" border-radius="10" v-model="showDelivery"></u-action-sheet>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
showDelivery: false,
|
||||
orderInfo: {},
|
||||
totalPrice: '0.00',
|
||||
addressInfo: {},
|
||||
freight: '',
|
||||
freight: {}, // 运费
|
||||
isTakeawayer: '', // 是否支持骑手
|
||||
deliveryList: [{
|
||||
text: '快递',
|
||||
value: 'express',
|
||||
}, {
|
||||
text: '骑手',
|
||||
value: 'takeawayer',
|
||||
}],
|
||||
delivery: {
|
||||
text: '快递',
|
||||
value: 'express',
|
||||
}, // 配送方式
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
showTotalPrice(object) {
|
||||
let price = 0;
|
||||
for (const key in object) {
|
||||
if (object.hasOwnProperty(key)) {
|
||||
const element = object[key];
|
||||
price += Number(element);
|
||||
}
|
||||
}
|
||||
return price.toFixed(2);
|
||||
},
|
||||
setTotalNumber(data) {
|
||||
let num = 0;
|
||||
for (const key in data) {
|
||||
@@ -112,12 +116,29 @@ export default {
|
||||
}
|
||||
return num;
|
||||
},
|
||||
setFreight(freight, index) {
|
||||
return freight[index];
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
console.log(JSON.parse(option.info));
|
||||
this.orderInfo = JSON.parse(option.info);
|
||||
this.addressInfo = this.orderInfo.address_info;
|
||||
this.getFreight();
|
||||
this.orderInfo = this.$store.state.cartInfo;
|
||||
},
|
||||
onShow() {
|
||||
// 判断是不是从选择地址页面返回
|
||||
if(JSON.stringify(this.$store.state.orderAddress) == '{}') {
|
||||
this.$store.commit('updateAddress', this.orderInfo.address_info);
|
||||
} else {
|
||||
this.addressInfo = this.$store.state.orderAddress;
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$store.commit('updateAddress', {});
|
||||
},
|
||||
watch: {
|
||||
'$store.state.orderAddress'(value) {
|
||||
this.addressInfo = value;
|
||||
this.getFreight();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
sendOrder() {
|
||||
@@ -156,12 +177,38 @@ export default {
|
||||
freight_hash: this.orderInfo.freight_hash,
|
||||
city_id: this.addressInfo.city_id,
|
||||
area_id: this.addressInfo.area_id,
|
||||
delivery: this.delivery.value,
|
||||
}).then(res => {
|
||||
if(res.errCode == 0) {
|
||||
// this.freight = res.
|
||||
this.freight = res.data.content;
|
||||
this.isTakeawayer = res.data.delivery.takeawayer;
|
||||
this.setTotalPrice(); // 计算总价
|
||||
}
|
||||
})
|
||||
},
|
||||
setTotalPrice(object) {
|
||||
const goods = this.orderInfo.store_goods_total;
|
||||
const freight = this.freight;
|
||||
let price = 0;
|
||||
[goods, freight].forEach(object => {
|
||||
for (const key in object) {
|
||||
if (object.hasOwnProperty(key)) {
|
||||
const element = object[key];
|
||||
price += Number(element);
|
||||
}
|
||||
}
|
||||
})
|
||||
// console.log(price);
|
||||
this.totalPrice = price.toFixed(2);
|
||||
},
|
||||
setDelivery(index) {
|
||||
if(index == 1) {
|
||||
if(!this.isTakeawayer) this.$u.toast('此地区不支持骑手配送');
|
||||
return false;
|
||||
}
|
||||
this.delivery = this.deliveryList[index];
|
||||
this.getFreight();
|
||||
},
|
||||
settlement() {
|
||||
uni.navigateTo({
|
||||
url: '/pageE/order/Details'
|
||||
@@ -169,7 +216,7 @@ export default {
|
||||
},
|
||||
changeAddress() {
|
||||
uni.navigateTo({
|
||||
url: '/pageE/more/Address'
|
||||
url: '/pageE/more/Address?type=choose'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -100,11 +100,9 @@ export default {
|
||||
// ifcart 结算方式 1:购物车 0:直接结算(立即购买/拼团/秒杀)
|
||||
this.$u.api.settlementOrder({ ifcart: 1, cart_id: id }).then(res => {
|
||||
if(res.errCode == 0) {
|
||||
this.$store.commit('updateCart', res.data)
|
||||
this.$u.route({
|
||||
url: '/pageC/cart/ConfirmOrder',
|
||||
params: {
|
||||
info: JSON.stringify(res.data),
|
||||
}
|
||||
url: '/pageC/cart/ConfirmOrder'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user