Просмотр исходного кода

花掌柜买花界面,添加展示出各跑腿平台的报价

shizhongqi 8 месяцев назад
Родитель
Сommit
0c24c88c05

+ 1 - 1
ghsApp/src/pagesOrder/detail.vue

@@ -875,7 +875,7 @@ export default {
 		//确认添加小费
 		confirmAddTip() {
 			if (!this.tipAmount || this.tipAmount <= 0) {
-				this.$msg('请输入有效的小费金额');
+				this.$msg('金额要求是正整数');
 				return;
 			}
 			

+ 204 - 5
hdApp/src/admin/billing/affirmGhs.vue

@@ -175,8 +175,26 @@
 			<text style="color: #3385FF;width:100%;">到店自取,没有配送费</text>
 		</view>
 		<view v-if="form.sendType == 2">
-			<text style="color: #3385FF;width:100%;" v-if="ghsInfo.openIntraCity == 1">有跑腿费</text>
-			<text style="color: #3385FF;width:100%;" v-else>运费自理或到付(请联系客服)</text>
+			<text style="color: #3385FF;width:100%;">各平台跑腿费</text>
+			<!-- 跑腿平台报价列表 -->
+			<view v-if="deliveryQuotes.length > 0" class="delivery-quotes-container">
+				<view class="delivery-quotes-grid">
+					<view 
+						v-for="(item, index) in deliveryQuotes" 
+						:key="index"
+						class="delivery-quote-item"
+						:class="{ 'active': selectedDeliveryIndex === index, 'disabled': !item.isAble }"
+						@click="selectDelivery(item, index)"
+					>
+						<view class="platform-name">{{ item.displayName || item.name }}</view>
+						<view class="platform-price">{{ item.priceText }}元</view>
+						<view v-if="item.type" class="platform-type">{{ item.type }}</view>
+					</view>
+				</view>
+			</view>
+			<view v-else-if="deliveryQuotesLoading" style="text-align: center; padding: 20upx 0; color: #999;">
+				正在获取报价...
+			</view>
 		</view>
 		<view v-if="form.sendType == 3">
 			<text style="color: #3385FF;width:100%;">运费到付</text>
@@ -300,6 +318,7 @@ import { freight,createOrder } from "@/api/purchase";
 import { mapActions, mapGetters } from "vuex";
 import { shopHouponHas } from '@/api/coupon'
 import {currentShop} from "@/api/shop"
+import { allDeliveryQuotes } from "@/api/express/delivery";
 import ModalModule from "@/components/plugin/modal";
 export default {
 	name: "affirmGhs",
@@ -372,7 +391,11 @@ export default {
 			needAddPackCost:false,
 			transCost:[],
 			lackList:[],
-			showDistance:0
+			showDistance:0,
+			deliveryQuotes: [], // 跑腿平台报价列表
+			selectedDeliveryIndex: -1, // 选中的报价索引
+			deliveryQuotesLoading: false, // 报价加载状态
+			selectedDeliveryData: null // 选中的报价数据
 		};
 	},
 	onLoad() {
@@ -387,7 +410,10 @@ export default {
 		}
 		if(this.form.sendType == 2){
 			//计算运费
-			this.calcFreight()
+			//this.calcFreight()
+
+			//各跑腿平台报价
+			this.getDeliveryQuotes()
 		}
 		//修改地址更新
 		this.getCurrentShop()
@@ -513,9 +539,86 @@ export default {
 			this.form.sendType = num
 			if(num == 2){
 				//计算运费
-				this.calcFreight()
+				//this.calcFreight()
+
+				//各跑腿平台报价
+				this.getDeliveryQuotes()
+			} else {
+				// 切换到其他配送方式时清空报价数据
+				this.deliveryQuotes = []
+				this.selectedDeliveryIndex = -1
+				this.selectedDeliveryData = null
+				this.form.sendCost = 0
 			}
 		},
+		// 获取跑腿平台报价
+		getDeliveryQuotes() {
+			this.deliveryQuotesLoading = true
+			this.deliveryQuotes = []
+			this.selectedDeliveryIndex = -1
+			this.selectedDeliveryData = null
+			
+			allDeliveryQuotes({
+				ghsId: this.option.id,
+				weight: this.allCountFun.weight,
+				selectList: this.selectList,
+			}).then(res => {
+				this.deliveryQuotesLoading = false
+				if (res.code === 1 && res.data && res.data.deliveryList) {
+					// 处理报价数据
+					this.deliveryQuotes = res.data.deliveryList.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)
+					if (firstAvailableIndex !== -1) {
+						this.selectDelivery(this.deliveryQuotes[firstAvailableIndex], firstAvailableIndex)
+					}
+				} else {
+					uni.showToast({
+						title: '暂无可用的配送平台',
+						icon: 'none'
+					})
+				}
+			}).catch(err => {
+				this.deliveryQuotesLoading = false
+				console.error('获取跑腿报价失败:', err)
+				uni.showToast({
+					title: '获取报价失败',
+					icon: 'none'
+				})
+			})
+		},
+		// 选择跑腿平台
+		selectDelivery(item, index) {
+			if (!item.isAble) {
+				uni.showToast({
+					title: '该平台暂不可用',
+					icon: 'none'
+				})
+				return
+			}
+			
+			this.selectedDeliveryIndex = index
+			this.selectedDeliveryData = item
+			this.form.sendCost = item.priceNumber
+			this.showDistance = item.distance || 0
+		},
 		modifyAddress(){
       		this.$util.pageTo({ url: '/admin/shop/add?id='+this.getLoginInfo.admin.currentShopId})
 		},
@@ -1126,4 +1229,100 @@ export default {
 		}
 	}
 }
+
+/* 跑腿平台报价样式 */
+.delivery-quotes-container {
+	width: 100%;
+	margin-top: 20upx;
+}
+
+.delivery-quotes-grid {
+	display: flex;
+	flex-wrap: wrap;
+	justify-content: space-between;
+	padding: 0;
+}
+
+.delivery-quote-item {
+	display: flex;
+	flex-direction: column;
+	align-items: center;
+	justify-content: center;
+	width: 31%;
+	min-height: 140upx;
+	padding: 16upx 10upx;
+	margin-bottom: 15upx;
+	background: #FFFFFF;
+	border: 2upx solid #DDDDDD;
+	border-radius: 8upx;
+	box-sizing: border-box;
+	transition: all 0.3s;
+	
+	.platform-name {
+		font-size: 26upx;
+		color: #333;
+		font-weight: bold;
+		margin-bottom: 8upx;
+		text-align: center;
+		line-height: 1.3;
+		max-width: 100%;
+		overflow: hidden;
+		text-overflow: ellipsis;
+		display: -webkit-box;
+		-webkit-line-clamp: 2;
+		line-clamp: 2;
+		-webkit-box-orient: vertical;
+		word-break: break-all;
+	}
+	
+	.platform-price {
+		font-size: 30upx;
+		color: #333;
+		font-weight: bold;
+		margin-bottom: 4upx;
+	}
+	
+	.platform-type {
+		font-size: 20upx;
+		color: #868686;
+		margin-top: 4upx;
+		text-align: center;
+		line-height: 1.3;
+		max-width: 100%;
+		overflow: hidden;
+		text-overflow: ellipsis;
+		display: -webkit-box;
+		-webkit-line-clamp: 2;
+		line-clamp: 2;
+		-webkit-box-orient: vertical;
+		word-break: break-all;
+	}
+	
+	// 选中状态
+	&.active {
+		background: #09C567;
+		border-color: #09C567;
+		
+		.platform-name,
+		.platform-price {
+			color: #FFFFFF;
+		}
+		
+		.platform-type {
+			color: rgba(255, 255, 255, 0.85);
+		}
+	}
+	
+	// 不可用状态
+	&.disabled {
+		opacity: 0.5;
+		background: #F5F5F5;
+		
+		.platform-name,
+		.platform-price,
+		.platform-type {
+			color: #CCCCCC;
+		}
+	}
+}
 </style>

+ 5 - 0
hdApp/src/api/express/delivery.js

@@ -0,0 +1,5 @@
+import https from '@/plugins/luch-request_0.0.7/request'
+
+export const allDeliveryQuotes = data => {
+	return https.post('/delivery/all-delivery-quotes', data)
+}