找回密码
 立即注册

扫一扫,访问微社区

查看: 20238|回复: 45

微信小程序demo:日历签到(3.1更新)

 火... [复制链接]
发表于 2017-3-7 14:05:06 | 显示全部楼层 |阅读模式
签到前

签到后




[mw_shl_code=html,true]//index.js
//获取应用实例
var app = getApp();
var calendarSignData;
var date;
var calendarSignDay;
Page({
  //事件处理函数
  calendarSign: function() {
   calendarSignData[date]=date;
    console.log(calendarSignData);
    calendarSignDay=calendarSignDay+1;
   wx.setStorageSync("calendarSignData",calendarSignData);
   wx.setStorageSync("calendarSignDay",calendarSignDay);
  
   wx.showToast({
  title: '签到成功',
  icon: 'success',
  duration: 2000
})
  this.setData({
      
        calendarSignData:calendarSignData,
        calendarSignDay:calendarSignDay
      })
  },
  onLoad: function () {
    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;
      }
    };
    // 判断是否签到过
    if(wx.getStorageSync("calendarSignData")==null||wx.getStorageSync("calendarSignData")==''){
      wx.setStorageSync("calendarSignData",new Array(monthDaySize));
    };
     if(wx.getStorageSync("calendarSignDay")==null||wx.getStorageSync("calendarSignDay")==''){
      wx.setStorageSync("calendarSignDay",0);
    }
     calendarSignData=wx.getStorageSync("calendarSignData")
      calendarSignDay=wx.getStorageSync("calendarSignDay")
    console.log(calendarSignData);
    console.log(calendarSignDay)
    this.setData({
        year:year,
        month:month,
        nbsp:nbsp,
        monthDaySize:monthDaySize,
        date:date,
        calendarSignData:calendarSignData,
        calendarSignDay:calendarSignDay
      })
  }
})[/mw_shl_code]



游客,如果您要查看本帖隐藏内容请回复

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

0

主题

5

回帖

90

金钱

新人求带

积分
0
发表于 2017-5-3 13:29:00 | 显示全部楼层
11111111111111111111111111

0

主题

1

回帖

15

金钱

新人求带

积分
0
发表于 2017-10-22 10:16:37 | 显示全部楼层
6666666666666666666666666666666666666666666666666

0

主题

2

回帖

47

金钱

新人求带

积分
0
发表于 2017-10-26 11:59:13 | 显示全部楼层
6666666666666666

0

主题

18

回帖

123

金钱

新人求带

积分
0
发表于 2017-10-29 09:07:24 | 显示全部楼层
正需要下载来学习一下

0

主题

1

回帖

15

金钱

新人求带

积分
0
发表于 2017-12-4 14:48:06 | 显示全部楼层
222222222222222

0

主题

1

回帖

17

金钱

新人求带

积分
0
发表于 2017-12-15 11:42:17 | 显示全部楼层
666666666666666666666666666666666666666666666

0

主题

1

回帖

58

金钱

新人求带

积分
0
发表于 2018-1-10 21:52:07 | 显示全部楼层
支持下,来学习啦

0

主题

1

回帖

15

金钱

新人求带

积分
0
发表于 2018-1-14 17:53:45 | 显示全部楼层
啥也不说了,感谢楼主分享哇!

0

主题

702

回帖

2万

金钱

新人求带

积分
0
发表于 2018-1-15 14:27:08 | 显示全部楼层
66666666666666666
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|微信小程序开发|教程|文档|资源汇总_即速论坛 ( 粤ICP备14097199号-1  

GMT+8, 2024-3-19 14:59 , Processed in 0.128680 second(s), 31 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表