Huanyuyuehui/components/blindBox/blindBox.vue

365 lines
7.8 KiB
Vue

<template>
<view class="content" v-show="blindShow">
<view class="bg">
<view class="top">
</view>
<view class="lucky-draw">
<view class="title">
</view>
<view class="blind-box">
<image src="https://store.tropjoin.com/images/mh-item.png" @click="openBlindBox(index)" :class="actionIndex==index?'action':''" class="box-item" v-for="(item,index) in 6">
</view>
<view class='iconfont icon-guanbi3' @click='closePop()'></view>
</view>
</view>
<view class="coupon_popups" v-if="popShow">
<view class="bg2"></view>
<view class="con" v-if="blind">
<view class="content" v-if="!this.prize.name">
<image :src="drawInfo.img" mode=""></image>
<view class="text-black">恭喜您获得</view>
<view class="text-red">{{drawInfo.text}}铸源星</view>
<view class="btn" @click="closePop()">开心收下</view>
</view>
<view v-if="this.prize.name" class="content" style="height: 660rpx;">
<image style="height: 300rpx;" :src="this.prize.image" mode=""></image>
<view class="text-black">恭喜您获得</view>
<view class="text-red">{{this.prize.name}}</view>
<view class="btn" @click="writeAddress()">填写地址</view>
</view>
</view>
<view class="con" v-else>
<view class="content">
<image src="https://store.tropjoin.com/images/notBlind.png" style="width: 80px;height: 80px;" mode=""></image>
<view class="text-black">谢谢参与</view>
<view class="text-red">期待您下次再来</view>
<view class="btn" @click="closePop()">我知道了</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {setBlind} from '@/api/user.js'
export default {
components: {
},
data() {
return {
wheel:0,
actionIndex:-1,
popShow:false,
blindShow:true,
blind:true,
defaultConfig: {
gutter: '5px',
speed: 60,
stopRange:'0.95'
},
popShow:false,
list:[],
prize:{
name:'',
id:'',
image:''
},
drawInfo:{
img:'',
text:'',
}
}
},
onLoad() {
this.init()
},
methods: {
async openBlindBox(val){
this.actionIndex=val;
if(val/2){
// this.popShow=true;
// this.blind=true;
await setBlind().then(res=>{
if(res.status == 200){
setTimeout(()=>{
this.popShow=true;
this.prize = res.data.prize || {name:'',image:'',id:'',draw_time:''}
this.drawInfo.text = res.data.integral;
this.blind=!!res.data.integral || !!this.prize.name;
},1500)
}else{
return this.$util.Tips({title:err})
}
}).catch(err=>{
// this.close();
return this.$util.Tips({title:err})
// return this.$util.Tips({title:err.message})
});
}else{
setTimeout(()=>{
this.popShow=true;
},800)
}
},
init(){
},
writeAddress(){
let {id,draw_time,image,name} = this.prize
uni.navigateTo({
url: `/pages/users/winning_confirm/index?id=${id}&draw_time=${draw_time}&image=${image}&name=${name}`,
});
this.closePop()
},
closePop(){
this.popShow=false;
this.blindShow=false;
this.$emit('cloneblindBox')
}
}
}
</script>
<style lang="less" scoped>
@keyframes bounce {
from {
transform: scale3d(1, 1, 1);
}
30% {
transform: scale3d(1.05, 0.85, 1);
}
40% {
transform: scale3d(0.85, 1.05, 1);
}
50% {
transform: scale3d(1.10, 0.85, 1);
}
65% {
transform: scale3d(0.95, 1.05, 1);
}
75% {
transform: scale3d(1.05, 0.95, 1);
}
to {
transform: scale3d(1, 1, 1);
}
}
.content {
width: 100%;
height: 100vh;
position: fixed;
background-color: rgba(0,0,0,.9);
z-index: 998;
top: 0;
display: flex;
align-items: center;
justify-content: center;
.coupon_popups{
z-index: 999;
position: fixed;
left: 0;
top: 120rpx;
width: 100%;
height: 100%;
text-align: center;
.bg2{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,.5);
}
.con{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
width: 680rpx;
height: 900rpx;
background-size: 100% 700rpx;
background-repeat: no-repeat;
display: flex;
justify-content: center;
.content{
width: 500rpx;
height: 520rpx;
border-radius: 20rpx;
margin: 0 auto;
background-color: white;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
grid-gap: 40rpx;
image{
width: 300rpx;
height: 200rpx;
margin-top: 50rpx;
}
.text-black{
font-size: 32rpx;
font-weight: bold;
}
.text-red{
font-size: 28rpx;
color: #FC3C70;
}
.btn{
color: white;
margin-bottom: 40rpx;
width: 328rpx;
height: 68rpx;
line-height: 68rpx;
padding: 4rpx 0;
border-radius: 60rpx;
background: linear-gradient(136deg, #FFDF6A 0%, #EF521F 100%);
}
}
.text{
width: 600rpx;
margin: 30rpx auto 0;
font-size: 20rpx;
color: #ffffff;
}
}
}
.bg {
width: 80%;
height: 80vh;
background-size: 100% 100%;
position: relative;
padding-bottom: 40rpx;
.rule {
width: 80rpx;
height: 120rpx;
background-image: url('https://store.tropjoin.com/images/right-btn.png');
background-size: 100%;
background-repeat: no-repeat;
position: absolute;
right: 0;
top: 320rpx;
// text-align: center;
display: flex;
align-items: center;
justify-content: center;
text {
width: 56rpx;
height: 80rpx;
font-family: PingFang SC;
font-weight: 500;
font-size: 28rpx;
color: #DC3424;
line-height: 36rpx;
}
}
.top{
height:180rpx;
}
.lucky-draw{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.title{
position: relative;
bottom: 20rpx;
width:80%;
height: 120rpx;
font-family: PingFang SC;
font-weight: 400;
font-size: 32rpx;
color: #FFFFFF;
margin: 20rpx 0;
line-height: 54rpx;
text-align: center;
// background: url('https://store.tropjoin.com/images/mh-title.png') no-repeat;
// background-size: 100% 100%;
// background-position: center;
}
.blind-box{
width: 100%;
height: 480rpx;
// background: #D753FC;
background-image: url('https://store.tropjoin.com/images/mh-bg.png');
background-repeat: no-repeat;
background-size: 100%;
display: flex;
flex-wrap: wrap;
padding: 40rpx;
padding-bottom: 80rpx;
grid-gap: 20rpx;
.box-item{
flex: 30%;
height: auto;
}
.action{
background: url('https://store.tropjoin.com/images/mh-item-bg.png');
background-repeat: no-repeat;
background-size: 100% 100%;
animation:bounce .8s 1;
animation-direction: normal;
}
}
}
.lucky-draw-info{
margin: 80rpx auto;
width: 680rpx;
height: 440rpx;
background-color: white;
display: flex;
flex-direction: column;
border-radius: 32rpx;
.title{
text-align: center;
font-size: 36rpx;
color: #FC3C70;
line-height: 72rpx;
}
.list{
flex: 1;
overflow: scroll;
display: flex;
flex-direction: column;
grid-gap: 20rpx;
.item{
font-size: 32rpx;
font-weight: bold;
padding: 10rpx 20rpx;
width: 100%;
display: flex;
justify-content: space-between;
}
}
}
.icon-guanbi3{
color: #ffffff;
font-size: 50rpx;
margin-top:50rpx;
}
}
}
</style>