|
|
@@ -175,9 +175,10 @@
|
|
|
<text style="color: #3385FF;width:100%;">到店自取,没有配送费</text>
|
|
|
</view>
|
|
|
<view v-if="form.sendType == 2">
|
|
|
- <text style="color: #3385FF;width:100%;">各平台跑腿费</text>
|
|
|
+ <text v-if="ghsInfo.openIntraCity == 0" style="color: #3385FF;width:100%;">运费自理或到付(请联系客服)</text>
|
|
|
+ <text v-if="ghsInfo.openIntraCity == 1" style="color: #3385FF;width:100%;">各平台跑腿费</text>
|
|
|
<!-- 跑腿平台报价列表 -->
|
|
|
- <view v-if="deliveryQuotes.length > 0" class="delivery-quotes-container">
|
|
|
+ <view v-if="ghsInfo.openIntraCity == 1 && deliveryQuotes.length > 0" class="delivery-quotes-container">
|
|
|
<view class="delivery-quotes-grid">
|
|
|
<view
|
|
|
v-for="(item, index) in deliveryQuotes"
|
|
|
@@ -192,7 +193,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view v-else-if="deliveryQuotesLoading" style="text-align: center; padding: 20upx 0; color: #999;">
|
|
|
+ <view v-else-if="ghsInfo.openIntraCity == 1 && deliveryQuotesLoading" style="text-align: center; padding: 20upx 0; color: #999;">
|
|
|
正在获取报价...
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -228,7 +229,13 @@
|
|
|
</tui-list-cell>
|
|
|
</block>
|
|
|
</block>
|
|
|
-
|
|
|
+ <tui-list-cell class="line-cell" :hover="false" v-if="displaySendCost == true">
|
|
|
+ <view class="tui-title">跑腿费</view>
|
|
|
+ <view>
|
|
|
+ <text :class="isFreeDelivery ? 'delivery-price-free' : 'delivery-price-normal'">¥ {{ form.sendCost }}</text>
|
|
|
+ <text v-if="isFreeDelivery" class="free-delivery-tag">【免跑腿费】</text>
|
|
|
+ </view>
|
|
|
+ </tui-list-cell>
|
|
|
<tui-list-cell class="line-cell" :hover="false" :arrow="true" v-if="displayAddress == true" @click="modifyAddress">
|
|
|
<view class="tui-title">收花地址</view>
|
|
|
<view v-if="!$util.isEmpty(shopInfo.address)">
|
|
|
@@ -242,12 +249,7 @@
|
|
|
|
|
|
<tui-list-cell class="line-cell" :hover="false" v-if="displaySendCost == true && Number(showDistance)>0">
|
|
|
<view class="tui-title">距离</view>
|
|
|
- <text style="color: #3385FF">{{ showDistance }}公里</text>
|
|
|
- </tui-list-cell>
|
|
|
-
|
|
|
- <tui-list-cell class="line-cell" :hover="false" v-if="displaySendCost == true">
|
|
|
- <view class="tui-title">跑腿费</view>
|
|
|
- <text style="color: #3385FF">¥{{ form.sendCost }}</text>
|
|
|
+ <text style="color: #3385FF">{{ showDistance }}米</text>
|
|
|
</tui-list-cell>
|
|
|
|
|
|
<tui-list-cell class="line-cell" :hover="false" v-if="needAddPackCost == true">
|
|
|
@@ -257,7 +259,7 @@
|
|
|
|
|
|
<tui-list-cell class="line-cell" :hover="false" :arrow="false" >
|
|
|
<view class="tui-title">总金额</view>
|
|
|
- <text style="color: #3385FF">¥{{ modifyPrice }}</text>
|
|
|
+ <text style="color: #3385FF">¥ {{ modifyPrice }}</text>
|
|
|
</tui-list-cell>
|
|
|
|
|
|
<tui-list-cell class="line-cell" :hover="false" :arrow="true">
|
|
|
@@ -412,8 +414,10 @@ export default {
|
|
|
//计算运费
|
|
|
//this.calcFreight()
|
|
|
|
|
|
- //各跑腿平台报价
|
|
|
- this.getDeliveryQuotes()
|
|
|
+ if(this.displaySendCost() == true){
|
|
|
+ //各跑腿平台报价
|
|
|
+ this.getDeliveryQuotes()
|
|
|
+ }
|
|
|
}
|
|
|
//修改地址更新
|
|
|
this.getCurrentShop()
|
|
|
@@ -429,6 +433,10 @@ export default {
|
|
|
}
|
|
|
return false
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 显示跑腿费
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
displaySendCost(){
|
|
|
if(this.form.sendType == 2){
|
|
|
if(this.ghsInfo.openIntraCity==0){
|
|
|
@@ -442,13 +450,65 @@ export default {
|
|
|
}
|
|
|
return false
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 判断是否免跑腿费
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+ isFreeDelivery(){
|
|
|
+ // 不显示跑腿费时,不需要判断
|
|
|
+ if(this.displaySendCost == false){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ // 条件1: 比较距离与免费公里数
|
|
|
+ // showDistance单位是米,hcFreeKm单位是千米
|
|
|
+ const distanceInMeters = Number(this.showDistance) || 0
|
|
|
+ const freeKmInMeters = (Number(this.ghsInfo.hcFreeKm) || 0) * 1000
|
|
|
+
|
|
|
+ // 如果距离小于免费公里数,则免运费
|
|
|
+ if(distanceInMeters < freeKmInMeters){
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ // 条件2: 如果距离大于免费公里数,判断hcMap
|
|
|
+ if(distanceInMeters > freeKmInMeters){
|
|
|
+ // 判断hcMap是否为空
|
|
|
+ if(this.ghsInfo.hcMap && Array.isArray(this.ghsInfo.hcMap) && this.ghsInfo.hcMap.length > 0){
|
|
|
+ // 获取花材数量和总价
|
|
|
+ const flowerCount = this.allCountFun.bigLength || 0
|
|
|
+ const flowerPrice = this.allPriceFun || 0
|
|
|
+
|
|
|
+ // 遍历hcMap,检查是否满足免运费条件
|
|
|
+ for(const rule of this.ghsInfo.hcMap){
|
|
|
+ const ruleNum = Number(rule.num) || 0
|
|
|
+ const rulePrice = Number(rule.price) || 0
|
|
|
+ const ruleDistance = (Number(rule.distance) || 0) * 1000 // 转换为米
|
|
|
+
|
|
|
+ // 如果花材数量大于num,花材总价大于price,距离小于distance,则免运费
|
|
|
+ if(flowerCount >= ruleNum && flowerPrice >= rulePrice && distanceInMeters <= ruleDistance){
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 计算总金额
|
|
|
+ * @returns {number}
|
|
|
+ */
|
|
|
modifyPrice(){
|
|
|
let allPrice = this.allPrice.toFixed(2)
|
|
|
allPrice = Number(allPrice)
|
|
|
let price = allPrice
|
|
|
|
|
|
+ // 判断是否需要加跑腿费
|
|
|
if(this.displaySendCost == true){
|
|
|
- price = price + this.form.sendCost
|
|
|
+ // 如果不是免跑腿费,则加上跑腿费
|
|
|
+ if(!this.isFreeDelivery){
|
|
|
+ price = price + this.form.sendCost
|
|
|
+ }
|
|
|
}
|
|
|
this.needAddPackCost = false
|
|
|
if(this.ghsInfo.pfLevel && this.ghsInfo.pfLevel == 1){
|
|
|
@@ -568,28 +628,25 @@ export default {
|
|
|
this.deliveryQuotesLoading = false
|
|
|
if (res.code === 1 && res.data && res.data.deliveryList) {
|
|
|
// 处理报价数据
|
|
|
- this.deliveryQuotes = res.data.deliveryList.map(item => {
|
|
|
- // 如果 isAble 为 false,则此项不显示
|
|
|
- if (item.isAble == false) {
|
|
|
- console.log('item.isAble == false', item)
|
|
|
- return false;
|
|
|
- }
|
|
|
- // 价格从分转换为元
|
|
|
- const price = item.price ? (item.price / 100).toFixed(1) : '0.0'
|
|
|
-
|
|
|
- // 提取平台名称(去掉括号内的内容)
|
|
|
- let displayName = item.name
|
|
|
- if (displayName && displayName.includes('(')) {
|
|
|
- displayName = displayName.split('(')[0].trim()
|
|
|
- }
|
|
|
-
|
|
|
- return {
|
|
|
- ...item,
|
|
|
- displayName: displayName,
|
|
|
- priceText: price,
|
|
|
- priceNumber: parseFloat(price)
|
|
|
- }
|
|
|
- })
|
|
|
+ this.deliveryQuotes = res.data.deliveryList
|
|
|
+ .filter(item => item.isAble !== false)
|
|
|
+ .map(item => {
|
|
|
+ // 价格从分转换为元
|
|
|
+ const price = item.price ? (item.price / 100).toFixed(1) : '0.0'
|
|
|
+
|
|
|
+ // 提取平台名称(去掉括号内的内容)
|
|
|
+ let displayName = item.name
|
|
|
+ if (displayName && displayName.includes('(')) {
|
|
|
+ displayName = displayName.split('(')[0].trim()
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ displayName: displayName,
|
|
|
+ priceText: price,
|
|
|
+ priceNumber: parseFloat(price)
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
// 自动选中第一个可用的报价
|
|
|
const firstAvailableIndex = this.deliveryQuotes.findIndex(item => item.isAble)
|
|
|
@@ -613,14 +670,6 @@ export default {
|
|
|
},
|
|
|
// 选择跑腿平台
|
|
|
selectDelivery(item, index) {
|
|
|
- if (!item.isAble) {
|
|
|
- uni.showToast({
|
|
|
- title: '该平台暂不可用',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
this.selectedDeliveryIndex = index
|
|
|
this.selectedDeliveryData = item
|
|
|
this.form.sendCost = item.priceNumber
|
|
|
@@ -1339,4 +1388,19 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/* 跑腿费价格样式 */
|
|
|
+.delivery-price-normal {
|
|
|
+ color: #3385FF;
|
|
|
+}
|
|
|
+
|
|
|
+.delivery-price-free {
|
|
|
+ color: #999;
|
|
|
+ text-decoration: line-through;
|
|
|
+}
|
|
|
+
|
|
|
+.free-delivery-tag {
|
|
|
+ color: #3385FF;
|
|
|
+ margin-left: 10upx;
|
|
|
+}
|
|
|
</style>
|