广告
返回顶部
首页 > 资讯 > 精选 >微信小程序日历签到怎么实现
  • 180
分享到

微信小程序日历签到怎么实现

2023-06-26 08:06:41 180人浏览 安东尼
摘要

这篇文章主要介绍“微信小程序日历签到怎么实现”,在日常操作中,相信很多人在微信小程序日历签到怎么实现问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”微信小程序日历签到怎么实现”的疑惑有所帮助!接下来,请跟着小编

这篇文章主要介绍“微信小程序日历签到怎么实现”,在日常操作中,相信很多人在微信小程序日历签到怎么实现问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”微信小程序日历签到怎么实现”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

 微信小程序日历签到怎么实现


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

  如:["16", "14"]

  点击签到执行

  calendarSign

  sign.wxml


<!--index.wxml-->

<view class="calendar">

  <view class='bcfff'>

    <view class="weekName">

      <view class="monday">一</view>

      <view class="tuesday">二</view>

      <view class="wednesday">三</view>

      <view class="thursday">四</view>

      <view class="friday">五</view>

      <view class="saturday">六</view>

      <view class="sunday">日</view>

    </view>

    <view class="week">

      <!--填补空格-->

      <view wx:for="{{nbsp}}">\n</view>

      <!--循环日期-->

      <!-- 当天以前 -->

      <view wx:for="{{date-1}}" style="color:gainsboro;">

        <text wx:if="{{item+1==calendarSignData[item+1]}}" style="color: #2ccecb;">{{item+1}}</text>

        <text wx:else="">{{item+1}}</text>

      </view>

      <!-- 当天 -->

      <view style="">

        <text wx:if="{{is_qd}}" style="color: #2ccecb;">{{date}}</text>

        <text wx:else="" style="">{{date}}</text>

      </view>

      <!-- 以后 -->

      <view wx:for="{{monthDaySize-date}}">{{item+date+1}}</view>

    </view>

  </view>

  <view class="calendarSign">

    <image bindtap="calendarSign" class='btnimg' src='https://jpadmin.99dudesign.com/public/img/source/btn_icon_wodekaoqin1.png'></image>

     <!-- wx:if="{{date!=calendarSignData[date]}}" -->

  </view>

</view>

<!-- 签到成功 -->

<view class='zhegai hide {{qdView?"block":""}}' bindtap='quxiaoQd'></view>

<view class='successqd hide {{qdView?"block":""}}'>

  <view class='qdtitle'>签到成功</view>

   <view class='qdcontent' wx:if="{{is_qd}}">今天已经签过了~</view>

  <view class='qdcontent' wx:else>签到成功,获得{{integral}}积分,您已连续签到{{rule}}天!</view>

  <view class='queding' bindtap='quxiaoQd'>确定</view>

</view>

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;

 

  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;

}

到此,关于“微信小程序日历签到怎么实现”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注编程网网站,小编会继续努力为大家带来更多实用的文章!

--结束END--

本文标题: 微信小程序日历签到怎么实现

本文链接: https://www.lsjlt.com/news/308192.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 微信小程序日历签到怎么实现
    这篇文章主要介绍“微信小程序日历签到怎么实现”,在日常操作中,相信很多人在微信小程序日历签到怎么实现问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”微信小程序日历签到怎么实现”的疑惑有所帮助!接下来,请跟着小编...
    99+
    2023-06-26
  • 微信小程序实现日历签到功能
    本文实例为大家分享了微信小程序实现日历签到的具体代码,供大家参考,具体内容如下 wxml: <!--pages/signin/signin.wxml--> <vi...
    99+
    2022-11-13
  • 微信小程序日历插件怎么实现
    这篇文章主要介绍了微信小程序日历插件怎么实现的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇微信小程序日历插件怎么实现文章都会有所收获,下面我们一起来看看吧。微信小程序的日历插件,主要针对酒店选择时间段的日历,带...
    99+
    2023-06-26
  • 微信小程序实现日历打卡
    本文实例为大家分享了微信小程序实现日历打卡的具体代码,供大家参考,具体内容如下 样式比较简单,要改自己改 let currentMonthDays = new Date(year,...
    99+
    2022-11-13
  • 微信小程序日历插件怎么用
    这篇“微信小程序日历插件怎么用”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“微信小程序日历插件怎么用”文章吧。属性如下:使用...
    99+
    2023-06-26
  • 微信小程序实现简单日历效果
    本文实例为大家分享了微信小程序实现日历效果的具体代码,供大家参考,具体内容如下 效果: wxml: <!-- 日历 -->         <view class...
    99+
    2022-11-13
  • 微信小程序本地存储如何实现每日签到、连续签到功能
    这篇文章给大家分享的是有关微信小程序本地存储如何实现每日签到、连续签到功能的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。先说说相关注意吧:其一就是 storage中只能存放字符串...
    99+
    2022-10-19
  • 微信小程序中日历/日期选择插件怎么用
    这篇文章给大家分享的是有关微信小程序中日历/日期选择插件怎么用的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。具体内容如下wxml<view class="...
    99+
    2022-10-19
  • 微信小程序怎么实现手写签名
    本文小编为大家详细介绍“微信小程序怎么实现手写签名”,内容详细,步骤清晰,细节处理妥当,希望这篇“微信小程序怎么实现手写签名”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。在微信小程序上实现手写签名,获取canva...
    99+
    2023-06-29
  • 微信小程序怎么实现电子签名
    要在微信小程序中实现电子签名,可以按照以下步骤操作:1. 在小程序页面中创建一个画布(canvas)组件,用于绘制签名。可以使用 `...
    99+
    2023-08-18
    微信小程序
  • 小程序怎么实现微信签到和消息弹幕功能
    这篇文章主要介绍“小程序怎么实现微信签到和消息弹幕功能”,在日常操作中,相信很多人在小程序怎么实现微信签到和消息弹幕功能问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”小程序怎么实现微信签到和消息弹幕功能”的疑...
    99+
    2023-06-26
  • 微信小程序和公众号实现签到页面
    本文实例为大家分享了微信小程序和公众号实现签到页面的具体代码,供大家参考,具体内容如下 微信小程序 之前做了一个酒庄的小程序签到,微信小程序和公众号一起的。 wxml: <!-...
    99+
    2022-11-13
  • php js怎么实现日历签到
    本篇内容主要讲解“php js怎么实现日历签到”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“php js怎么实现日历签到”吧!php js实现日历签到的方法:首先创建好前台代码“$("...
    99+
    2023-06-20
  • 微信小程序实现电子签名
    本文实例为大家分享了微信小程序实现电子签名的具体代码,供大家参考,具体内容如下 <view class="sign-contain"> <view class...
    99+
    2022-11-12
  • 微信小程序实现手写签名
    本文实例为大家分享了微信小程序实现手写签名的具体代码,供大家参考,具体内容如下 本示例具备的功能: 1、笔迹绘制 2、笔迹清空 以下是js代码: var content = null...
    99+
    2022-11-13
  • 微信小程序向系统日历添加事件(提醒)实现
    直接上代码 // pages/calendar/calendar.jsPage({ // 点击添加日程按钮 handleAddCalendar() { wx.getSetting({ success(res) { ...
    99+
    2023-09-22
    微信小程序 小程序 javascript
  • 微信小程序怎么用canvas实现电子签名
    这篇文章主要介绍“微信小程序怎么用canvas实现电子签名”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“微信小程序怎么用canvas实现电子签名”文章能帮助大家解决问题。具体代码如下<view...
    99+
    2023-07-02
  • 微信小程序如何实现数据遍历
    小编给大家分享一下微信小程序如何实现数据遍历,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!制作数据遍历的步骤在index.js中...
    99+
    2022-10-19
  • 微信小程序实现手写签名(签字版)
    本文实例为大家分享了微信小程序实现手写签名的具体代码,供大家参考,具体内容如下 公司近期有个需要用户签名的功能,就用小程序canvas写了个 wxml <view class...
    99+
    2022-11-13
  • 微信小程序canvas实现手写签名
    本文实例为大家分享了微信小程序canvas实现手写签名的具体代码,供大家参考,具体内容如下 很多时候,程序中需要用到签名的功能,附上源码(微信小程序) .wxml <view...
    99+
    2022-11-13
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作