|
|
@@ -29,6 +29,29 @@
|
|
|
<input v-model="form.floor" placeholder-class="phcolor" placeholder-style="color:#ccc" class="tui-input" name="floor" placeholder="楼号门牌号(选填)" @input="modifyShow" />
|
|
|
</tui-list-cell>
|
|
|
</div>
|
|
|
+
|
|
|
+ <div class="module-com">
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <div class="tui-title">贺卡内容</div>
|
|
|
+ <textarea v-model="form.cardInfo" placeholder-class="phcolor" placeholder-style="color:#ccc" class="tui-input textarea-input" name="cardInfo" placeholder="请填写" :adjust-position="false" :cursor-spacing="0" :auto-height="false" :disable-default-padding="true" :show-confirm-bar="false" />
|
|
|
+
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <div class="tui-title">派送方式</div>
|
|
|
+ <div class="delivery-mode-wrapper">
|
|
|
+ <switch :checked="form.anonymity == 1" @change="anonymityChange" color="#ff6b35" />
|
|
|
+ <span v-if="form.anonymity == 0" class="mode-text normal">不匿名</span>
|
|
|
+ <span v-else class="mode-text anonymous">要匿名</span>
|
|
|
+ </div>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <div class="tui-title">备注内容</div>
|
|
|
+ <textarea v-model="form.remark" placeholder-class="phcolor" placeholder-style="color:#ccc" class="tui-input textarea-input" name="remark" placeholder="选填,不要贺卡这里备注" :adjust-position="false" :cursor-spacing="0" :auto-height="false" :disable-default-padding="true" :show-confirm-bar="false" />
|
|
|
+ </tui-list-cell>
|
|
|
+ </div>
|
|
|
+
|
|
|
<!-- 订花人 -->
|
|
|
<div class="module-com">
|
|
|
<tui-list-cell class="line-cell" :hover="false" :arrow="true">
|
|
|
@@ -74,7 +97,7 @@
|
|
|
</tui-list-cell>
|
|
|
|
|
|
<!-- 跑腿平台报价列表 -->
|
|
|
- <tui-list-cell class="line-cell" :hover="false" :arrow="false" v-if="deliveryQuotes.length > 0">
|
|
|
+ <tui-list-cell v-if="isFreight && deliveryQuotes.length > 0" class="line-cell" :hover="false" :arrow="false">
|
|
|
<view class="delivery-quotes-container">
|
|
|
<view class="delivery-quotes-grid">
|
|
|
<view
|
|
|
@@ -95,35 +118,14 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</tui-list-cell>
|
|
|
- <tui-list-cell class="line-cell" :hover="false" :arrow="false" v-else-if="deliveryQuotesLoading">
|
|
|
+ <tui-list-cell v-else-if="isFreight && deliveryQuotesLoading" class="line-cell" :hover="false" :arrow="false">
|
|
|
<view style="text-align: center; padding: 20rpx 0; color: #999;">正在获取报价...</view>
|
|
|
</tui-list-cell>
|
|
|
</block>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
- <div class="module-com">
|
|
|
-
|
|
|
- <tui-list-cell class="line-cell" :hover="false">
|
|
|
- <div class="tui-title">贺卡内容</div>
|
|
|
- <textarea v-model="form.cardInfo" placeholder-class="phcolor" placeholder-style="color:#ccc" class="tui-input textarea-input" name="cardInfo" placeholder="请填写" :adjust-position="false" :cursor-spacing="0" :auto-height="false" :disable-default-padding="true" :show-confirm-bar="false" />
|
|
|
-
|
|
|
- </tui-list-cell>
|
|
|
-
|
|
|
- <tui-list-cell class="line-cell" :hover="false">
|
|
|
- <div class="tui-title">派送方式</div>
|
|
|
- <div class="delivery-mode-wrapper">
|
|
|
- <switch :checked="form.anonymity == 1" @change="anonymityChange" color="#ff6b35" />
|
|
|
- <span v-if="form.anonymity == 0" class="mode-text normal">不匿名</span>
|
|
|
- <span v-else class="mode-text anonymous">要匿名</span>
|
|
|
- </div>
|
|
|
- </tui-list-cell>
|
|
|
-
|
|
|
- <tui-list-cell class="line-cell" :hover="false">
|
|
|
- <div class="tui-title">备注内容</div>
|
|
|
- <textarea v-model="form.remark" placeholder-class="phcolor" placeholder-style="color:#ccc" class="tui-input textarea-input" name="remark" placeholder="选填,不要贺卡这里备注" :adjust-position="false" :cursor-spacing="0" :auto-height="false" :disable-default-padding="true" :show-confirm-bar="false" />
|
|
|
- </tui-list-cell>
|
|
|
- </div>
|
|
|
+
|
|
|
<!-- 省市联动 -->
|
|
|
<simple-address ref="simpleAddress" :region="orderShop.region" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onCityConfirm" >
|
|
|
</simple-address>
|
|
|
@@ -162,17 +164,22 @@ export default {
|
|
|
type: Number,
|
|
|
default: 0
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 是否收配送费
|
|
|
+ * @type {Boolean} True:收配送费 False:不收配送费
|
|
|
+ * @default false
|
|
|
+ */
|
|
|
isFreight: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
},
|
|
|
- hcFreeKm: {
|
|
|
+ hsFreeKm: {
|
|
|
type: Number,
|
|
|
default: 0
|
|
|
},
|
|
|
- hcMap: {
|
|
|
- type: Array,
|
|
|
- default: () => []
|
|
|
+ hsAddFee: {
|
|
|
+ type: Number,
|
|
|
+ default: 0
|
|
|
},
|
|
|
totalPrice: {
|
|
|
type: Number,
|
|
|
@@ -221,38 +228,46 @@ export default {
|
|
|
...mapGetters({ orderShop: "getOrderShop" }),
|
|
|
...mapGetters({ shopUser: "getShopUser" }),
|
|
|
isFreeDelivery(){
|
|
|
- // 如果父组件没传isFreight,或者isFreight为false,则直接判定为免运费
|
|
|
+ // 如果父组件isFreight为false,则直接判定为免运费
|
|
|
if(!this.isFreight) return true;
|
|
|
|
|
|
- const distanceInMeters = (Number(this.showDistance) || 0) * 1000;
|
|
|
- const freeKmInMeters = (Number(this.hcFreeKm) || 0) * 1000;
|
|
|
+ const distanceInKm = Number(this.showDistance) || 0;
|
|
|
+ const freeKm = Number(this.hsFreeKm) || 0;
|
|
|
|
|
|
- if (distanceInMeters > 0 && distanceInMeters < freeKmInMeters) {
|
|
|
+ // 距离小于等于免费公里数时,免费
|
|
|
+ if (distanceInKm <= freeKm) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- if(distanceInMeters > freeKmInMeters){
|
|
|
- if (this.hcMap && Array.isArray(this.hcMap) && this.hcMap.length > 0) {
|
|
|
- const goodsInfo = uni.getStorageSync("buyGoodsDetil") || {};
|
|
|
- const flowerCount = Number(goodsInfo.buyNum || 0);
|
|
|
- const flowerPrice = (Number(goodsInfo.price) || 0) * flowerCount;
|
|
|
-
|
|
|
- for (const rule of this.hcMap) {
|
|
|
- const ruleNum = Number(rule.num) || 0;
|
|
|
- const rulePrice = Number(rule.price) || 0;
|
|
|
- const ruleDistance = (Number(rule.distance) || 0) * 1000;
|
|
|
- if (flowerCount >= ruleNum && flowerPrice >= rulePrice && distanceInMeters <= ruleDistance) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
return false;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 计算跑腿费(使用 prop 的 showDistance)
|
|
|
+ * 新规则:距离 <= 免费公里数时免费,距离 > 免费公里数时按超出部分计费
|
|
|
+ */
|
|
|
+ calculatedDeliveryCost(){
|
|
|
+ // 如果不收配送费,返回0
|
|
|
+ if(!this.isFreight) return 0;
|
|
|
+
|
|
|
+ // 如果满足免费条件,返回0
|
|
|
+ if(this.isFreeDelivery) return 0;
|
|
|
+
|
|
|
+ const distanceInKm = Number(this.showDistance) || 0;
|
|
|
+ const freeKm = Number(this.hsFreeKm) || 0;
|
|
|
+ const addFee = Number(this.hsAddFee) || 0;
|
|
|
+
|
|
|
+ // 距离大于免费公里数时,计算超出部分的费用
|
|
|
+ if(distanceInKm > freeKm){
|
|
|
+ const extraKm = distanceInKm - freeKm;
|
|
|
+ const cost = extraKm * addFee;
|
|
|
+ return parseFloat(cost.toFixed(2));
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
orderShop(val) {
|
|
|
- console.log("val", val);
|
|
|
this.form.province = val.shop.province ? val.shop.province : "";
|
|
|
this.form.city = val.shop.city ? val.shop.city : "";
|
|
|
}
|
|
|
@@ -310,7 +325,35 @@ export default {
|
|
|
modifyShow(){
|
|
|
this.form.showAddress = this.form.province+this.form.city+this.form.address+this.form.floor
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 根据指定距离计算跑腿费
|
|
|
+ * @param {Number} distanceInKm - 距离(单位:公里)
|
|
|
+ * @returns {Number} 跑腿费
|
|
|
+ */
|
|
|
+ calculateDeliveryCostByDistance(distanceInKm){
|
|
|
+ // 如果不收配送费,返回0
|
|
|
+ if(!this.isFreight) return 0;
|
|
|
+
|
|
|
+ const freeKm = Number(this.hsFreeKm) || 0;
|
|
|
+ const addFee = Number(this.hsAddFee) || 0;
|
|
|
+
|
|
|
+ // 距离小于等于免费公里数时,免费
|
|
|
+ if(distanceInKm <= freeKm){
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 距离大于免费公里数时,计算超出部分的费用
|
|
|
+ if(distanceInKm > freeKm){
|
|
|
+ const extraKm = distanceInKm - freeKm;
|
|
|
+ const cost = extraKm * addFee;
|
|
|
+ return parseFloat(cost.toFixed(2));
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ },
|
|
|
triggerGetDeliveryQuotes() {
|
|
|
+ if(!this.isFreight) return;
|
|
|
+
|
|
|
if (this.form.receiveUserName && this.form.receiveMobile && this.form.address) {
|
|
|
this.getDeliveryQuotes();
|
|
|
}
|
|
|
@@ -372,11 +415,17 @@ export default {
|
|
|
if (!item.isAble) return;
|
|
|
this.selectedDeliveryIndex = index
|
|
|
this.selectedDeliveryData = item
|
|
|
- this.form.sendCost = this.isFreeDelivery ? 0 : item.priceNumber;
|
|
|
+
|
|
|
+ // 使用当前选择的配送平台的距离来计算跑腿费
|
|
|
+ const distanceInKm = item.distance ? parseFloat((item.distance / 1000).toFixed(2)) : 0;
|
|
|
+ const calculatedCost = this.calculateDeliveryCostByDistance(distanceInKm);
|
|
|
+
|
|
|
+ this.form.sendCost = calculatedCost;
|
|
|
this.form.deliveryPlatform = item.en_name;
|
|
|
this.form.deliveryPrice = item.priceNumber;
|
|
|
this.form.deliveryDistance = item.distance || 0;
|
|
|
this.form.deliveryBracketContent = item.bracketContent || '';
|
|
|
+
|
|
|
this.$emit("countFreight", {
|
|
|
sendCost: this.form.sendCost,
|
|
|
distance: item.distance,
|