欢迎光临,了解微信小程序开发,就上易用通!

当前位置 : 易用通 > 小程序模板
微信小程序实用demo;日历签到微信小程序实用demo;日历签到
立即下载

微信小程序实用demo;日历签到

模板分类 : 小程序模板 模板编号 : Y507 源码文件 : 完全开源 下载权限 : VIP会员
模板大小 :  模板指数 :  更新时间 : 2018-02-11 15:00 模板等级 : ☆☆☆☆☆

模板截图:

签到前 微信小程序实用demo;日历签到(图1)  签到后 微信小程序实用demo;日历签到(图2)  代码示例:
 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//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
      })
  }
})

加入收藏
立即下载
分享到微信朋友圈
X

免责声明:

1. 本站所有素材(未指定商用),仅限学习交流,请勿用于商业用途。
2. 本站所有小程序模板Demo和图片均来自用户分享上传和网络收集,模板和图片版权归原作者及原出处所有。
3. 未经合法授权,会员不得以任何形式发布、传播、复制、转售该素材。