活动名称修改

pull/100/head
岳琳红 2024-09-06 14:43:51 +08:00
parent 7a69d10a75
commit 8f9375911c
5 changed files with 85 additions and 30 deletions

6
.env
View File

@ -2,10 +2,10 @@
SHOPRO_VERSION = v1.8.3
# 后端接口 - 正式环境(通过 process.env.NODE_ENV 非 developmentSHOPRO_BASE_URL = http://api-dashboard.yudao.iocoder.cn
SHOPRO_BASE_URL = http://100.98.30.68:48080
SHOPRO_BASE_URL = http://100.80.97.101:48080
# 后端接口 - 测试环境(通过 process.env.NODE_ENV = developmentSHOPRO_DEV_BASE_URL = http://saas.yibeidl.cn
SHOPRO_DEV_BASE_URL = http://100.98.30.68:48080
SHOPRO_DEV_BASE_URL = http://100.80.97.101:48080
### SHOPRO_DEV_BASE_URL = http://yunai.natapp1.cc
# 后端接口前缀(一般不建议调整)
@ -18,7 +18,7 @@ SHOPRO_WEBSOCKET_PATH = /infra/ws
SHOPRO_DEV_PORT = 48080
# 客户端静态资源地址 空=默认使用服务端指定的CDN资源地址前缀 | local=本地 | http(s)://xxx.xxx=自定义静态资源地址前缀SHOPRO_STATIC_URL = https://file.sheepjs.com
SHOPRO_STATIC_URL = http://100.98.30.68
SHOPRO_STATIC_URL = http://100.80.97.101
# 是否开启直播 1 开启直播 | 0 关闭直播 (小程序官方后台未审核开通直播权限时请勿开启)
SHOPRO_MPLIVE_ON = 0

View File

@ -145,7 +145,8 @@
import {
formatSales,
formatGoodsSwiper,
fen2yuan
fen2yuan,
handList
} from '@/sheep/hooks/useGoods';
import detailNavbar from './components/detail/detail-navbar.vue';
import detailCellSku from './components/detail/detail-cell-sku.vue';
@ -331,13 +332,14 @@
if (res.code !== 0) {
return;
}
res.data.forEach(activity => {
let activData = handList(res.data)
activData.forEach(activity => {
if ([1, 2, 3].includes(activity.type)) { // //
state.activityList.push(activity);
} else if (activity.type === 5) { //
state.activityInfo.push(activity);
} else { // TODO
console.log('待实现!优先级不高');
// console.log('');
}
})
});

View File

@ -335,6 +335,7 @@
state.orderPayload = JSON.parse(options.data);
await getOrderInfo();
await getCoupons();
console.log('数据',state)
});
</script>

View File

@ -4,17 +4,16 @@
<view class="model-box">
<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠</view>
<view class="titleLi">促销</view>
<scroll-view class="model-content" scroll-y :scroll-with-animation="false"
:enable-back-to-top="true">
<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
<view class="actBox" v-for="item in state.activityInfo" :key="item.id">
<view class="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(item)">
<view class="model-content-tag ss-flex ss-row-center">{{item.name}}</view>
<view class="model-content-tag ss-flex ss-row-center">{{item.typeName}}</view>
<view class="model-content-title">
<view class="contBu" v-for="rule in state.activityMap[item.id]?.rules" :key="rule">
{{ formatRewardActivityRule(state.activityMap[item.id], rule) }}
</view>
<view class="ss-m-b-24 cotBu-txt">
2024.08.05-2025.10.10
{{formatDateRange(item.startTime,item.endTime)}}
</view>
</view>
<text class="cicon-forward" />
@ -22,13 +21,12 @@
</view>
</scroll-view>
<view class="titleLi">可领优惠券</view>
<scroll-view class="model-content" scroll-y :scroll-with-animation="false"
:enable-back-to-top="true">
<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
<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)}}
{{fen2yuan(item.discountPrice)}}
</view>
<view class="impose">
{{fen2yuan(item.usePrice)}}可用
@ -39,7 +37,7 @@
{{item.name}}
</view>
<view class="ss-m-b-24 cotBu-txt">
2024.08.05-2025.10.10
{{item.validityType==1?formatDateRange(item.startTime,item.endTime) : '领取后'+item.fixedStartTerm+'-'+item.fixedEndTerm +'天可用'}}
</view>
</view>
<view class="coupon" @click.stop="getBuy(item.id)" v-if="item.canTake">
@ -63,7 +61,9 @@
} from 'vue';
import RewardActivityApi from '@/sheep/api/promotion/rewardActivity';
import {
formatRewardActivityRule,fen2yuan
formatRewardActivityRule,
fen2yuan,
formatDateRange
} from '@/sheep/hooks/useGoods';
const props = defineProps({
modelValue: {
@ -79,7 +79,7 @@
const state = reactive({
activityInfo: computed(() => props.modelValue.activityInfo),
activityMap: {},
couponInfo:computed(() => props.modelValue.couponInfo)
couponInfo: computed(() => props.modelValue.couponInfo)
});
console.log('shuju', state)
watch(
@ -98,10 +98,11 @@
}
},
);
//
const getBuy = (id) => {
emits('get', id);
};
//
const getBuy = (id) => {
emits('get', id);
};
function onGoodsList(e) {
sheep.$router.go('/pages/activity/index', {
activityId: e.id,
@ -122,7 +123,7 @@
}
.model-content {
height:fit-content;
height: fit-content;
max-height: 350rpx;
padding: 0 20rpx;
box-sizing: border-box;
@ -137,11 +138,12 @@
width: 200rpx;
height: 150rpx;
text-align: center;
// border-radius: 5rpx;
}
.model-content-title {
width: 470rpx;
width: 450rpx;
height: 150rpx;
font-size: 26rpx;
font-weight: 500;
@ -157,10 +159,11 @@
}
//
.titleLi{
margin:10rpx 0 10rpx 20rpx;
.titleLi {
margin: 10rpx 0 10rpx 20rpx;
font-size: 26rpx;
}
.actBox {
width: 700rpx;
height: 150rpx;
@ -184,12 +187,14 @@
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
}
.cotBu-txt{
.cotBu-txt {
height: 70rpx;
line-height: 70rpx;
font-size: 25rpx;
color: #999999;
}
.model-content-tag2 {
font-size: 35rpx;
font-weight: 500;
@ -198,19 +203,22 @@
height: 150rpx;
text-align: center;
}
.usePrice{
.usePrice {
width: 200rpx;
height: 90rpx;
line-height: 100rpx;
// background-color: red;
}
.impose{
.impose {
width: 200rpx;
height: 50rpx;
// line-height: 75rpx;
font-size: 23rpx;
// background-color: gold;
}
.model-content-title2 {
width: 330rpx;
height: 150rpx;
@ -219,7 +227,8 @@
color: #333333;
overflow: hidden;
}
.coupon{
.coupon {
width: 150rpx;
height: 50rpx;
line-height: 50rpx;
@ -229,7 +238,8 @@
text-align: center;
font-size: 25rpx;
}
.coupon2{
.coupon2 {
width: 150rpx;
height: 50rpx;
line-height: 50rpx;

View File

@ -387,3 +387,45 @@ export function formatRewardActivityRule(activity, rule) {
}
return '';
}
// 新增将时间搓转换为开始时间-结束时间的格式
export function formatDateRange(startTimestamp, endTimestamp) {
// 定义一个辅助函数来格式化时间戳为 YYYY.MM.DD 格式
const formatDate = (timestamp) => {
const date = new Date(timestamp);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始所以需要+1
const day = String(date.getDate()).padStart(2, '0');
return `${year}.${month}.${day}`;
};
// 格式化开始和结束时间
const start = formatDate(startTimestamp);
const end = formatDate(endTimestamp);
// 返回格式化的日期范围
return `${start}-${end}`;
}
//处理活动信息
export function handList(orders) {
const typeMap = {
'1':'秒杀活动',
'2':'砍价活动',
'3':'拼团活动',
'4':'限时折扣',
'5':'满减送',
'6':'会员折扣',
'7':'优惠券',
'8':'积分'
};
// 给每个订单对象添加 typeName 属性
// console.log('函数',orders)
let updatedOrders = orders.map(order => {
return {
...order, // 展开现有的订单对象属性
typeName: typeMap[order.type] // 添加 typeName 属性
};
});
return updatedOrders
};