微信小程序实现连续签到七天

在这里插入图片描述
断签之后会从第一天重新开始


<template><view class="content" style="height: 100vh;background: white;"><view class="back"><view style="position: absolute;bottom: 200rpx;left: 40rpx;width: 90%;"><image :src="headimgUrl" mode="widthFix" style="width: 92rpx;height: 92rpx;border-radius: 50%;float: left;margin-top: -6rpx;margin-right: 14rpx;"></image><view style="float: left;"><span style="font-size: 32rpx;font-weight: bold;color: #FFFFFF;">当月连续签到 </span> <span style="font-size: 44rpx;color: #FF7D00;line-height: 40rpx;">{{ days }}</span><span style="font-size: 32rpx;font-weight: bold;color: #FFFFFF;"></span><view style="font-size: 24rpx;font-weight: 100;color: #FFFFFF;">连续签到七天可获得{{ sevenDay }}积分</view></view><uni-calendar ref="calendar" class="uni-calendar--hook":clear-date="true" :date="info.date":insert="info.insert" :startDate="info.startDate":endDate="info.endDate" :range="info.range" @confirm="confirm"  /></view></view><view class="sign_content"><div class="signBox"><text style="font-size: 30rpx;
font-weight: bold;
color: #0D052C;">签到得积分,直接当钱花</text><ul class="signBtnBox"><li class="signBtnOne" v-for="(item, index) in list" :key="index" :class="{ signed: index + 1 <= Number(days) }"><div @click="handleSignIn(index+1, item.code)"><p style="line-height: 50rpx;">{{ item.gift_num }}</p><!--  <p v-if="index + 1 <= Number(days)">已签到</p><p v-else>签到</p> --><p style="line-height: 210rpx;font-size: 20rpx;">{{ item.points }}积分</p></div></li></ul><view style="background: linear-gradient(to bottom right, #FF5A23, #FF920D);width: 80%;margin: 0 auto;text-align: center;color: white;font-size: 34rpx;height: 88rpx;line-height: 88rpx;margin-top: 120rpx;border-radius: 40rpx;" @click="handleSignIn1">签到</view></div></view></view>
</template><script>
export default {data() {return {showCalendar: false,info: {lunar: true,range: true,insert: false,selected: []},list: [{ gift_num: "第一天", code: "USER_SIGN_POINT_1", points: null },{ gift_num: "第二天", code: "USER_SIGN_POINT_2", points: null },{ gift_num: "第三天", code: "USER_SIGN_POINT_3", points: null },{ gift_num: "第四天", code: "USER_SIGN_POINT_4", points: null },{ gift_num: "第五天", code: "USER_SIGN_POINT_5", points: null },{ gift_num: "第六天", code: "USER_SIGN_POINT_6", points: null },{ gift_num: "第七天", code: "USER_SIGN_POINT_7", points: null },],res: "",days: "", // 签到的总天数signOK: "",headimgUrl: "",sevenDay: "",};},onReady() {this.$nextTick(() => {this.showCalendar = true})},methods: {open() {this.$refs.calendar.open()},async todaySignIn(code) {const res = await this.$request.post("user/userSign",{token: uni.getStorageSync("token").token,},{native: true,});if (res.data.status == "ok") {var data = res.data.data;uni.showToast({title: "签到成功!",duration:2000})setTimeout(()=>{this.getSignIn()},2000)} else {this.handleSignIn()}},handleSignIn1() {const index = Number(this.days) + 1;if (index <= this.list.length) {const code = this.list[index - 1].code;this.todaySignIn(code);} else {uni.showToast({icon: 'none',title: "明天再来签到吧"})}},async qiandao(code, index) {const res = await this.$request.post("user/getUserConf",{token: uni.getStorageSync("token").token,code: code,type: 1},{native: true,});if (res.data.status == "ok") {var data = res.data.data;console.log(data, "签到");this.sevenDay = data[0].valuesthis.list[index].points = data[0].values;}},// 点击签到handleSignIn(index, code) {if (index > Number(this.days) + 1) {uni.showToast({icon: 'none',title: "请按顺序签到"})} else if (index === Number(this.days) + 1) {this.todaySignIn(code);} else {uni.showToast({icon: 'none',title: "明天再来签到吧"})}},
// async getSignIn() {
//   const res = await this.$request.post(
//     "user/getUserSignList",
//     {
//       token: uni.getStorageSync("token").token,
//     },
//     {
//       native: true,
//     }
//   );
//   if (res.data.status == "ok") {
//     var data = res.data.data;
//     this.days = data.sign_num;
//     this.headimgUrl = data.headimgurl;
// 	console.log(this.headimgUrl,'头像')
//     // 更新签到列表数据
//     for (let i = 0; i < this.list.length; i++) {
//       if (i < 7) {	
//         // 前七天的日期都显示原始的第一天、第二天等日期
//         this.list[i].gift_num = `第${i + 1}天`;
//       } else {
//         // 第八天及以后的日期只有在连续签到七天后才显示
//         if (this.days >= 7) {
//           this.list[i].gift_num = `第${i + 1}天`;
//         } else {
//           this.list[i].gift_num = "";
//         }
//       }
//       this.qiandao(this.list[i].code, i);
//     }
//   }
// },async getSignIn() {const res = await this.$request.post("user/getUserSignList",{token: uni.getStorageSync("token").token,},{native: true,});if (res.data.status == "ok") {var data = res.data.data;this.days = data.sign_num;this.headimgUrl = data.headimgUrl;// this.apiDates = data.map(item => item.create_time.split(' ')[0]); // 提取日期字符串中的日期部分console.log(data, "签到列表");for (let i = 0; i < this.list.length; i++) {this.qiandao(this.list[i].code, i);}}},},components: {},onShow(){this.getSignIn();},created() {this.getSignIn();this.qiandao("USER_SIGN_POINT_7", 6);},
};
</script><style lang="scss" scoped>
.back {width: 100%;height: 460rpx;background: url("https://-picture.oss-cn-hangzhou.aliyuncs.com/ebk-wap/img-202308240245145778-Group%2034161%403x.png") no-repeat;position: relative;top: 0;.avatar {width: 400rpx;position: absolute;height: 100rpx;left: 40rpx;top: 20rpx;z-index: 9;}.sign-date {}
}
.sign_content {position: relative;top: -150rpx;// width: 96%;height: 622rpx;background: white;border-radius: 24rpx;padding: 34rpx;display: flex;justify-content: center; /* 水平居中 */.sign_day {display: flex;flex-wrap: wrap;justify-content: space-between;height: 436rpx;}
}
.signBox {width: 100%;background: white;border-radius: 10px;margin: 0 auto;.tips {margin-top: 3%;span {font-size: 16px;letter-spacing: -0.1px;line-height: 22px;font-weight: 500;}:nth-of-type(2) {color: #fe9300;letter-spacing: -0.1px;}}.signBtnBox {display: flex;justify-content: space-between;flex-wrap: wrap;& > li {// cursor: pointer;width: 22%;height: 172rpx;background:url('https://ebk-picture.oss-cn-hangzhou.aliyuncs.com/ebk-wap/img-202308300426108993-Group%2034210%403x.png');border-radius: 4px;background-size: 100%;margin-top: 50rpx;img {margin: 6px 0 0 10px;}p {text-align: center;opacity: 0.6;font-size: 14px;color: #333333;letter-spacing: 0;font-weight: 500;}}li:nth-child(7){width: 49%;height: 172rpx;color: #333333;background: url('https://ebk-picture.oss-cn-hangzhou.aliyuncs.com/ebk-wap/img-202308300506217750-Group%2034211%403x.png');background-size: cover;background-position: center;border-radius: 4px;margin-top: 50rpx;p{text-align: left;padding-left: 50rpx;}}.signed:nth-child(7){background: url('https://ebk-picture.oss-cn-hangzhou.aliyuncs.com/ebk-wap/img-202309070948277933-Group%2034267%403x.png');background-size: 100%;color: #333333;p {opacity: 1 !important;color: #333;}}.signed {background: url('https://ebk-picture.oss-cn-hangzhou.aliyuncs.com/ebk-wap/img-202308300412527364-Group%2034209%403x.png');background-size: 100%;color: #333333;p {opacity: 1 !important;color: #333;}}}
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/71711.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MySQL 连接查询和存储过程

一、连接查询 mysql的连接查询&#xff0c;通常都是将来自两个或多个表的记录行结合起来&#xff0c;基于这些表之间的共同字段&#xff0c;进行数据的拼接 首先&#xff0c;要确定一个主表作为结果集&#xff0c;然后将其它表的行有选择性的连接到选定的主表结果上&#xff…

stride与padding对输出尺寸的计算

公式&#xff1a; 练习&#xff1a; 图1&#xff1a; input4&#xff0c;filter3&#xff0c;padding0&#xff0c;stride1 output2 图2&#xff1a; input5&#xff0c;filter3&#xff0c;padding0&#xff0c;stride2 output2 图3&#xff1a; input6&#xff0c;filter3&am…

go语言基本操作---五

error接口的使用 Go语言引入了一个关于错误处理的标准模式&#xff0c;即error接口&#xff0c;它是Go语言内建的接口类型 type error interface {Error() string }package mainimport ("errors""fmt" )type Student struct {name stringid int }func …

elementui表格自定义表头的两种方法

表格自定义表头的方式 多选框表头换文字 请查看上篇博客&#xff1a;http://t.csdn.cn/69De2 文字换按钮 render-header render-header方法详情 Table-column Attributes 参数说明类型可选值默认值render-header列标题 Label 区域渲染使用的 FunctionFunction(h, { column, $in…

异常的顶级理解

目录 1.异常的概念与体系结构 1.1异常的体系结构 1.2异常的举例 1.3错误的举例 2.异常的分类 2.1编译时异常 2.2运行时异常 3.异常的处理 3.1异常的抛出throw 3.2try-catch捕获并处理 3.3finally 3.4 异常声明throws 4.自定义异常类 1.异常的概念与体系结构 1.1异常的…

springboot项目实现helloworld

使用Spring官方源创建项目&#xff08;推荐&#xff09; 缺陷&#xff1a;镜像在国外下载速度有点慢 选择配置 选择版本 实现HelloWorld 删除部分不重要的文件 idea隐藏文件 使用云原生的方式创建项目&#xff08;spring官方源&#xff09; 访问地址&#xff1a;Spring Init…

深入理解联邦学习——纵向联邦学习

分类目录&#xff1a;《深入理解联邦学习》总目录 假设进行联邦学习的数据提供方为 A A A和 B B B&#xff0c;第三方为 C C C&#xff0c;则纵向联邦学习步骤如下&#xff1a; 在系统级做加密样本对齐&#xff0c;在企业感知层面不会暴露非交叉用户对齐样本进行模型加密训练&…

Hadoop:HDFS--分布式文件存储系统

目录 HDFS的基础架构 VMware虚拟机部署HDFS集群 HDFS集群启停命令 HDFS Shell操作 hadoop 命令体系&#xff1a; 创建文件夹 -mkdir 查看目录内容 -ls 上传文件到hdfs -put 查看HDFS文件内容 -cat 下载HDFS文件 -get 复制HDFS文件 -cp 追加数据到HDFS文件中 -appendTo…

【FusionInsight 迁移】HBase从C50迁移到6.5.1(01)迁移概述

【FusionInsight 迁移】HBase从C50迁移到6.5.1&#xff08;01&#xff09;迁移概述 HBase从C50迁移到6.5.1&#xff08;01&#xff09;迁移概述迁移范围迁移前的准备HDFS文件检查确认HBase迁移目录确保数据落盘停止老集群HBase服务停止新集群HBase服务 HBase从C50迁移到6.5.1&a…

设计模式之观察者模式、访问者模式与模板方法模式

目录 观察者模式 简介 优缺点 结构 实现 运用场景 访问者模式 简介 优缺点 结构 实现 运用场景 模板方法模式 简介 优缺点 结构 实现 运用场景 观察者模式 简介 又叫发布-订阅模式&#xff0c;定义对象间一种一对多的依赖关系&#xff0c;使得每当一个对象改…

vue3自定义指令

自定义指令是用来增强与扩展元素功能的 在vue官方文当中写的很明白,这里我就不在赘述官方文档.只记录在项目中的实际应用. 局部定义 <template><h4>指令</h4><p v-color-red>字体固定颜色的指令</p><p v-color-value"blue">可…

【List篇】ArrayList 详解(含图示说明)

Java中的ArrayList是一个动态数组&#xff0c;可以自动扩展容量以适应数据的添加和删除。它可以用来存储各种类型的数据&#xff0c;例如String&#xff0c;Integer&#xff0c;Boolean等。ArrayList实现了List接口&#xff0c;可以进行常见的List操作&#xff0c;例如添加、插…

Gridea+GitPage+Gittalk 搭建个人博客

&#x1f44b;通过GrideaGitPage 搭建属于自己的博客&#xff01; &#x1f47b;GitPage 负责提供 Web 功能&#xff01; &#x1f63d;Gridea 作为本地编辑器&#xff0c;方便 push 文章&#xff01; &#x1f3f7;本文讲解如何使用 GrideaGitPage 服务域名&#xff08;可选&a…

原生Js Canvas去除视频绿幕背景

Js去除视频背景 注&#xff1a; 这里的去除视频背景并不是对视频文件进行操作去除背景 如果需要对视频扣除背景并导出可以使用ffmpeg等库&#xff0c;这里仅作播放用所以采用这种方法 由于uniapp中的canvas经过封装&#xff0c;且 uniapp 的 drawImage 无法绘制视频帧画面&…

TOWE雷达光敏感应开关,让生活更智能、更安全

现代生活中&#xff0c;智能家居成为人们追求品质生活的必备之选。其中&#xff0c;照明控制的智能化已然成为一种趋势&#xff0c;传统的灯光开关需要人们手动操作&#xff0c;既不方便&#xff0c;有时候也会造成资源的过度浪费&#xff0c;而雷达光敏感应开关的出现&#xf…

QT之形态学操作

形态学操作包含以下操作&#xff1a; 腐蚀 (Erosion)膨胀 (Dilation)开运算 (Opening)闭运算 (Closing)形态梯度 (Morphological Gradient)顶帽 (Top Hat)黑帽(Black Hat) 其中腐蚀和膨胀操作是最基本的操作&#xff0c;其他操作由这两个操作变换而来。 腐蚀 用一个结构元素…

【MySQL】MySQL的安装,登录,配置和相关命令

文章目录 前言一. 卸载不需要的环境二. 获取MySQL的yum源三. 安装MySQL和启动四. 尝试登录MySQL方法1&#xff1a;获取临时root密码方法2&#xff1a;没有密码方法3&#xff1a;配置文件 五. 简单配置结束语 前言 本篇文章是基于云服务器&#xff1b;Linux&#xff1a;Centos7…

Leetcode.174 地下城游戏

题目链接 Leetcode.174 地下城游戏 hard 题目描述 恶魔们抓住了公主并将她关在了地下城 d u n g e o n dungeon dungeon 的 右下角 。地下城是由 m x n 个房间组成的二维网格。我们英勇的骑士最初被安置在 左上角 的房间里&#xff0c;他必须穿过地下城并通过对抗恶魔来拯救公…

Vuepress样式修改内容宽度

1、相关文件 一般所在目录node_modules\vuepress\theme-default\styles\wrapper.styl 2、调整宽度&#xff0c;截图中是已经调整好的&#xff0c;在我电脑上显示刚刚好。

【Maven教程】(五)仓库:解析Maven仓库—布局、分类和配置,远程仓库的认证与部署,快照版本,依赖解析机制,镜像和搜索服务 ~

Maven 仓库 1️⃣ 什么是Maven仓库2️⃣ 仓库的布局3️⃣ 仓库的分类3.1 本地仓库3.2 远程仓库3.3 中央仓库3.4 私服 4️⃣ 远程仓库的配置4.1 远程仓库的认证4.2 部署至远程仓库 5️⃣ 快照版本6️⃣ 从仓库解析依赖的机制7️⃣ 镜像8️⃣ 仓库搜索服务8.1 Sonatype Nexus8.2…