Commit c9a24b8b authored by spc's avatar spc

fixed

parent b7e90c1c
......@@ -40,7 +40,8 @@ data:{
receiveStatus:1,//优惠券状态 0-未领取 1-已领取
receiveTime:1,//领取时间
}
]
],
next2810Countdown:0,//2810活动倒计时
}
*/
......
......@@ -15,11 +15,11 @@ const {
// request.js
// 通常可以吧 baseUrl 单独放在一个 js 文件了
// const baseUrl = "http://172.16.230.108:7777/pmall";
const baseUrl = "http://172.16.230.108:7777/pmall";
// const baseUrl = "https://momclub-uat.feihe.com/pmall";//测试环境
// let baseUrl = "https://momclub.feihe.com/pmall";//生产环境
// const baseUrl = "https://docs.dui88.com/mock/1956/api";//mock
const baseUrl = "https://feihe.m.duibatest.com.cn/pmall"
// const baseUrl = "https://feihe.m.duibatest.com.cn/pmall"
const request = (options = {}) => {
// 在这里可以对请求头进行一些设置
......
......@@ -2,7 +2,7 @@
<view class="babyclass">
<!-- 根据展示等级动态显示对应等级页面 -->
<view v-if="currentLevelName === 'diamond'" class="diamond">
<image class="diamondbg" :src="`${$baseUrl}${BABY_CLASS_IMAGES.DIAMOND.BG}`" mode="aspectFit"></image>
<image class="diamondbg" :src="`${$baseUrl}${BABY_CLASS_IMAGES.DIAMOND.BG}`"></image>
<image class="diamondtitle" :src="`${$baseUrl}${BABY_CLASS_IMAGES.DIAMOND.TITLE}`" mode="aspectFit"></image>
<view class="diamondips">
<image class="diamondips1" :src="`${$baseUrl}${BABY_CLASS_IMAGES.DIAMOND.IPS1}`" mode="aspectFit">
......@@ -20,7 +20,7 @@
</view>
<view v-if="currentLevelName === 'starshine'" class="starshine">
<image class="starshinebg" :src="`${$baseUrl}${BABY_CLASS_IMAGES.STARSHINE.BG}`" mode="aspectFit"></image>
<image class="starshinebg" :src="`${$baseUrl}${BABY_CLASS_IMAGES.STARSHINE.BG}`"></image>
<image class="starshinetitle" :src="`${$baseUrl}${BABY_CLASS_IMAGES.STARSHINE.TITLE}`" mode="aspectFit">
</image>
<view class="starshineips">
......@@ -40,7 +40,7 @@
</view>
<view v-if="currentLevelName === 'starlight'" class="starlight">
<image class="starlightbg" :src="`${$baseUrl}${BABY_CLASS_IMAGES.STARLIGHT.BG}`" mode="aspectFit"></image>
<image class="starlightbg" :src="`${$baseUrl}${BABY_CLASS_IMAGES.STARLIGHT.BG}`"></image>
<image class="starlighttitle" :src="`${$baseUrl}${BABY_CLASS_IMAGES.STARLIGHT.TITLE}`" mode="aspectFit">
</image>
<view class="starlightips">
......@@ -60,7 +60,7 @@
</view>
<view v-if="currentLevelName === 'gold'" class="gold">
<image class="goldipsbg" :src="`${$baseUrl}${BABY_CLASS_IMAGES.GOLD.BG}`" mode="aspectFit"></image>
<image class="goldipsbg" :src="`${$baseUrl}${BABY_CLASS_IMAGES.GOLD.BG}`"></image>
<image class="goldipstitle" :src="`${$baseUrl}${BABY_CLASS_IMAGES.GOLD.TITLE}`" mode="aspectFit"></image>
<view class="goldips">
<image class="goldips1" :src="`${$baseUrl}${BABY_CLASS_IMAGES.GOLD.IPS1}`" mode="aspectFit"></image>
......@@ -74,7 +74,7 @@
</view>
<view v-if="currentLevelName === 'platinum'" class="platinum">
<image class="platinumbg" :src="`${$baseUrl}${BABY_CLASS_IMAGES.PLATINUM.BG}`" mode="aspectFit"></image>
<image class="platinumbg" :src="`${$baseUrl}${BABY_CLASS_IMAGES.PLATINUM.BG}`"></image>
<image class="platinumtitle" :src="`${$baseUrl}${BABY_CLASS_IMAGES.PLATINUM.TITLE}`" mode="aspectFit">
</image>
<view class="platinumips">
......@@ -138,18 +138,18 @@ const jump = (level) => {
console.log(`跳转到 ${level} 等级页面`)
// 检查用户等级是否符合要求
const levelOrder = [0, 1, 2, 3, 4]; // gold, platinum, diamond, starlight, starshine
const userLevelIndex = levelOrder.indexOf(props.userLevel);
const requiredLevelIndex = levelOrder.indexOf(props.currentLevel);
if (userLevelIndex < requiredLevelIndex) {
uni.showToast({
title: '等级不够,无法访问',
icon: 'none',
duration: 2000
})
return;
}
// const levelOrder = [0, 1, 2, 3, 4]; // gold, platinum, diamond, starlight, starshine
// const userLevelIndex = levelOrder.indexOf(props.userLevel);
// const requiredLevelIndex = levelOrder.indexOf(props.currentLevel);
// if (userLevelIndex < requiredLevelIndex) {
// uni.showToast({
// title: '等级不够,无法访问',
// icon: 'none',
// duration: 2000
// })
// return;
// }
// 跳转到 H5 页面,地址暂时默认 https://www.baidu.com
// 可以根据不同等级跳转到不同的地址
......@@ -157,15 +157,15 @@ const jump = (level) => {
// 使用 uni.navigateTo 跳转到 webview 页面
uni.navigateTo({
url: `/pages/webview/webview?url=${encodeURIComponent(url)}&title=${level}等级页面`
url: `/pages/webview/webview?url=${encodeURIComponent(url)}`
})
}
</script>
<style lang="less" scoped>
.babyclass {
width: 635rpx;
height: 713rpx;
width: 655rpx;
height: 773rpx;
left: 0rpx;
top: 0rpx;
right: 0rpx;
......@@ -174,25 +174,26 @@ const jump = (level) => {
.diamond {
width: 635rpx;
height: 713rpx;
left: 0rpx;
top: 0rpx;
height: 753rpx;
left: 10rpx;
top: 10rpx;
position: absolute;
.diamondbg {
width: 635rpx;
height: 713rpx;
left: 0rpx;
top: 0rpx;
width: 655rpx;
height: 763rpx;
left: -10rpx;
top: -10rpx;
position: absolute;
opacity: 0.2;
border-radius: 45rpx;
}
.diamondtitle {
width: 126rpx;
height: 31rpx;
left: 4rpx;
top: 0rpx;
left: 8rpx;
top: 30rpx;
position: absolute;
}
......@@ -200,7 +201,7 @@ const jump = (level) => {
width: 610rpx;
height: 373rpx;
left: 13rpx;
top: 76rpx;
top: 96rpx;
position: absolute;
.diamondips1 {
......@@ -240,9 +241,9 @@ const jump = (level) => {
width: 442rpx;
height: 85rpx;
left: 97rpx;
top: 493rpx;
top: 513rpx;
position: absolute;
cursor: pointer;
transition: transform 0.2s ease;
&:active {
......@@ -254,23 +255,24 @@ const jump = (level) => {
width: 635rpx;
height: 92rpx;
left: 0rpx;
top: 621rpx;
top: 641rpx;
position: absolute;
}
}
.starshine {
width: 635rpx;
height: 713rpx;
left: 0rpx;
top: 0rpx;
height: 753rpx;
left: 10rpx;
top: 10rpx;
position: absolute;
.starshinebg {
width: 635rpx;
height: 713rpx;
left: 0rpx;
top: 0rpx;
width: 655rpx;
height: 763rpx;
left: -10rpx;
top: -10rpx;
border-radius: 45rpx;
position: absolute;
opacity: 0.1;
}
......@@ -278,8 +280,8 @@ const jump = (level) => {
.starshinetitle {
width: 126rpx;
height: 31rpx;
left: 4rpx;
top: 0rpx;
left: 8rpx;
top: 30rpx;
position: absolute;
}
......@@ -287,7 +289,7 @@ const jump = (level) => {
width: 610rpx;
height: 373rpx;
left: 13rpx;
top: 76rpx;
top: 96rpx;
position: absolute;
.starshineips1 {
......@@ -327,9 +329,9 @@ const jump = (level) => {
width: 442rpx;
height: 85rpx;
left: 97rpx;
top: 493rpx;
top: 513rpx;
position: absolute;
cursor: pointer;
transition: transform 0.2s ease;
&:active {
......@@ -341,23 +343,24 @@ const jump = (level) => {
width: 635rpx;
height: 92rpx;
left: 0rpx;
top: 621rpx;
top: 641rpx;
position: absolute;
}
}
.starlight {
width: 635rpx;
height: 713rpx;
left: 0rpx;
top: 0rpx;
height: 753rpx;
left: 10rpx;
top: 10rpx;
position: absolute;
.starlightbg {
width: 635rpx;
height: 713rpx;
left: 0rpx;
top: 0rpx;
width: 655rpx;
height: 763rpx;
left: -10rpx;
top: -10rpx;
border-radius: 45rpx;
position: absolute;
opacity: 0.2;
}
......@@ -365,8 +368,8 @@ const jump = (level) => {
.starlighttitle {
width: 126rpx;
height: 31rpx;
left: 4rpx;
top: 0rpx;
left: 8rpx;
top: 30rpx;
position: absolute;
}
......@@ -374,7 +377,7 @@ const jump = (level) => {
width: 610rpx;
height: 373rpx;
left: 13rpx;
top: 76rpx;
top: 96rpx;
position: absolute;
.starlightips1 {
......@@ -414,9 +417,9 @@ const jump = (level) => {
width: 442rpx;
height: 85rpx;
left: 97rpx;
top: 493rpx;
top: 513rpx;
position: absolute;
cursor: pointer;
transition: transform 0.2s ease;
&:active {
......@@ -428,32 +431,33 @@ const jump = (level) => {
width: 635rpx;
height: 92rpx;
left: 0rpx;
top: 621rpx;
top: 641rpx;
position: absolute;
}
}
.gold {
width: 635rpx;
height: 713rpx;
left: 0rpx;
top: 0rpx;
height: 753rpx;
left: 10rpx;
top: 10rpx;
position: absolute;
.goldipsbg {
width: 635rpx;
height: 713rpx;
left: 0rpx;
top: 0rpx;
width: 655rpx;
height: 763rpx;
left: -10rpx;
top: -10rpx;
position: absolute;
border-radius: 45rpx;
opacity: 0.2;
}
.goldipstitle {
width: 126rpx;
height: 31rpx;
left: 4rpx;
top: 0rpx;
left: 8rpx;
top: 30rpx;
position: absolute;
}
......@@ -461,7 +465,7 @@ const jump = (level) => {
width: 610rpx;
height: 373rpx;
left: 13rpx;
top: 76rpx;
top: 96rpx;
position: absolute;
.goldips1 {
......@@ -501,9 +505,9 @@ const jump = (level) => {
width: 442rpx;
height: 85rpx;
left: 97rpx;
top: 493rpx;
top: 513rpx;
position: absolute;
cursor: pointer;
transition: transform 0.2s ease;
&:active {
......@@ -515,23 +519,24 @@ const jump = (level) => {
width: 634rpx;
height: 57rpx;
left: 1rpx;
top: 621rpx;
top: 641rpx;
position: absolute;
}
}
.platinum {
width: 635rpx;
height: 713rpx;
left: 0rpx;
top: 0rpx;
height: 753rpx;
left: 10rpx;
top: 10rpx;
position: absolute;
.platinumbg {
width: 635rpx;
height: 713rpx;
left: 0rpx;
top: 0rpx;
width: 655rpx;
height: 763rpx;
left: -10rpx;
top: -10rpx;
border-radius: 45rpx;
position: absolute;
opacity: 0.2;
}
......@@ -539,8 +544,8 @@ const jump = (level) => {
.platinumtitle {
width: 126rpx;
height: 31rpx;
left: 4rpx;
top: 0rpx;
left: 8rpx;
top: 30rpx;
position: absolute;
}
......@@ -548,7 +553,7 @@ const jump = (level) => {
width: 610rpx;
height: 373rpx;
left: 13rpx;
top: 76rpx;
top: 96rpx;
position: absolute;
.platinumips1 {
......@@ -588,9 +593,9 @@ const jump = (level) => {
width: 442rpx;
height: 85rpx;
left: 97rpx;
top: 493rpx;
top: 513rpx;
position: absolute;
cursor: pointer;
transition: transform 0.2s ease;
&:active {
......@@ -602,14 +607,14 @@ const jump = (level) => {
width: 635rpx;
height: 92rpx;
left: 0rpx;
top: 621rpx;
top: 641rpx;
position: absolute;
}
}
.default-text {
width: 635rpx;
height: 713rpx;
height: 753rpx;
left: 0rpx;
top: 0rpx;
position: absolute;
......
......@@ -463,7 +463,7 @@
</template>
<script setup>
import { getCurrentInstance, reactive, computed, onMounted, watch } from 'vue'
import { getCurrentInstance, reactive, computed, onMounted, watch, onUnmounted } from 'vue'
import { MONTH_GIFT_IMAGES } from './monthGiftImages.js'
import { monthlyGiftIndex, monthlyGiftDrawOne, monthlyGiftDrawAll } from '../../api/monthGift.js'
......@@ -551,7 +551,10 @@ const state = reactive({
// 新增:batchCoupon 数据 - 根据接口返回结构调整
batchCoupon: [], // 改为数组,因为接口返回的是数组
// 新增:equityCouponList 数据
equityCouponList: []
equityCouponList: [],
// 新增:倒计时相关状态
next2810Countdown: -1,
countdownTimer: null
})
// 等级映射常量
......@@ -610,30 +613,97 @@ const handleCouponClick = async (level) => {
const handleBuyClick = async (level) => {
console.log(`Clicked buy for ${level}`)
// 检查用户等级是否符合领取条件
// 检查用户等级是否符合领取条件(优先级最高)
const levelOrder = [0, 1, 2, 3, 4]; // gold, platinum, diamond, starlight, starshine
const userLevelIndex = levelOrder.indexOf(props.userLevel)
const userLevelIndex = levelOrder.indexOf(props.userLevel * 1)
const diamondIndex = levelOrder.indexOf(2); // Diamond level is 2
// 如果用户等级不够,显示提示
if (userLevelIndex < diamondIndex) {
//点击跳转升级攻略页面
uni.navigateTo({
url: '/pages/webview/webview?url=https://member.feihe.com/memberH5/#/coupon'
});
return
}
// 检查倒计时状态(其次)
if (state.next2810Countdown !== -1) {
uni.showToast({
title: '等级不够,无法领取',
title: '活动暂未开启',
icon: 'none',
duration: 2000
})
});
return
}
// 可以购买,执行购买逻辑
if (state.buyStatus[level] === 'unlocked') {
console.log("state.buyStatus", state.buyStatus, level)
// 在 next2810Countdown == -1 的情况下
const currentTimeSlot = state.timeSlots[state.selectedTimeSlot]
// 如果已领取,跳转到使用页面
if (currentTimeSlot.received) {
uni.navigateTo({
url: '/pages/webview/webview?url=https://member.feihe.com/memberH5/#/coupon'
});
return
}
// 根据 status 处理不同状态
if (currentTimeSlot.status === 0) {
// status = 0,显示"活动暂未开启"
uni.showToast({
title: '活动暂未开启',
icon: 'none',
duration: 2000
});
return
} else if (currentTimeSlot.status === 1) {
// status = 1,一键完成领取
try {
// 调用API领取限时1分购,不需要传递参数
const result = await monthlyGiftDrawOne()
const equityCouponInfoId = currentTimeSlot.equityCouponInfoId
const stockBatchId = currentTimeSlot.stockBatchId
console.log("equityCouponInfoId", equityCouponInfoId, stockBatchId)
const result = await monthlyGiftDrawOne({ equityCouponInfoId, stockBatchId })
if (result.success) {
// 购买成功,更新时间段状态
currentTimeSlot.status = 'purchased'
currentTimeSlot.received = true
state.buyStatus[level] = 'purchased'
uni.showToast({
title: '领取成功!',
icon: 'success',
duration: 2000
})
} else {
uni.showToast({
title: result.message || '领取失败',
icon: 'none',
duration: 2000
})
}
} catch (error) {
console.error('领取限时1分购失败:', error)
uni.showToast({
title: '网络错误,请重试',
icon: 'none',
duration: 2000
})
}
} else if (currentTimeSlot.status === 2) {
// status = 2,一键完成领取
try {
const equityCouponInfoId = currentTimeSlot.equityCouponInfoId
const stockBatchId = currentTimeSlot.stockBatchId
console.log("equityCouponInfoId", equityCouponInfoId, stockBatchId)
const result = await monthlyGiftDrawOne({ equityCouponInfoId, stockBatchId })
if (result.success) {
// 购买成功,更新时间段状态
const currentTimeSlot = state.timeSlots[state.selectedTimeSlot]
currentTimeSlot.status = 'purchased'
currentTimeSlot.received = true
state.buyStatus[level] = 'purchased'
......@@ -673,7 +743,7 @@ const getCouponButtonText = (level) => {
return '去使用'
}
const levelOrder = [0, 1, 2, 3, 4];
const userLevelIndex = levelOrder.indexOf(props.userLevel)
const userLevelIndex = levelOrder.indexOf(props.userLevel * 1)
const goldIndex = levelOrder.indexOf(0) // Gold level is 0
if (userLevelIndex < goldIndex) {
return '待解锁'
......@@ -689,7 +759,7 @@ const getCouponButtonClass = () => {
return 'coupon-btn-purchased-' + levelName
}
const levelOrder = [0, 1, 2, 3, 4];
const userLevelIndex = levelOrder.indexOf(props.userLevel)
const userLevelIndex = levelOrder.indexOf(props.userLevel * 1)
const goldIndex = levelOrder.indexOf(0) // Gold level is 0
if (userLevelIndex < goldIndex) {
return 'coupon-btn-locked'
......@@ -701,44 +771,66 @@ const getCouponButtonClass = () => {
const getBuyButtonText = (level) => {
// 检查用户等级是否符合领取条件
const levelOrder = [0, 1, 2, 3, 4]; // gold, platinum, diamond, starlight, starshine
const userLevelIndex = levelOrder.indexOf(props.userLevel)
const userLevelIndex = levelOrder.indexOf(props.userLevel * 1)
const diamondIndex = levelOrder.indexOf(2) // Diamond level is 2
// 如果用户等级不够,显示"待解锁"
// 如果用户等级不够,显示"去升级"(优先级最高)
if (userLevelIndex < diamondIndex) {
return '待解锁'
return '去升级'
}
// 检查时间段状态,如果有时间段状态为 'unlocked',则显示 '立即领取'
const hasUnlockedTimeSlot = state.timeSlots.some(timeSlot => timeSlot.status === 'unlocked')
// 检查倒计时状态(其次)
if (state.next2810Countdown !== -1) {
return '待开启'
}
if (hasUnlockedTimeSlot) {
return '立即领取'
} else if (state.buyStatus[level] === 'purchased') {
return '已领取'
} else {
// 在 next2810Countdown == -1 的情况下
// 检查当前选中的时间段状态
const currentTimeSlot = state.timeSlots[state.selectedTimeSlot]
// 如果已领取,显示"去使用"
if (currentTimeSlot.received) {
return '去使用'
}
// 根据 stockBatchList 对应 index 的 status 显示按钮文本
if (currentTimeSlot.status === 0) {
return '待开启'
} else if (currentTimeSlot.status === 1) {
return '立即领取'
} else if (currentTimeSlot.status === 2) {
return '已结束'
}
return '待开启'
}
// 获取限时1分购按钮样式类
const getBuyButtonClass = (level) => {
const levelName = currentLevelName.value
const levelOrder = [0, 1, 2, 3, 4]; // gold, platinum, diamond, starlight, starshine
const userLevelIndex = levelOrder.indexOf(props.userLevel)
const userLevelIndex = levelOrder.indexOf(props.userLevel * 1)
const diamondIndex = levelOrder.indexOf(2); // Diamond level is 2
console.log("userLevelIndex", userLevelIndex, diamondIndex)
if (userLevelIndex < diamondIndex) {
return 'buy-btn-upgrade-' + levelName
}
if (state.buyStatus[level] === 'unlocked') {
return 'buy-btn-unlocked-' + levelName
} else if (state.buyStatus[level] === 'purchased') {
return 'buy-btn-purchased-' + levelName
// 检查倒计时状态
if (state.next2810Countdown !== -1) {
return 'buy-btn-locked-' + levelName
}
return 'buy-btn-locked-' + levelName
const currentTimeSlot = state.timeSlots[state.selectedTimeSlot]
if (currentTimeSlot.received) {
return 'buy-btn-purchased-' + levelName
} else if (currentTimeSlot.status === 1) {
return 'buy-btn-unlocked-' + levelName
} else {
return 'buy-btn-locked-' + levelName
}
}
......@@ -788,7 +880,7 @@ const fetchMonthlyGiftData = async () => {
// 保存 batchCoupon 数据 - 根据接口结构调整
if (data.batchCoupon) {
console.log('batchCoupon:', data.batchCoupon)
state.batchCoupon = data.batchCoupon // 直接保存数组
state.batchCoupon = data.batchCoupon // 直接保存对象
// 根据 batchCoupon 更新限时1分购状态和时间段状态
updateBuyStatusAndTimeSlots(data.batchCoupon)
}
......@@ -797,12 +889,44 @@ const fetchMonthlyGiftData = async () => {
if (data.currentTimeSlot !== undefined) {
state.selectedTimeSlot = data.currentTimeSlot
}
// 处理倒计时逻辑
if (data.next2810Countdown !== undefined) {
state.next2810Countdown = data.next2810Countdown
if (data.next2810Countdown !== -1) {
startCountdown(data.next2810Countdown)
}
}
}
} catch (error) {
console.error('获取月礼包数据失败:', error)
}
}
// 倒计时处理函数
const startCountdown = (milliseconds) => {
// 清除之前的定时器
if (state.countdownTimer) {
clearTimeout(state.countdownTimer)
}
// 设置倒计时
state.countdownTimer = setTimeout(() => {
console.log('倒计时结束,1秒后刷新页面')
// 延时1秒后刷新页面接口
setTimeout(() => {
fetchMonthlyGiftData()
}, 1000)
}, milliseconds)
}
// 清理定时器
onUnmounted(() => {
if (state.countdownTimer) {
clearTimeout(state.countdownTimer)
}
})
// 初始化
onMounted(async () => {
console.log('MonthGift component mounted, current level:', props.currentLevel, props.userLevel)
......@@ -839,7 +963,7 @@ const updateCouponStatus = (equityCouponList) => {
}
// 根据 batchCoupon 更新限时1分购状态和时间段状态
const updateBuyStatusAndTimeSlots = (batchCouponArray) => {
const updateBuyStatusAndTimeSlots = (batchCouponData) => {
// 重置所有等级的购买状态
Object.keys(state.buyStatus).forEach(level => {
state.buyStatus[level] = 'locked'
......@@ -847,7 +971,7 @@ const updateBuyStatusAndTimeSlots = (batchCouponArray) => {
// 根据用户等级解锁相应等级及以下的功能
const levelOrder = [0, 1, 2, 3, 4]; // gold, platinum, diamond, starlight, starshine
const userLevelIndex = levelOrder.indexOf(props.userLevel);
const userLevelIndex = levelOrder.indexOf(props.userLevel * 1);
// 解锁用户等级及以下的所有等级
for (let i = 0; i <= userLevelIndex; i++) {
......@@ -857,92 +981,83 @@ const updateBuyStatusAndTimeSlots = (batchCouponArray) => {
}
}
// 处理 batchCoupon 数组数
if (batchCouponArray && batchCouponArray.length > 0) {
console.log('Processing batchCoupon array:', batchCouponArray)
// 处理 batchCoupon 数据
if (batchCouponData) {
console.log('Processing batchCoupon data:', batchCouponData)
// 找到当前展示等级对应的 batchCoupon
const currentLevelBatchCoupon = batchCouponArray.find(item => {
// 这里需要根据实际业务逻辑来判断哪个 batchCoupon 对应当前展示等级
// 暂时使用第一个,或者根据其他字段判断
return true
})
if (currentLevelBatchCoupon) {
console.log('Current level batchCoupon:', currentLevelBatchCoupon)
// 更新限时1分购状态
if (currentLevelBatchCoupon.gradeAllow !== undefined) {
const level = currentLevelName.value
if (state.buyStatus.hasOwnProperty(level)) {
// 如果用户等级足够,保持unlocked状态;否则设为locked
if (userLevelIndex >= levelOrder.indexOf(props.currentLevel)) {
state.buyStatus[level] = currentLevelBatchCoupon.gradeAllow ? 'unlocked' : 'locked'
}
// 更新限时1分购状态
if (batchCouponData.gradeAllow !== undefined) {
const level = currentLevelName.value
if (state.buyStatus.hasOwnProperty(level)) {
// 如果用户等级足够,保持unlocked状态;否则设为locked
if (userLevelIndex >= levelOrder.indexOf(props.currentLevel * 1)) {
state.buyStatus[level] = batchCouponData.gradeAllow ? 'unlocked' : 'locked'
}
}
}
// 更新限时1分购状态(如果已领取)
if (currentLevelBatchCoupon.received !== undefined) {
const level = currentLevelName.value
if (state.buyStatus.hasOwnProperty(level) && currentLevelBatchCoupon.received) {
state.buyStatus[level] = 'purchased'
}
// 更新限时1分购状态(如果已领取)
if (batchCouponData.received !== undefined) {
const level = currentLevelName.value
if (state.buyStatus.hasOwnProperty(level) && batchCouponData.received) {
state.buyStatus[level] = 'purchased'
}
}
// 处理 stockBatchList 数据,更新时间段状态
if (currentLevelBatchCoupon.stockBatchList && currentLevelBatchCoupon.stockBatchList.length > 0) {
console.log('Processing stockBatchList:', currentLevelBatchCoupon.stockBatchList)
// 根据实际的时间段数据更新,而不是硬编码的4个时间段
currentLevelBatchCoupon.stockBatchList.forEach((batch, index) => {
console.log(`Processing batch ${index}:`, batch)
// 确保 timeSlots 数组有足够的元素
while (state.timeSlots.length <= index) {
state.timeSlots.push({
time: '', // 动态时间,从API获取
status: 'locked',
stockBatchId: null,
startTime: '',
endTime: '',
stockUsage: 0,
stockLimit: 0,
received: false
})
}
// 更新时间段信息
const mappedStatus = getBatchStatus(batch.status)
console.log(`Batch ${index} status: ${batch.status} -> mapped to: ${mappedStatus}`)
state.timeSlots[index] = {
...state.timeSlots[index],
stockBatchId: batch.stockBatchId,
startTime: batch.startTime,
endTime: batch.endTime || '',
stockUsage: currentLevelBatchCoupon.stockUsage || 0,
stockLimit: currentLevelBatchCoupon.stockLimit || 0,
received: currentLevelBatchCoupon.received || false,
status: mappedStatus
}
console.log(`Updated timeSlot ${index}:`, state.timeSlots[index])
})
// 处理 stockBatchList 数据,更新时间段状态
if (batchCouponData.stockBatchList && batchCouponData.stockBatchList.length > 0) {
console.log('Processing stockBatchList:', batchCouponData.stockBatchList)
// 根据实际的时间段数据更新,而不是硬编码的4个时间段
batchCouponData.stockBatchList.forEach((batch, index) => {
console.log(`Processing batch ${index}:`, batch)
// 确保 timeSlots 数组有足够的元素
while (state.timeSlots.length <= index) {
state.timeSlots.push({
time: '', // 动态时间,从API获取
status: 'locked',
stockBatchId: null,
equityCouponInfoId: null, // 添加这个字段
startTime: '',
endTime: '',
stockUsage: 0,
stockLimit: 0,
received: false
})
}
// 更新时间段信息
const mappedStatus = getBatchStatus(batch.status)
console.log(`Batch ${index} status: ${batch.status} -> mapped to: ${mappedStatus}`)
state.timeSlots[index] = {
...state.timeSlots[index],
stockBatchId: batch.stockBatchId,
equityCouponInfoId: batchCouponData.equityCouponInfoId, // 从 batchCoupon 对象中获取
startTime: batch.startTime,
endTime: batch.endTime || '',
stockUsage: batchCouponData.stockUsage || 0,
stockLimit: batchCouponData.stockLimit || 0,
received: batchCouponData.received || false,
status: batch.status // 直接使用原始 status 值
}
console.log(`Updated timeSlot ${index}:`, state.timeSlots[index])
})
// 如果API返回的时间段少于4个,保持原有的4个时间段结构
if (currentLevelBatchCoupon.stockBatchList.length < 4) {
// 保持原有的4个时间段,未返回的保持默认状态
for (let i = currentLevelBatchCoupon.stockBatchList.length; i < 4; i++) {
if (state.timeSlots[i]) {
state.timeSlots[i].status = 'locked'
state.timeSlots[i].time = getDefaultTimeText(i)
}
// 如果API返回的时间段少于4个,保持原有的4个时间段结构
if (batchCouponData.stockBatchList.length < 4) {
// 保持原有的4个时间段,未返回的保持默认状态
for (let i = batchCouponData.stockBatchList.length; i < 4; i++) {
if (state.timeSlots[i]) {
state.timeSlots[i].status = 'locked'
state.timeSlots[i].time = getDefaultTimeText(i)
}
}
console.log('Final timeSlots state:', state.timeSlots)
}
console.log('Final timeSlots state:', state.timeSlots)
}
}
......@@ -988,7 +1103,7 @@ const getDefaultTimeText = (index) => {
// 检查用户等级是否足够
const isLevelSufficient = () => {
const levelOrder = [2, 3, 4]; // gold, platinum, diamond, starlight, starshine
const userLevelIndex = levelOrder.indexOf(props.userLevel);
const userLevelIndex = levelOrder.indexOf(props.userLevel * 1);
return userLevelIndex >= 0;
}
......@@ -1017,8 +1132,8 @@ const getTimeSlotStatusText = (index) => {
// 检查用户等级是否符合要求 - 用户等级必须等于或高于要操作的等级
const levelOrder = [0, 1, 2, 3, 4]; // gold, platinum, diamond, starlight, starshine
const userLevelIndex = levelOrder.indexOf(props.userLevel)
const requiredLevelIndex = levelOrder.indexOf(props.currentLevel)
const userLevelIndex = levelOrder.indexOf(props.userLevel * 1)
const requiredLevelIndex = levelOrder.indexOf(props.currentLevel * 1)
console.log(`User level: ${props.userLevel} (${userLevelName.value}), Required level: ${props.currentLevel} (${currentLevelName.value})`)
console.log(`User level index: ${userLevelIndex}, Required level index: ${requiredLevelIndex}`)
......@@ -1051,14 +1166,18 @@ const getTimeSlotStatusText = (index) => {
.monthgift {
width: 663rpx;
height: 1084rpx;
left: 0rpx;
top: 0rpx;
right: 0rpx;
margin: auto;
position: relative;
margin: 0 auto;
.diamond {
width: 663rpx;
height: 1084rpx;
left: 0rpx;
top: 0rpx;
position: absolute;
.diamondbg {
......@@ -1067,6 +1186,8 @@ const getTimeSlotStatusText = (index) => {
left: 0rpx;
top: 0rpx;
position: absolute;
border-radius: 45rpx 0 45rpx 45rpx;
opacity: 0.2;
}
......@@ -1300,6 +1421,8 @@ const getTimeSlotStatusText = (index) => {
left: 0rpx;
top: 0rpx;
position: absolute;
border-radius: 45rpx 0 45rpx 45rpx;
opacity: 0.1;
}
......@@ -1589,6 +1712,8 @@ const getTimeSlotStatusText = (index) => {
height: 1084rpx;
left: 0rpx;
top: 0rpx;
border-radius: 45rpx 0 45rpx 45rpx;
position: absolute;
opacity: 0.2;
}
......@@ -1878,6 +2003,7 @@ const getTimeSlotStatusText = (index) => {
width: 663rpx;
height: 1084rpx;
left: 0rpx;
border-radius: 45rpx 0 45rpx 45rpx;
top: 0rpx;
position: absolute;
opacity: 0.2;
......@@ -2175,6 +2301,7 @@ const getTimeSlotStatusText = (index) => {
.platinumbg {
width: 663rpx;
height: 1084rpx;
border-radius: 45rpx 0 45rpx 45rpx;
left: 0rpx;
top: 0rpx;
position: absolute;
......@@ -2643,27 +2770,27 @@ const getTimeSlotStatusText = (index) => {
&.buy-btn-locked-gold {
background: linear-gradient(135deg, #503404, #6a4505);
color: #99662e;
color: #fff;
}
&.buy-btn-locked-platinum {
background: linear-gradient(135deg, #284a6c, #3a5e80);
color: #284a6c;
color: #fff;
}
&.buy-btn-locked-diamond {
background: linear-gradient(135deg, #503404, #6a4505);
color: #503404;
color: #fff;
}
&.buy-btn-locked-starlight {
background: linear-gradient(135deg, #503404, #6a4505);
color: #503404;
color: #fff;
}
&.buy-btn-locked-starshine {
background: linear-gradient(135deg, #f7d1a0, #f9dca8);
color: #241b15;
color: #000;
}
&.buy-btn-upgrade-gold {
......@@ -2698,7 +2825,6 @@ const getTimeSlotStatusText = (index) => {
.diamond1buycomtime2,
.diamond1buycomtime3,
.diamond1buycomtime4 {
cursor: pointer;
transition: all 0.3s ease;
......
......@@ -22,10 +22,9 @@
<image class="diamondthreeaward" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.DIAMOND.THREE.AWARD}`"
mode="aspectFit">
</image>
<image class="diamondthreebtn" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.DIAMOND.THREE.BTN}`"
mode="aspectFit" @click="handleButtonClick('diamond')">
</image>
<view class="diamondthreebtn active" @click="handleButtonClick('diamond')">
<text>{{ buttonInfo.text }}</text>
</view>
</view>
</view>
......@@ -52,10 +51,9 @@
</image>
<image class="starshinethreeaward" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.STARSHINE.THREE.AWARD}`"
mode="aspectFit"></image>
<image class="starshinethreebtn" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.STARSHINE.THREE.BTN}`"
mode="aspectFit" @click="handleButtonClick('starshine')">
</image>
<view class="starshinethreebtn starshine" @click="handleButtonClick('starshine')">
<text>{{ buttonInfo.text }}</text>
</view>
</view>
</view>
......@@ -82,10 +80,9 @@
</image>
<image class="starlightthreeaward" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.STARLIGHT.THREE.AWARD}`"
mode="aspectFit"></image>
<image class="starlightthreebtn" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.STARLIGHT.THREE.BTN}`"
mode="aspectFit" @click="handleButtonClick('starlight')">
</image>
<view class="starlightthreebtn starlight" @click="handleButtonClick('starlight')">
<text>{{ buttonInfo.text }}</text>
</view>
</view>
</view>
......@@ -106,9 +103,9 @@
</image>
<image class="goldthreeaward" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.GOLD.THREE.AWARD}`" mode="aspectFit">
</image>
<image class="goldthreebtn" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.GOLD.THREE.BTN}`" mode="aspectFit"
@click="handleButtonClick('gold')"></image>
<view class="goldthreebtn gold" @click="handleButtonClick('gold')">
<text>{{ buttonInfo.text }}</text>
</view>
</view>
<image class="goldlocktip" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.GOLD.LOCKTIP}`" mode="aspectFit"></image>
</view>
......@@ -138,10 +135,9 @@
<image class="platinumthreebg" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.PLATINUM.THREE.BG}`"
mode="aspectFit">
</image>
<image class="platinumthreebtn" :src="`${$baseUrl}${YEAR_GIFT_IMAGES.PLATINUM.THREE.BTN}`"
mode="aspectFit" @click="handleButtonClick('platinum')">
</image>
<view class="platinumthreebtn platinum" @click="handleButtonClick('platinum')">
<text>{{ buttonInfo.text }}</text>
</view>
</view>
</view>
</view>
......@@ -188,48 +184,34 @@ const userLevelName = computed(() => LEVEL_MAP[props.userLevel])
const buttonInfo = computed(() => {
const levelOrder = [0, 1, 2, 3, 4]; // gold, platinum, diamond, starlight, starshine
const userLevelIndex = levelOrder.indexOf(props.userLevel);
const requiredLevelIndex = levelOrder.indexOf(props.currentLevel);
if (userLevelIndex < requiredLevelIndex) {
return {
text: '待解锁',
action: 'none'
};
} else if (state.isReceived) {
const diamondIndex = levelOrder.indexOf(2); // Diamond level
const platinumIndex = levelOrder.indexOf(1); // Platinum level
if (userLevelIndex <= platinumIndex) {
return {
text: '已领取',
action: 'none'
text: '去升级',
action: 'upgrade'
};
} else {
} else if (userLevelIndex >= diamondIndex) {
return {
text: '立即领取',
action: 'receive'
text: '去查看',
action: 'view'
};
}
})
// 按钮点击事件处理
const handleButtonClick = () => {
if (buttonInfo.value.action === 'receive') {
// 检查用户等级是否符合领取条件
const levelOrder = [0, 1, 2, 3, 4]; // gold, platinum, diamond, starlight, starshine
const userLevelIndex = levelOrder.indexOf(props.userLevel);
const requiredLevelIndex = levelOrder.indexOf(props.currentLevel);
if (userLevelIndex < requiredLevelIndex) {
uni.showToast({
title: '等级不够,无法领取',
icon: 'none',
duration: 2000
});
return;
}
receiveYearGift();
} else if (buttonInfo.value.action === 'upgrade') {
if (buttonInfo.value.action === 'upgrade') {
// 跳转到升级页面
uni.navigateTo({
url: '/pages/upgrade/upgradeGuide'
});
} else if (buttonInfo.value.action === 'view') {
// 跳转到查看页面
uni.navigateTo({
url: '/pages/webview/webview?url=https://member.feihe.com/memberH5/#/coupon'
});
}
}
</script>
......@@ -237,7 +219,7 @@ const handleButtonClick = () => {
<style lang="less" scoped>
.yeargift {
width: 686rpx;
height: 1139rpx;
height: 1218rpx;
left: 0rpx;
top: 0rpx;
right: 0rpx;
......@@ -358,7 +340,7 @@ const handleButtonClick = () => {
left: 61rpx;
top: 436rpx;
position: absolute;
cursor: pointer;
transition: transform 0.2s ease;
&:active {
......@@ -473,7 +455,7 @@ const handleButtonClick = () => {
left: 61rpx;
top: 436rpx;
position: absolute;
cursor: pointer;
transition: transform 0.2s ease;
&:active {
......@@ -588,7 +570,7 @@ const handleButtonClick = () => {
left: 61rpx;
top: 436rpx;
position: absolute;
cursor: pointer;
transition: transform 0.2s ease;
&:active {
......@@ -703,7 +685,7 @@ const handleButtonClick = () => {
left: 61rpx;
top: 436rpx;
position: absolute;
cursor: pointer;
transition: transform 0.2s ease;
&:active {
......@@ -833,7 +815,7 @@ const handleButtonClick = () => {
left: 61rpx;
top: 436rpx;
position: absolute;
cursor: pointer;
transition: transform 0.2s ease;
&:active {
......@@ -845,4 +827,79 @@ const handleButtonClick = () => {
}
}
}
/* 按钮样式 */
.diamondthreebtn,
.starshinethreebtn,
.starlightthreebtn,
.goldthreebtn,
.platinumthreebtn {
display: flex;
align-items: center;
justify-content: center;
border-radius: 42.5rpx;
font-size: 32rpx;
font-weight: bold;
transition: transform 0.2s ease;
&.active {
background: linear-gradient(to right, #7253a5, #9879cc);
/* 钻石 */
color: #fff;
box-shadow: 0 4rpx 12rpx rgba(114, 83, 165, 0.3);
&:active {
transform: scale(0.95);
box-shadow: 0 2rpx 8rpx rgba(114, 83, 165, 0.4);
}
}
&.starshine {
background: linear-gradient(to right, #000000, #2c1600);
/* 星耀 */
color: #fff;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.3);
&:active {
transform: scale(0.95);
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.4);
}
}
&.starlight {
background: linear-gradient(to right, #cda36b, #e0b97d);
/* 星光 */
color: #fff;
box-shadow: 0 4rpx 12rpx rgba(205, 163, 107, 0.3);
&:active {
transform: scale(0.95);
box-shadow: 0 2rpx 8rpx rgba(205, 163, 107, 0.4);
}
}
&.gold {
background: linear-gradient(to right, #906632, #ab7a44);
/* 黄金 */
color: #fff;
box-shadow: 0 4rpx 12rpx rgba(144, 102, 50, 0.3);
&:active {
transform: scale(0.95);
box-shadow: 0 2rpx 8rpx rgba(144, 102, 50, 0.4);
}
}
&.platinum {
background: linear-gradient(to right, #5189c0, #6fa2d5);
/* 白金 */
color: #fff;
box-shadow: 0 4rpx 12rpx rgba(81, 137, 192, 0.3);
&:active {
transform: scale(0.95);
box-shadow: 0 2rpx 8rpx rgba(81, 137, 192, 0.4);
}
}
}
</style>
......@@ -15,7 +15,7 @@ export const YEAR_GIFT_IMAGES = {
},
THREE: {
BG: `pointRights/YearGift/${version}/diamondThreeBg.png`,
AWARD: `pointRights/YearGift/${version}/diamondThreeAward.png`,
AWARD: `pointRights/YearGift/${version}/goldThreeAward2.png`,
BTN: `pointRights/YearGift/${version}/diamondThreeBtn.png`
}
},
......@@ -33,7 +33,7 @@ export const YEAR_GIFT_IMAGES = {
},
THREE: {
BG: `pointRights/YearGift/${version}/starshineThreeBg.png`,
AWARD: `pointRights/YearGift/${version}/starshineThreeAward.png`,
AWARD: `pointRights/YearGift/${version}/goldThreeAward2.png`,
BTN: `pointRights/YearGift/${version}/starshineThreeBtn.png`
}
},
......@@ -51,7 +51,7 @@ export const YEAR_GIFT_IMAGES = {
},
THREE: {
BG: `pointRights/YearGift/${version}/starlightThreeBg.png`,
AWARD: `pointRights/YearGift/${version}/starlightThreeAward.png`,
AWARD: `pointRights/YearGift/${version}/goldThreeAward2.png`,
BTN: `pointRights/YearGift/${version}/starlightThreeBtn.png`
}
},
......@@ -69,7 +69,7 @@ export const YEAR_GIFT_IMAGES = {
},
THREE: {
BG: `pointRights/YearGift/${version}/goldThreeBg.png`,
AWARD: `pointRights/YearGift/${version}/goldThreeAward.png`,
AWARD: `pointRights/YearGift/${version}/goldThreeAward2.png`,
BTN: `pointRights/YearGift/${version}/goldThreeBtn.png`
},
LOCKTIP: `pointRights/YearGift/${version}/goldLockTip.png`
......@@ -89,7 +89,7 @@ export const YEAR_GIFT_IMAGES = {
},
THREE: {
BG: `pointRights/YearGift/${version}/platinumThreeBg.png`,
AWARD: `pointRights/YearGift/${version}/platinumThreeAward.png`,
AWARD: `pointRights/YearGift/${version}/goldThreeAward2.png`,
BTN: `pointRights/YearGift/${version}/platinumThreeBtn.png`
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment