本文实例为大家分享了微信小程序实现签到功能的具体代码,供大家参考,具体内容如下

效果图:

今天是16号,所以显示已签到,渲染页面时请求后台传的参数为这月签到的日期

如:["16", "14"]

点击签到执行

calendarSign

sign.wxml

\n

{{item+1}}

{{item+1}}

{{date}}

{{date}}

{{item+date+1}}

签到成功

今天已经签过了~

签到成功,获得{{integral}}积分,您已连续签到{{rule}}天!

确定

sign.js

var app = getApp();

var calendarSignData;

var date;

var calendarSignDay;

var is_qd;

Page({

/**

* 页面的初始数据

*/

data: {

qdView: false,

calendarSignData: "",

calendarSignDay: "",

is_qd: false,

},

quxiaoQd: function (e) {

var that = this;

that.setData({

qdView: false,

is_qd: true

})

},

//事件处理函数

calendarSign: function (e) {

var that = this;

that.setData({

qdView: true

})

calendarSignData[date] = date;

console.log(calendarSignData);

calendarSignDay = calendarSignDay + 1;

var today = new Date().getDate()

wx.request({

url: getApp().data.host + '后台的接口',

method: "POST",

data: {

"user_id": wx.getStorageSync('user_id'),

"sign_num": today

},

header: {

'content-type': 'application/x-www-form-urlencoded' //通过post传值,所以要加header

},

success: function (res) {

that.setData({

rule: res.data.rule,

integral: res.data.integral,

})

}

})

wx.setStorageSync("calendarSignData", calendarSignData);

wx.setStorageSync("calendarSignDay", calendarSignDay);

this.setData({

calendarSignData: calendarSignData,

calendarSignDay: calendarSignDay

})

},

/**

* 生命周期函数--监听页面加载

*/

onLoad: function () {

var that = this;

var mydate = new Date();

var year = mydate.getFullYear();

var month = mydate.getMonth() + 1;

date = mydate.getDate();

console.log("date" + date)

var day = mydate.getDay();

console.log(day)

var nbsp = 7 - ((date - day) % 7);

console.log("nbsp" + nbsp);

var monthDaySize;

if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {

monthDaySize = 31;

} else if (month == 4 || month == 6 || month == 9 || month == 11) {

monthDaySize = 30;

} else if (month == 2) {

// 计算是否是闰年,如果是二月份则是29天

if ((year - 2000) % 4 == 0) {

monthDaySize = 29;

} else {

monthDaySize = 28;

}

};

// 传ajax

wx.request({

url: getApp().data.host + 'index.php?g=api&m=output&a=sign_list',

method: "POST",

data: {

"user_id": wx.getStorageSync('user_id')

},

header: {

'content-type': 'application/x-www-form-urlencoded'

},

success: function (res) {

// 判断是否签到过

if (res.data == null) {

calendarSignData = new Array(monthDaySize)

wx.setStorageSync("calendarSignData", calendarSignData);

} else {

var is_qd;

for (var i in res.data) {

parseInt(res.data[i])

calendarSignData = new Array(monthDaySize)

calendarSignData[parseInt(res.data[i])] = parseInt(res.data[i])

wx.setStorageSync("calendarSignData", calendarSignData);

console.log(date)

console.log(parseInt(res.data[i]))

if (parseInt(res.data[i]) == date) {

console.log(1)

wx.setStorageSync("calendarSignDay", 1);

is_qd = true

} else {

wx.setStorageSync("calendarSignDay", 0);

}

}

}

console.log(is_qd)

calendarSignData = wx.getStorageSync("calendarSignData")

calendarSignDay = wx.getStorageSync("calendarSignDay")

console.log(calendarSignData);

console.log(calendarSignDay)

that.setData({

is_qd: is_qd,

year: year,

month: month,

nbsp: nbsp,

monthDaySize: monthDaySize,

date: date,

calendarSignData: calendarSignData,

calendarSignDay: calendarSignDay

})

}

})

},

/**

* 生命周期函数--监听页面初次渲染完成

*/

onReady: function () {

},

/**

* 生命周期函数--监听页面显示

*/

onShow: function () {

},

/**

* 生命周期函数--监听页面隐藏

*/

onHide: function () {

},

/**

* 生命周期函数--监听页面卸载

*/

onUnload: function () {

wx.removeStorageSync("calendarSignData")

wx.removeStorageSync("calendarSignDay")

},

/**

* 页面相关事件处理函数--监听用户下拉动作

*/

onPullDownRefresh: function () {

},

/**

* 页面上拉触底事件的处理函数

*/

onReachBottom: function () {

},

/**

* 用户点击右上角分享

*/

onShareAppMessage: function () {

}

})

sign.wxss

page {

background-color: #2ccecb;

}

.t_red {

color: red;

}

.t_blue {

color: royalblue;

}

.calendar {

width: 500rpx;

margin: 200rpx 125rpx;

/* height: 600rpx; *//* background-color: #ffffff; */

border-radius: 4rpx;

}

.time {

padding: 16rpx 20rpx;

background-color: wheat;

display: flex;

}

.time view {

flex: 1;

font-size: 30rpx;

}

.time view text {

font-size: 38rpx;

}

.weekName {

background-color: #54ff9c;

width: 100%;

display: flex;

padding: 30rpx 0;

font-size: 40rpx;

color: #fff;

}

.weekName view {

flex: 1;

text-align: center;

}

.week {

width: 100%;

}

.week view {

width: 14.2%;

height: 50rpx;

line-height: 50rpx;

display: inline-block;

margin: 10rpx 0;

text-align: center;

font-size: 30rpx;

color: #747474;

}

.week view text {

width: 100%;

height: 100%;

display: inline-block;

}

.calendarSign {

margin-top: -75rpx;

text-align: center;

}

.btnimg {

width: 150rpx;

height: 150rpx;

border-radius: 50%;

}

.bcfff {

background-color: white;

padding-bottom: 100rpx;

}

.zhegai {

position: fixed;

top: 0;

left: 0;

bottom: 0;

width: 100%;

height: 100%;

background-color: black;

opacity: 0.4;

}

.successqd {

position: fixed;

top: 50%;

left: 50%;

width: 550rpx;

margin-left: -275rpx;

margin-top: -200rpx;

background-color:white;

border-radius: 6rpx;

border: 2rpx solid #54ff9c;

text-align: center;

}

.qdtitle{

font-size: 32rpx;

font-weight: bold;

color: #232323;

padding: 20rpx;

}

.qdcontent{

font-size: 30rpx;

color: #232323;

padding: 20rpx 10rpx;

}

.queding{

font-size: 30rpx;

color: #232323;

border-top: 1rpx solid #cccccc;

padding: 20rpx;

}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持w3xue。

php 微信签到功能,微信小程序实现签到功能相关推荐

  1. 浅析微信头脑王者答题小程序源码功能模块与价格之间关系

    随着移动互联网的发展,微信小程序开发日渐成熟.答题小程序头脑王者源码的出现大大的方便了人们的生活.也为部分企业带来了很大的利益,正是因为这样越来越多的企业都会选择去开发一个微信答题小程序自己以来更多的 ...

  2. 微信小程序实现语音识别功能

    原标题:微信小程序实现语音识别功能 使用小程序实现语音识别功能,由于语音识别可以直接使用各厂家的API接口,并且小程序为腾讯所有,因此考虑到可能的低延时,采用了腾讯提供的免费API接口,准确讲是腾讯语 ...

  3. 微信小程序语音识别java_微信小程序实现语音识别功能

    原标题:微信小程序实现语音识别功能 使用小程序实现语音识别功能,由于语音识别可以直接使用各厂家的API接口,并且小程序为腾讯所有,因此考虑到可能的低延时,采用了腾讯提供的免费API接口,准确讲是腾讯语 ...

  4. 小程序毕设作品之微信校园浴室预约小程序毕业设计成品(3)后台功能

    整个项目包含了:开题报告 + 开题报告PPT + 任务书 + 中期报告 + 论文模板 + 答辩PPT等 + 项目源码 主要安介绍了系统在开发过程中所应用到的一些关键的技术,主要包括了前端小程序开发的M ...

  5. Java实现微信小程序客服功能

    微信官方文档 - 小程序 /*** 客服功能 - 自动回复小程序APP链接* Created by Lance on 2020/10/10 17:52*/ @Slf4j @Api(descriptio ...

  6. python玩微信小程序游戏_使用python实现微信小程序自动签到功能

    功能描述目标 完成多账号微信小程序每天自动签到 输出 签到成功则向微信群发送签到成功的信息 否则提示用户签到失败,需手动签到 包管理 requests itchat time threading 程序 ...

  7. 微信小程序-000-签到功能-004-新建签到

    微信小程序-000-签到功能-004-新建签到-2020-4-23 目录 一.wxml 二.js pages.newact.newact 一.wxml <form bindsubmit=&quo ...

  8. 使用python实现微信小程序自动签到2.0

    微信小程序自动签到 功能描述 目标 输出 包管理 程序的结构设计 步骤1 步骤2 步骤3 步骤4 代码实现 使用findler抓包工具查看请求类型 再次使用findler抓包,查看请求内容 使用多线程 ...

  9. 微信小程序-000-签到功能-011-我报名过的活动-查看详情

    微信小程序-000-签到功能-011-我报名过的活动-查看详情 目录 一.wxml 二.js pages.joinsetact.joinsetact 一.wxml {{aid}} <button ...

  10. 在线刷题题库微信小程序开发制作功能介绍

    在线刷题题库微信小程序开发制作功能介绍 1.题库大全:支持搜索查询各类课程试题答案. 2.多试题类型:支持单选题.多选题.判断题.问答题等多种类型. 3.批量导入:支持批量导入课程试题. 4.试题纠错 ...

最新文章

  1. SQL Server数据库六种数据移动方法
  2. Java 责任链模式
  3. 以下内容仅对你可见个性签名_这些微信个性签名,有你喜欢的吗?
  4. 圆形百分比_还有半圆形的饼图!怎么做出来的?
  5. HDU 5044 Tree 树链剖分
  6. 整型和浮点型的区别_C的基础内容:常量之数值型常量,适合新手的学习
  7. 吉大19秋学期计算机应用基础在线作业,吉大16秋学期《计算机应用基础》在线作业一答案...
  8. parameter与define 区别
  9. 转:C# Interview Questions
  10. AbstractBeanFactory 生产Bean 实例对象
  11. Please install [clang](http://clang.llvm.org/) or check configuration `clang.executable`
  12. ORA-01858: 在要求输入数字处找到非数字字符 13行
  13. android 接口的调用方法参数类型转换,Android NDK开发之JNI基础
  14. 小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_5-10.Springboot2.x用户登录拦截器开发实战...
  15. 操作系统(1) 操作系统概念
  16. 加拿大计算机科学薪酬,加拿大最好找工作及薪酬最高的十大专业介绍
  17. 16讲项目实战详细页制作及与首页和内页的链接添加
  18. 【推荐】程序员必读的三十本经典巨作
  19. Android中点击链接调起App
  20. 计算机文档翻页怎么设置,PDF文档翻页设置

热门文章

  1. 电视信号服务器,基于Web服务器远程控制数字电视信号节目源再利用系统
  2. 马斯克联名2000多AI专家誓言禁绝杀人机器人!发起人泰格马克将亲临AI World2018...
  3. JAVA综合实习报告
  4. 计算机版本过低怎么办,浏览器版本过低嗡嗡叫怎么办_电脑显示浏览器版本过低嗡嗡叫如何处理-win7之家...
  5. Spring实战——UrlResource
  6. vs vsvim viemu vax 备忘
  7. 极域电子教室软件怎么脱离控制_如何制定职业发展目标,才能避免“现实发展脱离职业规划”的问题...
  8. 最好用的数据分析软件jmp16中文版
  9. wps h5制作软件
  10. 永洪bi_永洪BI_咨询服务_数据服务_云市场-华为云