当前位置: 首页 > news >正文

uniapp小程序砸金蛋抽奖

砸之前是金蛋png图片,点击砸完之后切换砸金蛋动效gif图片;

当前代码封装为砸金蛋的组件;

vue代码: 

<template><view class="page" v-if="merchantInfo.cdn_static"><image class="bg" :src="merchantInfo.cdn_static +'statistics/luckDrawImg/smashGoldenEggs/page_bg.png'" mode="aspectFill"></image><view class="content"><view class="logo"><image :src="merchantInfo.logo" mode="heightFix"></image></view><view class="title"><image :src="merchantInfo.cdn_static +'statistics/luckDrawImg/smashGoldenEggs/title.png'" mode="heightFix"></image></view><view class="notification"><image :src="merchantInfo.cdn_static +'statistics/luckDrawImg/smashGoldenEggs/notification.png'" mode="heightFix"></image><text>欢乐砸金蛋,一起瓜分好礼</text></view><view class="box"><view class="eggs"><image class="egg" v-for="(item,index) in eggList" :key="index" :src="merchantInfo.cdn_static + 'statistics/luckDrawImg/smashGoldenEggs/'+ item.eggUrl" @click="startPlay(index)"></image></view><view class="count"><image :src="merchantInfo.cdn_static +'statistics/luckDrawImg/smashGoldenEggs/count.png'"></image><view class="tip">您今天还有<text>{{total}}</text>次抽奖机会</view></view><view class="btns"><view class="btn" @click="rule_show=true"><image :src="merchantInfo.cdn_static +'statistics/luckDrawImg/smashGoldenEggs/rule.png'"></image><text>活动规则</text></view><view class="btn" @click="getResult()"><image :src="merchantInfo.cdn_static +'statistics/luckDrawImg/smashGoldenEggs/prize.png'"></image><text>我的奖品</text></view></view></view></view><view class="win" v-if="rule_show"><scroll-view scroll-y class="win_box .win_box_bg"><mp-html :content="luckDrawInfo.rule" /></scroll-view><text class="iconfont iconcolseIcon theme-font-white" @click="rule_show=false"></text></view><view class="win" v-if="result_show"><view class="win_box1"><image class="win_bg" :src="merchantInfo.cdn_static +'statistics/luckDrawImg/result_bg.png'" mode=""></image><view class="win_content"><view class="win_tips theme-font-white">{{currentPrize.desc}}</view><view class="win_title">{{currentPrize.title}}</view><view class="win_btn" @click="choiseAddress()">{{currentPrize.is_address==1?'选择地址':'确定'}}</view></view></view></view><view class="win" v-if="prize_show"><view class="win_tit theme-font-white">我的奖品</view><view class="win_box2"><view class="items"><view class="left i_title">奖品</view><view class="right i_title">中奖时间</view></view><scroll-view scroll-y class="list"><view class="item" v-for="(item,index) in list" :key="index"><view class="left">{{item.lottery_prize_title}}</view><view class="right" v-if="item.is_address==1&&!item.address_id"><view class="r_btn"  @click="choiseAddress1(item)">去领奖</view></view><view class="right" v-else>{{item.created_time}}</view></view></scroll-view></view><text class="iconfont iconcolseIcon theme-font-white" @click="prize_show=false"></text></view></view></template><script>import { luckDrawInfo } from '@/api/luckDraw.js';import colors from '@/mixins/color';export default {mixins: [colors],data() {return {//https://cdn.dev.scrm.juplus.cn/InQLzDLoAl2S9LyNJUXQ45gpA.pngmask: true,wtf:true,luckDrawInfo: {},rule_show:false,result_show:false,prize_show:false,total:0,currentPrize:{},list:[],id: "",eggList: []}},props: {userId: {type: [Number,String]},type:{type: [Number,String]}},//渲染完了mounted() {this.id = this.userId;this.setEggList(); this.init();},methods: {/*** 设置金蛋数据*/setEggList() {this.eggList = [];for (let i = 0; i < 3; i++) {this.eggList.push({eggUrl: `goldEgg.png`})}},init(){if(this.userInfo){this.getInfo()}else{setTimeout(()=>{this.init()},500)}},getInfo(){luckDrawInfo.getDetail({id:this.id}).then(res => {this.luckDrawInfo=res.datathis.total=res.data.my_can_numthis.action('lottery',this.id,0,2,this.luckDrawInfo.title,'','lottery')})},choiseAddress(){this.currentPrize.is_address==1?uni.navigateTo({url:'/pages/address/address'}):''this.result_show=false},choiseAddress1(data){this.currentPrize=datauni.navigateTo({url:'/pages/address/address'})this.prize_show=false},setAddress(id){luckDrawInfo.setAddress({address_id:id,history_id:this.currentPrize.history_id||this.currentPrize.id}).then(res => {uni.showToast({title:"地址设置成功",icon:'none'})})},getResult(){if(!this.wtf){return false}luckDrawInfo.getResult({lottery_id:this.id}).then(res => {this.list=res.data.datathis.prize_show=true})},// 点击开始,请求接口抽奖startPlay(index) {if(this.luckDrawInfo.is_register==1&&!this.userInfo.type){uni.navigateTo({url:'/pages/login/login'})return false}if(this.luckDrawInfo.is_form==1&&this.luckDrawInfo.user_form_count==0){uni.navigateTo({url:'/pages/form/form?id='+this.luckDrawInfo.form_id+'&type_id=' + this.id + '&type=lottery'})return false}if(!this.wtf){return false}// 活动未开始或活动已结束let startTimeMs = new Date(this.luckDrawInfo.start_time).getTime();let endTimeMs = new Date(this.luckDrawInfo.end_time).getTime();let nowTimeMs = new Date().getTime();if (nowTimeMs < startTimeMs) {uni.showToast({icon: "none",title: "活动未开始"})return false;}if (nowTimeMs > endTimeMs) {uni.showToast({icon: "none",title: "活动已结束"})return false;}this.mask = false;this.wtf = false;luckDrawInfo.run({id:this.id}).then(res => {this.currentPrize = res.data;this.total = res.data.row_lottery_new.my_can_num;this.eggList[index].eggUrl = `breakOpenGoldEgg.gif`;setTimeout(()=>{this.eggList[index].eggUrl = `goldEgg.png`;this.result_show = true;this.wtf = true;},2000)}).catch(err => {this.wtf = true;});}}}
</script><style scoped lang="scss">@import 'index.scss';/**/
</style>

scss代码:


.page{width: 750rpx;height: 100vh;position: relative;
}.bg{width: 750rpx;height: 100vh;
}.content{width: 750rpx;min-height: 100vh;height: 1448rpx;position: absolute;top: 0;left: 0;
}.logo{height: 60rpx;display: flex;justify-content: center;margin-top: 90rpx;image{height: 60rpx;}
}.title{height: 194rpx;display: flex;justify-content: center;margin-top: 20rpx;image{height: 194rpx;}
}.notification{margin-top: 170rpx;height: 40rpx;display: flex;justify-content: center;align-items: center;image{height: 32rpx;margin-right: 16rpx;}text{font-size: 28rpx;font-family: PingFangSC-Regular, PingFang SC;font-weight: 400;color: #FFFFFF;}
}.box{width: 680rpx;height: 360rpx;margin: 0 auto;margin-top: 160rpx;.egg {width: 220rpx;height: 300rpx;margin-top: 80rpx;}.egg:first-of-type{margin-left: 20rpx;}.count{display: flex;justify-content: center;margin-top: 14rpx;position: relative;image{width: 424rpx;height: 108rpx;}.tip{position: absolute;top: 50%;transform: translateY(-50%);font-size: 28rpx;font-family: PingFangSC-Medium, PingFang SC;font-weight: 500;color: #FFFFFF;text{color: #FF9611;}} }.btns{display: flex;align-items: center;justify-content: space-between;margin-top: 58rpx;}.btn{width: 292rpx;height: 116rpx;position: relative;image{width: 100%;height: 100%;}text{position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);font-size: 36rpx;font-family: PingFangSC-Medium, PingFang SC;font-weight: 500;color: #FFFFFF;}}}.win{width: 750rpx;height: 100vh;background: rgba(0, 0, 0, 0.8);position: fixed;top: 0;left: 0;z-index: 2;display: flex;flex-direction: column;align-items: center;justify-content: center;
}.win_box{width: 662rpx;height: 60%;padding: 40rpx;box-sizing: border-box;border-radius: 24rpx;
}.win_box_bg{background: #FFCE2B;
}.bg3{background: #C3E5FE;
}.iconcolseIcon{font-size: 58rpx;margin-top: 98rpx;
}.win_box1{width: 630rpx;height: 922rpx;position: relative;
}.win_bg{width: 630rpx;height: 922rpx;
}.win_content{width: 630rpx;height: 922rpx;position: absolute;left: 0;top: 0;display: flex;flex-direction: column;align-items: center;
}.win_tips{font-size: 48rpx;font-family: SourceHanSansSC-Medium, SourceHanSansSC;font-weight: bold;margin-top: 290rpx;
}.win_title{font-size: 48rpx;font-family: SourceHanSansSC-Medium, SourceHanSansSC;font-weight: bold;color: #FE6631;margin: 170rpx 0;
}.win_btn{width: 280rpx;height: 80rpx;line-height: 80rpx;text-align: center;background: #FFE047;border-radius: 46rpx;font-size: 32rpx;font-family: SourceHanSansSC-Medium, SourceHanSansSC;font-weight: bold;color: #13112C;
}.win_tit{font-size: 48rpx;font-family: SourceHanSansSC-Medium, SourceHanSansSC;font-weight: bold;margin-bottom: 32rpx;
}.win_box2{width: 662rpx;height: 900rpx;background: #FFFFFF;border-radius: 24rpx;display: flex;flex-direction: column;
}.items{width: 662rpx;height: 108rpx;background: #C3E5FE;border-radius: 24rpx 24rpx 0rpx 0rpx;display: flex;align-items: center;flex-shrink:0
}.left,.right{width: 50%;text-align: center;font-family: SourceHanSansSC-Medium, SourceHanSansSC;font-weight: bold;
}.i_title{font-size: 36rpx;
}.list{height: 792rpx;padding-bottom: 20rpx;overflow: hidden;
}.item{width: 662rpx;height: 88rpx;display: flex;align-items: center;justify-content: space-around;
}.item:nth-child(2n){background-color: #F4F4F4;
}.r_btn{width: 160rpx;height: 60rpx;line-height: 60rpx;text-align: center;background: #FFC659;border-radius: 46rpx;font-family: SourceHanSansSC-Medium, SourceHanSansSC;font-weight: bold;font-size: 32rpx;margin:0 auto;
}

效果:

相关文章:

uniapp小程序砸金蛋抽奖

砸之前是金蛋png图片&#xff0c;点击砸完之后切换砸金蛋动效gif图片&#xff1b; 当前代码封装为砸金蛋的组件&#xff1b; vue代码&#xff1a; <template><view class"page" v-if"merchantInfo.cdn_static"><image class"bg&qu…...

数据结构(超详细讲解!!)第二十节 数组

1.定义 1.概念 相同类型的数据元素的集合。 记作&#xff1a;A(A0,A1,…,Am-1) 二维数组可看作是每个数据元素都是相同类型的一维数组的一维数组。多维数组依此类推。 二维数组是数据元素为线性表的线性表。 A(A0&#xff0c;A1&#xff0c;……&#xff0c;An-1) 其中…...

【Android】Android Framework系列---CarPower深度睡眠STR

Android Framework系列—CarPower深度睡眠 之前博客说了CarPower的开机启动流程 这里分析一下&#xff0c;Android CarPower实现深度睡眠的流程。 首先&#xff0c;什么是深度睡眠(Deep Sleep)? Android进入Deep Sleep后&#xff0c;关闭屏幕、关闭CPU的电源&#xff0c;保持…...

【漏洞复现】Fastjson_1.2.47_rce

感谢互联网提供分享知识与智慧&#xff0c;在法治的社会里&#xff0c;请遵守有关法律法规 文章目录 1.1、漏洞描述1.2、漏洞等级1.3、影响版本1.4、漏洞复现1、基础环境2、漏洞检测3、漏洞验证 1.5、深度利用1、反弹Shell 说明内容漏洞编号漏洞名称Fastjson_1.2.47_远程执行漏…...

玩转AIGC:如何选择最佳的Prompt提示词?

&#x1f337;&#x1f341; 博主猫头虎 带您 Go to New World.✨&#x1f341; &#x1f984; 博客首页——猫头虎的博客&#x1f390; &#x1f433;《面试题大全专栏》 文章图文并茂&#x1f995;生动形象&#x1f996;简单易学&#xff01;欢迎大家来踩踩~&#x1f33a; &a…...

ELK搭建以及使用教程(多pipiline)

1、环境准备 服务器&#xff1a;Centos7 Jdk版本&#xff1a;1.8 Es版本&#xff1a;7.12.1 kibana版本&#xff1a;7.12.1 logstash版本:7.12.1 IP地址安装软件192.168.50.211Es&#xff0c;Kibana&#xff0c;logstash 2、安装docker 安装步骤参考&#xff1a;https:…...

小程序如何设置用户同意服务协议并上传头像和昵称

为了保护用户权益和提供更好的用户体验&#xff0c;设置一些必填项和必读协议是非常必要的。首先&#xff0c;用户必须阅读服务协议。服务协议是明确规定用户和商家之间权益和义务的文件。通过要求用户在下单前必须同意协议&#xff0c;可以确保用户在使用服务之前了解并同意相…...

6.4 例程:使用互斥量

这个例程为使用多线程配合互斥量进行点乘计算&#xff0c;相关的数据通过全局变量的形式存在&#xff0c;因此可以被各个线程访问&#xff1b;每个线程会在相关数据的不同区域上进行处理&#xff0c;主线程等待子线程完成操作后&#xff0c;将最后的结果打印出来。 代码如下 #…...

[算法日志]图论: 深度优先搜索(DFS)

[算法日志]图论&#xff1a; 深度优先搜索(DFS) 深度优先概论 ​ 深度优先搜索算法是一种遍历图这种数据结构的算法策略&#xff0c;其中心思想是朝图节点的一个方向不断跳转&#xff0c;当该节点无下一个节点或所有方向都遍历完时&#xff0c;便回溯朝上一个节点的另一个方向…...

这道经典SQL面试问题你会吗?

大家经常自嘲后端开发就是crud boy嘛&#xff0c;今天给大家看一道SQL题&#xff0c;我相信很多人写不出来。我们来看一下这个题目。 create table course (id int primary key,name varchar(32) not null ); create table student (id int primary key,name varchar(32) not …...

网络服务退出一个问题的解析

一、问题 在实际开发中遇到一个问题&#xff0c;解决的过程虽然不长&#xff0c;但确实是想得比较多&#xff0c;总结一下&#xff0c;以供参考。这是一个网络通信的服务端而且使用的是别人封装好的库&#xff0c;通信等都没有问题&#xff0c;但在退出时会报一个错误&#xf…...

第四次pta认证P测试

第一题 试题编号&#xff1a; 试题名称&#xff1a;整数排序 时间限制&#xff1a; 1.0s 内存限制&#xff1a; 128.0MB 【问题描述】 老师给定 10 个整数的序列&#xff0c;要求对其重新排序。排序要求: 1.奇数在前&#xff0c;偶数在后&#xff1b; 2.奇数按从大到小排序&am…...

mysql:B+树/事务

B树 : 为了数据库量身定做的数据结构 我们当前这里的讨论都是围绕 mysql 的 innodb 这个存储引擎来讨论的 其他存储引擎可能会用到hash 作为索引,此时就只能应对这种精准匹配的情况了 要了解 B树 我们先了解 B树, B树 是 B树 的改进 B树 有时候会写作 B-树 (这里的" -…...

python-在系统托盘显示CPU使用率和内存使用率

一、添加轮子 1.添加托盘区图标库 infi.systray from infi.systray import SysTrayIcon 2.添加图像处理库 Pillow from PIL import Image, ImageDraw, ImageFont 3.添加 psutil 来获取CPU、内存信息 import psutil 二、完整代码 from infi.systray import SysTrayIcon …...

构建mono-repo风格的脚手架库

前段时间阅读了 https://juejin.cn/post/7260144602471776311#heading-25 这篇文章&#xff1b;本文做一个梳理和笔记&#xff1b; 主要聚焦的知识点如下&#xff1a; 如何搭建脚手架工程如何开发调试如何处理命令行参数如何实现用户交互如何拷贝文件夹或文件如何动态生成文件…...

云安全—etcd攻击面

0x00 前言 本篇还是一样&#xff0c;先来说一说etcd是什么&#xff0c;干啥的&#xff0c;然后再来看看etcd的攻击面到底有哪些&#xff0c;做一个抛砖引玉的作用&#xff0c;如有不妥之处还请斧正 0x01 etcd 依旧还是按照问问题的方式来进行阐述&#xff0c;因为学到的东西…...

类锁和实例对象锁你分清了吗?

系列文章目录 文章目录 系列文章目录前言一、什么是锁竞争&#xff1f;二、什么是类锁&#xff1f;什么是实例对象锁&#xff1f;三、给类对象加锁不是锁住了整个类四、总结 前言 java选手们应该都对锁不陌生&#xff0c;加锁了就是为保证操作语句的原子性&#xff0c;如果你是…...

如何在麒麟上安装 ONLYOFFICE 桌面编辑器

我们很高兴地告诉大家&#xff0c;ONLYOFFICE 桌面编辑器现已上架麒麟软件商店。请阅读下文了解详情。 关于麒麟 麒麟是一款国产操作系统&#xff0c;主要是为了满足中国市场的需求和偏好而设计的。 它能够与各种硬件平台和软件应用程序的广泛兼容&#xff0c;因而受到认可。…...

记录:如何编写linux驱动,用module的方式

记录:如何编写Linux驱动,用module的方式 记录:如何编写Linux驱动,用module的方式参考记录:如何编写Linux驱动,用module的方式 编写一个 Linux 的驱动,用 module 方式开发,一般来说,编写一个 Linux 的驱动,需要遵循以下步骤: 确定设备的类型和功能,以及它在系统中的…...

3款免费又好用的 Docker 可视化管理工具

前言 Docker提供了命令行工具&#xff08;Docker CLI&#xff09;来管理Docker容器、镜像、网络和数据卷等Docker组件。我们也可以使用可视化管理工具来更方便地查看和管理Docker容器、镜像、网络和数据卷等Docker组件。今天我们来介绍3款免费且好用的 Docker 可视化管理工具。…...

为什么92%的Sora 2初学者卡在第4步?——帧一致性崩塌诊断工具包+时间轴锚点校准法

更多请点击&#xff1a; https://kaifayun.com 第一章&#xff1a;Sora 2视频生成的核心原理与环境准备 Sora 2并非OpenAI官方发布的模型&#xff0c;而是社区基于Sora技术理念构建的开源复现与增强框架&#xff0c;其核心依托于时空联合建模的扩散变换器&#xff08;Spacetim…...

tools.simonwillison.net图像处理工具集:从裁剪到优化的完整指南

tools.simonwillison.net图像处理工具集&#xff1a;从裁剪到优化的完整指南 【免费下载链接】tools Assorted useful tools, almost entirely generated using LLMs 项目地址: https://gitcode.com/gh_mirrors/tools23/tools tools.simonwillison.net图像处理工具集是一…...

酒店门锁V10SDK接口说明-幽冥大陆(一百23)—东方仙盟

相关文件系统环境C# :NET.20,NET3.5,NET4,NET4.5,NET 5.0C:VS2005,VS2012,VS2015操作系统&#xff1a;未来之窗VOSWEB:CHROME43核心代码完整代码using System; using System.Collections.Generic; using System.Text; using System.Collections.Specialized;using System.Windo…...

百考通智能任务书:贴合你的选题,拒绝空话假大空

毕业设计任务书是高校教学管理中的关键环节&#xff0c;它不仅标志着研究工作的正式启动&#xff0c;更是后续开题、实施、论文撰写和答辩全过程的行动依据。然而&#xff0c;许多学生在撰写时常常因不熟悉本专业写作规范、技术表达能力有限&#xff0c;或缺乏权威模板参考而陷…...

别再乱算相似度了!用Python实战二元变量聚类:从Jaccard系数到病人分组

医疗数据分析实战&#xff1a;用Python实现基于Jaccard系数的病人症状聚类在医疗数据分析领域&#xff0c;如何从海量病人症状数据中发现潜在规律一直是临床研究的难点。传统方法往往依赖医生经验或简单统计&#xff0c;而现代数据挖掘技术为我们提供了更科学的解决方案。本文将…...

HFSS仿真结果怎么看?一文读懂S参数与电场图,让你的T型波导分析不再迷茫

HFSS仿真结果深度解析&#xff1a;从S参数到电场图的工程实践指南面对HFSS仿真生成的复杂数据图表&#xff0c;许多工程师常陷入"看得见数据却读不懂含义"的困境。本文将带您穿透数据表象&#xff0c;掌握T型波导性能分析的核心方法论。1. S参数&#xff1a;波导性能…...

从Office功能区的“局外人“到“掌控者“:Office RibbonX Editor深度指南

从Office功能区的"局外人"到"掌控者"&#xff1a;Office RibbonX Editor深度指南 【免费下载链接】office-ribbonx-editor An overhauled fork of the original Custom UI Editor for Microsoft Office, built with WPF 项目地址: https://gitcode.com/g…...

Unity主题系统设计:状态驱动的主题抽象与自动注入方案

1. 这不是换个颜色那么简单&#xff1a;为什么Unity项目里“换肤”总在发布前夜崩盘&#xff1f;你有没有经历过这样的场景&#xff1a;美术同学凌晨两点发来一套新主题资源包&#xff0c;UI设计师说“这次配色更符合品牌调性”&#xff0c;产品说“上线前必须支持深色模式”&a…...

半导体元件(二极管/三极管/MOS管/IC)损坏诊断全解

半导体元件&#xff08;二极管、三极管、MOS 管、集成电路&#xff09;是 PCB 的核心功能单元&#xff0c;对过压、过流、ESD、高温极度敏感&#xff0c;损坏后直接导致电路功能失效、短路烧板。很多工程师维修时盲目更换芯片&#xff0c;不仅成本高&#xff0c;还易误判。​一…...

可解释AI新突破:基于局部帕累托最优的模型解释框架

1. 项目概述&#xff1a;当AI模型成为“黑箱”&#xff0c;我们如何撬开它&#xff1f;在机器学习项目里摸爬滚打十几年&#xff0c;我见过太多这样的场景&#xff1a;团队花大力气训练出一个准确率高达95%的复杂模型&#xff08;比如深度神经网络&#xff09;&#xff0c;业务…...