<template>
|
<view class="lottery">
|
<view class="header" :style="'padding-top:' + statusBarTop + 'px;height:'+statusBarHeight+'px'">
|
<view class="header_content">
|
<view class="return iconfont icon-xiangzuo" @click.stop="goback"></view>
|
</view>
|
</view>
|
<view class="lottery_title"></view>
|
<view class="lottery_box1">
|
<view class="block_box">
|
<view class="block" v-for="(item,index) in prizeList" :key="index" :class="activeIndex==index?'active':''">
|
<image class="image" :src="item.prizeImgUrl"></image>
|
<view class="name">{{item.prizeName}}</view>
|
</view>
|
</view>
|
<view class="lottery_blockNone"></view>
|
<view class="lottery_btn" :class="!mdayInfo.isOnLine||lotteryNum<=0?'disable':''" @click="getPrize">
|
<view class="text">剩{{ lotteryNum }}次</view>
|
</view>
|
<view class="lottery_newList">
|
<view class="lottery_newWrapper" :style="'animation-duration:' + newList.length*2 + 's'">
|
<view class="newList_item" v-for="(newItem, newIndex) in newList" :key="newItem.uniKey">
|
客户{{ newItem.maskRealName }}抽中了{{ newItem.prizeName }}
|
</view>
|
</view>
|
</view>
|
|
</view>
|
<view class="ruleBox">
|
<view class="btn" @click="goToCate()"><text style="opacity: 0;">去选购</text></view>
|
</view>
|
<view class="lottery_return"></view>
|
<view style="height: 30rpx;"></view>
|
<view class="lottery_btnRule" @click="showRule()"></view>
|
<view class="lottery_btnCourse" @click="getMyPrize()"></view>
|
<popRule ref="popRule"></popRule>
|
<popMyPrize ref="popMyPrize" :myPrizeList="myPrizeList"></popMyPrize>
|
<popGetPrize ref="popGetPrize" :mday-info="mdayInfo" :prizeInfo="curPrize"></popGetPrize>
|
<popCoupon ref="popCoupon" :pageName="'lottery'"></popCoupon>
|
</view>
|
</template>
|
|
<script>
|
import {
|
parseQueryString
|
} from "@/utils/index.js";
|
import {
|
handsCoupon
|
} from '@/api/user.js';
|
import {
|
setCouponReceive
|
}
|
from '@/api/api.js';
|
import {
|
getLast10Prize,
|
getMdayLast,
|
getPrize,
|
getMyPrize
|
} from '@/api/lottery.js';
|
import popCoupon from '@/components/popCoupon/index.vue';
|
import popRule from './components/popRule.vue';
|
import popMyPrize from './components/popMyPrize.vue';
|
import popGetPrize from './components/popGetPrize.vue';
|
export default {
|
components: {
|
popRule,
|
popMyPrize,
|
popGetPrize,
|
popCoupon
|
},
|
data() {
|
return {
|
statusBarTop: 0,
|
statusBarHeight: 50,
|
prizeList: [],
|
myPrizeList: [],
|
lotteryNum: 2,
|
newList: [],
|
couponList: [],
|
curPrize: {},
|
activeIndex: 999,
|
mdayId: 0,
|
mdayInfo: {}
|
}
|
},
|
onLoad(options) {
|
let that = this;
|
let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
|
that.statusBarTop = menuButtonInfo.top;
|
that.statusBarHeight = menuButtonInfo.height;
|
},
|
mounted() {},
|
onHide() {
|
let that = this;
|
if (that.$store.getters.isSystemHide) {
|
console.log('系统事件触发了onhide事件');
|
return false;
|
}
|
this.isPageShow = false;
|
uni.$off('BELONG_READY', that.belongInfoReadyFn);
|
},
|
onShow() {
|
let that = this;
|
if (that.$store.getters.isSystemHide) {
|
console.log('系统事件触发了onshow事件');
|
that.$store.getters.isSystemHide=false;
|
return false;
|
}
|
uni.$off('BELONG_READY', that.belongInfoReadyFn);
|
that.isPageShow = true;
|
let pages = getCurrentPages(),
|
currPage = pages[pages.length - 1];
|
console.log('------------------page onShow start-----------------');
|
console.log('route', currPage.route);
|
console.log('options', currPage.options);
|
console.log('------------------page onShow end-----------------');
|
|
if (that.$store.getters.isBelong) {
|
that.belongInfoReadyFn({
|
isRegister: false
|
})
|
} else {
|
uni.$once('BELONG_READY', that.belongInfoReadyFn);
|
}
|
},
|
methods: {
|
goToCate(){
|
uni.switchTab({
|
url: '/pages/goods_cate/goods_cate'
|
})
|
},
|
getPrize() {
|
let that = this;
|
if (!that.$store.getters.isLogin) {
|
toLogin(that);
|
return false;
|
}
|
if (!that.mdayId) {
|
uni.$emit("showTips", {
|
'title': '会员日数据缺失',
|
'icon': 'none'
|
});
|
return false;
|
}
|
if(!that.mdayInfo.isOnLine){
|
return false;
|
}
|
if (that.lotteryNum <= 0 || that.isDrawing) {
|
return false;
|
}
|
that.isDrawing = true;
|
uni.showLoading();
|
getPrize({
|
mdayId: that.mdayId
|
}).then(res => {
|
that.lotteryNum = res.data.drawNum;
|
uni.hideLoading();
|
|
var num=0;
|
var timer=setInterval(()=>{
|
num++;
|
that.activeIndex=num%8;
|
if(num>32){
|
clearInterval(timer);
|
that.activeIndex=999;
|
|
that.isDrawing = false;
|
that.curPrize = res.data;
|
that.$refs.popGetPrize.show();
|
}
|
},50)
|
|
})
|
|
},
|
showRule() {
|
this.$refs.popRule.show();
|
},
|
getMyPrize() {
|
let that = this;
|
if (!that.$store.getters.isLogin) {
|
toLogin(that);
|
return false;
|
}
|
getMyPrize({
|
pageNo: 1,
|
pageSize: 9999
|
}).then(res => {
|
that.myPrizeList = res.data.records;
|
that.$refs.popMyPrize.show();
|
})
|
},
|
getCoupon: function(item, index) {
|
let that = this;
|
if (!that.$store.getters.isLogin) {
|
that.goToLogin();
|
return false;
|
}
|
//领取优惠券
|
if (item.userCouponStatus >= 0) {
|
if (item.appId && item.toPath) {
|
that.goToThird(item.toPath, item.appId);
|
} else if (item.toPath) {
|
if (that.isTabLink(item.toPath)) {
|
uni.switchTab({
|
url: item.toPath
|
})
|
} else {
|
uni.navigateTo({
|
url: item.toPath
|
})
|
}
|
} else {
|
uni.switchTab({
|
url: '/pages/goods_cate/goods_cate'
|
})
|
}
|
} else {
|
setCouponReceive(item.id).then(function(res) {
|
that.addTrack('yy_getCoupon', {
|
'couponName_var': item.name,
|
'couponId_var': item.id
|
});
|
that.$set(that.couponList[index], 'userCouponStatus', 0);
|
that.$util.Tips({
|
title: '领取成功'
|
});
|
}).catch(err => {
|
return that.$util.Tips({
|
title: (err && err.message) ? err.message : err
|
});
|
})
|
}
|
|
},
|
goback() {
|
// #ifdef H5
|
return history.back();
|
// #endif
|
// #ifndef H5
|
return uni.navigateBack({
|
delta: 1,
|
})
|
// #endif
|
},
|
belongInfoReadyFn(data) {
|
let that = this;
|
if (!data.isRegister) {
|
that.checkLoginFn();
|
}
|
},
|
checkLoginFn() {
|
console.log('checkLoginFn')
|
let that = this;
|
let pages = getCurrentPages(),
|
currPage = pages[pages.length - 1];
|
that.addTrack('yy_pageView', {
|
pageTitle_var: '抽奖',
|
pagePath_var: currPage.$page.fullPath,
|
pageType_var: '抽奖'
|
});
|
that.getLast10Prize();
|
that.getMdayLast();
|
// if(that.$store.getters.isLogin){
|
// handsCoupon().then(res=>{
|
// if(res.code==200){
|
// that.$refs.popCoupon.show();
|
// }
|
// });
|
// }
|
},
|
getLast10Prize: function() {
|
let that = this;
|
getLast10Prize({}).then(res => {
|
let data = res.data.concat(JSON.parse(JSON.stringify(res.data)));
|
data.forEach((item, index) => {
|
item.uniKey = 'newList' + index;
|
});
|
that.$set(that, 'newList', data);
|
});
|
},
|
getMdayLast: function() {
|
let that = this;
|
uni.showLoading();
|
getMdayLast({}).then(res => {
|
that.mdayInfo = res.data.mday;
|
that.mdayId = res.data.mday.id;
|
that.lotteryNum = res.data.drawNum;
|
uni.hideLoading();
|
let data = res.data.mday.couponList.concat([]);
|
data.forEach((item, index) => {
|
item.uniKey = 'couponList' + index;
|
});
|
that.couponList = data;
|
let prizeList = res.data.prizePool.prizeList.concat([]);
|
if (res.data.prizePool.prizeList.length > 0) {
|
while (prizeList.length < 7) {
|
prizeList = prizeList.concat(res.data.prizePool.prizeList);
|
}
|
}
|
if (prizeList.length > 7) {
|
prizeList = prizeList.slice(0, 7);
|
}
|
prizeList.push({
|
'name': '谢谢参与'
|
})
|
prizeList.forEach((item, index) => {
|
item.uniKey = 'prizeList' + index;
|
});
|
that.prizeList = prizeList;
|
});
|
},
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.lottery {
|
min-height: 100vh;
|
position: relative;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lotteryBg.png) center top/100% auto no-repeat;
|
background-color: #fffee3;
|
}
|
|
.header {
|
padding-top: 88rpx;
|
height: 64rpx;
|
box-sizing: content-box;
|
.header_content {
|
position: relative;
|
width: 100%;
|
height: 100%;
|
}
|
|
.return {
|
font-size: 40rpx;
|
position: absolute;
|
left: 32rpx;
|
top: 50%;
|
transform: translate(0, -50%);
|
}
|
}
|
|
.page_content {
|
position: relative;
|
}
|
|
.lottery_title {
|
width: 623rpx;
|
height: 152rpx;
|
margin: 0 auto;
|
margin-top: -70rpx;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_title.png) center top/contain no-repeat;
|
}
|
|
.lottery_box1 {
|
width: 714rpx;
|
height: 789rpx;
|
margin: 30rpx auto 0 auto;
|
position: relative;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_box1Bg.png) center top/contain no-repeat;
|
|
.block_box {
|
width: 454rpx;
|
height: 454rpx;
|
position: absolute;
|
left: 127rpx;
|
top: 165rpx;
|
display: flex;
|
}
|
|
.block {
|
width: 142rpx;
|
height: 142rpx;
|
position: absolute;
|
left: 0;
|
top: 0;
|
|
&:nth-child(4),
|
&:nth-child(8) {
|
left: 160rpx;
|
}
|
|
&:nth-child(5),
|
&:nth-child(6),
|
&:nth-child(7) {
|
left: unset;
|
right: 0;
|
}
|
|
&:nth-child(2),
|
&:nth-child(6) {
|
top: 160rpx;
|
}
|
|
&:nth-child(1),
|
&:nth-child(7),
|
&:nth-child(8) {
|
top: unset;
|
bottom: 0;
|
}
|
|
.image {
|
width: 80%;
|
display: block;
|
height: 85rpx;
|
margin: 0 auto;
|
margin-top: 10rpx;
|
margin-bottom: 10rpx;
|
position: relative;
|
}
|
|
.name {
|
font-size: 25rpx;
|
line-height: 1;
|
color: #220d20;
|
text-align: center;
|
white-space: nowrap;
|
position: relative;
|
}
|
|
&:last-child {
|
.image{
|
width: 100%;
|
height: 100%;
|
margin: 0;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_blockNone.png) center center/auto 68rpx no-repeat;
|
}
|
.name{
|
display: none;
|
}
|
}
|
&.active:before{
|
content: '';
|
display: block;
|
width: 165rpx;
|
height: 165rpx;
|
position: absolute;
|
z-index: 0;
|
left: 50%;
|
top: 50%;
|
margin-left: -83rpx;
|
margin-top: -83rpx;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_blockActive.png) center center/contain no-repeat;
|
}
|
}
|
}
|
.ruleBox{
|
width: 695rpx;
|
height: 620rpx;
|
margin: 0 auto;
|
margin-top: -70rpx;
|
position: relative;
|
z-index: 2;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_ruleBox.png) center top/contain no-repeat;
|
.btn{
|
width: 131rpx;
|
height: 60rpx;
|
position: absolute;
|
right: 77rpx;
|
bottom: 88rpx;
|
|
}
|
}
|
.lottery_btn {
|
width: 146rpx;
|
height: 148rpx;
|
position: absolute;
|
left: 50%;
|
margin-left: -75.0rpx;
|
top: 317rpx;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_btn.png) center top/contain no-repeat;
|
|
&.disable {
|
filter: grayscale(1);
|
}
|
|
.text {
|
width: 100%;
|
position: absolute;
|
left: 0;
|
top: 95rpx;
|
font-size: 21rpx;
|
line-height: 1.5em;
|
text-align: center;
|
color: #ffffff;
|
}
|
}
|
|
.lottery_newList {
|
width: 425rpx;
|
position: absolute;
|
left: 141rpx;
|
top: 14rpx;
|
overflow: hidden;
|
|
@keyframes moveAni {
|
0% {
|
transform: none;
|
}
|
|
100% {
|
transform: translate(-50%, 0)
|
}
|
}
|
|
.lottery_newWrapper {
|
width: max-content;
|
white-space: nowrap;
|
animation: moveAni 1s linear both infinite;
|
}
|
|
.newList_item {
|
display: inline-block;
|
margin: 0 5rpx;
|
width: max-content;
|
line-height: 64rpx;
|
font-size: 24rpx;
|
color: #333333;
|
padding-left: 1em;
|
padding-right: 1em;
|
border-radius: 24rpx;
|
}
|
}
|
|
|
|
.lottery_couponBox {
|
width: 690rpx;
|
padding-top: 97rpx;
|
padding-bottom: 30rpx;
|
margin: 0 auto;
|
margin-top: 30rpx;
|
position: relative;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_couponBoxBg.png) center top/100% auto no-repeat;
|
background-color: #ffffff;
|
box-sizing: border-box;
|
border: 2rpx solid #ffffff;
|
border-radius: 24rpx;
|
}
|
|
.couponList_item {
|
position: relative;
|
width: 620rpx;
|
height: 150rpx;
|
color: #000000;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_coupon.png) center top/100% auto no-repeat;
|
border-radius: 11rpx;
|
overflow: hidden;
|
margin: 0 auto 20rpx auto;
|
|
&:last-child {
|
margin-bottom: 0;
|
}
|
|
&:before,
|
&:after {
|
content: '';
|
display: block;
|
width: 18rpx;
|
height: 18rpx;
|
position: absolute;
|
left: 205rpx;
|
margin-left: -9rpx;
|
background: #f5f5f5;
|
border-radius: 50%;
|
z-index: 2;
|
}
|
|
&:before {
|
top: -9rpx;
|
}
|
|
&:after {
|
bottom: -9rpx;
|
}
|
|
.line {
|
height: 100%;
|
border-left: 1px dashed #f5f5f5;
|
position: absolute;
|
left: 205rpx;
|
top: 0;
|
}
|
|
.amount {
|
font-size: 57rpx;
|
line-height: 1em;
|
position: absolute;
|
left: 102rpx;
|
top: 30rpx;
|
width: max-content;
|
transform: translateX(-50%);
|
font-weight: bold;
|
text-align: center;
|
|
&.amountSmall {
|
font-size: 30rpx;
|
padding-top: 15rpx;
|
}
|
|
.unit1 {
|
font-size: 22rpx;
|
position: absolute;
|
left: -15rpx;
|
top: -18rpx;
|
}
|
|
.unit2 {
|
font-size: 23rpx;
|
line-height: 30rpx;
|
}
|
}
|
|
.info {
|
font-size: 19rpx;
|
line-height: 29rpx;
|
position: absolute;
|
left: 102rpx;
|
top: 93rpx;
|
width: max-content;
|
transform: translateX(-50%);
|
}
|
|
.get_btn {
|
width: 132rpx;
|
font-size: 27rpx;
|
line-height: 54rpx;
|
text-align: center;
|
background: linear-gradient(to right, #fdb011, #fa4100);
|
color: #ffffff;
|
border-radius: 27rpx;
|
position: absolute;
|
right: 22rpx;
|
bottom: 23rpx;
|
}
|
|
.name {
|
font-weight: bold;
|
font-size: 27rpx;
|
line-height: 30rpx;
|
position: absolute;
|
left: 239rpx;
|
top: 25rpx;
|
display: flex;
|
|
.type {
|
border-radius: 15rpx;
|
background-color: #04C763;
|
padding: 0 12rpx;
|
font-size: 20rpx;
|
color: #ffffff;
|
margin-right: 10rpx;
|
}
|
}
|
|
.time {
|
font-size: 27rpx;
|
line-height: 30rpx;
|
position: absolute;
|
left: 239rpx;
|
top: 25rpx;
|
}
|
}
|
|
|
.lottery_couponBoxTitle {
|
width: 380rpx;
|
height: 84rpx;
|
position: absolute;
|
left: 50%;
|
margin-left: -189.0rpx;
|
top: -20rpx;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_couponBoxTitle.png) center top/contain no-repeat;
|
}
|
|
.lottery_btnRule {
|
width: 52rpx;
|
height: 80rpx;
|
position: absolute;
|
right: -2rpx;
|
top: 214rpx;
|
display: none;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_btnRule.png) center top/contain no-repeat;
|
}
|
|
.lottery_btnCourse {
|
width: 52rpx;
|
height: 80rpx;
|
position: absolute;
|
right: -2rpx;
|
top: 310rpx;
|
top: 214rpx;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/lottery_btnCourse.png) center top/contain no-repeat;
|
}
|
</style>
|