活动弹窗有部分问题

pull/100/head
岳琳红 2024-09-03 16:29:56 +08:00
parent a6543dc7ca
commit 7a69d10a75
2 changed files with 269 additions and 137 deletions

View File

@ -15,16 +15,16 @@
<su-swiper class="ss-m-b-14" isPreview :list="formatGoodsSwiper(state.goodsInfo.sliderPicUrls)" <su-swiper class="ss-m-b-14" isPreview :list="formatGoodsSwiper(state.goodsInfo.sliderPicUrls)"
otStyle="tag" imageMode="widthFix" dotCur="bg-mask-40" :seizeHeight="750" /> otStyle="tag" imageMode="widthFix" dotCur="bg-mask-40" :seizeHeight="750" />
<!-- 限时折扣 --> <!-- 限时折扣 -->
<view class="discount"> <view class="discount" v-if="setShow">
<image class="disImg" src="../../static/images/dis.png"></image> <image class="disImg" src="../../static/images/dis.png"></image>
<view class="discountCont"> <view class="discountCont">
<view class="disContT"> <view class="disContT">
<view class="disContT1"> <view class="disContT1">
<view class="disContT1P"> <view class="disContT1P">
0.7 {{fen2yuan(settleData.price)}}
</view> </view>
<view class="disContT1End"> <view class="disContT1End">
限时到手0.4 直降{{fen2yuan( state.goodsInfo.price - settleData.price)}}
</view> </view>
</view> </view>
<view class="disContT2"> <view class="disContT2">
@ -33,12 +33,12 @@
</view> </view>
<view class="disContB"> <view class="disContB">
<view class="disContB1"> <view class="disContB1">
价格1 剩余100 价格{{fen2yuan(state.goodsInfo.price)}} 剩余{{settleData.stock}}
</view> </view>
<view class="disContB2"> <view class="disContB2">
距结束仅剩 距结束仅剩
<countDown :tipText="' '" :bgColor="bgColor" :dayText="':'" :hourText="':'" <countDown :tipText="' '" :bgColor="bgColor" :dayText="':'" :hourText="':'"
:minuteText="':'" :secondText="' '" :datatime="1725033600000 / 1000" :minuteText="':'" :secondText="' '" :datatime="settleData.endTime / 1000"
:isDay="false" /> :isDay="false" />
</view> </view>
</view> </view>
@ -47,7 +47,7 @@
<!-- 限时折扣 --> <!-- 限时折扣 -->
<!-- 价格+标题 --> <!-- 价格+标题 -->
<view class="title-card detail-card ss-p-y-40 ss-p-x-20"> <view class="title-card detail-card ss-p-y-40 ss-p-x-20">
<view class="ss-flex ss-row-between ss-col-center ss-m-b-26"> <view class="ss-flex ss-row-between ss-col-center ss-m-b-26" v-if="!setShow">
<view class="price-box ss-flex ss-col-bottom"> <view class="price-box ss-flex ss-col-bottom">
<view class="price-text ss-m-r-16"> <view class="price-text ss-m-r-16">
{{ fen2yuan(state.selectedSku.price || state.goodsInfo.price) }} {{ fen2yuan(state.selectedSku.price || state.goodsInfo.price) }}
@ -121,8 +121,8 @@
@get="onGet" /> --> @get="onGet" /> -->
<!-- 满减送/限时折扣活动弹窗 --> <!-- 满减送/限时折扣活动弹窗 -->
<s-activity-pop v-model="state.activityInfo" :show="state.showActivityModel" <s-activity-pop v-model="state" :show="state.showActivityModel"
@close="state.showActivityModel = false" /> @close="state.showActivityModel = false" @get="onGet" />
</block> </block>
</s-layout> </s-layout>
</view> </view>
@ -261,15 +261,38 @@
} = await CouponApi.getCouponTemplateList(state.goodsId, 2, 10); } = await CouponApi.getCouponTemplateList(state.goodsId, 2, 10);
if (code === 0) { if (code === 0) {
state.couponInfo = data; state.couponInfo = data;
console.log('优惠券',state)
} }
} }
// //
const setShow = ref(false)
const settleData = ref() const settleData = ref()
async function getSettlementByIds(ids) { async function getSettlementByIds(ids) {
const { data } = await SpuApi.getSettlementProduct(ids); const { data } = await SpuApi.getSettlementProduct(ids);
settleData.value = data settleData.value = handle(data)
console.log('结算信息',data) console.log('结算信息',data)
return data; console.log('处理后数据',settleData.value)
}
//
function handle(array){
let setList = {}
array.forEach(item => {
item.skus.forEach(items => {
if(items.type == 4){
setShow.value = true
setList = items
return;
}
})
})
//
state.goodsInfo.skus.forEach(item =>{
if(item.id == setList.skuId){
setList.stock = item.stock
}
})
return setList
} }
onLoad((options) => { onLoad((options) => {
// //

View File

@ -3,20 +3,17 @@
<su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose> <su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose>
<view class="model-box"> <view class="model-box">
<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠</view> <view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠</view>
<scroll-view <view class="titleLi">促销</view>
class="model-content ss-m-t-50" <scroll-view class="model-content" scroll-y :scroll-with-animation="false"
scroll-y :enable-back-to-top="true">
:scroll-with-animation="false"
:enable-back-to-top="true"
>
<view class="actBox" v-for="item in state.activityInfo" :key="item.id"> <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="boxCont ss-flex ss-col-top ss-m-b-40" @tap="onGoodsList(item)">
<view class="model-content-tag ss-flex ss-row-center">活动</view> <view class="model-content-tag ss-flex ss-row-center">{{item.name}}</view>
<view class="ss-m-l-20 model-content-title ss-flex-1"> <view class="model-content-title">
<view class="contBu ss-m-b-24" v-for="rule in state.activityMap[item.id]?.rules" :key="rule"> <view class="contBu" v-for="rule in state.activityMap[item.id]?.rules" :key="rule">
{{ formatRewardActivityRule(state.activityMap[item.id], rule) }} {{ formatRewardActivityRule(state.activityMap[item.id], rule) }}
</view> </view>
<view class="contBu ss-m-b-24"> <view class="ss-m-b-24 cotBu-txt">
2024.08.05-2025.10.10 2024.08.05-2025.10.10
</view> </view>
</view> </view>
@ -24,15 +21,50 @@
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<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 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">
2024.08.05-2025.10.10
</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> </view>
</su-popup> </su-popup>
</template> </template>
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import { computed, reactive, watch } from 'vue'; import {
computed,
reactive,
watch
} from 'vue';
import RewardActivityApi from '@/sheep/api/promotion/rewardActivity'; import RewardActivityApi from '@/sheep/api/promotion/rewardActivity';
import { formatRewardActivityRule } from '@/sheep/hooks/useGoods'; import {
formatRewardActivityRule,fen2yuan
} from '@/sheep/hooks/useGoods';
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
type: Object, type: Object,
@ -45,8 +77,9 @@
}); });
const emits = defineEmits(['close']); const emits = defineEmits(['close']);
const state = reactive({ const state = reactive({
activityInfo: computed(() => props.modelValue), activityInfo: computed(() => props.modelValue.activityInfo),
activityMap: {} activityMap: {},
couponInfo:computed(() => props.modelValue.couponInfo)
}); });
console.log('shuju', state) console.log('shuju', state)
watch( watch(
@ -65,7 +98,10 @@
} }
}, },
); );
//
const getBuy = (id) => {
emits('get', id);
};
function onGoodsList(e) { function onGoodsList(e) {
sheep.$router.go('/pages/activity/index', { sheep.$router.go('/pages/activity/index', {
activityId: e.id, activityId: e.id,
@ -75,6 +111,7 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.model-box { .model-box {
height: 60vh; height: 60vh;
.title { .title {
justify-content: center; justify-content: center;
font-size: 36rpx; font-size: 36rpx;
@ -83,37 +120,47 @@
color: #333333; color: #333333;
} }
} }
.model-content { .model-content {
height: 300rpx; height:fit-content;
max-height: 350rpx;
padding: 0 20rpx; padding: 0 20rpx;
box-sizing: border-box; box-sizing: border-box;
background-color: red; margin-top: 20rpx;
.model-content-tag { .model-content-tag {
// background: rgba(#ff6911, 0.1); // background: rgba(#ff6911, 0.1);
font-size: 35rpx; font-size: 35rpx;
font-weight: 500; font-weight: 500;
color: #ff6911; color: #ff6911;
line-height: 150rpx; line-height: 150rpx;
width: 150rpx; width: 200rpx;
height: 150rpx; height: 150rpx;
text-align: center; text-align: center;
// border-radius: 5rpx; // border-radius: 5rpx;
} }
.model-content-title { .model-content-title {
width: 470rpx;
height: 150rpx; height: 150rpx;
font-size: 26rpx; font-size: 26rpx;
font-weight: 500; font-weight: 500;
color: #333333; color: #333333;
background-color: gold;
overflow: hidden; overflow: hidden;
} }
.cicon-forward { .cicon-forward {
font-size: 28rpx; font-size: 28rpx;
color: #999999; color: #999999;
margin: 0 auto;
} }
} }
// //
.titleLi{
margin:10rpx 0 10rpx 20rpx;
font-size: 26rpx;
}
.actBox { .actBox {
width: 700rpx; width: 700rpx;
height: 150rpx; height: 150rpx;
@ -121,13 +168,75 @@
margin: 10rpx auto; margin: 10rpx auto;
border-radius: 10rpx; border-radius: 10rpx;
} }
.boxCont { .boxCont {
width: 700rpx; width: 700rpx;
height: 150rpx; height: 150rpx;
align-items: center; align-items: center;
} }
.contBu { .contBu {
height: 75rpx; height: 80rpx;
line-height: 75rpx; 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;
}
.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;
}
.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;
}
.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;
} }
</style> </style>