最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js實現(xiàn)簽到日歷

 更新時間:2022年08月29日 08:36:26   作者:向陽而生,靜待余生  
這篇文章主要為大家詳細介紹了js實現(xiàn)簽到日歷,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了js實現(xiàn)簽到日歷的具體代碼,供大家參考,具體內(nèi)容如下

wxml代碼

<view class="boxMain" style="height:{{dateList.length>35?'805rpx':'730rpx'}}">
? ? <view class="calendarHeader">
? ? ? ? <view>本月已簽到<text>{{recordList.length}}</text>天</view>
? ? </view>
? ? <view class="calendarChange">
? ? ? ? <view class="calendarChangeLeftRight" catchtap="initDateList" data-month="{{chooseMonth-1}}">
? ? ? ? ? ? <image mode="widthFix" src="{{static}}left_arrow.png"></image>
? ? ? ? </view> ? ? ? ? ? ? ? ?
? ? ? ? <text>{{chooseYear}}年{{chooseMonth+1}}月</text>
? ? ? ? <view class="calendarChangeLeftRight" catchtap="initDateList" data-month="{{chooseMonth+1}}">
? ? ? ? ? ? <image mode="widthFix" src="{{static}}right_arrow.png"></image>
? ? ? ? </view>
? ? </view>
? ? <view class="calendarContent">
? ? ? ? <view class="calendarWeek">
? ? ? ? ? ? <text>日</text>
? ? ? ? ? ? <text>一</text>
? ? ? ? ? ? <text>二</text>
? ? ? ? ? ? <text>三</text>
? ? ? ? ? ? <text>四</text>
? ? ? ? ? ? <text>五</text>
? ? ? ? ? ? <text>六</text>
? ? ? ? </view>
? ? ? ? <view class="calendarDays">
? ? ? ? ? ? <view wx:for="{{dateList}}" wx:key="index" wx:for-item="dateItem">
? ? ? ? ? ? ? ? <view style="color:{{dateItem.type=='current'?'#ffffff':(dateItem.type=='before'?'#979797':(dateItem.type=='selected'?'#FE7458':''))}};background-color:{{ dateItem.type=='current'?'#FE7458':(dateItem.type=='before'?'#F8F8FA':(dateItem.type=='selected'?'#ffdcd5':'')) }}">
? ? ? ? ? ? ? ? ? ? {{dateItem.day}}
? ? ? ? ? ? ? ? </view> ? ? ?
? ? ? ? ? ? </view>
? ? ? ? </view>
? ? </view>
</view>

js代碼:

const app = getApp()
const http = require('../../config/api.js');
Page({
? data: {
? ? static: app.data.static,
? ? recordList: [],
? ? totalReward: {},
? ? dateList: [],
? ? chooseYear: new Date().getFullYear(),
? ? chooseMonth: new Date().getMonth(),
? ? currentDay: new Date().getDate(),
? ? dayNumsByMonth: null
? },
? onLoad() {
? ? this.initDateList(); //初始化日歷
? },
? initDateList: function (e) {
? ? let that = this;
?
? ? let chooseMonth = that.data.chooseMonth;
? ? let chooseYear = that.data.chooseYear;
?
? ? let currentDate = new Date();
? ? let currentYear = currentDate.getFullYear();
? ? let currentMonth = currentDate.getMonth();
?
? ? if (e) {
? ? ? chooseMonth = e.currentTarget.dataset.month;
? ? ? if (chooseMonth >= 12) {
? ? ? ? chooseMonth = chooseMonth - 12;
? ? ? ? chooseYear = chooseYear + 1;
? ? ? } else if (chooseMonth < 0) {
? ? ? ? chooseMonth = chooseMonth + 12;
? ? ? ? chooseYear = chooseYear - 1;
? ? ? } else {
? ? ? ? chooseMonth = chooseMonth;
? ? ? }
? ? ? let monthCount = (currentYear - chooseYear) * 12 + currentMonth - chooseMonth;
? ? ? if (monthCount > 0 && Math.abs(monthCount) > 6) {
? ? ? ? wx.showToast({
? ? ? ? ? title: '往前最多查看六個月',
? ? ? ? ? icon: 'none',
? ? ? ? ? duration: 1500
? ? ? ? })
?
? ? ? ? return
? ? ? } else if (monthCount < 0 && Math.abs(monthCount) > 1) {
? ? ? ? wx.showToast({
? ? ? ? ? title: '往后最多查看一個月',
? ? ? ? ? icon: 'none',
? ? ? ? ? duration: 1500
? ? ? ? })
? ? ? ? return
? ? ? }
? ? }
?
? ? that.setData({
? ? ? chooseMonth: chooseMonth,
? ? ? chooseYear: chooseYear
? ? })
? ? var dateList = [];
?
? ? let firstDayWeek = new Date(that.data.chooseYear, that.data.chooseMonth, 1).getDay();
? ? let dayNumsByMonth = new Date(that.data.chooseYear, that.data.chooseMonth + 1, 0).getDate();
? ? that.setData({
? ? ? dayNumsByMonth: dayNumsByMonth
? ? })
?
? ? for (let i = 0; i < 43; i++) {
? ? ? let day = i - firstDayWeek + 1;
? ? ? if (day > dayNumsByMonth && (i == 35 || i == 42)) {
? ? ? ? that.setData({
? ? ? ? ? dateList: dateList
? ? ? ? });
? ? ? ? return
? ? ? }
? ? ? dateList.push({
? ? ? ? 'year': '',
? ? ? ? 'month': '',
? ? ? ? 'day': '',
? ? ? ? 'type': '',
? ? ? })
?
? ? ? if (day > 0 && day <= dayNumsByMonth) {
? ? ? ? dateList[i].year = that.data.chooseYear;
? ? ? ? dateList[i].month = that.isTen(that.data.chooseMonth + 1);
? ? ? ? dateList[i].day = that.isTen(day);
? ? ? ? if (that.data.chooseYear == currentYear && that.data.chooseMonth == currentMonth) {
?
? ? ? ? ? if (day < that.data.currentDay) {
? ? ? ? ? ? dateList[i].type = 'before';
? ? ? ? ? } else if (day > that.data.currentDay) {
? ? ? ? ? ? dateList[i].type = 'after';
? ? ? ? ? } else {
? ? ? ? ? ? dateList[i].type = 'current'
? ? ? ? ? }
? ? ? ? ??
? ? ? ? } else if (that.data.chooseYear < currentYear || (that.data.chooseYear == currentYear && that.data.chooseMonth < currentMonth)) {
? ? ? ? ? dateList[i].type = 'before';
? ? ? ? ?
? ? ? ? } else {
? ? ? ? ? dateList[i].type = 'after';
? ? ? ? }
? ? ? }
? ? }
? },
? isTen: function (v) {
? ? return v >= 10 ? v : `0${v}`
? }
});

wxss代碼

.boxMain {
? background-color: #fff;
? margin: 36rpx 30rpx 22rpx 30rpx;
? border-radius: 10rpx;
? padding: 0 20rpx;
? display: flex;
? flex-direction: column;
}
?
.boxMain .calendarHeader {
? display: flex;
? justify-content: space-between;
? color: #333333;
? font-size: 28rpx;
? margin-top: 40rpx;
? padding: 0 4rpx;
}
?
.boxMain .calendarHeader view text {
? color: #FE7458;
? padding: 0 6rpx;
}
?
.boxMain .calendarHeader view:last-child {
? font-size: 24rpx;
}
?
.boxMain .calendarChange {
? display: flex;
? padding: 0 50rpx;
? align-items: center;
? justify-content: space-between;
? background-color: #F8F8FA;
? border-radius: 25rpx;
? height: 50rpx;
? line-height: 50rpx;
? font-size: 24rpx;
? text-align: center;
? margin: 25rpx 0;
}
.boxMain .calendarChange .calendarChangeLeftRight{
? width: 50rpx;
? height: 50rpx;
? display: flex;
? flex-direction: column;
? justify-content: center;
}
.boxMain .calendarChange image{
? width: 12rpx;
? margin: 0 auto;
}
.boxMain .calendarContent .calendarWeek{
? font-size: 26rpx;
? display: flex; ? ?
? justify-content: space-between;
}
.boxMain .calendarContent .calendarWeek text{
? width: 14%;
? height: 40rpx;
? text-align: center;
}
.boxMain .calendarContent .calendarDays{
? font-size: 26rpx;
? display: flex;
? justify-content: space-between;
? flex-wrap:wrap;
? align-items: center;
? margin-top: 47rpx;
}
.boxMain .calendarContent .calendarDays>view{
? width: 14%;
? text-align: center;
? display: block; ? ?
? margin-bottom: 32rpx;
? height: 46rpx;
? line-height: 46rpx;
}
.boxMain .calendarContent .calendarDays>view>view{
? width: 46rpx;
? height: 46rpx;
? margin: 0 auto;
? border-radius: 50%;
}
.boxMain .calendarContent .calendarDays .box{
? margin-top: -10rpx;
}
.boxMain .calendarContent .calendarDays .box image{
? width: 42rpx;
}
.boxMain .calendarContent .calendarDays .box text{
? float: left;
? margin-top: -20rpx;
? padding-left: 4rpx;
? color: #FE7458;
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Chrome中模態(tài)對話框showModalDialog返回值問題的解決方法

    Chrome中模態(tài)對話框showModalDialog返回值問題的解決方法

    chrome中彈出模態(tài)對話框,通過window.returnValue賦返回值關(guān)閉后,有的情況下無法取得返回值。
    2010-05-05
  • 常見的瀏覽器Hack技巧整理

    常見的瀏覽器Hack技巧整理

    這篇文章主要介紹了常見的瀏覽器Hack技巧整理的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • JavaScript鼠標禁止右鍵禁止打開控制臺及鍵盤禁用

    JavaScript鼠標禁止右鍵禁止打開控制臺及鍵盤禁用

    這篇文章主要給大家介紹了關(guān)于JavaScript鼠標禁止右鍵禁止打開控制臺及鍵盤禁用的相關(guān)資料,實現(xiàn)禁止右鍵和禁止打開控制臺是一種常見的網(wǎng)頁保護技巧,可以防止非法復(fù)制、盜取網(wǎng)頁資源等安全問題,需要的朋友可以參考下
    2023-10-10
  • JavaScript輪播停留效果的實現(xiàn)思路

    JavaScript輪播停留效果的實現(xiàn)思路

    輪播停留與無線滾動十分類似,都是利用屬性及變量控制移動實現(xiàn)輪播。下面通過本文給大家分享JavaScript輪播停留效果的實現(xiàn)思路,感興趣的朋友一起看看吧
    2018-05-05
  • JavaScript canvas仿代碼流瀑布

    JavaScript canvas仿代碼流瀑布

    這篇文章主要為大家詳細介紹了JavaScript canvas仿代碼流瀑布,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-02-02
  • js中常用的Tab切換效果(推薦)

    js中常用的Tab切換效果(推薦)

    下面小編就為大家?guī)硪黄猨s中常用的Tab切換效果(推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧,祝大家游戲愉快哦
    2016-08-08
  • JavaScript語句錯誤throw、try及catch實例解析

    JavaScript語句錯誤throw、try及catch實例解析

    這篇文章主要介紹了JavaScript語句錯誤throw、try及catch實例解析,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-08-08
  • Three.js中的紋理圖像應(yīng)用和屬性調(diào)整方法

    Three.js中的紋理圖像應(yīng)用和屬性調(diào)整方法

    在three.js中紋理貼圖是用來給物體表面添加圖案、顏色或者其他視覺效果的一種技術(shù),這篇文章主要給大家介紹了關(guān)于Three.js中紋理圖像應(yīng)用和屬性調(diào)整的相關(guān)資料,需要的朋友可以參考下
    2024-01-01
  • 利用js獲取下拉框中所選的值

    利用js獲取下拉框中所選的值

    本文介紹利用js取到下拉框中選擇的值。并附上實例代碼,需要的朋友可以參考下
    2016-12-12
  • 如何在?xHTML?中驗證?noscript+meta?refresh?標簽

    如何在?xHTML?中驗證?noscript+meta?refresh?標簽

    這篇文章主要介紹了如何在?xHTML?中驗證?noscript+meta?refresh?標簽,需要的朋友可以參考下
    2023-03-03

最新評論

石林| 黄龙县| 绥化市| 徐闻县| 邵阳市| 孟州市| 雷山县| 枣强县| 江川县| 松潘县| 双江| 福州市| 射洪县| 双桥区| 巴青县| 江川县| 勃利县| 瑞丽市| 东乌| 吉安县| 大厂| 奉贤区| 班玛县| 仙游县| 贵德县| 克山县| 郯城县| 武冈市| 临清市| 中山市| 山丹县| 阿荣旗| 尖扎县| 岳池县| 康马县| 大田县| 新绛县| 方山县| 巴南区| 乌兰县| 武强县|