Commit 51d27199 authored by spc's avatar spc

跳转逻辑

parent fccce63e
...@@ -532,6 +532,39 @@ const handleBannerClick = (index) => { ...@@ -532,6 +532,39 @@ const handleBannerClick = (index) => {
} }
} }
// 处理邀请助力的通用函数
const handleInvitationAssist = async (incomingCode) => {
try {
console.log('处理助力邀请码:', incomingCode)
const res = await invitationAssist(incomingCode);
if (res && res.success) {
uni.showToast({
title: '助力成功',
icon: 'success',
duration: 2000
});
// 助力成功后重新获取数据
await fetchAct915HomeData();
return Promise.resolve();
} else {
uni.showToast({
title: '助力失败',
icon: 'none',
duration: 2000
});
return Promise.reject();
}
} catch (error) {
console.error('助力请求失败:', error)
uni.showToast({
title: '助力失败',
icon: 'none',
duration: 2000
});
return Promise.reject();
}
}
// 邀请按钮点击处理 // 邀请按钮点击处理
const handleInviteClick = () => { const handleInviteClick = () => {
console.log('点击邀请按钮') console.log('点击邀请按钮')
...@@ -543,11 +576,35 @@ const handleInviteClick = () => { ...@@ -543,11 +576,35 @@ const handleInviteClick = () => {
return return
} }
// 已登录用户直接分享 // 已登录用户也需要检查是否有邀请码需要处理助力
uni.showShareMenu({ const pages = getCurrentPages();
withShareTicket: true, const currentPage = pages[pages.length - 1];
menus: ['shareAppMessage', 'shareTimeline'] const options = currentPage.options;
}); const incomingCode = options.invitationCode;
if (incomingCode) {
console.log('已登录用户处理助力邀请码:', incomingCode)
// 先处理助力,再分享
handleInvitationAssist(incomingCode).then(() => {
// 助力完成后分享
uni.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
});
}).catch(() => {
// 助力失败也继续分享
uni.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
});
});
} else {
// 没有邀请码直接分享
uni.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
});
}
} }
// 生命周期 // 生命周期
...@@ -600,30 +657,8 @@ const onGetPhoneNumber = async (e) => { ...@@ -600,30 +657,8 @@ const onGetPhoneNumber = async (e) => {
const incomingCode = options.invitationCode; const incomingCode = options.invitationCode;
if (incomingCode) { if (incomingCode) {
console.log('处理助力邀请码:', incomingCode) // 使用统一的助力处理函数
try { await handleInvitationAssist(incomingCode);
const res = await invitationAssist(incomingCode);
if (res && res.success) {
uni.showToast({
title: '助力成功',
icon: 'success',
duration: 2000
});
} else {
uni.showToast({
title: '助力失败',
icon: 'none',
duration: 2000
});
}
} catch (error) {
console.error('助力请求失败:', error)
uni.showToast({
title: '助力失败',
icon: 'none',
duration: 2000
});
}
} }
} catch (error) { } catch (error) {
console.error('授权后处理失败:', error) console.error('授权后处理失败:', error)
......
...@@ -68,8 +68,7 @@ ...@@ -68,8 +68,7 @@
<span class="lotterypagenoticeconbg" <span class="lotterypagenoticeconbg"
:style="{ backgroundImage: `url(${$baseUrl}${getImageUrl(config.images.noticeConBg)})` }"></span> :style="{ backgroundImage: `url(${$baseUrl}${getImageUrl(config.images.noticeConBg)})` }"></span>
<div class="lotterypagenoticecontext-wrapper"> <div class="lotterypagenoticecontext-wrapper">
<div class="lotterypagenoticecontext-container" <div class="lotterypagenoticecontext-container" :class="{ 'no-transition': isResetting }"
:class="{ 'no-transition': isResetting }"
:style="{ transform: `translateY(-${currentNoticeIndex * 40}rpx)` }"> :style="{ transform: `translateY(-${currentNoticeIndex * 40}rpx)` }">
<span class="lotterypagenoticecontext" v-for="(notice, index) in displayNotices" <span class="lotterypagenoticecontext" v-for="(notice, index) in displayNotices"
:key="`${notice.userNickname}-${index}`">{{ formatNotice(notice.userNickname, notice.prizeName) :key="`${notice.userNickname}-${index}`">{{ formatNotice(notice.userNickname, notice.prizeName)
...@@ -163,16 +162,27 @@ const isPrizeHighlighted = (index) => { ...@@ -163,16 +162,27 @@ const isPrizeHighlighted = (index) => {
// 获取最近的20条公告 // 获取最近的20条公告
const recentNotices = computed(() => { const recentNotices = computed(() => {
let notices = [];
if (winningCarousel.value.length > 0) { if (winningCarousel.value.length > 0) {
return winningCarousel.value.slice(0, 20); notices = winningCarousel.value.slice(0, 20);
} else { } else {
// 如果没有API数据,显示默认公告 // 如果没有API数据,显示默认公告
return [ notices = [
{ userNickname: '用户152****8839', prizeName: 'XXXXXX' }, { userNickname: '用户152****8839', prizeName: 'XXXXXX' },
{ userNickname: '用户138****5678', prizeName: 'YYYYYY' }, { userNickname: '用户138****5678', prizeName: 'YYYYYY' },
{ userNickname: '用户159****1234', prizeName: 'ZZZZZZ' } { userNickname: '用户159****1234', prizeName: 'ZZZZZZ' }
]; ];
} }
// 如果只有1条数据,复制成3条以确保轮播效果
if (notices.length === 1) {
const singleNotice = notices[0];
notices = [singleNotice, singleNotice, singleNotice];
console.log('轮播数据只有1条,已复制成3条:', notices);
}
return notices;
}); });
// 用于轮播显示的公告列表(重复数据以实现无缝循环) // 用于轮播显示的公告列表(重复数据以实现无缝循环)
...@@ -204,9 +214,45 @@ const handleRuleModalClose = () => { ...@@ -204,9 +214,45 @@ const handleRuleModalClose = () => {
// 奖品按钮点击处理 // 奖品按钮点击处理
const handleAwardClick = () => { const handleAwardClick = () => {
console.log('点击奖品按钮') console.log('点击奖品按钮')
uni.showToast({
title: '奖品列表', // 根据环境获取对应的appId
icon: 'none' const getAppId = () => {
// 可以根据实际环境判断
// uat2: wxabebc35e71e66795
// test2: wx18428fc8a569a3c7
// 生产: wx4205ec55b793245e
// 这里可以根据实际需求调整环境判断逻辑
// 例如:根据域名、配置等判断当前环境
const currentEnv = 'uat2' // 可以动态获取
const appIdMap = {
'uat2': 'wxabebc35e71e66795',
'test2': 'wx18428fc8a569a3c7',
'prod': 'wx4205ec55b793245e'
}
return appIdMap[currentEnv] || appIdMap['uat2'] // 默认uat2环境
}
const appId = getAppId()
const path = '/subPackages/xmhMainProcess/mine/index'
uni.navigateToMiniProgram({
appId: appId,
path: path,
extraData: {},
envVersion: 'release', // 可以根据环境调整:develop, trial, release
success: (res) => {
console.log('跳转小程序成功:', res)
},
fail: (err) => {
console.error('跳转小程序失败:', err)
uni.showToast({
title: '跳转失败',
icon: 'none'
})
}
}) })
} }
...@@ -259,10 +305,10 @@ const startNoticeCarousel = () => { ...@@ -259,10 +305,10 @@ const startNoticeCarousel = () => {
if (currentNoticeIndex.value >= recentNotices.value.length) { if (currentNoticeIndex.value >= recentNotices.value.length) {
// 禁用过渡动效 // 禁用过渡动效
isResetting.value = true isResetting.value = true
// 立即重置到原始位置 // 立即重置到原始位置
currentNoticeIndex.value = 0 currentNoticeIndex.value = 0
// 下一帧恢复过渡动效 // 下一帧恢复过渡动效
setTimeout(() => { setTimeout(() => {
isResetting.value = false isResetting.value = false
...@@ -302,7 +348,7 @@ const handleDrawClick = async () => { ...@@ -302,7 +348,7 @@ const handleDrawClick = async () => {
isDrawing.value = true isDrawing.value = true
selectedPrizeIndex.value = -1 // 重置选中状态 selectedPrizeIndex.value = -1 // 重置选中状态
currentHighlightIndex.value = -1 // 重置高亮状态 currentHighlightIndex.value = -1 // 重置高亮状态
uni.showLoading({ uni.showLoading({
title: '抽奖中...', title: '抽奖中...',
mask: true mask: true
...@@ -311,13 +357,13 @@ const handleDrawClick = async () => { ...@@ -311,13 +357,13 @@ const handleDrawClick = async () => {
try { try {
const response = await getAct915LotteryDraw() const response = await getAct915LotteryDraw()
console.log('getAct915LotteryDraw 接口返回结果:', response) console.log('getAct915LotteryDraw 接口返回结果:', response)
if (response && response.ok) { if (response && response.ok) {
remainingTimes.value = response.data.remainingChances remainingTimes.value = response.data.remainingChances
// 根据接口返回的prizeId找到对应的奖品索引 // 根据接口返回的prizeId找到对应的奖品索引
const prizeIndex = turntablePrizes.value.findIndex(prize => prize.prizeId === response.data.prizeId) const prizeIndex = turntablePrizes.value.findIndex(prize => prize.prizeId === response.data.prizeId)
if (prizeIndex !== -1) { if (prizeIndex !== -1) {
// 开始轮流亮起效果 // 开始轮流亮起效果
startHighlightAnimation(prizeIndex, response.data.isWin) startHighlightAnimation(prizeIndex, response.data.isWin)
...@@ -349,7 +395,7 @@ const handleDrawClick = async () => { ...@@ -349,7 +395,7 @@ const handleDrawClick = async () => {
// 轮流亮起动画 // 轮流亮起动画
const startHighlightAnimation = (targetIndex, isWin) => { const startHighlightAnimation = (targetIndex, isWin) => {
console.log(`开始轮流亮起动画,目标奖品索引: ${targetIndex}, 是否中奖: ${isWin}`) console.log(`开始轮流亮起动画,目标奖品索引: ${targetIndex}, 是否中奖: ${isWin}`)
// 按照指定顺序:1 -> 5 -> 3 -> 2 -> 4 -> 6 // 按照指定顺序:1 -> 5 -> 3 -> 2 -> 4 -> 6
// 对应索引:0 -> 4 -> 2 -> 1 -> 3 -> 5 // 对应索引:0 -> 4 -> 2 -> 1 -> 3 -> 5
const turntableOrder = [0, 4, 2, 1, 3, 5] // 按照指定顺序 const turntableOrder = [0, 4, 2, 1, 3, 5] // 按照指定顺序
...@@ -358,33 +404,33 @@ const startHighlightAnimation = (targetIndex, isWin) => { ...@@ -358,33 +404,33 @@ const startHighlightAnimation = (targetIndex, isWin) => {
let roundCount = 0 let roundCount = 0
const maxRounds = 2 // 最多转2圈 const maxRounds = 2 // 最多转2圈
const highlightSpeed = 200 // 每个奖品高亮200ms const highlightSpeed = 200 // 每个奖品高亮200ms
const highlightTimer = setInterval(() => { const highlightTimer = setInterval(() => {
// 获取当前转盘顺序中的奖品索引 // 获取当前转盘顺序中的奖品索引
const currentPrizeIndex = turntableOrder[currentOrderIndex] const currentPrizeIndex = turntableOrder[currentOrderIndex]
currentHighlightIndex.value = currentPrizeIndex currentHighlightIndex.value = currentPrizeIndex
// 检查是否到达目标位置 // 检查是否到达目标位置
if (roundCount >= maxRounds && currentPrizeIndex === targetIndex) { if (roundCount >= maxRounds && currentPrizeIndex === targetIndex) {
clearInterval(highlightTimer) clearInterval(highlightTimer)
// 停止高亮,显示最终选中状态 // 停止高亮,显示最终选中状态
setTimeout(() => { setTimeout(() => {
currentHighlightIndex.value = -1 currentHighlightIndex.value = -1
selectedPrizeIndex.value = targetIndex selectedPrizeIndex.value = targetIndex
uni.hideLoading() uni.hideLoading()
// 显示结果弹窗 // 显示结果弹窗
setTimeout(() => { setTimeout(() => {
isDrawing.value = false isDrawing.value = false
if (isWin) { if (isWin) {
currentAwardName.value = turntablePrizes.value[targetIndex].prizeName currentAwardName.value = turntablePrizes.value[targetIndex].prizeName
showDrawSucModal.value = true showDrawSucModal.value = true
} else { } else {
showDrawFailModal.value = true showDrawFailModal.value = true
} }
// 延迟重置选中状态 // 延迟重置选中状态
setTimeout(() => { setTimeout(() => {
selectedPrizeIndex.value = -1 selectedPrizeIndex.value = -1
...@@ -394,7 +440,7 @@ const startHighlightAnimation = (targetIndex, isWin) => { ...@@ -394,7 +440,7 @@ const startHighlightAnimation = (targetIndex, isWin) => {
} else { } else {
// 移动到下一个奖品(按转盘顺序) // 移动到下一个奖品(按转盘顺序)
currentOrderIndex = (currentOrderIndex + 1) % totalPrizes currentOrderIndex = (currentOrderIndex + 1) % totalPrizes
// 如果回到起点,增加圈数 // 如果回到起点,增加圈数
if (currentOrderIndex === 0) { if (currentOrderIndex === 0) {
roundCount++ roundCount++
......
...@@ -29,22 +29,34 @@ ...@@ -29,22 +29,34 @@
{ {
"id": 1, "id": 1,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=1" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=791811288869839822&skuId=791811288869839823"
} }
}, },
{ {
"id": 2, "id": 2,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=2" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=748378985404945887&skuId=748378985404945888"
} }
}, },
{ {
"id": 3, "id": 3,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=3" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=749105279435866513&skuId=749105279435866514"
} }
} }
] ]
...@@ -55,43 +67,67 @@ ...@@ -55,43 +67,67 @@
{ {
"id": 1, "id": 1,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=4" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=767546274051183809&skuId=767546274051183810"
} }
}, },
{ {
"id": 2, "id": 2,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=5" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=748659115456528889&skuId=748659115456528890"
} }
}, },
{ {
"id": 3, "id": 3,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=6" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=749098220531287139&skuId=749098220531287140"
} }
}, },
{ {
"id": 4, "id": 4,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=7" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=791808935596365423&skuId=791808935596365424"
} }
}, },
{ {
"id": 5, "id": 5,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=8" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=768991288915277214&skuId=768991288915277215"
} }
}, },
{ {
"id": 6, "id": 6,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=9" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=7914062957339698784&skuId=791406295733969879"
} }
} }
] ]
...@@ -102,43 +138,67 @@ ...@@ -102,43 +138,67 @@
{ {
"id": 1, "id": 1,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=10" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=748373470406312440&skuId=748373470406312441"
} }
}, },
{ {
"id": 2, "id": 2,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=11" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=748374838109458955&skuId=748374838109458956"
} }
}, },
{ {
"id": 3, "id": 3,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=12" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=748374193441031857&skuId=748374193441031858"
} }
}, },
{ {
"id": 4, "id": 4,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=13" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=748376191670080756&skuId=748376191670080757"
} }
}, },
{ {
"id": 5, "id": 5,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=14" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=803065749907539292&skuId=803065749907539293"
} }
}, },
{ {
"id": 6, "id": 6,
"link": { "link": {
"type": 1, "extra": {
"url": "/pages/goodsDetail/goodsDetail?id=15" "envVersion": "release",
"appId": "wx4205ec55b793245e"
},
"type": 2,
"url": "/subPackages/shopMainProcess/product/index?productId=803077734359466778&skuId=803077734359466779"
} }
} }
] ]
......
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