【功能优化】商城:调整满减送的数据返回
							parent
							
								
									e727974806
								
							
						
					
					
						commit
						3dad154ca0
					
				|  | @ -7,7 +7,7 @@ | |||
|         <view class="type-text ss-flex ss-row-center">满减:</view> | ||||
|         <view class="ss-flex-1"> | ||||
|           <view class="tip-content" v-for="item in state.activityInfo.rules" :key="item"> | ||||
|             {{ item.description[1] }} | ||||
|             {{ item.description }} | ||||
|           </view> | ||||
|         </view> | ||||
|         <image class="activity-left-image" src="/static/activity-left.png" /> | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -1,259 +1,255 @@ | |||
| <!-- 商品信息:满减送等营销活动的弹窗 --> | ||||
| <template> | ||||
| 	<su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose> | ||||
| 		<view class="model-box"> | ||||
| 			<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠</view> | ||||
| 			<view v-if="state.rewardActivity && state.rewardActivity.id > 0"> | ||||
| 				<view class="titleLi">促销</view> | ||||
| 				<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true"> | ||||
| 					<view class="actBox" v-for="(item, index) in state.handeActivity" :key="index"> | ||||
| 						<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(state.rewardActivity)"> | ||||
| 							<view class="model-content-tag ss-flex ss-row-center">{{item.name}}</view> | ||||
| 							<view class="model-content-title"> | ||||
| 								<view class="contBu"> | ||||
| 									<text v-for="(items,indexs) in item.value" :key="indexs">{{ items }};</text> | ||||
| 								</view> | ||||
| 								<view class="ss-m-b-24 cotBu-txt"> | ||||
| 									{{ sheep.$helper.timeFormat(state.rewardActivity.startTime, 'yyyy.mm.dd') }} | ||||
| 									- | ||||
| 									{{ sheep.$helper.timeFormat(state.rewardActivity.endTime, 'yyyy.mm.dd') }} | ||||
| 								</view> | ||||
| 							</view> | ||||
| 							<text class="cicon-forward" /> | ||||
| 						</view> | ||||
| 					</view> | ||||
| 				</scroll-view> | ||||
| 			</view> | ||||
| 			<view class="titleLi">可领优惠券</view> | ||||
| 			<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true" v-if="state.couponInfo.length"> | ||||
| 				<view class="actBox" v-for="item in state.couponInfo" :key="item.id"> | ||||
| 					<view class="boxCont ss-flex ss-col-top ss-m-b-40"> | ||||
| 						<view class="model-content-tag2"> | ||||
| 							<view class="usePrice"> ¥{{ fen2yuan(item.discountPrice) }} </view> | ||||
| 							<view class="impose"> 满¥{{ fen2yuan(item.usePrice) }}可用 </view> | ||||
| 						</view> | ||||
| 						<view class="model-content-title2"> | ||||
| 							<view class="contBu"> | ||||
| 								{{ item.name }} | ||||
| 							</view> | ||||
| 							<view class="ss-m-b-24 cotBu-txt"> | ||||
| 								{{ | ||||
| 		              item.validityType == 1 | ||||
| 		                ? sheep.$helper.timeFormat(item.validStartTime, 'yyyy.mm.dd') - | ||||
| 		                  sheep.$helper.timeFormat(item.validEndTime, 'yyyy.mm.dd') | ||||
| 		                : '领取后' + item.fixedStartTerm + '-' + item.fixedEndTerm + '天可用' | ||||
| 		            }} | ||||
| 							</view> | ||||
| 						</view> | ||||
| 						<view class="coupon" @click.stop="getBuy(item.id)" v-if="item.canTake"> 立即领取 </view> | ||||
| 						<view class="coupon2" v-else> 已领取 </view> | ||||
| 					</view> | ||||
| 				</view> | ||||
| 			</scroll-view> | ||||
| 			<view class="nullBox" v-else> | ||||
| 				暂无可领优惠券 | ||||
| 			</view> | ||||
| 		</view> | ||||
| 	</su-popup> | ||||
|   <su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose> | ||||
|     <view class="model-box"> | ||||
|       <view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠</view> | ||||
|       <view v-if="state.rewardActivity && state.rewardActivity.id > 0"> | ||||
|         <view class="titleLi">促销</view> | ||||
|         <scroll-view | ||||
|           class="model-content" | ||||
|           scroll-y | ||||
|           :scroll-with-animation="false" | ||||
|           :enable-back-to-top="true" | ||||
|         > | ||||
|           <view | ||||
|             class="actBox" | ||||
|             v-for="(item, index) in getRewardActivityRuleGroupDescriptions(state.rewardActivity)" | ||||
|             :key="index" | ||||
|           > | ||||
|             <view | ||||
|               class="boxCont ss-flex ss-col-top ss-m-b-40" | ||||
|               @tap="onGoodsList(state.rewardActivity)" | ||||
|             > | ||||
|               <view class="model-content-tag ss-flex ss-row-center">{{ item.name }}</view> | ||||
|               <view class="model-content-title"> | ||||
|                 <view class="contBu"> | ||||
|                   {{ item.values.join(';') }} | ||||
|                 </view> | ||||
|                 <view class="ss-m-b-24 cotBu-txt"> | ||||
|                   {{ sheep.$helper.timeFormat(state.rewardActivity.startTime, 'yyyy.mm.dd') }} | ||||
|                   - | ||||
|                   {{ sheep.$helper.timeFormat(state.rewardActivity.endTime, 'yyyy.mm.dd') }} | ||||
|                 </view> | ||||
|               </view> | ||||
|               <text class="cicon-forward" /> | ||||
|             </view> | ||||
|           </view> | ||||
|         </scroll-view> | ||||
|       </view> | ||||
|       <view class="titleLi">可领优惠券</view> | ||||
|       <scroll-view | ||||
|         class="model-content" | ||||
|         scroll-y | ||||
|         :scroll-with-animation="false" | ||||
|         :enable-back-to-top="true" | ||||
|         v-if="state.couponInfo.length" | ||||
|       > | ||||
|         <view class="actBox" v-for="item in state.couponInfo" :key="item.id"> | ||||
|           <view class="boxCont ss-flex ss-col-top ss-m-b-40"> | ||||
|             <view class="model-content-tag2"> | ||||
|               <view class="usePrice"> ¥{{ fen2yuan(item.discountPrice) }} </view> | ||||
|               <view class="impose"> 满¥{{ fen2yuan(item.usePrice) }}可用 </view> | ||||
|             </view> | ||||
|             <view class="model-content-title2"> | ||||
|               <view class="contBu"> | ||||
|                 {{ item.name }} | ||||
|               </view> | ||||
|               <view class="ss-m-b-24 cotBu-txt"> | ||||
|                 {{ | ||||
|                   item.validityType == 1 | ||||
|                     ? sheep.$helper.timeFormat(item.validStartTime, 'yyyy.mm.dd') - | ||||
|                       sheep.$helper.timeFormat(item.validEndTime, 'yyyy.mm.dd') | ||||
|                     : '领取后' + item.fixedStartTerm + '-' + item.fixedEndTerm + '天可用' | ||||
|                 }} | ||||
|               </view> | ||||
|             </view> | ||||
|             <view class="coupon" @click.stop="getBuy(item.id)" v-if="item.canTake"> 立即领取 </view> | ||||
|             <view class="coupon2" v-else> 已领取 </view> | ||||
|           </view> | ||||
|         </view> | ||||
|       </scroll-view> | ||||
|       <view class="nullBox" v-else> 暂无可领优惠券 </view> | ||||
|     </view> | ||||
|   </su-popup> | ||||
| </template> | ||||
| <script setup> | ||||
| 	import sheep from '@/sheep'; | ||||
| 	import { | ||||
| 		handeleData | ||||
| 	} from '@/sheep/hooks/useGoods'; | ||||
| 	import { | ||||
| 		computed, | ||||
| 		reactive, | ||||
| 		watch, | ||||
| 		ref | ||||
| 	} from 'vue'; | ||||
| 	import { | ||||
| 		fen2yuan | ||||
| 	} from '@/sheep/hooks/useGoods'; | ||||
| 	const props = defineProps({ | ||||
| 		modelValue: { | ||||
| 			type: Object, | ||||
| 			default () {}, | ||||
| 		}, | ||||
| 		show: { | ||||
| 			type: Boolean, | ||||
| 			default: false, | ||||
| 		}, | ||||
| 	}); | ||||
| 	const emits = defineEmits(['close']); | ||||
| 	const state = reactive({ | ||||
| 		rewardActivity: computed(() => props.modelValue.rewardActivity), | ||||
| 		couponInfo: computed(() => props.modelValue.couponInfo), | ||||
| 	}); | ||||
| 	// setTimeout(()=>{ | ||||
| 	// 	 console.log('历程数据',state.rewardActivity.ruleDescriptions) | ||||
| 	// 	 console.log('处理数据',handeleData(props.modelValue.rewardActivity.ruleDescriptions)) | ||||
| 	// },5000) | ||||
| 	// 领取优惠劵 | ||||
| 	const getBuy = (id) => { | ||||
| 		emits('get', id); | ||||
| 	}; | ||||
|   import sheep from '@/sheep'; | ||||
|   import { getRewardActivityRuleGroupDescriptions } from '@/sheep/hooks/useGoods'; | ||||
|   import { computed, reactive, watch, ref } from 'vue'; | ||||
|   import { fen2yuan } from '@/sheep/hooks/useGoods'; | ||||
|   const props = defineProps({ | ||||
|     modelValue: { | ||||
|       type: Object, | ||||
|       default() {}, | ||||
|     }, | ||||
|     show: { | ||||
|       type: Boolean, | ||||
|       default: false, | ||||
|     }, | ||||
|   }); | ||||
|   const emits = defineEmits(['close']); | ||||
|   const state = reactive({ | ||||
|     rewardActivity: computed(() => props.modelValue.rewardActivity), | ||||
|     couponInfo: computed(() => props.modelValue.couponInfo), | ||||
|   }); | ||||
| 
 | ||||
| 	function onGoodsList(e) { | ||||
| 		sheep.$router.go('/pages/activity/index', { | ||||
| 			activityId: e.id, | ||||
| 		}); | ||||
| 	} | ||||
| 	//监听获取到数据后再执行且只执行一次 | ||||
| 	let flag = ref(true) | ||||
| 	watch(state, (newValue, oldValue) => { | ||||
| 		if (flag.value) { | ||||
| 			flag.value = false | ||||
| 			state.handeActivity = handeleData(state.rewardActivity.ruleDescriptions) | ||||
| 		} | ||||
| 	}); | ||||
|   // 领取优惠劵 | ||||
|   const getBuy = (id) => { | ||||
|     emits('get', id); | ||||
|   }; | ||||
| 
 | ||||
|   function onGoodsList(e) { | ||||
|     sheep.$router.go('/pages/activity/index', { | ||||
|       activityId: e.id, | ||||
|     }); | ||||
|   } | ||||
| </script> | ||||
| <style lang="scss" scoped> | ||||
| 	.model-box { | ||||
| 		height: 60vh; | ||||
|   .model-box { | ||||
|     height: 60vh; | ||||
| 
 | ||||
| 		.title { | ||||
| 			justify-content: center; | ||||
| 			font-size: 36rpx; | ||||
| 			height: 80rpx; | ||||
| 			font-weight: bold; | ||||
| 			color: #333333; | ||||
| 		} | ||||
| 	} | ||||
|     .title { | ||||
|       justify-content: center; | ||||
|       font-size: 36rpx; | ||||
|       height: 80rpx; | ||||
|       font-weight: bold; | ||||
|       color: #333333; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 	.model-content { | ||||
| 		height: fit-content; | ||||
| 		max-height: 380rpx; | ||||
| 		padding: 0 20rpx; | ||||
| 		box-sizing: border-box; | ||||
| 		margin-top: 20rpx; | ||||
|   .model-content { | ||||
|     height: fit-content; | ||||
|     max-height: 380rpx; | ||||
|     padding: 0 20rpx; | ||||
|     box-sizing: border-box; | ||||
|     margin-top: 20rpx; | ||||
| 
 | ||||
| 		.model-content-tag { | ||||
| 			// background: rgba(#ff6911, 0.1); | ||||
| 			font-size: 35rpx; | ||||
| 			font-weight: 500; | ||||
| 			color: #ff6911; | ||||
| 			line-height: 150rpx; | ||||
| 			width: 200rpx; | ||||
| 			height: 150rpx; | ||||
| 			text-align: center; | ||||
|     .model-content-tag { | ||||
|       // background: rgba(#ff6911, 0.1); | ||||
|       font-size: 35rpx; | ||||
|       font-weight: 500; | ||||
|       color: #ff6911; | ||||
|       line-height: 150rpx; | ||||
|       width: 200rpx; | ||||
|       height: 150rpx; | ||||
|       text-align: center; | ||||
| 
 | ||||
| 			// border-radius: 5rpx; | ||||
| 		} | ||||
|       // border-radius: 5rpx; | ||||
|     } | ||||
| 
 | ||||
| 		.model-content-title { | ||||
| 			width: 450rpx; | ||||
| 			height: 150rpx; | ||||
| 			font-size: 26rpx; | ||||
| 			font-weight: 500; | ||||
| 			color: #333333; | ||||
| 			overflow: hidden; | ||||
| 		} | ||||
|     .model-content-title { | ||||
|       width: 450rpx; | ||||
|       height: 150rpx; | ||||
|       font-size: 26rpx; | ||||
|       font-weight: 500; | ||||
|       color: #333333; | ||||
|       overflow: hidden; | ||||
|     } | ||||
| 
 | ||||
| 		.cicon-forward { | ||||
| 			font-size: 28rpx; | ||||
| 			color: #999999; | ||||
| 			margin: 0 auto; | ||||
| 		} | ||||
| 	} | ||||
|     .cicon-forward { | ||||
|       font-size: 28rpx; | ||||
|       color: #999999; | ||||
|       margin: 0 auto; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 	// 新增的 | ||||
| 	.titleLi { | ||||
| 		margin: 10rpx 0 10rpx 20rpx; | ||||
| 		font-size: 26rpx; | ||||
| 	} | ||||
|   // 新增的 | ||||
|   .titleLi { | ||||
|     margin: 10rpx 0 10rpx 20rpx; | ||||
|     font-size: 26rpx; | ||||
|   } | ||||
| 
 | ||||
| 	.actBox { | ||||
| 		width: 700rpx; | ||||
| 		height: 150rpx; | ||||
| 		background-color: #fff2f2; | ||||
| 		margin: 10rpx auto; | ||||
| 		border-radius: 10rpx; | ||||
| 	} | ||||
|   .actBox { | ||||
|     width: 700rpx; | ||||
|     height: 150rpx; | ||||
|     background-color: #fff2f2; | ||||
|     margin: 10rpx auto; | ||||
|     border-radius: 10rpx; | ||||
|   } | ||||
| 
 | ||||
| 	.boxCont { | ||||
| 		width: 700rpx; | ||||
| 		height: 150rpx; | ||||
| 		align-items: center; | ||||
| 	} | ||||
|   .boxCont { | ||||
|     width: 700rpx; | ||||
|     height: 150rpx; | ||||
|     align-items: center; | ||||
|   } | ||||
| 
 | ||||
| 	.contBu { | ||||
| 		height: 80rpx; | ||||
| 		line-height: 80rpx; | ||||
| 		overflow: hidden; | ||||
| 		font-size: 30rpx; | ||||
| 		white-space: nowrap; | ||||
| 		text-overflow: ellipsis; | ||||
| 		-o-text-overflow: ellipsis; | ||||
| 	} | ||||
|   .contBu { | ||||
|     height: 80rpx; | ||||
|     line-height: 80rpx; | ||||
|     overflow: hidden; | ||||
|     font-size: 30rpx; | ||||
|     white-space: nowrap; | ||||
|     text-overflow: ellipsis; | ||||
|     -o-text-overflow: ellipsis; | ||||
|   } | ||||
| 
 | ||||
| 	.cotBu-txt { | ||||
| 		height: 70rpx; | ||||
| 		line-height: 70rpx; | ||||
| 		font-size: 25rpx; | ||||
| 		color: #999999; | ||||
| 	} | ||||
|   .cotBu-txt { | ||||
|     height: 70rpx; | ||||
|     line-height: 70rpx; | ||||
|     font-size: 25rpx; | ||||
|     color: #999999; | ||||
|   } | ||||
| 
 | ||||
| 	.model-content-tag2 { | ||||
| 		font-size: 35rpx; | ||||
| 		font-weight: 500; | ||||
| 		color: #ff6911; | ||||
| 		width: 200rpx; | ||||
| 		height: 150rpx; | ||||
| 		text-align: center; | ||||
| 	} | ||||
|   .model-content-tag2 { | ||||
|     font-size: 35rpx; | ||||
|     font-weight: 500; | ||||
|     color: #ff6911; | ||||
|     width: 200rpx; | ||||
|     height: 150rpx; | ||||
|     text-align: center; | ||||
|   } | ||||
| 
 | ||||
| 	.usePrice { | ||||
| 		width: 200rpx; | ||||
| 		height: 90rpx; | ||||
| 		line-height: 100rpx; | ||||
| 		// background-color: red; | ||||
| 	} | ||||
|   .usePrice { | ||||
|     width: 200rpx; | ||||
|     height: 90rpx; | ||||
|     line-height: 100rpx; | ||||
|     // background-color: red; | ||||
|   } | ||||
| 
 | ||||
| 	.impose { | ||||
| 		width: 200rpx; | ||||
| 		height: 50rpx; | ||||
| 		// line-height: 75rpx; | ||||
| 		font-size: 23rpx; | ||||
| 		// background-color: gold; | ||||
| 	} | ||||
|   .impose { | ||||
|     width: 200rpx; | ||||
|     height: 50rpx; | ||||
|     // line-height: 75rpx; | ||||
|     font-size: 23rpx; | ||||
|     // background-color: gold; | ||||
|   } | ||||
| 
 | ||||
| 	.model-content-title2 { | ||||
| 		width: 330rpx; | ||||
| 		height: 150rpx; | ||||
| 		font-size: 26rpx; | ||||
| 		font-weight: 500; | ||||
| 		color: #333333; | ||||
| 		overflow: hidden; | ||||
| 	} | ||||
|   .model-content-title2 { | ||||
|     width: 330rpx; | ||||
|     height: 150rpx; | ||||
|     font-size: 26rpx; | ||||
|     font-weight: 500; | ||||
|     color: #333333; | ||||
|     overflow: hidden; | ||||
|   } | ||||
| 
 | ||||
| 	.coupon { | ||||
| 		width: 150rpx; | ||||
| 		height: 50rpx; | ||||
| 		line-height: 50rpx; | ||||
| 		background-color: rgb(255, 68, 68); | ||||
| 		color: white; | ||||
| 		border-radius: 30rpx; | ||||
| 		text-align: center; | ||||
| 		font-size: 25rpx; | ||||
| 	} | ||||
|   .coupon { | ||||
|     width: 150rpx; | ||||
|     height: 50rpx; | ||||
|     line-height: 50rpx; | ||||
|     background-color: rgb(255, 68, 68); | ||||
|     color: white; | ||||
|     border-radius: 30rpx; | ||||
|     text-align: center; | ||||
|     font-size: 25rpx; | ||||
|   } | ||||
| 
 | ||||
| 	.coupon2 { | ||||
| 		width: 150rpx; | ||||
| 		height: 50rpx; | ||||
| 		line-height: 50rpx; | ||||
| 		background-color: rgb(203, 192, 191); | ||||
| 		color: white; | ||||
| 		border-radius: 30rpx; | ||||
| 		text-align: center; | ||||
| 		font-size: 25rpx; | ||||
| 	} | ||||
| 	.nullBox{ | ||||
| 		width: 100%; | ||||
| 		height: 300rpx; | ||||
| 		font-size: 25rpx; | ||||
| 		line-height: 300rpx; | ||||
| 		text-align: center; | ||||
| 		color: #999999; | ||||
| 	} | ||||
|   .coupon2 { | ||||
|     width: 150rpx; | ||||
|     height: 50rpx; | ||||
|     line-height: 50rpx; | ||||
|     background-color: rgb(203, 192, 191); | ||||
|     color: white; | ||||
|     border-radius: 30rpx; | ||||
|     text-align: center; | ||||
|     font-size: 25rpx; | ||||
|   } | ||||
|   .nullBox { | ||||
|     width: 100%; | ||||
|     height: 300rpx; | ||||
|     font-size: 25rpx; | ||||
|     line-height: 300rpx; | ||||
|     text-align: center; | ||||
|     color: #999999; | ||||
|   } | ||||
| </style> | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -1,11 +1,7 @@ | |||
| import { | ||||
| 	ref | ||||
| } from 'vue'; | ||||
| import { ref } from 'vue'; | ||||
| import dayjs from 'dayjs'; | ||||
| import $url from '@/sheep/url'; | ||||
| import { | ||||
| 	formatDate | ||||
| } from '@/sheep/util'; | ||||
| import { formatDate } from '@/sheep/util'; | ||||
| 
 | ||||
| /** | ||||
|  * 格式化销量 | ||||
|  | @ -14,8 +10,8 @@ import { | |||
|  * @return {string} 格式化后的销量字符串 | ||||
|  */ | ||||
| export function formatSales(type, num) { | ||||
| 	let prefix = type !== 'exact' && num < 10 ? '销量' : '已售'; | ||||
| 	return formatNum(prefix, type, num); | ||||
|   let prefix = type !== 'exact' && num < 10 ? '销量' : '已售'; | ||||
|   return formatNum(prefix, type, num); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -25,7 +21,7 @@ export function formatSales(type, num) { | |||
|  * @return {string} 格式化后的销量字符串 | ||||
|  */ | ||||
| export function formatExchange(type, num) { | ||||
| 	return formatNum('已兑换', type, num); | ||||
|   return formatNum('已兑换', type, num); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -35,7 +31,7 @@ export function formatExchange(type, num) { | |||
|  * @return {string} 格式化后的销量字符串 | ||||
|  */ | ||||
| export function formatStock(type, num) { | ||||
| 	return formatNum('库存', type, num); | ||||
|   return formatNum('库存', type, num); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -46,27 +42,27 @@ export function formatStock(type, num) { | |||
|  * @return {string} 格式化后的销量字符串 | ||||
|  */ | ||||
| export function formatNum(prefix, type, num) { | ||||
| 	num = num || 0; | ||||
| 	// 情况一:精确数值
 | ||||
| 	if (type === 'exact') { | ||||
| 		return prefix + num; | ||||
| 	} | ||||
| 	// 情况二:小于等于 10
 | ||||
| 	if (num < 10) { | ||||
| 		return `${prefix}≤10`; | ||||
| 	} | ||||
| 	// 情况三:大于 10,除第一位外,其它位都显示为0
 | ||||
| 	// 例如:100  - 199  显示为 100+
 | ||||
| 	//      9000 - 9999 显示为 9000+
 | ||||
| 	const numStr = num.toString(); | ||||
| 	const first = numStr[0]; | ||||
| 	const other = '0'.repeat(numStr.length - 1); | ||||
| 	return `${prefix}${first}${other}+`; | ||||
|   num = num || 0; | ||||
|   // 情况一:精确数值
 | ||||
|   if (type === 'exact') { | ||||
|     return prefix + num; | ||||
|   } | ||||
|   // 情况二:小于等于 10
 | ||||
|   if (num < 10) { | ||||
|     return `${prefix}≤10`; | ||||
|   } | ||||
|   // 情况三:大于 10,除第一位外,其它位都显示为0
 | ||||
|   // 例如:100  - 199  显示为 100+
 | ||||
|   //      9000 - 9999 显示为 9000+
 | ||||
|   const numStr = num.toString(); | ||||
|   const first = numStr[0]; | ||||
|   const other = '0'.repeat(numStr.length - 1); | ||||
|   return `${prefix}${first}${other}+`; | ||||
| } | ||||
| 
 | ||||
| // 格式化价格
 | ||||
| export function formatPrice(e) { | ||||
| 	return e.length === 1 ? e[0] : e.join('~'); | ||||
|   return e.length === 1 ? e[0] : e.join('~'); | ||||
| } | ||||
| 
 | ||||
| // 视频格式后缀列表
 | ||||
|  | @ -79,19 +75,19 @@ const VIDEO_SUFFIX_LIST = ['.avi', '.mp4']; | |||
|  * @return {{src: string, type: 'video' | 'image' }[]}  转换后的链接列表 | ||||
|  */ | ||||
| export function formatGoodsSwiper(urlList) { | ||||
| 	return ( | ||||
| 		urlList | ||||
| 		?.filter((url) => url) | ||||
| 		.map((url, key) => { | ||||
| 			const isVideo = VIDEO_SUFFIX_LIST.some((suffix) => url.includes(suffix)); | ||||
| 			const type = isVideo ? 'video' : 'image'; | ||||
| 			const src = $url.cdn(url); | ||||
| 			return { | ||||
| 				type, | ||||
| 				src, | ||||
| 			}; | ||||
| 		}) || [] | ||||
| 	); | ||||
|   return ( | ||||
|     urlList | ||||
|       ?.filter((url) => url) | ||||
|       .map((url, key) => { | ||||
|         const isVideo = VIDEO_SUFFIX_LIST.some((suffix) => url.includes(suffix)); | ||||
|         const type = isVideo ? 'video' : 'image'; | ||||
|         const src = $url.cdn(url); | ||||
|         return { | ||||
|           type, | ||||
|           src, | ||||
|         }; | ||||
|       }) || [] | ||||
|   ); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -101,16 +97,16 @@ export function formatGoodsSwiper(urlList) { | |||
|  * @return {string} 颜色的 class 名称 | ||||
|  */ | ||||
| export function formatOrderColor(order) { | ||||
| 	if (order.status === 0) { | ||||
| 		return 'info-color'; | ||||
| 	} | ||||
| 	if (order.status === 10 || order.status === 20 || (order.status === 30 && !order.commentStatus)) { | ||||
| 		return 'warning-color'; | ||||
| 	} | ||||
| 	if (order.status === 30 && order.commentStatus) { | ||||
| 		return 'success-color'; | ||||
| 	} | ||||
| 	return 'danger-color'; | ||||
|   if (order.status === 0) { | ||||
|     return 'info-color'; | ||||
|   } | ||||
|   if (order.status === 10 || order.status === 20 || (order.status === 30 && !order.commentStatus)) { | ||||
|     return 'warning-color'; | ||||
|   } | ||||
|   if (order.status === 30 && order.commentStatus) { | ||||
|     return 'success-color'; | ||||
|   } | ||||
|   return 'danger-color'; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -119,25 +115,25 @@ export function formatOrderColor(order) { | |||
|  * @param order 订单 | ||||
|  */ | ||||
| export function formatOrderStatus(order) { | ||||
| 	if (order.status === 0) { | ||||
| 		return '待付款'; | ||||
| 	} | ||||
| 	if (order.status === 10 && order.deliveryType === 1) { | ||||
| 		return '待发货'; | ||||
| 	} | ||||
| 	if (order.status === 10 && order.deliveryType === 2) { | ||||
| 		return '待核销'; | ||||
| 	} | ||||
| 	if (order.status === 20) { | ||||
| 		return '待收货'; | ||||
| 	} | ||||
| 	if (order.status === 30 && !order.commentStatus) { | ||||
| 		return '待评价'; | ||||
| 	} | ||||
| 	if (order.status === 30 && order.commentStatus) { | ||||
| 		return '已完成'; | ||||
| 	} | ||||
| 	return '已关闭'; | ||||
|   if (order.status === 0) { | ||||
|     return '待付款'; | ||||
|   } | ||||
|   if (order.status === 10 && order.deliveryType === 1) { | ||||
|     return '待发货'; | ||||
|   } | ||||
|   if (order.status === 10 && order.deliveryType === 2) { | ||||
|     return '待核销'; | ||||
|   } | ||||
|   if (order.status === 20) { | ||||
|     return '待收货'; | ||||
|   } | ||||
|   if (order.status === 30 && !order.commentStatus) { | ||||
|     return '待评价'; | ||||
|   } | ||||
|   if (order.status === 30 && order.commentStatus) { | ||||
|     return '已完成'; | ||||
|   } | ||||
|   return '已关闭'; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -146,22 +142,22 @@ export function formatOrderStatus(order) { | |||
|  * @param order 订单 | ||||
|  */ | ||||
| export function formatOrderStatusDescription(order) { | ||||
| 	if (order.status === 0) { | ||||
| 		return `请在 ${formatDate(order.payExpireTime)} 前完成支付`; | ||||
| 	} | ||||
| 	if (order.status === 10) { | ||||
| 		return '商家未发货,请耐心等待'; | ||||
| 	} | ||||
| 	if (order.status === 20) { | ||||
| 		return '商家已发货,请耐心等待'; | ||||
| 	} | ||||
| 	if (order.status === 30 && !order.commentStatus) { | ||||
| 		return '已收货,快去评价一下吧'; | ||||
| 	} | ||||
| 	if (order.status === 30 && order.commentStatus) { | ||||
| 		return '交易完成,感谢您的支持'; | ||||
| 	} | ||||
| 	return '交易关闭'; | ||||
|   if (order.status === 0) { | ||||
|     return `请在 ${formatDate(order.payExpireTime)} 前完成支付`; | ||||
|   } | ||||
|   if (order.status === 10) { | ||||
|     return '商家未发货,请耐心等待'; | ||||
|   } | ||||
|   if (order.status === 20) { | ||||
|     return '商家已发货,请耐心等待'; | ||||
|   } | ||||
|   if (order.status === 30 && !order.commentStatus) { | ||||
|     return '已收货,快去评价一下吧'; | ||||
|   } | ||||
|   if (order.status === 30 && order.commentStatus) { | ||||
|     return '交易完成,感谢您的支持'; | ||||
|   } | ||||
|   return '交易关闭'; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -170,32 +166,32 @@ export function formatOrderStatusDescription(order) { | |||
|  * @param order 订单 | ||||
|  */ | ||||
| export function handleOrderButtons(order) { | ||||
| 	order.buttons = []; | ||||
| 	if (order.type === 3) { | ||||
| 		// 查看拼团
 | ||||
| 		order.buttons.push('combination'); | ||||
| 	} | ||||
| 	if (order.status === 20) { | ||||
| 		// 确认收货
 | ||||
| 		order.buttons.push('confirm'); | ||||
| 	} | ||||
| 	if (order.logisticsId > 0) { | ||||
| 		// 查看物流
 | ||||
| 		order.buttons.push('express'); | ||||
| 	} | ||||
| 	if (order.status === 0) { | ||||
| 		// 取消订单 / 发起支付
 | ||||
| 		order.buttons.push('cancel'); | ||||
| 		order.buttons.push('pay'); | ||||
| 	} | ||||
| 	if (order.status === 30 && !order.commentStatus) { | ||||
| 		// 发起评价
 | ||||
| 		order.buttons.push('comment'); | ||||
| 	} | ||||
| 	if (order.status === 40) { | ||||
| 		// 删除订单
 | ||||
| 		order.buttons.push('delete'); | ||||
| 	} | ||||
|   order.buttons = []; | ||||
|   if (order.type === 3) { | ||||
|     // 查看拼团
 | ||||
|     order.buttons.push('combination'); | ||||
|   } | ||||
|   if (order.status === 20) { | ||||
|     // 确认收货
 | ||||
|     order.buttons.push('confirm'); | ||||
|   } | ||||
|   if (order.logisticsId > 0) { | ||||
|     // 查看物流
 | ||||
|     order.buttons.push('express'); | ||||
|   } | ||||
|   if (order.status === 0) { | ||||
|     // 取消订单 / 发起支付
 | ||||
|     order.buttons.push('cancel'); | ||||
|     order.buttons.push('pay'); | ||||
|   } | ||||
|   if (order.status === 30 && !order.commentStatus) { | ||||
|     // 发起评价
 | ||||
|     order.buttons.push('comment'); | ||||
|   } | ||||
|   if (order.status === 40) { | ||||
|     // 删除订单
 | ||||
|     order.buttons.push('delete'); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -204,31 +200,31 @@ export function handleOrderButtons(order) { | |||
|  * @param afterSale 售后 | ||||
|  */ | ||||
| export function formatAfterSaleStatus(afterSale) { | ||||
| 	if (afterSale.status === 10) { | ||||
| 		return '申请售后'; | ||||
| 	} | ||||
| 	if (afterSale.status === 20) { | ||||
| 		return '商品待退货'; | ||||
| 	} | ||||
| 	if (afterSale.status === 30) { | ||||
| 		return '商家待收货'; | ||||
| 	} | ||||
| 	if (afterSale.status === 40) { | ||||
| 		return '等待退款'; | ||||
| 	} | ||||
| 	if (afterSale.status === 50) { | ||||
| 		return '退款成功'; | ||||
| 	} | ||||
| 	if (afterSale.status === 61) { | ||||
| 		return '买家取消'; | ||||
| 	} | ||||
| 	if (afterSale.status === 62) { | ||||
| 		return '商家拒绝'; | ||||
| 	} | ||||
| 	if (afterSale.status === 63) { | ||||
| 		return '商家拒收货'; | ||||
| 	} | ||||
| 	return '未知状态'; | ||||
|   if (afterSale.status === 10) { | ||||
|     return '申请售后'; | ||||
|   } | ||||
|   if (afterSale.status === 20) { | ||||
|     return '商品待退货'; | ||||
|   } | ||||
|   if (afterSale.status === 30) { | ||||
|     return '商家待收货'; | ||||
|   } | ||||
|   if (afterSale.status === 40) { | ||||
|     return '等待退款'; | ||||
|   } | ||||
|   if (afterSale.status === 50) { | ||||
|     return '退款成功'; | ||||
|   } | ||||
|   if (afterSale.status === 61) { | ||||
|     return '买家取消'; | ||||
|   } | ||||
|   if (afterSale.status === 62) { | ||||
|     return '商家拒绝'; | ||||
|   } | ||||
|   if (afterSale.status === 63) { | ||||
|     return '商家拒收货'; | ||||
|   } | ||||
|   return '未知状态'; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -237,31 +233,31 @@ export function formatAfterSaleStatus(afterSale) { | |||
|  * @param afterSale 售后 | ||||
|  */ | ||||
| export function formatAfterSaleStatusDescription(afterSale) { | ||||
| 	if (afterSale.status === 10) { | ||||
| 		return '退款申请待商家处理'; | ||||
| 	} | ||||
| 	if (afterSale.status === 20) { | ||||
| 		return '请退货并填写物流信息'; | ||||
| 	} | ||||
| 	if (afterSale.status === 30) { | ||||
| 		return '退货退款申请待商家处理'; | ||||
| 	} | ||||
| 	if (afterSale.status === 40) { | ||||
| 		return '等待退款'; | ||||
| 	} | ||||
| 	if (afterSale.status === 50) { | ||||
| 		return '退款成功'; | ||||
| 	} | ||||
| 	if (afterSale.status === 61) { | ||||
| 		return '退款关闭'; | ||||
| 	} | ||||
| 	if (afterSale.status === 62) { | ||||
| 		return `商家不同意退款申请,拒绝原因:${afterSale.auditReason}`; | ||||
| 	} | ||||
| 	if (afterSale.status === 63) { | ||||
| 		return `商家拒绝收货,不同意退款,拒绝原因:${afterSale.auditReason}`; | ||||
| 	} | ||||
| 	return '未知状态'; | ||||
|   if (afterSale.status === 10) { | ||||
|     return '退款申请待商家处理'; | ||||
|   } | ||||
|   if (afterSale.status === 20) { | ||||
|     return '请退货并填写物流信息'; | ||||
|   } | ||||
|   if (afterSale.status === 30) { | ||||
|     return '退货退款申请待商家处理'; | ||||
|   } | ||||
|   if (afterSale.status === 40) { | ||||
|     return '等待退款'; | ||||
|   } | ||||
|   if (afterSale.status === 50) { | ||||
|     return '退款成功'; | ||||
|   } | ||||
|   if (afterSale.status === 61) { | ||||
|     return '退款关闭'; | ||||
|   } | ||||
|   if (afterSale.status === 62) { | ||||
|     return `商家不同意退款申请,拒绝原因:${afterSale.auditReason}`; | ||||
|   } | ||||
|   if (afterSale.status === 63) { | ||||
|     return `商家拒绝收货,不同意退款,拒绝原因:${afterSale.auditReason}`; | ||||
|   } | ||||
|   return '未知状态'; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -270,15 +266,15 @@ export function formatAfterSaleStatusDescription(afterSale) { | |||
|  * @param afterSale 售后 | ||||
|  */ | ||||
| export function handleAfterSaleButtons(afterSale) { | ||||
| 	afterSale.buttons = []; | ||||
| 	if ([10, 20, 30].includes(afterSale.status)) { | ||||
| 		// 取消订单
 | ||||
| 		afterSale.buttons.push('cancel'); | ||||
| 	} | ||||
| 	if (afterSale.status === 20) { | ||||
| 		// 退货信息
 | ||||
| 		afterSale.buttons.push('delivery'); | ||||
| 	} | ||||
|   afterSale.buttons = []; | ||||
|   if ([10, 20, 30].includes(afterSale.status)) { | ||||
|     // 取消订单
 | ||||
|     afterSale.buttons.push('cancel'); | ||||
|   } | ||||
|   if (afterSale.status === 20) { | ||||
|     // 退货信息
 | ||||
|     afterSale.buttons.push('delivery'); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -288,28 +284,28 @@ export function handleAfterSaleButtons(afterSale) { | |||
|  * @return {{s: string, ms: number, h: string, m: string}} 持续时间 | ||||
|  */ | ||||
| export function useDurationTime(toTime, fromTime = '') { | ||||
| 	toTime = getDayjsTime(toTime); | ||||
| 	if (fromTime === '') { | ||||
| 		fromTime = dayjs(); | ||||
| 	} | ||||
| 	let duration = ref(toTime - fromTime); | ||||
| 	if (duration.value > 0) { | ||||
| 		setTimeout(() => { | ||||
| 			if (duration.value > 0) { | ||||
| 				duration.value -= 1000; | ||||
| 			} | ||||
| 		}, 1000); | ||||
| 	} | ||||
|   toTime = getDayjsTime(toTime); | ||||
|   if (fromTime === '') { | ||||
|     fromTime = dayjs(); | ||||
|   } | ||||
|   let duration = ref(toTime - fromTime); | ||||
|   if (duration.value > 0) { | ||||
|     setTimeout(() => { | ||||
|       if (duration.value > 0) { | ||||
|         duration.value -= 1000; | ||||
|       } | ||||
|     }, 1000); | ||||
|   } | ||||
| 
 | ||||
| 	let durationTime = dayjs.duration(duration.value); | ||||
| 	return { | ||||
| 		h: (durationTime.months() * 30 * 24 + durationTime.days() * 24 + durationTime.hours()) | ||||
| 			.toString() | ||||
| 			.padStart(2, '0'), | ||||
| 		m: durationTime.minutes().toString().padStart(2, '0'), | ||||
| 		s: durationTime.seconds().toString().padStart(2, '0'), | ||||
| 		ms: durationTime.$ms, | ||||
| 	}; | ||||
|   let durationTime = dayjs.duration(duration.value); | ||||
|   return { | ||||
|     h: (durationTime.months() * 30 * 24 + durationTime.days() * 24 + durationTime.hours()) | ||||
|       .toString() | ||||
|       .padStart(2, '0'), | ||||
|     m: durationTime.minutes().toString().padStart(2, '0'), | ||||
|     s: durationTime.seconds().toString().padStart(2, '0'), | ||||
|     ms: durationTime.$ms, | ||||
|   }; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -318,19 +314,19 @@ export function useDurationTime(toTime, fromTime = '') { | |||
|  * @return {dayjs.Dayjs} | ||||
|  */ | ||||
| function getDayjsTime(time) { | ||||
| 	time = time.toString(); | ||||
| 	if (time.indexOf('-') > 0) { | ||||
| 		// 'date'
 | ||||
| 		return dayjs(time); | ||||
| 	} | ||||
| 	if (time.length > 10) { | ||||
| 		// 'timestamp'
 | ||||
| 		return dayjs(parseInt(time)); | ||||
| 	} | ||||
| 	if (time.length === 10) { | ||||
| 		// 'unixTime'
 | ||||
| 		return dayjs.unix(parseInt(time)); | ||||
| 	} | ||||
|   time = time.toString(); | ||||
|   if (time.indexOf('-') > 0) { | ||||
|     // 'date'
 | ||||
|     return dayjs(time); | ||||
|   } | ||||
|   if (time.length > 10) { | ||||
|     // 'timestamp'
 | ||||
|     return dayjs(parseInt(time)); | ||||
|   } | ||||
|   if (time.length === 10) { | ||||
|     // 'unixTime'
 | ||||
|     return dayjs.unix(parseInt(time)); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -340,7 +336,28 @@ function getDayjsTime(time) { | |||
|  * @returns {string} 元,例如说 1.00 元 | ||||
|  */ | ||||
| export function fen2yuan(price) { | ||||
| 	return (price / 100.0).toFixed(2); | ||||
|   return (price / 100.0).toFixed(2); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * 将分转成元 | ||||
|  * | ||||
|  * 如果没有小数点,则不展示小数点部分 | ||||
|  * | ||||
|  * @param price 分,例如说 100 分 | ||||
|  * @returns {string} 元,例如说 1 元 | ||||
|  */ | ||||
| export function fen2yuanSimple(price) { | ||||
|   return fen2yuan(price).replace(/\.?0+$/, ''); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * 将折扣百分比转化为“打x者”的 x 部分 | ||||
|  * | ||||
|  * @param discountPercent | ||||
|  */ | ||||
| export function formatDiscountPercent(discountPercent) { | ||||
|   return (discountPercent / 10.0).toFixed(1).replace(/\.?0+$/, ''); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -358,92 +375,125 @@ export function fen2yuan(price) { | |||
|  * @param skus 商品 SKU 数组 | ||||
|  */ | ||||
| export function convertProductPropertyList(skus) { | ||||
| 	let result = []; | ||||
| 	for (const sku of skus) { | ||||
| 		if (!sku.properties) { | ||||
| 			continue; | ||||
| 		} | ||||
| 		for (const property of sku.properties) { | ||||
| 			// ① 先处理属性
 | ||||
| 			let resultProperty = result.find((item) => item.id === property.propertyId); | ||||
| 			if (!resultProperty) { | ||||
| 				resultProperty = { | ||||
| 					id: property.propertyId, | ||||
| 					name: property.propertyName, | ||||
| 					values: [], | ||||
| 				}; | ||||
| 				result.push(resultProperty); | ||||
| 			} | ||||
| 			// ② 再处理属性值
 | ||||
| 			let resultValue = resultProperty.values.find((item) => item.id === property.valueId); | ||||
| 			if (!resultValue) { | ||||
| 				resultProperty.values.push({ | ||||
| 					id: property.valueId, | ||||
| 					name: property.valueName, | ||||
| 				}); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return result; | ||||
|   let result = []; | ||||
|   for (const sku of skus) { | ||||
|     if (!sku.properties) { | ||||
|       continue; | ||||
|     } | ||||
|     for (const property of sku.properties) { | ||||
|       // ① 先处理属性
 | ||||
|       let resultProperty = result.find((item) => item.id === property.propertyId); | ||||
|       if (!resultProperty) { | ||||
|         resultProperty = { | ||||
|           id: property.propertyId, | ||||
|           name: property.propertyName, | ||||
|           values: [], | ||||
|         }; | ||||
|         result.push(resultProperty); | ||||
|       } | ||||
|       // ② 再处理属性值
 | ||||
|       let resultValue = resultProperty.values.find((item) => item.id === property.valueId); | ||||
|       if (!resultValue) { | ||||
|         resultProperty.values.push({ | ||||
|           id: property.valueId, | ||||
|           name: property.valueName, | ||||
|         }); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   return result; | ||||
| } | ||||
| 
 | ||||
| export function appendSettlementProduct(spus, settlementInfos) { | ||||
| 	if (!settlementInfos || settlementInfos.length === 0) { | ||||
| 		return; | ||||
| 	} | ||||
| 	for (const spu of spus) { | ||||
| 		const settlementInfo = settlementInfos.find((info) => info.spuId === spu.id); | ||||
| 		if (!settlementInfo) { | ||||
| 			return; | ||||
| 		} | ||||
| 		// 选择价格最小的 SKU 设置到 SPU 上
 | ||||
| 		const settlementSku = settlementInfo.skus | ||||
| 			.filter((sku) => sku.promotionPrice > 0) | ||||
| 			.reduce((prev, curr) => (prev.promotionPrice < curr.promotionPrice ? prev : curr)); | ||||
| 		if (settlementSku) { | ||||
| 			spu.promotionType = settlementSku.promotionType; | ||||
| 			spu.promotionPrice = settlementSku.promotionPrice; | ||||
| 		} | ||||
| 		// 设置【满减送】活动
 | ||||
| 		if (settlementInfo.rewardActivity) { | ||||
| 			spu.rewardActivity = settlementInfo.rewardActivity; | ||||
| 		} | ||||
| 	} | ||||
|   if (!settlementInfos || settlementInfos.length === 0) { | ||||
|     return; | ||||
|   } | ||||
|   for (const spu of spus) { | ||||
|     const settlementInfo = settlementInfos.find((info) => info.spuId === spu.id); | ||||
|     if (!settlementInfo) { | ||||
|       return; | ||||
|     } | ||||
|     // 选择价格最小的 SKU 设置到 SPU 上
 | ||||
|     const settlementSku = settlementInfo.skus | ||||
|       .filter((sku) => sku.promotionPrice > 0) | ||||
|       .reduce((prev, curr) => (prev.promotionPrice < curr.promotionPrice ? prev : curr)); | ||||
|     if (settlementSku) { | ||||
|       spu.promotionType = settlementSku.promotionType; | ||||
|       spu.promotionPrice = settlementSku.promotionPrice; | ||||
|     } | ||||
|     // 设置【满减送】活动
 | ||||
|     if (settlementInfo.rewardActivity) { | ||||
|       spu.rewardActivity = settlementInfo.rewardActivity; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| //处理促销信息
 | ||||
| export function handeleData(array) { | ||||
| 	const array2 = ref([{ | ||||
| 			name: '满减', | ||||
| 			value: [] | ||||
| 		}, | ||||
| 		{ | ||||
| 			name: '赠品', | ||||
| 			value: [] | ||||
| 		}, | ||||
| 		{ | ||||
| 			name: '包邮', | ||||
| 			value: [] | ||||
| 		} | ||||
| 	]); | ||||
| 
 | ||||
| 	array.forEach(item => { | ||||
| 		Object.entries(item).forEach(([key, value]) => { | ||||
| 			const type = parseInt(key); | ||||
| 			switch (type) { | ||||
| 				case 1: | ||||
| 					array2.value[0].value.push(value); // 满减
 | ||||
| 					break; | ||||
| 				case 2: | ||||
| 					array2.value[1].value.push(value); // 满送
 | ||||
| 					break; | ||||
| 				case 3: | ||||
| 					array2.value[2].value.push(value); // 包邮
 | ||||
| 					break; | ||||
| 				default: | ||||
| 					break; | ||||
| 			} | ||||
| 		}); | ||||
| 	}); | ||||
| 	return array2 | ||||
| // 获得满减送活动的规则描述(group)
 | ||||
| export function getRewardActivityRuleGroupDescriptions(activity) { | ||||
|   if (!activity || !activity.rules || activity.rules.length === 0) { | ||||
|     return []; | ||||
|   } | ||||
|   const result = [ | ||||
|     { name: '满减', values: [] }, | ||||
|     { name: '赠品', values: [] }, | ||||
|     { name: '包邮', values: [] }, | ||||
|   ]; | ||||
|   activity.rules.forEach((rule) => { | ||||
|     const conditionTypeStr = | ||||
|       activity.conditionType === 10 ? `满 ${fen2yuanSimple(rule.limit)} 元` : `满 ${rule.limit} 件`; | ||||
|     // 满减
 | ||||
|     if (rule.limit) { | ||||
|       result[0].values.push(`${conditionTypeStr} 减 ${fen2yuanSimple(rule.discountPrice)} 元`); | ||||
|     } | ||||
|     // 赠品
 | ||||
|     if (rule.point || (rule.giveCouponTemplateCounts && rule.giveCouponTemplateCounts.length > 0)) { | ||||
|       let tips = []; | ||||
|       if (rule.point) { | ||||
|         tips.push(`送 ${rule.point} 积分`); | ||||
|       } | ||||
|       if (rule.giveCouponTemplateCounts && rule.giveCouponTemplateCounts.length > 0) { | ||||
|         tips.push(`送 ${rule.giveCouponTemplateCounts.length} 张优惠券`); | ||||
|       } | ||||
|       result[1].values.push(`${conditionTypeStr} ${tips.join('、')}`); | ||||
|     } | ||||
|     // 包邮
 | ||||
|     if (rule.freeDelivery) { | ||||
|       result[2].values.push(`${conditionTypeStr} 包邮`); | ||||
|     } | ||||
|   }); | ||||
|   // 移除 values 为空的元素
 | ||||
|   result.forEach((item) => { | ||||
|     if (item.values.length === 0) { | ||||
|       result.splice(result.indexOf(item), 1); | ||||
|     } | ||||
|   }); | ||||
|   return result; | ||||
| } | ||||
| 
 | ||||
| // 获得满减送活动的规则描述(item)
 | ||||
| export function getRewardActivityRuleItemDescriptions(activity) { | ||||
|   if (!activity || !activity.rules || activity.rules.length === 0) { | ||||
|     return []; | ||||
|   } | ||||
|   const result = []; | ||||
|   activity.rules.forEach((rule) => { | ||||
|     const conditionTypeStr = | ||||
|       activity.conditionType === 10 ? `满${fen2yuanSimple(rule.limit)}元` : `满${rule.limit}件`; | ||||
|     // 满减
 | ||||
|     if (rule.limit) { | ||||
|       result.push(`${conditionTypeStr}减${fen2yuanSimple(rule.discountPrice)}元`); | ||||
|     } | ||||
|     // 赠品
 | ||||
|     if (rule.point) { | ||||
|       result.push(`${conditionTypeStr}送${rule.point}积分`); | ||||
|     } | ||||
|     if (rule.giveCouponTemplateCounts && rule.giveCouponTemplateCounts.length > 0) { | ||||
|       result.push(`${conditionTypeStr}送${rule.giveCouponTemplateCounts.length}张优惠券`); | ||||
|     } | ||||
|     // 包邮
 | ||||
|     if (rule.freeDelivery) { | ||||
|       result.push(`${conditionTypeStr}包邮`); | ||||
|     } | ||||
|   }); | ||||
|   return result; | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	 YunaiV
						YunaiV