修复红包失效逻辑

This commit is contained in:
tcubic
2022-08-08 19:27:11 +08:00
parent a67a865e35
commit 5f6b3f39d9
4 changed files with 113 additions and 107 deletions

View File

@@ -109,7 +109,6 @@
<div class="ishas_service_box"></div> <div class="ishas_service_box"></div>
<div class="ishas_service_box_cls" @click="ishasServicePopHide"></div> <div class="ishas_service_box_cls" @click="ishasServicePopHide"></div>
</div> </div>
</template> </template>
<script setup> <script setup>
@@ -174,18 +173,21 @@ const serviceLuckyMsg = reactive({
id: 1, id: 1,
}); });
// 判断红包是否生效
const isLost1 = ref(false);
const isLost2 = ref(false);
const hideServiceLuckyPop = () => { const hideServiceLuckyPop = () => {
gsap.to(".serviceLuckyPop", { duration: 0.5, autoAlpha: 0 }); gsap.to(".serviceLuckyPop", { duration: 0.5, autoAlpha: 0 });
}; };
// 已经添加企微逻辑 // 已经添加企微逻辑
const ishasServicePop = ()=>{ const ishasServicePop = () => {
gsap.to('.ishas_service_pop',{duration:0.5,autoAlpha:1}) gsap.to(".ishas_service_pop", { duration: 0.5, autoAlpha: 1 });
} };
const ishasServicePopHide = ()=>{ const ishasServicePopHide = () => {
gsap.to('.ishas_service_pop',{duration:0.5,autoAlpha:0}) gsap.to(".ishas_service_pop", { duration: 0.5, autoAlpha: 0 });
} };
// 点击领取企微红包 // 点击领取企微红包
const getServiceLucky = () => { const getServiceLucky = () => {
@@ -281,9 +283,6 @@ const activityList = reactive([
// 页面挂载前 // 页面挂载前
onBeforeMount(() => { onBeforeMount(() => {
// 判断参与活动红包是否领取 // 判断参与活动红包是否领取
let arr = store.state.userAccount.prizeList; let arr = store.state.userAccount.prizeList;
arr.forEach((element) => { arr.forEach((element) => {
@@ -291,12 +290,18 @@ onBeforeMount(() => {
isDraw.value = true; isDraw.value = true;
gameOver.value = true; gameOver.value = true;
drawAmount.value = element.amount; drawAmount.value = element.amount;
if (element.receiveStatus == -2) {
isLost1.value = true;
}
} }
// 判断红包记录里面是否存在企微红包 // 判断红包记录里面是否存在企微红包
if (element.type == 2) { if (element.type == 2) {
isGetedServiceLucky.value = true; isGetedServiceLucky.value = true;
if (element.receiveStatus == -2) {
isLost2.value = true;
}
} }
}); });
}); });
@@ -380,12 +385,17 @@ onMounted(() => {
addPoint(); addPoint();
// 如果添加了企微,直接调抽奖结果,中奖了就弹窗,未中奖的话不弹窗 // 如果添加了企微,直接调抽奖结果,中奖了就弹窗,未中奖的话不弹窗
if (store.state.userAccount.isAddCustomerBefore == 0 && !isGetedServiceLucky.value) { if (
store.state.userAccount.isAddCustomerBefore == 0 &&
!isGetedServiceLucky.value
) {
if ( if (
store.state.userAccount.isAddCustomer == 1 && store.state.userAccount.isAddCustomer == 1 &&
!isGetedServiceLucky.value !isGetedServiceLucky.value
) { ) {
getluckyBag2(2); if (!isLost2.value) {
getluckyBag2(2);
}
} }
} }
@@ -405,7 +415,10 @@ const drawBtn = () => {
if (!isDraw.value) { if (!isDraw.value) {
// LuckyWheelCon.value.showDrawAni(3, true) // LuckyWheelCon.value.showDrawAni(3, true)
gsap.killTweensOf(".draw_btn"); gsap.killTweensOf(".draw_btn");
getluckyBag(1); //大转盘抽奖传参数1 if (!isLost1.value) {
getluckyBag(1); //大转盘抽奖传参数1
}
} else { } else {
Toast("您已经抽过奖"); Toast("您已经抽过奖");
} }
@@ -422,19 +435,14 @@ const luckyWheelFn = () => {
const activityBtn = (item) => { const activityBtn = (item) => {
console.log(item.id); console.log(item.id);
console.log(wx); console.log(wx);
if (item.id == 1) { if (item.id == 1) {
if (store.state.userAccount.isAddCustomerBefore == 1) {
if(store.state.userAccount.isAddCustomerBefore == 1 ){
// Toast("您已添加过专属服务人员,请参与下方其他活动吧") // Toast("您已添加过专属服务人员,请参与下方其他活动吧")
ishasServicePop() ishasServicePop();
}else{ } else {
showServicePop.value = true; showServicePop.value = true;
} }
} }
if (item.id == 2) { if (item.id == 2) {
@@ -454,7 +462,6 @@ const activityBtn = (item) => {
if (item.id == 4) { if (item.id == 4) {
console.log("牛牛杯"); console.log("牛牛杯");
window.location.href = window.location.href =
"https://appstatic.cmschina.com/activity/cmszhyxpt/bees/index.html?id=INT_SMKTC_uD5KUL2d"; "https://appstatic.cmschina.com/activity/cmszhyxpt/bees/index.html?id=INT_SMKTC_uD5KUL2d";
// setTimeout(()=>{ // setTimeout(()=>{
@@ -1103,31 +1110,30 @@ const deleteData = (type) => {
} }
} }
.ishas_service_pop {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background-color: rgba(0, 0, 0, 0.7);
visibility: hidden;
.ishas_service_pop{ .ishas_service_box {
width: 100%; @include box(573px, 362px);
height: 100%; @include bg_pos("../assets/img/pop/ishas_service.png");
position: fixed; }
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background-color: rgba(0, 0, 0, 0.7);
visibility: hidden;
.ishas_service_box{ .ishas_service_box_cls {
@include box(573px, 362px); @include box(72px, 72px);
@include bg_pos("../assets/img/pop/ishas_service.png"); @include bg_pos("../assets/img/pop/cls_btn.png");
} margin-top: 50px;
}
.ishas_service_box_cls{
@include box(72px, 72px);
@include bg_pos("../assets/img/pop/cls_btn.png");
margin-top: 50px;
}
} }
</style> </style>

View File

@@ -139,35 +139,13 @@ const hidePop = () => {
const getMoney = (val) => { const getMoney = (val) => {
console.log("val:", val); console.log("val:", val);
// 红包类型未参与红包: 需先绑定牛卡号 // 先判断红包是否生效
if (val.type == 1) { if (val.isGeted == -2) {
console.log("牛卡号:", store.state.userAccount.nkh); Toast("红包已过24小时不能再提现啦");
if ( } else {
store.state.userAccount.nkh == "" || // 红包类型未参与红包: 需先绑定牛卡号
store.state.userAccount.nkh == undefined if (val.type == 1) {
) { console.log("牛卡号:", store.state.userAccount.nkh);
// Toast("牛卡号为空,先绑定牛卡号");
Dialog.confirm({
title: "温馨提示",
message: "请先绑定牛卡号",
confirmButtonText: "前往绑定",
})
.then(() => {
wx.miniProgram.navigateTo({
url: "/subs/bind/pages/login/login?source=zszq",
});
})
.catch(() => {
console.log(2);
// on cancel
});
} else {
getLuckyBag(val.id);
}
}
if (val.type == 2) {
if (val.isGeted == 0) {
if ( if (
store.state.userAccount.nkh == "" || store.state.userAccount.nkh == "" ||
store.state.userAccount.nkh == undefined store.state.userAccount.nkh == undefined
@@ -188,10 +166,37 @@ const getMoney = (val) => {
// on cancel // on cancel
}); });
} else { } else {
console.log("未领取", val);
getLuckyBag(val.id); getLuckyBag(val.id);
} }
} }
if (val.type == 2) {
if (val.isGeted == 0) {
if (
store.state.userAccount.nkh == "" ||
store.state.userAccount.nkh == undefined
) {
// Toast("牛卡号为空,先绑定牛卡号");
Dialog.confirm({
title: "温馨提示",
message: "请先绑定牛卡号",
confirmButtonText: "前往绑定",
})
.then(() => {
wx.miniProgram.navigateTo({
url: "/subs/bind/pages/login/login?source=zszq",
});
})
.catch(() => {
console.log(2);
// on cancel
});
} else {
console.log("未领取", val);
getLuckyBag(val.id);
}
}
}
} }
}; };

View File

@@ -46,7 +46,7 @@ import {
} from "vue"; } from "vue";
import gsap from "gsap"; import gsap from "gsap";
import axios from "axios"; import axios from "axios";
import { Toast,Dialog } from "vant"; import { Toast, Dialog } from "vant";
import { useStore } from "vuex"; import { useStore } from "vuex";
import service from "@/api/httpServe"; import service from "@/api/httpServe";
import qs from "qs"; import qs from "qs";
@@ -67,18 +67,17 @@ const isBingo = ref(false); //是否中过奖
const noPrize = ref(false); //未中奖 const noPrize = ref(false); //未中奖
const noFirstAdd = ref(false) const noFirstAdd = ref(false);
// 刷新添加状态 // 刷新添加状态
const updateStaus = () => { const updateStaus = () => {
getIsAddService(); getIsAddService();
}; };
const isLost = ref(false);
// 页面挂载前 // 页面挂载前
onBeforeMount(() => { onBeforeMount(() => {
let arr = store.state.userAccount.prizeList; let arr = store.state.userAccount.prizeList;
arr.forEach((element) => { arr.forEach((element) => {
@@ -86,7 +85,10 @@ onBeforeMount(() => {
console.log("已经抽过》》》》》"); console.log("已经抽过》》》》》");
isgot.value = true; isgot.value = true;
isDraw.value = true; isDraw.value = true;
noFirstAdd.value = true noFirstAdd.value = true;
if (element.receiveStatus == -2) {
isLost.value = true;
}
} }
// if(element.amount != 0){ // if(element.amount != 0){
@@ -94,8 +96,6 @@ onBeforeMount(() => {
// } // }
}); });
if (store.state.userAccount.isAddCustomer == 1) { if (store.state.userAccount.isAddCustomer == 1) {
isadd.value = 1; isadd.value = 1;
} }
@@ -171,9 +171,12 @@ const draw = () => {
}); });
}; };
const getMoneyFn = () => {
const getMoneyFn = ()=>{ if (!isLost.value) {
if (store.state.userAccount.nkh == '' || store.state.userAccount.nkh == undefined) { if (
store.state.userAccount.nkh == "" ||
store.state.userAccount.nkh == undefined
) {
// Toast("牛卡号为空,先绑定牛卡号"); // Toast("牛卡号为空,先绑定牛卡号");
Dialog.confirm({ Dialog.confirm({
title: "温馨提示", title: "温馨提示",
@@ -192,7 +195,8 @@ const getMoneyFn = ()=>{
// 有牛卡号的话领取 // 有牛卡号的话领取
getLuckyBag(); getLuckyBag();
} }
} }
};
// 领取接口 // 领取接口
const getLuckyBag = () => { const getLuckyBag = () => {

View File

@@ -161,7 +161,7 @@ const apiAll = () => {
// 页面未挂载 // 页面未挂载
onBeforeMount(() => { onBeforeMount(() => {
if (!h5plugin.isWX()) { if (!h5plugin.isWX()) {
// apiAll(); apiAll();
} }
console.log("link", window.location.href); console.log("link", window.location.href);
@@ -169,14 +169,8 @@ onBeforeMount(() => {
console.log("code:", h5plugin.getQueryString("code")); console.log("code:", h5plugin.getQueryString("code"));
// 微信环境授权 // 微信环境授权
if (h5plugin.isWX()) { if (h5plugin.isWX()) {
if (h5plugin.getQueryString("code")) { if (h5plugin.getQueryString("code")) {
// 存在code的话去换取openid // 存在code的话去换取openid
authCode.value = h5plugin.getQueryString("code"); authCode.value = h5plugin.getQueryString("code");
@@ -191,6 +185,7 @@ onBeforeMount(() => {
onMounted(() => { onMounted(() => {
fontAdpat(); fontAdpat();
// stopBack() // stopBack()
goBackEvent()
}); });
// 来自首页的事件 // 来自首页的事件
@@ -198,11 +193,9 @@ const indexPage = (actions) => {
console.log("来自index组件", actions); console.log("来自index组件", actions);
}; };
const getCode = () => { const getCode = () => {
let redirect_uri = window.location.href; let redirect_uri = window.location.href;
// service.post(process.env.VUE_APP_API + '/cms-activity/cms88/zsApi/xfhdAuthorize?redirect_uri='+redirect_uri,
service service
.post(process.env.VUE_APP_API + "/cms-activity/cms88/zsApi/xfhdAuthorize", { .post(process.env.VUE_APP_API + "/cms-activity/cms88/zsApi/xfhdAuthorize", {
redirect_uri: redirect_uri, redirect_uri: redirect_uri,
@@ -298,13 +291,11 @@ const stopBack = () => {
// 监听后退事件 // 监听后退事件
const goBackEvent = () => { const goBackEvent = () => {
if (window.history && window.history.pushState) { history.pushState({ page: 1 }, null, window.location.href);
window.onpopstate = function () { //然后监听popstate事件
//后退按钮触发事件 window.addEventListener("popstate", (event) => {
console.log("后退"); wx.miniProgram.navigateBack();
window.history.go(-1); });
};
}
}; };
</script> </script>