Ver código fonte

包配送政策

shizhongqi 7 meses atrás
pai
commit
377c610f6c

+ 144 - 1
hdApp/src/admin/billing/affirmGhs.vue

@@ -245,6 +245,9 @@
 				<view>
 					<text :class="isFreeDelivery ? 'delivery-price-free' : 'delivery-price-normal'">¥ {{ form.sendCost }}</text>
 					<text v-if="isFreeDelivery" class="free-delivery-tag">【免跑腿费】</text>
+					<text v-if="showDeliveryPolicy" class="delivery-policy-link" @click="showDeliveryPolicyModal">
+						<text class="iconfont iconchangjianwentixiangguanwenti2 policy-icon"></text>包配送政策
+					</text>
 				</view>
 			</tui-list-cell>
 					<tui-list-cell class="line-cell" :hover="false" :arrow="true" v-if="displayAddress == true" @click="modifyAddress">
@@ -304,6 +307,20 @@
 			</view>
 		</uni-popup>
 
+		<uni-popup ref="deliveryPolicyPopup" type="center" background-color="#fff">
+			<view class="policy-popup-content">
+				<view class="policy-title">包配送政策</view>
+				<scroll-view scroll-y="true" class="policy-scroll">
+					<view class="policy-list">
+						<block v-for="(item, index) in deliveryPolicyList" :key="index">
+							<view class="policy-item">{{ item }}</view>
+						</block>
+					</view>
+				</scroll-view>
+				<view class="policy-btn" @click="closeDeliveryPolicy">知道了</view>
+			</view>
+		</uni-popup>
+
 	</view>
 </template>
 
@@ -403,7 +420,8 @@ export default {
 			deliveryQuotes: [], // 跑腿平台报价列表
 			selectedDeliveryIndex: -1, // 选中的报价索引
 			deliveryQuotesLoading: false, // 报价加载状态
-			selectedDeliveryData: null // 选中的报价数据
+			selectedDeliveryData: null, // 选中的报价数据
+			deliveryPolicyList: [] // 包配送政策列表
 		};
 	},
 	onLoad() {
@@ -479,6 +497,9 @@ export default {
 			
 			// 条件2: 如果距离大于免费公里数,判断hcMap
 			if(distanceInMeters > freeKmInMeters){
+				if(this.ghsInfo.hcMap && typeof this.ghsInfo.hcMap == 'string'){
+					this.ghsInfo.hcMap = JSON.parse(this.ghsInfo.hcMap)
+				}
 				// 判断hcMap是否为空
 				if(this.ghsInfo.hcMap && Array.isArray(this.ghsInfo.hcMap) && this.ghsInfo.hcMap.length > 0){
 					// 获取花材数量和总价
@@ -501,6 +522,31 @@ export default {
 			
 			return false
 		},
+		/**
+		 * 是否显示包配送政策
+		 */
+		showDeliveryPolicy() {
+			if (!this.ghsInfo) return false
+			
+			// 检查 hcFreeKm
+			const hasFreeKm = this.ghsInfo.hcFreeKm && Number(this.ghsInfo.hcFreeKm) > 0
+			
+			// 检查 hcMap
+			let hasMap = false
+			let mapData = this.ghsInfo.hcMap
+			if(mapData && typeof mapData == 'string'){
+				try {
+					mapData = JSON.parse(mapData)
+				} catch(e) {
+					// 解析失败忽略
+				}
+			}
+			if(mapData && Array.isArray(mapData) && mapData.length > 0){
+				hasMap = true
+			}
+			
+			return hasFreeKm || hasMap
+		},
 		/**
 		 * 计算总金额
 		 * @returns {number}
@@ -548,6 +594,47 @@ export default {
 			this.form.wlId = this.wlSelData.id
 			this.form.wlName = this.wlSelData.name
 		},
+		// 展示包配送政策弹窗
+		showDeliveryPolicyModal() {
+			this.deliveryPolicyList = []
+			
+			// 1. hcFreeKm 规则
+			if (this.ghsInfo.hcFreeKm && Number(this.ghsInfo.hcFreeKm) > 0) {
+				this.deliveryPolicyList.push(`${Number(this.ghsInfo.hcFreeKm)}公里内免费配送`)
+			}
+			
+			// 2. hcMap 规则
+			let mapData = this.ghsInfo.hcMap
+			if(mapData && typeof mapData == 'string'){
+				try {
+					mapData = JSON.parse(mapData)
+				} catch(e) {
+					mapData = []
+				}
+			}
+			if(mapData && Array.isArray(mapData) && mapData.length > 0){
+				mapData.forEach(rule => {
+					const num = Number(rule.num) || 0
+					const price = Number(rule.price) || 0
+					const distance = Number(rule.distance) || 0
+					
+					this.deliveryPolicyList.push(`满${num}扎${price}元,${distance}公里内免费配送`)
+				})
+			}
+			
+			if (this.deliveryPolicyList.length === 0) {
+				uni.showToast({
+					title: '暂无详细配送政策',
+					icon: 'none'
+				})
+				return
+			}
+			
+			this.$refs.deliveryPolicyPopup.open()
+		},
+		closeDeliveryPolicy() {
+			this.$refs.deliveryPolicyPopup.close()
+		},
 		closeRemind(){
 			this.$refs.selectFlowerNumRef.close()
 			this.lackList = []
@@ -1440,4 +1527,60 @@ export default {
 	color: #3385FF;
 	margin-left: 10upx;
 }
+
+.delivery-policy-link {
+	color: rgb(201, 52, 52);
+	font-size: 28upx;
+	margin-left: 26upx;
+	text-decoration: underline;
+}
+
+.policy-icon {
+	font-size: 28upx;
+	margin-left: 4upx;
+}
+
+.policy-popup-content {
+	width: 600upx;
+	background-color: #fff;
+	border-radius: 20upx;
+	padding: 30upx;
+	display: flex;
+	flex-direction: column;
+	align-items: center;
+}
+.policy-title {
+	font-size: 34upx;
+	font-weight: bold;
+	color: #333;
+	margin-bottom: 30upx;
+}
+.policy-scroll {
+	width: 100%;
+	max-height: 50vh;
+	margin-bottom: 30upx;
+}
+.policy-list {
+	width: 100%;
+}
+.policy-item {
+	font-size: 30upx;
+	color: #666;
+	margin-bottom: 20upx;
+	text-align: left;
+	line-height: 1.5;
+	display: list-item;
+	list-style-type: disc;
+	margin-left: 40upx;
+}
+.policy-btn {
+	width: 100%;
+	height: 80upx;
+	line-height: 80upx;
+	text-align: center;
+	background-color: #3385ff;
+	color: #fff;
+	font-size: 32upx;
+	border-radius: 40upx;
+}
 </style>

+ 142 - 2
mallApp/src/pages/billing/affirmGhs.vue

@@ -112,6 +112,9 @@
 							<view>
 								<text :class="isFreeDelivery ? 'delivery-price-free' : 'delivery-price-normal'">¥ {{ form.sendCost }}</text>
 								<text v-if="isFreeDelivery" class="free-delivery-tag">【免跑腿费】</text>
+								<text v-if="showDeliveryPolicy" class="delivery-policy-link" @click="showDeliveryPolicyModal">
+									<text class="iconfont iconchangjianwentixiangguanwenti2 policy-icon"></text>包配送政策
+								</text>
 							</view>
 						</tui-list-cell>
 					</block>
@@ -168,7 +171,7 @@
 	<mx-date-picker :show="showDatePicker" format="yyyy-mm-dd" type="date" :value="defaultPickerDate" :show-tips="true" @confirm="confirmDatePicker" @cancel="showDatePicker = false" />
 
 	<!-- 配送时间选择弹框 -->
-	<uni-popup ref="timePopup" type="bottom" background-color="#fff">
+		<uni-popup ref="timePopup" type="bottom" background-color="#fff">
 		<view class="time-picker-popup">
 			<view class="popup-header">
 				<text class="popup-title">选择配送时间</text>
@@ -231,6 +234,20 @@
 		</view>
 	</uni-popup>
 
+	<uni-popup ref="deliveryPolicyPopup" type="center" background-color="#fff">
+		<view class="policy-popup-content">
+			<view class="policy-title">包配送政策</view>
+			<scroll-view scroll-y="true" class="policy-scroll">
+				<view class="policy-list">
+					<block v-for="(item, index) in deliveryPolicyList" :key="index">
+						<view class="policy-item">{{ item }}</view>
+					</block>
+				</view>
+			</scroll-view>
+			<view class="policy-btn" @click="closeDeliveryPolicy">知道了</view>
+		</view>
+	</uni-popup>
+
 </view>
 </template>
 <script>
@@ -283,7 +300,8 @@ export default {
 			selectedDeliveryIndex: -1, // 选中的报价索引
 			deliveryQuotesLoading: false, // 报价加载状态
 			selectedDeliveryData: null, // 选中的报价数据
-			isFreeDelivery: false // 是否免跑腿费
+			isFreeDelivery: false, // 是否免跑腿费
+			deliveryPolicyList: [] // 包配送政策列表
 		};
 	},
 	onShow() {
@@ -350,6 +368,31 @@ export default {
 			}
 			return price.toFixed(2)
 		},
+		/**
+		 * 是否显示包配送政策
+		 */
+		showDeliveryPolicy() {
+			if (!this.shopInfo) return false
+			
+			// 检查 hcFreeKm
+			const hasFreeKm = this.shopInfo.hcFreeKm && Number(this.shopInfo.hcFreeKm) > 0
+			
+			// 检查 hcMap
+			let hasMap = false
+			let mapData = this.shopInfo.hcMap
+			if(mapData && typeof mapData == 'string'){
+				try {
+					mapData = JSON.parse(mapData)
+				} catch(e) {
+					// 解析失败忽略
+				}
+			}
+			if(mapData && Array.isArray(mapData) && mapData.length > 0){
+				hasMap = true
+			}
+			
+			return hasFreeKm || hasMap
+		},
 	},
 	onLoad(){
 		if(this.option.account){
@@ -377,6 +420,47 @@ export default {
 			this.form.reachPeriod = `${this.selectedHour}:${this.selectedMinute}`
 			this.closeTimePopup()
 		},
+		// 展示包配送政策弹窗
+		showDeliveryPolicyModal() {
+			this.deliveryPolicyList = []
+			
+			// 1. hcFreeKm 规则
+			if (this.shopInfo.hcFreeKm && Number(this.shopInfo.hcFreeKm) > 0) {
+				this.deliveryPolicyList.push(`${Number(this.shopInfo.hcFreeKm)}公里内免费配送`)
+			}
+			
+			// 2. hcMap 规则
+			let mapData = this.shopInfo.hcMap
+			if(mapData && typeof mapData == 'string'){
+				try {
+					mapData = JSON.parse(mapData)
+				} catch(e) {
+					mapData = []
+				}
+			}
+			if(mapData && Array.isArray(mapData) && mapData.length > 0){
+				mapData.forEach(rule => {
+					const num = Number(rule.num) || 0
+					const price = Number(rule.price) || 0
+					const distance = Number(rule.distance) || 0
+					
+					this.deliveryPolicyList.push(`满${num}扎${price}元,${distance}公里内免费配送`)
+				})
+			}
+			
+			if (this.deliveryPolicyList.length === 0) {
+				uni.showToast({
+					title: '暂无详细配送政策',
+					icon: 'none'
+				})
+				return
+			}
+			
+			this.$refs.deliveryPolicyPopup.open()
+		},
+		closeDeliveryPolicy() {
+			this.$refs.deliveryPolicyPopup.close()
+		},
 		checkFreeDelivery(){
 			// 不显示跑腿费时,不需要判断
 			if(this.displaySendCost == false){
@@ -1125,4 +1209,60 @@ export default {
     opacity: 0;
   }
 }
+
+.delivery-policy-link {
+	color: rgb(201, 52, 52);
+	font-size: 28upx;
+	margin-left: 26upx;
+	text-decoration: underline;
+}
+
+.policy-icon {
+	font-size: 28upx;
+	margin-left: 4upx;
+}
+
+.policy-popup-content {
+	width: 600upx;
+	background-color: #fff;
+	border-radius: 20upx;
+	padding: 30upx;
+	display: flex;
+	flex-direction: column;
+	align-items: center;
+}
+.policy-title {
+	font-size: 34upx;
+	font-weight: bold;
+	color: #333;
+	margin-bottom: 30upx;
+}
+.policy-scroll {
+	width: 100%;
+	max-height: 50vh;
+	margin-bottom: 30upx;
+}
+.policy-list {
+	width: 100%;
+}
+.policy-item {
+	font-size: 30upx;
+	color: #666;
+	margin-bottom: 20upx;
+	text-align: left;
+	line-height: 1.5;
+	display: list-item;
+	list-style-type: disc;
+	margin-left: 40upx;
+}
+.policy-btn {
+	width: 100%;
+	height: 80upx;
+	line-height: 80upx;
+	text-align: center;
+	background-color: #3385ff;
+	color: #fff;
+	font-size: 32upx;
+	border-radius: 40upx;
+}
 </style>

+ 114 - 1
mallApp/src/pages/order/components/app-delivery.vue

@@ -72,6 +72,9 @@
               <view class="tui-input">
                 <text :class="isFreeDelivery ? 'delivery-price-free' : 'delivery-price-normal'">¥ {{ form.sendCost }}</text>
                 <text v-if="isFreeDelivery" class="free-delivery-tag">【免跑腿费】</text>
+                <text v-if="showDeliveryPolicy" class="delivery-policy-link" @click="showDeliveryPolicyModal">
+									<text class="iconfont iconchangjianwentixiangguanwenti2 policy-icon"></text>包配送政策
+								</text>
               </view>
           </tui-list-cell>
           
@@ -189,6 +192,20 @@
     <view v-if="showDatePicker" class="date-picker-mask" @click="showDatePicker = false"></view>
     
     <mx-date-picker :show="showDatePicker" format="yyyy-mm-dd" type="date" :value="defaultPickerDate" :show-tips="true" @confirm="confirmDatePicker" @cancel="showDatePicker = false" />
+
+    <uni-popup ref="deliveryPolicyPopup" type="center" background-color="#fff">
+      <view class="policy-popup-content">
+        <view class="policy-title">包配送政策</view>
+        <scroll-view scroll-y="true" class="policy-scroll">
+          <view class="policy-list">
+            <block v-for="(item, index) in deliveryPolicyList" :key="index">
+              <view class="policy-item">{{ item }}</view>
+            </block>
+          </view>
+        </scroll-view>
+        <view class="policy-btn" @click="closeDeliveryPolicy">知道了</view>
+      </view>
+    </uni-popup>
   </div>
 </template>
 
@@ -285,12 +302,20 @@ export default {
       selectedDeliveryIndex: -1, // 选中的报价索引
       deliveryQuotesLoading: false, // 报价加载状态
       selectedDeliveryData: null, // 选中的报价数据
-      goodsInfo: {}
+      goodsInfo: {},
+      deliveryPolicyList: []
     };
   },
   computed: {
     ...mapGetters({ orderShop: "getOrderShop" }),
     ...mapGetters({ shopUser: "getShopUser" }),
+    /**
+     * 是否显示包配送政策
+     */
+    showDeliveryPolicy() {
+      // 只要有免费公里数或者有加收费用配置且不是收配送费,就显示政策
+      return (Number(this.hsFreeKm) > 0 || Number(this.hsAddFee) > 0) && !this.isFreight;
+    },
     /**
      * 是否免跑腿费
      * @returns {boolean}
@@ -504,6 +529,38 @@ export default {
       }
       
       return 0;
+    },
+    // 展示包配送政策弹窗
+    showDeliveryPolicyModal() {
+      this.deliveryPolicyList = []
+      
+      const freeKm = Number(this.hsFreeKm) || 0
+      const addFee = Number(this.hsAddFee) || 0
+
+      if (freeKm > 0) {
+        this.deliveryPolicyList.push(`${freeKm}公里内免费配送`)
+      }
+
+      if (addFee > 0) {
+        if (freeKm > 0) {
+          this.deliveryPolicyList.push(`超出${freeKm}公里后,每公里收取${addFee}元`)
+        } else {
+          this.deliveryPolicyList.push(`每公里收取${addFee}元配送费`)
+        }
+      }
+      
+      if (this.deliveryPolicyList.length === 0) {
+        uni.showToast({
+          title: '暂无详细配送政策',
+          icon: 'none'
+        })
+        return
+      }
+      
+      this.$refs.deliveryPolicyPopup.open()
+    },
+    closeDeliveryPolicy() {
+      this.$refs.deliveryPolicyPopup.close()
     }
   }
 };
@@ -995,4 +1052,60 @@ export default {
     opacity: 0;
   }
 }
+
+.delivery-policy-link {
+	color: rgb(201, 52, 52);
+	font-size: 28upx;
+	margin-left: 26upx;
+	text-decoration: underline;
+}
+
+.policy-icon {
+	font-size: 28upx;
+	margin-left: 4upx;
+}
+
+.policy-popup-content {
+	width: 600upx;
+	background-color: #fff;
+	border-radius: 20upx;
+	padding: 30upx;
+	display: flex;
+	flex-direction: column;
+	align-items: center;
+}
+.policy-title {
+	font-size: 34upx;
+	font-weight: bold;
+	color: #333;
+	margin-bottom: 30upx;
+}
+.policy-scroll {
+	width: 100%;
+	max-height: 50vh;
+	margin-bottom: 30upx;
+}
+.policy-list {
+	width: 100%;
+}
+.policy-item {
+	font-size: 30upx;
+	color: #666;
+	margin-bottom: 20upx;
+	text-align: left;
+	line-height: 1.5;
+	display: list-item;
+	list-style-type: disc;
+	margin-left: 40upx;
+}
+.policy-btn {
+	width: 100%;
+	height: 80upx;
+	line-height: 80upx;
+	text-align: center;
+	background-color: #3385ff;
+	color: #fff;
+	font-size: 32upx;
+	border-radius: 40upx;
+}
 </style>