添加抽奖ui动画等

This commit is contained in:
rucky 2022-08-02 17:10:20 +08:00
parent d419800cdc
commit 4ac1bef80a
7 changed files with 628 additions and 502 deletions

BIN
src/assets/img/p_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
src/assets/img/p_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
src/assets/img/p_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
src/assets/img/p_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
src/assets/img/p_5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -55,12 +55,16 @@
class="activity_li" class="activity_li"
v-for="(item, index) in activityList" v-for="(item, index) in activityList"
:key="index" :key="index"
:style="{ 'background-image': 'url(' + item.banner + ')' }" :style="{
'background-image': 'url(' + item.banner + ')',
}"
v-show="item.show" v-show="item.show"
> >
<div <div
class="btn" class="btn"
:style="{ 'background-image': 'url(' + item.btnImg + ')' }" :style="{
'background-image': 'url(' + item.btnImg + ')',
}"
@click="activityBtn(item)" @click="activityBtn(item)"
></div> ></div>
</div> </div>
@ -185,11 +189,14 @@ const btn = () => {
const drawBtn = () => { const drawBtn = () => {
console.log("抽奖22"); console.log("抽奖22");
service.get(process.env.VUE_APP_API + '/cms88/card/qrcode/',cardId=store.state.userAccount.cardId ) service
.get(
process.env.VUE_APP_API + "/cms88/card/qrcode/",
(cardId = store.state.userAccount.cardId)
)
.then((res) => { .then((res) => {
console.log(res); console.log(res);
}) });
// console.log("",getAuthorize(1)); // console.log("",getAuthorize(1));
// if (h5plugin.getQueryString("forceauth")) { // if (h5plugin.getQueryString("forceauth")) {

View File

@ -2,17 +2,26 @@
<div class="LuckyWheelCon" @touchmove.prevent> <div class="LuckyWheelCon" @touchmove.prevent>
<div class="LuckyWheel_container"> <div class="LuckyWheel_container">
<div class="LuckyWheel_box"> <div class="LuckyWheel_box">
<svg width="100%" height="100%" viewBox="-20 0 557 190" id="svg"> <div class="prize p-1" ref="p1"></div>
<circle cx="100" cy="100" r="3" /> <div class="prize p-2" ref="p2"></div>
<circle cx="300" cy="20" r="3" /> <div class="prize p-3" ref="p3"></div>
<path id="path" <div class="prize p-4" ref="p4"></div>
d="M9,100c0,0,18.53-41.58,49.91-65.11c30-22.5,65.81-24.88,77.39-24.88c33.87,0,57.55,11.71,77.05,28.47c23.09,19.85,40.33,46.79,61.71,69.77c24.09,25.89,53.44,46.75,102.37,46.75c22.23,0,40.62-2.83,55.84-7.43c27.97-8.45,44.21-22.88,54.78-36.7c14.35-18.75,16.43-36.37,16.43-36.37" /> <div class="prize p-5" ref="p5"></div>
<g id="rect"> <div class="prize p-1" ref="p6"></div>
<rect width="85" height="30" fill="dodgerblue" /> <div class="prize p-2" ref="p7"></div>
<text x="10" y="19" font-size="14">SVG &lt;rect&gt;</text> <div class="prize p-3" ref="p8"></div>
</g> <div class="prize p-4" ref="p9"></div>
</svg> <div class="prize p-5" ref="p10"></div>
<div id="div">#div</div> <div class="prize p-1" ref="p11"></div>
<div class="prize p-2" ref="p12"></div>
<div class="prize p-3" ref="p13"></div>
<div class="prize p-4" ref="p14"></div>
<div class="prize p-5" ref="p15"></div>
<div class="prize p-5" ref="p16"></div>
<div class="prize p-5" ref="p17"></div>
<div class="prize p-5" ref="p18"></div>
<div class="prize p-5" ref="p19"></div>
<!-- <div class="prize p-3" ref="p20"></div> -->
</div> </div>
<div class="btn" @click="btn">开始抽奖</div> <div class="btn" @click="btn">开始抽奖</div>
</div> </div>
@ -20,54 +29,138 @@
</template> </template>
<script setup> <script setup>
import { onBeforeMount, onMounted, defineEmits, defineProps, reactive, ref, toRefs } from 'vue' import {
onBeforeMount,
onMounted,
defineEmits,
defineProps,
reactive,
ref,
toRefs,
} from "vue";
import gsap from "gsap"; import gsap from "gsap";
import axios from 'axios' import axios from "axios";
import { Toast } from 'vant'; import { Toast } from "vant";
import { useStore } from "vuex"; import { useStore } from "vuex";
import { PixiPlugin } from "gsap/PixiPlugin.js"; // import { PixiPlugin } from "gsap/PixiPlugin.js";
import { MotionPathPlugin } from "gsap/MotionPathPlugin.js"; import { MotionPathPlugin } from "gsap/MotionPathPlugin.js";
// import { MorphSVGPlugin } from "gsap/MorphSVGPlugin"; // import { MorphSVGPlugin } from "gsap/MorphSVGPlugin";
gsap.registerPlugin(PixiPlugin, MotionPathPlugin) gsap.registerPlugin(MotionPathPlugin);
// //
const emit = defineEmits(["ServicePop"]); // const emit = defineEmits(["ServicePop"]); //
const props = defineProps({ sendMessage: Object }); // props const props = defineProps({ sendMessage: Object }); // props
const store = useStore() const store = useStore();
const p1 = ref(null);
const p2 = ref(null);
const eqcode = ref(require('../assets/img/pop/eqcode.png')) const p3 = ref(null);
const p4 = ref(null);
const p5 = ref(null);
const p6 = ref(null);
const p7 = ref(null);
const p8 = ref(null);
const p9 = ref(null);
const p10 = ref(null);
const p11 = ref(null);
const p12 = ref(null);
const p13 = ref(null);
const p14 = ref(null);
const p15 = ref(null);
const p16 = ref(null);
const p17 = ref(null);
const p18 = ref(null);
const p19 = ref(null);
const aniGroup = ref([]);
const eqcode = ref(require("../assets/img/pop/eqcode.png"));
// //
onBeforeMount(() => { }) onBeforeMount(() => {});
onMounted(() => {
showDrawAni();
const btn = () => {
console.log('抽奖');
// gsap.to('.LuckyWheel_box', { duration: 10, repeat: -1, "rotation": '+=360' })
gsap.to("#rect", {
duration: 5,
repeat: 12,
repeatDelay: 3,
yoyo: true,
ease: "power1.inOut",
motionPath: {
path: "#path",
align: "#path",
autoRotate: true,
alignOrigin: [0.5, 0.5]
}
}); });
// bingo index pArrindex
const showDrawAni = (bingo, repeat) => {
const pArr = [
p1, // 1.08
p2, // 2.68
p3, // 6.66
p4, // 8.88
p5, //
p6, // 便
p7,
p8,
p9,
p10,
p11,
p12,
p13,
p14,
p15,
p16,
p17,
p18,
p19,
];
const singleRate = 1 / pArr.length; //
const delta = singleRate + 0.068; //
let rotateDelta = 0; // |
if (bingo) {
rotateDelta = (5 - bingo) * singleRate;
} }
for (let i = 1; i < pArr.length + 1; i++) {
let ani = gsap.to(
[pArr[i - 1].value],
{
duration: 10,
paused: bingo ? false : true, //
// repeat: -1,
// delay: i * 0.5 - 1,
// stagger: 0.5,
// repeatDelay: 3,
// yoyo: true,
ease: "back.out(1.4)",
motionPath: {
path: "M115.37,73.45C177.05-25.14,462-22.69,535,70,686.45,248.93,797.17,321.7,324.48,321.7-121,321.7-20.39,248.93,115.37,73.45Z",
// align: [1, 1],
autoRotate: true,
start: i * singleRate + rotateDelta - delta, // 0-1
end: i * singleRate + 1 + rotateDelta - delta, // 0-
offsetX: -177,
offsetY: -43,
alignOrigin: [0.5, 0],
},
onUpdate: () => {
// if (i === 1) console.log(ani.progress());
},
},
"same"
);
//
ani.seek(0);
if (bingo && repeat) {
setTimeout(() => {
showDrawAni(bingo, false);
}, 800);
}
}
};
const btn = () => {
console.log("抽奖");
// ID
// 1 - 1.08
// 2 - 2.68
// 3 - 6.66
// 4 - 8.88
// 5 -
// id, fasle
showDrawAni(1, true);
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -75,41 +168,40 @@ const btn = () => {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: fixed; position: fixed;
z-index: 10;
top: 0; top: 0;
left: 0; left: 0;
right: 0; // right: 0;
bottom: 0; // bottom: 0;
display: flex; // display: flex;
justify-content: center; // justify-content: center;
align-items: center; // align-items: center;
background-color: rgba(0, 0, 0, 0.7); background-color: rgba(0, 0, 0, 0.3);
.LuckyWheel_container { .LuckyWheel_container {
width: 750px; position: absolute;
height: 1180px; top: 770px;
left: 0;
width: 760px;
height: 500px;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
.LuckyWheel_box { .LuckyWheel_box {
// // border-width: 123px;
border-width: 123px; // border-style: solid;
border-style: solid; // border-radius: 50%;
border-radius: 50%; // // box-shadow: -1.569px -17.932px 16px 0px rgba(234, 6, 16, 0.16);
box-shadow: -1.569px -17.932px 16px 0px rgba(234, 6, 16, 0.16); // width: 831px;
width: 831px; // height: 305px;
height: 305px;
.li { .li {
width: 100px; width: 100px;
height: 100px; height: 100px;
background-color: #ff6000; background-color: #ff6000;
} }
} }
.btn { .btn {
@ -121,8 +213,35 @@ const btn = () => {
color: #fff; color: #fff;
background: #ff6000; background: #ff6000;
} }
} }
.prize {
position: absolute;
width: 160px;
height: 96px;
left: 0;
top: 10px;
//
&.p-1 {
background-image: url("~@/assets/img/p_1.png");
background-size: 160px 96px;
}
&.p-2 {
background-image: url("~@/assets/img/p_2.png");
background-size: 160px 96px;
}
&.p-3 {
background-image: url("~@/assets/img/p_3.png");
background-size: 160px 96px;
}
&.p-4 {
background-image: url("~@/assets/img/p_4.png");
background-size: 160px 96px;
}
&.p-5 {
background-image: url("~@/assets/img/p_5.png");
background-size: 160px 96px;
}
// background-color: #f00;
}
} }
</style> </style>