ios判断,红包修改
This commit is contained in:
138
pages/index/prizeDraw/choujiangcanvas.vue
Normal file
138
pages/index/prizeDraw/choujiangcanvas.vue
Normal file
@@ -0,0 +1,138 @@
|
||||
<template>
|
||||
<view class="lottery-container">
|
||||
<!-- 抽奖圆盘 -->
|
||||
<view class="lottery-wheel" @click="startLottery">
|
||||
<view class="lottery-item" v-for="(item, index) in lotteryItems" :key="index">
|
||||
<image :src="item.icon" mode="aspectFit"></image>
|
||||
<text>{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="start-btn">开始抽奖</view>
|
||||
</view>
|
||||
<!-- 剩余抽奖次数 -->
|
||||
<view class="lottery-info">
|
||||
<text>剩余免费抽奖{{ remainingTimes }}次</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
// 抽奖项目数据
|
||||
const lotteryItems = [
|
||||
{
|
||||
name: '现金红包',
|
||||
icon: 'https://example.com/red-envelope-icon.png'
|
||||
},
|
||||
{
|
||||
name: '平板',
|
||||
icon: 'https://example.com/tablet-icon.png'
|
||||
},
|
||||
{
|
||||
name: '爱奇艺会员',
|
||||
icon: 'https://example.com/iqiyi-icon.png'
|
||||
},
|
||||
{
|
||||
name: '淘宝优惠券',
|
||||
icon: 'https://example.com/taobao-coupon-icon.png'
|
||||
},
|
||||
{
|
||||
name: '京东优惠券',
|
||||
icon: 'https://example.com/jd-coupon-icon.png'
|
||||
},
|
||||
{
|
||||
name: '拼多多优惠券',
|
||||
icon: 'https://example.com/pdd-coupon-icon.png'
|
||||
}
|
||||
];
|
||||
|
||||
// 剩余抽奖次数
|
||||
const remainingTimes = ref(2);
|
||||
|
||||
// 开始抽奖函数
|
||||
const startLottery = () => {
|
||||
if (remainingTimes.value > 0) {
|
||||
// 这里可以添加实际的抽奖逻辑,例如随机选择一个奖项
|
||||
// 以下只是模拟抽奖过程
|
||||
const randomIndex = Math.floor(Math.random() * lotteryItems.length);
|
||||
const selectedItem = lotteryItems[randomIndex];
|
||||
console.log('恭喜你获得:', selectedItem.name);
|
||||
remainingTimes.value--;
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '抽奖次数已用完',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.lottery-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.lottery-wheel {
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
border-radius: 50%;
|
||||
background-color: #ffd700;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.lottery-item {
|
||||
width: 50%;
|
||||
height: 50%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.lottery-item:nth-child(1) {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
.lottery-item:nth-child(2) {
|
||||
transform: rotate(60deg);
|
||||
}
|
||||
|
||||
.lottery-item:nth-child(3) {
|
||||
transform: rotate(120deg);
|
||||
}
|
||||
|
||||
.lottery-item:nth-child(4) {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.lottery-item:nth-child(5) {
|
||||
transform: rotate(240deg);
|
||||
}
|
||||
|
||||
.lottery-item:nth-child(6) {
|
||||
transform: rotate(300deg);
|
||||
}
|
||||
|
||||
.start-btn {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border-radius: 50%;
|
||||
background-color: #ff4500;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #fff;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.lottery-info {
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user