|
|
@@ -39,6 +39,16 @@
|
|
|
/>
|
|
|
</block>
|
|
|
|
|
|
+ <tui-list-cell class="line-cell" :hover="false" :arrow="true" v-if="hasAvailableHb">
|
|
|
+ <view class="tui-title">红包</view>
|
|
|
+ <hb-select
|
|
|
+ :hbData="hbData"
|
|
|
+ :totalPrice="allPriceFun"
|
|
|
+ v-model="selectedHbId"
|
|
|
+ @change="(hb) => { selectedHb = hb }"
|
|
|
+ ></hb-select>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
<view style="height:90upx;"> </view>
|
|
|
|
|
|
<view class="page-btn app-footer">
|
|
|
@@ -59,16 +69,19 @@
|
|
|
import TuiListCell from "@/components/plugin/list-cell";
|
|
|
import AppDeliveryModule from "./components/app-delivery";
|
|
|
import AppListModule from "./components/app-order-list2";
|
|
|
+import HbSelect from "@/components/hb/hb-select";
|
|
|
//import { getShopUser } from "@/utils/auth";
|
|
|
import { getOrderShop } from "@/utils/config";
|
|
|
import { createOrder,newFreight } from "@/api/order";
|
|
|
import { getHasMap } from "@/api/express";
|
|
|
+import { getAvailableHb } from "@/api/hb"
|
|
|
export default {
|
|
|
name: "buy",
|
|
|
components: {
|
|
|
AppDeliveryModule,
|
|
|
TuiListCell,
|
|
|
- AppListModule
|
|
|
+ AppListModule,
|
|
|
+ HbSelect
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -101,12 +114,15 @@ export default {
|
|
|
deliveryPrice: 0, // 跑腿报价
|
|
|
deliveryDistance: 0, // 跑腿距离
|
|
|
deliveryBracketContent: '',// 跑腿平台括号里的内容
|
|
|
- freightType:1
|
|
|
+ freightType:1,
|
|
|
+ hbData:[], // 可用红包数据
|
|
|
+ selectedHbId: null, // 选中的红包ID
|
|
|
+ selectedHb: null, // 选中的红包对象
|
|
|
};
|
|
|
},
|
|
|
onLoad(option) {
|
|
|
this.option = option || {};
|
|
|
- this.init();
|
|
|
+ //this.init();
|
|
|
this.freightType = this.option.freightType?this.option.freightType:1
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -132,8 +148,28 @@ export default {
|
|
|
|
|
|
return false
|
|
|
},
|
|
|
+ hasAvailableHb() {
|
|
|
+ if(!this.hbData || this.hbData.length === 0){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ const price = this.allPriceFun
|
|
|
+ return this.hbData.some(item => {
|
|
|
+ const min = Number(item.minConsume) || 0
|
|
|
+ return price >= min
|
|
|
+ })
|
|
|
+ },
|
|
|
+ allPriceFun() {
|
|
|
+ return this.goodsTotalPrice
|
|
|
+ },
|
|
|
mayPayAmount(){
|
|
|
let price = (this.goodsInfo.price || 0) * (this.goodsInfo.buyNum || 0)
|
|
|
+
|
|
|
+ // 减去红包金额
|
|
|
+ if(this.hasAvailableHb && this.selectedHbId && this.selectedHb){
|
|
|
+ price = price - Number(this.selectedHb.amount)
|
|
|
+ }
|
|
|
+ if(price < 0) price = 0
|
|
|
+
|
|
|
price = Number(this.freightPrice)+Number(price)
|
|
|
return parseFloat(price.toFixed(2))
|
|
|
}
|
|
|
@@ -168,6 +204,7 @@ export default {
|
|
|
this.openIntraCity = shopData.openIntraCity || 0;
|
|
|
this.hsFreeKm = shopData.hsFreeKm || 0;
|
|
|
this.hsAddFee = shopData.hsAddFee || 0;
|
|
|
+ this.getHbData();
|
|
|
}else{
|
|
|
this.$msg('获取配送范围与配送规则失败');
|
|
|
console.log('获取配送范围与配送规则失败:', res.msg || res)
|
|
|
@@ -215,6 +252,13 @@ export default {
|
|
|
this.createOrderFn()
|
|
|
})
|
|
|
},
|
|
|
+ getHbData(){
|
|
|
+ getAvailableHb().then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ this.hbData = res.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
createOrderFn() {
|
|
|
let hdId = this.option.hdId?this.option.hdId:0
|
|
|
let account = this.option.account?this.option.account:0
|
|
|
@@ -265,6 +309,12 @@ export default {
|
|
|
deliveryBracketContent: this.deliveryBracketContent,
|
|
|
isFreeDelivery: this.isFreeDelivery
|
|
|
};
|
|
|
+
|
|
|
+ // 添加红包ID
|
|
|
+ if(this.hasAvailableHb && this.selectedHbId && this.selectedHb){
|
|
|
+ params.hbId = this.selectedHbId
|
|
|
+ params.hbAmount = this.selectedHb.amount
|
|
|
+ }
|
|
|
|
|
|
createOrder(params).then(res => {
|
|
|
uni.hideLoading()
|