完成红包领取逻辑

This commit is contained in:
tcubic 2022-08-04 16:36:17 +08:00
parent fd0f93cf80
commit fc817eafb8
8 changed files with 370 additions and 295 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -4,7 +4,10 @@
<div class="draw_container" v-if="!isgetMoney"> <div class="draw_container" v-if="!isgetMoney">
<!-- 正常中奖 --> <!-- 正常中奖 -->
<div class="has_prize" v-if="drawStatus"> <div class="has_prize" v-if="drawStatus">
<div class="money_num"><span>8.88</span></div> <div class="money_num">
<span>{{ amount }}</span
>
</div>
<div class="get_btn" @click="getMoney"></div> <div class="get_btn" @click="getMoney"></div>
</div> </div>
@ -21,9 +24,7 @@
<div class="go_index_btn"></div> <div class="go_index_btn"></div>
</div> </div>
<div class="cls_btn" @click="hide"></div> <div class="cls_btn" @click="hide"></div>
</div> </div>
</div> </div>
</template> </template>
@ -42,23 +43,30 @@ import gsap from "gsap";
import axios from "axios"; import axios from "axios";
import service from "@/api/httpServe"; import service from "@/api/httpServe";
import qs from "qs"; import qs from "qs";
import wx from "@/utils/wx-jssdk.1.6.0.js";
import { Toast, Dialog } from "vant";
import { Toast } from "vant";
import { useStore } from "vuex"; import { useStore } from "vuex";
// //
const emit = defineEmits(["drawCon"]); // const emit = defineEmits(["drawCon"]); //
const props = defineProps({ sendMessage: Object }); // props const props = defineProps({ prizeMsg: Object }); // props
const store = useStore(); const store = useStore();
const drawStatus = ref(true);
const drawStatus = ref(true) const isgetMoney = ref(false);
const isgetMoney = ref(false) const amount = ref(0);
const prizeId = ref(1);
// //
onBeforeMount(() => {}); onBeforeMount(() => {
amount.value = props.prizeMsg.amount;
prizeId.value = props.prizeMsg.id;
if (props.prizeMsg.amount == 0) {
drawStatus.value = false;
}
console.log("props:", props.prizeMsg);
});
// //
onMounted(() => { onMounted(() => {
@ -76,27 +84,14 @@ const hide = () => {
emit("drawCon"); emit("drawCon");
}; };
// //
const getMoney = () => { const getMoney = () => {
redpacket() redpacket(prizeId.value);
};
gsap.to('.draw_container',{duration:0.3,scale:0,autoAlpha:0,onComplete:()=>{
drawStatus.value = false
isgetMoney.value = true
gsap.form('.add_container',{duration:0.5,scale:0,autoAlpha:0,})
}})
}
// //
const redpacket = (prizeId) => { const redpacket = (prizeId) => {
let redpacketId = 84; let redpacketId = prizeId;
service service
.post( .post(
process.env.VUE_APP_API + process.env.VUE_APP_API +
@ -106,10 +101,38 @@ const redpacket = (prizeId) => {
) )
.then((res) => { .then((res) => {
console.log("领取红包结果", res); console.log("领取红包结果", res);
let data = res.data;
if (data.code == 0) {
gsap.to(".draw_container", {
duration: 0.3,
scale: 0,
autoAlpha: 0,
onComplete: () => {
drawStatus.value = false;
isgetMoney.value = true;
// gsap.form('.add_container',{duration:0.5,scale:0,autoAlpha:0,})
},
});
} else {
Toast(data.msg);
Dialog.confirm({
title: "温馨提示",
message: data.msg,
confirmButtonText: '前往绑定',
})
.then(() => {
wx.miniProgram.navigateTo({
url: "/subs/bind/pages/login/login",
});
})
.catch(() => {
console.log(2);
// on cancel
});
}
}); });
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -161,7 +184,6 @@ const redpacket = (prizeId) => {
@include box(573px, 362px); @include box(573px, 362px);
@include bg_pos("../assets/img/pop/no_prize_pop.png"); @include bg_pos("../assets/img/pop/no_prize_pop.png");
} }
} }
.add_container { .add_container {
@ -181,12 +203,9 @@ const redpacket = (prizeId) => {
@include pos(394px, 92px, 79px, 389px); @include pos(394px, 92px, 79px, 389px);
@include bg_pos("../assets/img/pop/to_index_btn.png"); @include bg_pos("../assets/img/pop/to_index_btn.png");
} }
} }
} }
.cls_btn { .cls_btn {
@include box(72px, 72px); @include box(72px, 72px);
@include bg_pos("../assets/img/pop/cls_btn.png"); @include bg_pos("../assets/img/pop/cls_btn.png");

View File

@ -8,9 +8,11 @@
<div class="luckybag_left"></div> <div class="luckybag_left"></div>
<div class="luckybag_right"></div> <div class="luckybag_right"></div>
<div class="icon_left_1"></div> <div class="icon_left_1"></div>
<div class="lucky_bag"></div> <div class="lucky_bag" v-if="!gameOver"></div>
<div class="lucky_bag_2"> <div class="lucky_bag_2" v-if="gameOver">
<div class="prize_num">{{ prizeResult }}<span></span></div> <div class="no_prize_text" v-if="drawAmount == 0"></div>
<div class="prize_text" v-if="drawAmount != 0"></div>
<div class="prize_num" v-if="drawAmount != 0">{{ drawAmount }}<span></span></div>
</div> </div>
<div class="notice"> <div class="notice">
<span class="icon" <span class="icon"
@ -25,7 +27,7 @@
<div class="cloud_right_2"></div> <div class="cloud_right_2"></div>
<!-- 大转盘 --> <!-- 大转盘 -->
<div class="zhuanpan"></div> <div class="zhuanpan"></div>
<LuckyWheel v-if="true" ref="LuckyWheelCon" /> <LuckyWheel v-if="true" ref="LuckyWheelCon" @luckyWheel="luckyWheelFn" />
<div class="icon_right_2"></div> <div class="icon_right_2"></div>
<div class="icon_right_3"></div> <div class="icon_right_3"></div>
@ -80,7 +82,7 @@
<!-- 添加专属服务人员企微弹窗 --> <!-- 添加专属服务人员企微弹窗 -->
<ServiceList v-if="showServicePop" @ServicePop="hideServicePop" /> <ServiceList v-if="showServicePop" @ServicePop="hideServicePop" />
<!-- 抽奖结果弹窗 --> <!-- 抽奖结果弹窗 -->
<Draw v-if="showDrawCon" @drawCon="drawConFn" /> <Draw v-if="showDrawCon" @drawCon="drawConFn" :prizeMsg="prizeMsg" />
</div> </div>
</template> </template>
@ -126,10 +128,18 @@ const showRulesPop = ref(false);
const showMyPrize = ref(false); const showMyPrize = ref(false);
const showServicePop = ref(false); const showServicePop = ref(false);
const gameOver = ref(false)
const drawType = ref(1); const drawType = ref(1);
const isDraw = ref(false); const isDraw = ref(false);
const LuckyWheelCon = ref(null); const LuckyWheelCon = ref(null);
const showDrawCon = ref(false); // const showDrawCon = ref(false); //
const drawAmount = ref('') //
const prizeMsg = reactive({
amount: 0,
id: 1,
})
// //
const activityList = reactive([ const activityList = reactive([
@ -179,7 +189,8 @@ onBeforeMount(() => {
arr.forEach(element => { arr.forEach(element => {
if(element.type == 1){ if(element.type == 1){
isDraw.value = true; isDraw.value = true;
console.log("222222222222222222222222222222222"); gameOver.value = true
drawAmount.value = element.amount
} }
}); });
@ -250,10 +261,20 @@ const drawBtn = () => {
// LuckyWheelCon.value.showDrawAni(3, true) // LuckyWheelCon.value.showDrawAni(3, true)
getluckyBag(1); //1 getluckyBag(1); //1
isDraw.value = true;
}else{
Toast('您已经抽过奖')
} }
}; };
//
const luckyWheelFn = ()=>{
console.log("game over");
showDrawCon.value = true;
gameOver.value = true
}
// //
const activityBtn = (item) => { const activityBtn = (item) => {
console.log(item.id); console.log(item.id);
@ -265,8 +286,6 @@ const activityBtn = (item) => {
if (item.id == 2) { if (item.id == 2) {
console.log("新客专享页面"); console.log("新客专享页面");
// let url = "/subs/financial/pages/index/index"; // let url = "/subs/financial/pages/index/index";
// console.log(wx);
wx.miniProgram.navigateTo({ wx.miniProgram.navigateTo({
url: "/subs/financial/pages/index/index", url: "/subs/financial/pages/index/index",
}); });
@ -361,7 +380,12 @@ const getMyPrizeRecored = () => {
service service
.post(process.env.VUE_APP_API + "/cms-activity/cms88/prize/list", {}) .post(process.env.VUE_APP_API + "/cms-activity/cms88/prize/list", {})
.then((res) => { .then((res) => {
console.log("红包记录:", res); console.log("红包记录:", res.data);
store.commit({
type: "updatePrizeList",
prizeList: res.data.data,
});
}); });
}; };
@ -391,17 +415,16 @@ const getluckyBag = (id) => {
}) })
.then((res) => { .then((res) => {
console.log("抽取红包结果:", res); console.log("抽取红包结果:", res);
let prizeNum = res.data.data.amount;
// drawType = 1
if (drawType.value == 1) {
//
if (res.data.code == 0) { if (res.data.code == 0) {
isDraw.value = true;
let prizeNum = res.data.data.amount;
drawAmount.value = res.data.data.amount
prizeMsg.amount = res.data.data.amount
prizeMsg.id = res.data.data.id
// //
if (prizeNum == 0) { if (prizeNum == 0) {
// //
console.log("抽中1");
LuckyWheelCon.value.showDrawAni(5, true); LuckyWheelCon.value.showDrawAni(5, true);
} }
if (prizeNum == 1.08) { if (prizeNum == 1.08) {
@ -420,15 +443,13 @@ const getluckyBag = (id) => {
// 6.66 // 6.66
LuckyWheelCon.value.showDrawAni(4, true); LuckyWheelCon.value.showDrawAni(4, true);
} }
getMyPrizeRecored() //
} else { } else {
if (res.data.data == 0) { Toast(res.data.msg)
//
LuckyWheelCon.value.showDrawAni(5, true);
}
}
} else {
//
} }
}); });
}; };
@ -631,7 +652,7 @@ const deleteData = (type) => {
@include pos(308px, 355px, 227px, 356px); @include pos(308px, 355px, 227px, 356px);
@include bg_pos("../assets/img/luckybag.png"); @include bg_pos("../assets/img/luckybag.png");
pointer-events: none; pointer-events: none;
visibility: hidden; // visibility: hidden;
} }
.lucky_bag_2 { .lucky_bag_2 {
@ -641,6 +662,18 @@ const deleteData = (type) => {
// display: flex; // display: flex;
.no_prize_text{
@include pos(221px, 59px, 55px, 55px);
@include bg_pos("../assets/img/no_prize_text.png");
pointer-events: none;
}
.prize_text{
@include pos(172px, 23px, 80px, 37px);
@include bg_pos("../assets/img/prize_text.png");
pointer-events: none;
}
.prize_num { .prize_num {
@include pos(330px, 50px, 0px, 79px); @include pos(330px, 50px, 0px, 79px);
font-weight: 700; font-weight: 700;

View File

@ -37,7 +37,7 @@ import {
reactive, reactive,
ref, ref,
toRefs, toRefs,
defineExpose defineExpose,
} from "vue"; } from "vue";
import gsap from "gsap"; import gsap from "gsap";
import axios from "axios"; import axios from "axios";
@ -51,7 +51,7 @@ import { MotionPathPlugin } from "gsap/MotionPathPlugin.js";
gsap.registerPlugin(MotionPathPlugin); gsap.registerPlugin(MotionPathPlugin);
// //
const emit = defineEmits(["ServicePop"]); // const emit = defineEmits(["luckyWheel"]); //
const props = defineProps({ sendMessage: Object }); // props const props = defineProps({ sendMessage: Object }); // props
const store = useStore(); const store = useStore();
const p1 = ref(null); const p1 = ref(null);
@ -76,6 +76,16 @@ const p19 = ref(null);
const aniGroup = ref([]); const aniGroup = ref([]);
const eqcode = ref(require("../assets/img/pop/eqcode.png")); const eqcode = ref(require("../assets/img/pop/eqcode.png"));
const luckyWheelStatus = ref(false);
//
const isStop = () => {
if (!luckyWheelStatus.value) {
luckyWheelStatus.value = true;
console.log("大转盘结束");
emit('luckyWheel') //
}
};
// //
onBeforeMount(() => {}); onBeforeMount(() => {});
@ -138,6 +148,16 @@ const showDrawAni = (bingo, repeat) => {
onUpdate: () => { onUpdate: () => {
// if (i === 1) console.log(ani.progress()); // if (i === 1) console.log(ani.progress());
}, },
onStart: () => {
if (i == pArr.length - 1) {
setTimeout(() => {
// console.log("2");
isStop()
}, 5000);
}
},
onComplete: () => {},
}, },
"same" "same"
); );
@ -165,9 +185,8 @@ const btn = () => {
// //
defineExpose({ defineExpose({
showDrawAni showDrawAni,
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -93,6 +93,7 @@ onBeforeMount(() => {
if (element.type == 1) { if (element.type == 1) {
prizeList.push({ prizeList.push({
id: element.id, id: element.id,
type: element.type,
prizeNum: element.amount, prizeNum: element.amount,
isGeted: element.receiveStatus, isGeted: element.receiveStatus,
spe: "财富88与“礼”共见证", spe: "财富88与“礼”共见证",
@ -102,6 +103,7 @@ onBeforeMount(() => {
if (element.type == 2) { if (element.type == 2) {
prizeList.push({ prizeList.push({
id: element.id, id: element.id,
type: element.type,
prizeNum: element.amount, prizeNum: element.amount,
isGeted: element.receiveStatus, isGeted: element.receiveStatus,
spe: "添加专属服务人员企微", spe: "添加专属服务人员企微",
@ -128,15 +130,28 @@ const hide = () => {
}; };
const hidePop = () => { const hidePop = () => {
gsap.to('.GotedPop',{duration:0.5,autoAlpha:0}) gsap.to(".GotedPop", { duration: 0.5, autoAlpha: 0 });
gsap.to('.myPrizeCon',{duration:0.5,autoAlpha:1,delay:0.2}) gsap.to(".myPrizeCon", { duration: 0.5, autoAlpha: 1, delay: 0.2 });
}; };
// //
const getMoney = (val) => { const getMoney = (val) => {
console.log("val:", val);
//
if (val.type == 1) {
if (!store.state.userAccount.nkh) {
Toast("牛卡号为空,先绑定牛卡号");
} else {
getLuckyBag(val.id);
}
}
if (val.type == 2) {
if (val.isGeted == 0) { if (val.isGeted == 0) {
console.log("未领取", val); console.log("未领取", val);
getLuckyBag(val.id) getLuckyBag(val.id);
}
} }
}; };
@ -144,19 +159,15 @@ const getMoney = (val) => {
const getLuckyBag = (id) => { const getLuckyBag = (id) => {
service service
.post( .post(
process.env.VUE_APP_API + process.env.VUE_APP_API + "/cms-activity/cms88/redpacket/receive/" + id,
"/cms-activity/cms88/redpacket/receive/" + id,
{} {}
) )
.then((res) => { .then((res) => {
console.log("领取红包结果", res); console.log("领取红包结果", res);
gsap.to('.GotedPop',{duration:1,autoAlpha:1,delay:0.2}) gsap.to(".GotedPop", { duration: 1, autoAlpha: 1, delay: 0.2 });
gsap.to('.myPrizeCon',{duration:1,autoAlpha:0}) gsap.to(".myPrizeCon", { duration: 1, autoAlpha: 0 });
}); });
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -313,7 +324,6 @@ const getLuckyBag = (id) => {
flex-direction: column; flex-direction: column;
.goted_box { .goted_box {
@include box(530px, 594px); @include box(530px, 594px);
@include bg_pos("../assets/img/pop/got_luckyBag_pop.png"); @include bg_pos("../assets/img/pop/got_luckyBag_pop.png");
position: relative; position: relative;
@ -324,7 +334,6 @@ const getLuckyBag = (id) => {
} }
} }
.cls_btn { .cls_btn {
@include box(72px, 72px); @include box(72px, 72px);
@include bg_pos("../assets/img/pop/cls_btn.png"); @include bg_pos("../assets/img/pop/cls_btn.png");

View File

@ -146,7 +146,7 @@ onBeforeMount(() => {
getActivityNum(), getActivityNum(),
getIsAddService(), getIsAddService(),
]).then((result) => { ]).then((result) => {
console.log("接口都请求完成"); console.log("接口都请求完成",result);
// //
pageImgsArrLoad(imgList).then(() => { pageImgsArrLoad(imgList).then(() => {
console.log("load done"); console.log("load done");
@ -156,11 +156,6 @@ onBeforeMount(() => {
}); });
console.log("link", window.location.href); console.log("link", window.location.href);
// URLtoken
// store.commit({ type: "updateToken", token: h5plugin.getQueryString('token') });
// store.commit({ type: "updateCardId", cardId: h5plugin.getQueryString('cardId') });
// store.commit({ type: "updateNkh", nkh: h5plugin.getQueryString('nkh') });
console.log("用户活动信息:", store.state.userAccount); console.log("用户活动信息:", store.state.userAccount);
// //