修改抽奖动画

This commit is contained in:
xiaoaojiao
2025-09-17 16:38:42 +08:00
parent 427bdfc0ed
commit 1b89cc367b
4 changed files with 112 additions and 62 deletions

View File

@@ -32,11 +32,11 @@ import ModalTransition from "./ModalTransition.vue"
import confetti from "canvas-confetti";
import { Request, Sleep } from "../libs/utils"
import { globalStore } from "@/globalstore";
import getUserPicture from "../libs/getUserPicture";
//TODO: globalStore.result_url 这里这张图要用用户分享那张图
// import lotteryFace from "../assets/images/haibao-cover.webp"
const lotteryFace = globalStore.result_url;
const lotteryFaceUrl = ref(lotteryFace)
const lotteryFaceUrl = ref('')
const cardRef = ref(null)
const sceneRef = ref(null)
const guangRef = ref(null)
@@ -117,12 +117,24 @@ watch(() => props.show, async (newVal) => {
return
}
const loading = weui.loading()
const userPicture = await getUserPicture()
const preimg = async() => {
new Promise((resolve) => {
const img = new Image()
img.onload = () => resolve(img)
img.src = userPicture
})
}
await preimg()
lotteryFaceUrl.value = userPicture
shakeTimeline.play()
//TODO: 延时测试,上限删掉
// await Sleep(2000)
// await Sleep(20000)
shakeTimeline.pause()
const lottteryResult = await Request("lottery/draw", { pool: 'game', consume_type: 'points' })
// TODO: 测试数据
// const lottteryResult = {
@@ -136,6 +148,9 @@ watch(() => props.show, async (newVal) => {
// }
// }
loading.hide()
shakeTimeline.pause()
if (lottteryResult.res.status !== 200) {
emit('close')
return