Init project

This commit is contained in:
lifizer
2023-09-20 21:49:33 +08:00
parent 85a5989c96
commit c9ceac9f37
710 changed files with 125705 additions and 0 deletions
+379
View File
@@ -0,0 +1,379 @@
<template>
<view class="luck-view">
<image class="bg-luck" :src="webUrl+'/20220210153759193846.png'" mode="scaleToFill"></image>
<image class="btn-log" :src="webUrl+'/20220210142514268256.png'" mode="scaleToFill" @click="goLogs"></image>
<image class="dialog" :src="webUrl+'/20220210142530967881.png'" mode="scaleToFill" v-if="newRecords.length>0">
</image>
<view class="dialog" v-if="newRecords.length>0">
<swiper :indicator-dots="false" :autoplay="true" :interval="5000" :duration="1000" circular>
<swiper-item v-for="item in newRecords" :key="item">
<view class="acea-row row-middle">
<image class="avatar" :src="item.avatar" mode="scaleToFill"></image>
<text>恭喜{{ item.username }}获得{{ item.prizeName }}</text>
</view>
</swiper-item>
</swiper>
</view>
<!-- 大转盘抽奖 -->
<view class="wheel-box" v-show="!isDialog">
</view>
<image class="btn-tip" :src="webUrl+'/20220210142525648150.png'" mode="scaleToFill" v-if="lotteryInfo"></image>
<view class="btn-tip acea-row row-center-wrapper" v-if="lotteryInfo">
<view>剩余
<text>{{ lotteryInfo.lotteryUserInfo.dayLimit }}</text>
次抽奖机会
</view>
<!-- <view>剩余<text>{{parseInt(lotteryInfo.lotteryUserInfo.lotteryPoints/lotteryInfo.singleCost)}}</text>次抽奖机会</view> -->
</view>
<view class="tip-box" v-html="lotteryInfo.description" v-if="lotteryInfo">
<!-- <view>1.每天有1次幸运大转盘的抽奖机会</view>
<view>2.每次抽奖需要消耗{{lotteryInfo.singleCost}}幸运币</view>
<view>3.抽中商品后可去个人中心页面查看订单详情</view> -->
</view>
<image class="btn-role" :src="webUrl+'/20220210142520109834.png'" mode="scaleToFill"></image>
<cover-view class="result-mark" v-if="isDialog">
<cover-view class="result-dialog flex flex-col ai-center">
<cover-image class="icon-close" :src="webUrl+'/20220610111928963051.png'" mode="scaleToFill"
@click="isDialog=false"/>
<cover-view class="title">恭喜您中奖啦</cover-view>
<cover-image class="cover" :src="result.imgs[0].src" mode="scaleToFill"/>
<cover-view class="name">获得的是{{ result.fonts[0].text }}</cover-view>
<button class="btn-fetch" type="default" @click="goReceive">去领取</button>
<button class="btn-close" type="default" @click="isDialog=false">关闭</button>
</cover-view>
</cover-view>
</view>
</template>
<script>
import {draw, getLotteryInfo, getLotteryRecordsNew} from "@/api/luck.js";
export default {
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
blocks: [],
buttons: [],
prizes: [],
defaultConfig: {
stopRange: 0.5
},
lotteryId: null,
newRecords: [],
lotteryInfo: null,
isDialog: false,
result: {},
lotteryRecordId: null, //抽奖记录ID
hitIndex: 0,
isWait: false
}
},
onLoad() {
this.getLuck();
this.blocks = [{
imgs: [{
src: this.webUrl + '/20220210142536583482.png',
width: '100%',
height: '100%'
}]
}]
this.buttons = [{
radius: '50%',
imgs: [{
src: this.webUrl + '/20220210142504244580.png',
width: '177rpx',
top: '-65%'
}]
}]
},
methods: {
// 初始化
getLuck() {
getLotteryInfo().then(({
data
}) => {
this.lotteryId = data.id;
this.lotteryInfo = data;
// 处理奖品数据
let len = this.lotteryInfo.prizeList.length;
let temp;
for (let i = 0; i < len; i++) {
temp = {
imgs: [{
src: this.lotteryInfo.prizeList[i].image,
width: "80rpx",
height: "80rpx",
top: "85%"
}],
fonts: [{
text: this.lotteryInfo.prizeList[i].name,
top: '50%',
fontSize: '28rpx'
}]
}
this.$set(this.prizes, i, temp)
}
getLotteryRecordsNew(this.lotteryId).then(({
data
}) => this.newRecords = data);
})
},
// 跳转奖品记录
goLogs() {
this.$yrouter.push('/v4/views/luck/logs?id=' + this.lotteryId);
},
// 点击抽奖按钮触发回调
startCallBack() {
let that = this;
if (this.isWait) return;
this.isWait = true;
if (this.lotteryId == null) {
uni.showToast({
title: "无抽奖活动",
icon: 'none'
})
return;
}
draw(this.lotteryId).then(res => {
if (res.success) {
that.lotteryRecordId = res.data.id;
let surplus = that.lotteryInfo.lotteryUserInfo.dayLimit - 1;
if (surplus > -1) {
that.$set(that.lotteryInfo.lotteryUserInfo, "dayLimit", surplus)
}
for (let i = 0, len = that.lotteryInfo.prizeList.length; i < len; i++) {
if (res.data.prizeId == that.lotteryInfo.prizeList[i].id) {
that.hitIndex = i;
break;
}
}
// 先开始旋转
that.$refs.myLucky.play()
that.isHit = res.data.isHit;
// 使用定时器来模拟请求接口
setTimeout(() => {
// 调用stop停止旋转并传递中奖索引
if (res.data.prizeId == null) that.hitIndex = -1;
that.$refs.myLucky.stop(that.hitIndex)
}, 3000)
} else {
that.isWait = false;
uni.showToast({
title: res.msg,
icon: "none",
duration: 3000
});
}
}).catch(err => {
that.isWait = false;
uni.showToast({
title: err.msg,
icon: "none",
duration: 3000
});
})
},
// 抽奖结束触发回调
endCallBack(prize) {
// 奖品详情
console.log(prize)
this.result = prize;
this.isWait = false;
if (this.lotteryInfo.prizeList[this.hitIndex].name == "谢谢参与") {
uni.showToast({
title: "别灰心,好运一定会来",
icon: "none",
duration: 3000
});
return
}
this.isDialog = true;
},
goReceive() {
this.isDialog = false;
uni.navigateTo({
url: "receive?id=" + this.lotteryRecordId
})
}
}
}
</script>
<style scoped lang="scss">
image {
vertical-align: middle;
}
.luck-view {
position: relative;
}
.bg-luck {
width: 750rpx;
height: 1523rpx;
}
.btn-log {
width: 109rpx;
height: 49rpx;
position: absolute;
top: 18rpx;
right: 0;
}
.dialog {
width: 521rpx;
height: 111rpx;
position: absolute;
top: 240rpx;
left: 114.5rpx;
font-size: 24rpx;
color: #fff;
.acea-row {
margin-top: 27rpx;
margin-left: 22rpx;
}
.avatar {
width: 36rpx;
height: 36rpx;
margin-right: 20rpx;
background: #FFBEBE;
border-radius: 50%;
}
}
.wheel-box {
position: absolute;
top: 352rpx;
left: 65rpx;
}
.btn-tip {
width: 372rpx;
height: 61rpx;
position: absolute;
top: 1014rpx;
left: 189rpx;
font-size: 24rpx;
color: #fff;
text {
font-size: 40rpx;
}
}
.tip-box {
width: 670rpx;
height: 290rpx;
position: absolute;
bottom: 90rpx;
left: 40rpx;
box-sizing: border-box;
padding: 46rpx 30rpx 30rpx;
border: 4rpx solid #E69F42;
border-radius: 32rpx;
background: #fff;
font-size: 30rpx;
line-height: 1.5;
overflow-y: auto;
}
.btn-role {
width: 156rpx;
height: 60rpx;
position: absolute;
bottom: 363rpx;
left: 92rpx;
}
.result-mark {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(51, 51, 51, 0.39);
overflow: hidden;
}
.result-dialog {
position: absolute;
top: 300rpx;
left: 50%;
transform: translate(-50%, 0);
width: 458rpx;
height: 560rpx;
border-radius: 20rpx;
background: #FFF5DB;
.icon-close {
position: absolute;
top: 20rpx;
right: 26rpx;
width: 26rpx;
height: 26rpx;
}
.title {
margin-top: 40rpx;
font-size: 34rpx;
font-weight: bold;
line-height: 50rpx;
color: #FF0000;
}
.cover {
width: 240rpx;
height: 240rpx;
vertical-align: middle;
margin: 15rpx 0;
border-radius: 15rpx;
}
.name {
font-size: 24rpx;
line-height: 34rpx;
color: #333333;
}
button::after {
border: none;
}
.btn-fetch {
width: 176rpx;
height: 60rpx;
line-height: 60rpx;
margin-top: 28rpx;
border-radius: 30rpx;
background: #FD685D;
color: #fff;
font-size: 28rpx;
}
.btn-close {
height: 34rpx;
line-height: 34rpx;
margin-top: 12rpx;
font-size: 24rpx;
color: #D6BA70;
}
}
</style>