微信小程序日历组件(swiper可滑动的日历)

微信小程序ec-canvas(echarts)显示地图【以甘肃省为例】 微信小程序ec-canvas(echarts)显示地图。下载地图数据、定制图表、微信中使用 阅读详情

可滑动的日历组件

根据现实需求自行调整其他
在这里插入图片描述

rili.wxml页面

<!--pages/rili/rili.wxml-->
<view class="rili">

</view>
<view class='month'>
    <!-- <view class='arrow' bindtap='prevMonth'>《 </view> -->
    <view class="shijian">
        <!-- <picker mode="date" value="{{date}}" start="2015-09" end="2020-09" fields='month' bindchange="bindDateChange"> -->
        <view class="flex">
           <view style="color: #1677FF;margin-right: 20rpx;font-weight: bold;">く</view>{{date}}
        </view>
        <!-- </picker> -->
        <view class="jintian" bindtap="jintian">回今天</view>
    </view>
    <!-- <view class='arrow' bindtap='nextMonth'> 》</view> -->
</view>
<view class='container'>
  <view class='calendar flex column s-center'>
    <view class='week-row flex m-around wid100'>
      <view class='grid weeks' wx:for="{{week}}" wx:key='key'>{{item}}</view>
    </view>
    <swiper class='swpier-box' circular="true" current="{{swiperIndex}}" bindchange='swiperChange'>
      <swiper-item class='flex m-around days-table '>
        <view wx:for="{{calendar.first}}" wx:for-item='x' wx:key='key'
          class='grid fw {{x.month === month?"":"notCurrent"}} {{x.date === today?"today":""}} {{x.date === beSelectDate ? "choice":"" || bindDayTap === x.date ? "choice" :"" }}' data-month='{{x.month}}' data-day='{{x.day}}' data-date='{{x.date}}' bindtap='bindDayTap'>
          <view  class='views {{x.date === today ? "view" :""}} {{ bindDayTap === x.date ? "view" :""}} {{x.year+"-"+x.month+"-"+x.day === date+"-01"?"yellow":""}} {{x.year+"-"+x.month+"-"+x.day === date+"-02"?"blue":""}}'>
              <!-- <view class="weizhi">{{x.date === today?'今天':x.day}}</view> -->
              <view class="weizhi">{{x.day}}</view>
              <view class="tods" wx:if="{{x.date === today}}">今天</view>
          </view>
              <!-- <block wx:if="{{workerClockData.length>0}}">
              <view wx:for="{{workerClockData}}" wx:key="key">
                <text class='da' wx:if="{{x.year+'-'+x.month+'-'+x.day==item.clockDate}}">记</text>
                <text class='da2'wx:if="{{x.year+'-'+x.month+'-'+x.day==item.clockDate}}">+{{item.actualDayWage}}</text>
              </view>
              </block> -->
        </view>
      </swiper-item>
      <!-- 当前月 -->
      <swiper-item class='flex m-around days-table '>
        <view wx:for="{{calendar.second}}" wx:for-item='x' wx:key='key'
          class='grid fw {{x.month === month?"":"notCurrent"}} {{x.date === today?"today":""}} {{x.date === beSelectDate ? "choice":"" || bindDayTap === x.date ? "choice" :"" }}' data-month='{{x.month}}' data-day='{{x.day}}' data-date='{{x.date}}' data-test='{{(year + "-" +month + "-" + day)}}'  bindtap='bindDayTap'>
          <view class='views {{x.date === today || x.date === date+"-05" ? "view" :""}} {{ bindDayTap === x.date ? "view" :""}} {{x.year+"-"+x.month+"-"+x.day === date+"-01"?"yellow":""}} {{x.year+"-"+x.month+"-"+x.day === date+"-02"?"blue":""}} '>
              <!-- <view class="weizhi">{{x.date === today?'今天':x.day}}</view> -->
              <view class="weizhi">{{x.day}}</view>
              <view class="tods" wx:if="{{x.date === today}}">今天</view>
          <!-- {{x.date === today?'今天':x.day}} -->
          </view>
          <!-- <block wx:if="{{workerClockData.length>0}}">
          <view wx:for="{{workerClockData}}" wx:key="key">
            <text class='da' wx:if="{{x.year+'-'+x.month+'-'+x.day==item.clockDate}}">记</text>
            <text class='da2'wx:if="{{x.year+'-'+x.month+'-'+x.day==item.clockDate}}">+{{item.actualDayWage}}</text>
          </view>
          </block> -->
        </view>
      </swiper-item>
      <swiper-item class='flex m-around days-table'>
        <view wx:for="{{calendar.third}}" wx:for-item='x' wx:key='key'
          class='grid fw  {{x.date === today?"today":""}} {{x.date === beSelectDate ? "choice":"" || bindDayTap === x.date ? "choice" :"" }}' data-month='{{x.month}}' data-day='{{x.day}}' data-date='{{x.date}}' bindtap='bindDayTap'>
          <!-- <view class='view {{x.year+"-"+x.month+"-"+x.day === date+"-01"?"choice2":""}}{{x.month === month?"":"notCurrent"}}'>{{x.date === today?'今天':x.day}}</view> -->
          <!-- <view style="color: #1677FF;">{{date+"-01"}}</view> -->
          <!-- <view>1{{bindDayTap}}</view> -->
          <view class='views {{x.date === date+"-01" ? "view" :""}} {{ bindDayTap === x.date ? "view" :""}} {{x.year+"-"+x.month+"-"+x.day === date+"-01"?"yellow":""}} {{x.year+"-"+x.month+"-"+x.day === date+"-02"?"blue":""}} {{x.month === month?"":"notCurrent"}}'>
              <view class="weizhi">{{x.day}}</view>
              <view class="tods" wx:if="{{x.date === today}}">今天</view>
          </view>
          
          <!-- <block wx:if="{{workerClockData.length>0}}">
          <view wx:for="{{workerClockData}}" wx:key="key">
            <text class='da' wx:if="{{x.year+'-'+x.month+'-'+x.day==item.clockDate}}">记</text>
            <text class='da2'wx:if="{{x.year+'-'+x.month+'-'+x.day==item.clockDate}}">+{{item.actualDayWage}}</text>
          </view>
          </block> -->
        </view>
      </swiper-item>
      <swiper-item class='flex m-around days-table '>
        <view wx:for="{{calendar.fourth}}" wx:for-item='x' wx:key='key'
          class='grid fw {{x.month === month?"":"notCurrent"}} {{x.date === today?"today":""}} {{x.date === beSelectDate ? "choice":"" || bindDayTap === x.date ? "choice" :"" }}' data-month='{{x.month}}' data-day='{{x.day}}' data-date='{{x.date}}' bindtap='bindDayTap'>
          <!-- <view class='view {{x.year+"-"+x.month+"-"+x.day === date+"-01"?"choice2":""}}'>{{x.date === today?'今天':x.day}}</view> -->
          <view class='views {{x.date === today ? "view" :""}} {{ bindDayTap === x.date ? "view" :""}} {{x.year+"-"+x.month+"-"+x.day === date+"-01"?"yellow":""}} {{x.year+"-"+x.month+"-"+x.day === date+"-02"?"blue":""}}'>
              <view class="weizhi">{{x.day}}</view>
              <view class="tods" wx:if="{{x.date === today}}">今天</view>
          </view>
            <!-- <block wx:if="{{workerClockData.length>0}}">
            <view wx:for="{{workerClockData}}" wx:key="key">
              <text class='da' wx:if="{{x.year+'-'+x.month+'-'+x.day==item.clockDate}}">记</text>
              <text class='da2'wx:if="{{x.year+'-'+x.month+'-'+x.day==item.clockDate}}">+{{item.actualDayWage}}</text>
            </view>
          </block> -->
        </view>
      </swiper-item>
    </swiper>

    <view class="lunbo_yue">
      <view><view class="cicle"></view>{{lastMonth}}月</view>
      <view class="center"><view class="cicle"></view>{{month}}月</view>
      <view><view class="cicle"></view>{{nextMonth}}月</view>
    </view>
    
  </view>
  <!-- <view class="lists">
    <view class="lis">
      <view class="my_class">我的排课</view>
      <view class="conts">
        <image src="https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AAOzTNc?w=40&h=40&q=60&m=6&f=png&u=t"></image>
        <view class="con">
          <view class="con_title">心理测量与数据分析Psychological measurement san data</view>
          <view class="con_type">analysiszoom 线上·直播2</view>
        </view>
      </view>
      <view class="class_date">上课日期:<view>2021-11-11</view></view>
      <view class="last_cont">
        <view class="study">学习形式:<view>录播</view></view>
        <view class="sty_type dian_sty">点我签到</view>
      </view>
    </view>

    <view class="lis">
      <view class="my_class">我的排课</view>
      <view class="conts">
        <image src="https://assets.msn.com/statics/icons/favicon_newtabpage.png"></image>
        <view class="con">
          <view class="con_title">心理测量与数据分析Psychological measurement san data</view>
          <view class="con_type">analysiszoom 线上·直播2</view>
        </view>
      </view>
      <view class="class_date">上课日期:<view>2021-11-11</view></view>
      <view class="last_cont">
        <view class="study">学习形式:<view>录播</view></view>
        <view class="sty_type yi_sty">已签到</view>
      </view>
    </view>

    <view class="lis">
      <view class="my_class">我的排课</view>
      <view class="conts">
        <image src="https://f10.baidu.com/it/u=4136243218,164074552&fm=30&app=106&f=PNG&access=215967316?w=534&h=421&s=C0738F704D1FC9CE5CFD79CA0000E0B2"></image>
        <view class="con">
          <view class="con_title">心理测量与数据分析Psychological measurement san data</view>
          <view class="con_type">analysiszoom 线上·直播2</view>
        </view>
      </view>
      <view class="class_date">上课日期:<view>2021-11-11</view></view>
      <view class="last_cont">
        <view class="study">学习形式:<view>录播</view></view>
        <view class="sty_type deng_sty">待核准</view>
      </view>
    </view>

    <view class="lis">
      <view class="my_class">我的排课</view>
      <view class="conts">
        <image src="https://f10.baidu.com/it/u=4136243218,164074552&fm=30&app=106&f=PNG&access=215967316?w=534&h=421&s=C0738F704D1FC9CE5CFD79CA0000E0B2"></image>
        <view class="con">
          <view class="con_title">心理测量与数据分析Psychological measurement san data</view>
          <view class="con_type">analysiszoom 线上·直播2</view>
        </view>
      </view>
      <view class="class_date">上课日期:<view>2021-11-11</view></view>
      <view class="last_cont">
        <view class="study">学习形式:<view>录播</view></view>
        <view class="sty_type que_sty">缺勤</view>
      </view>
    </view>

  </view> -->
</view>

rili.js页面

// pages/rili/rili.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        day: '',
        year: '',
        month: '',
        date: '2017-01',
        today: '',
        time:'',
        
        lastMonth:'',
        nextMonth:'',
        
        week: ['日', '一', '二', '三', '四', '五', '六'],
        calendar: {
          first: [],
          second: [],
          third: [],
          fourth: []
        },
        swiperMap: ['first', 'second', 'third', 'fourth'],
        swiperIndex: 1,
        showCaldenlar: false,
    },

      getinit() { //初始化
        const date = new Date()
          , month = this.formatMonth(date.getMonth() + 1)
          , year = date.getFullYear()
          , day = this.formatDay(date.getDate())
          , today = `${year}-${month}-${day}`
          
        let calendar = this.generateThreeMonths(year, month)
        // console.log(calendar)
        
        // 上月
        let lastMonth=this.formatMonth(date.getMonth())
        // 下月
        let nextMonth=this.formatMonth(date.getMonth() + 2)

        this.setData({
          calendar,
          month,
          year,
          day,
          today,
          beSelectDate: today,
          date: `${year}-${month}`,
          
          lastMonth,
          nextMonth
        })
        // console.log(this.data.date+'-01');
        // console.log(this.data.calendar);//整体的日子  数组

        // console.log(this.data.month);//当前月
        // console.log(this.data.year);//当前年
        // console.log(this.data.day);//当前日

        // console.log(this.data.today);//今天
        // console.log(this.data.beSelectDate);//今天

        // console.log(this.data.date);//当前年月
      },
      showCaldenlar() {
        this.setData({
          showCaldenlar: !this.data.showCaldenlar
        })
      },
      // 点击 回今天
      jintian:function(){
        let date = new Date()
        ,month = this.formatMonth(date.getMonth() + 1)
        , year = date.getFullYear()
        , day = this.formatDay(date.getDate())
        let bindDayTap = year + '-' + month + '-' + day;
        console.log(bindDayTap);
        this.setData({
          bindDayTap:bindDayTap
        })
        //发送事件监听
        this.triggerEvent('bindDayTap', bindDayTap);
        console.log(this.data.bindDayTap);

        
        //初始化日历组件UI
        this.getinit(year, month, day);
        
      },



      /**
       * 
       * 左右滑动
       * @param {any} e 
       */
      swiperChange(e) {
        console.log(e);
        const lastIndex = this.data.swiperIndex
          , currentIndex = e.detail.current
          let source = e.detail.source
      // console.log(source);
        let flag = false
          , { year, month, day, today, date, calendar, swiperMap } = this.data
          , change = swiperMap[(lastIndex + 2) % 4]
          , time = this.countMonth(year, month)
          , key = 'lastMonth'
        console.log('上一个索引',lastIndex,'当前索引',currentIndex)
        console.log(time);
        
        // 回今天
        let bindDayTap = year + '-' + month + '-' + day;
        //发送事件监听
        this.triggerEvent('bindDayTap', bindDayTap);
        // console.log(bindDayTap);

        if (lastIndex > currentIndex) {
          lastIndex === 3 && currentIndex === 0
            ? flag = true
            : null
  
        } else {
          lastIndex === 0 && currentIndex === 3
            ? null
            : flag = true
        }
        if (flag) {
          key = 'nextMonth'
        }
        console.log(key);
        console.log(time[key].year)
        year = time[key].year
        month = time[key].month
        date = `${year}-${month}`
        day = ''
  
        if (today.indexOf(date) !== -1) {
          day = today.slice(-2)
        }
  
        time = this.countMonth(year, month)
        calendar[change] = null
        calendar[change] = this.generateAllDays(time[key].year, time[key].month)


        // 上月
        let lastMonth=month-1
        if (lastMonth==0) {
          lastMonth=12
        } else if(lastMonth==1){
          lastMonth=`01`
        } else if(lastMonth==2){
          lastMonth=`02`
        } else if(lastMonth==3){
          lastMonth=`03`
        } else if(lastMonth==4){
          lastMonth=`04`
        } else if(lastMonth==5){
          lastMonth=`05`
        } else if(lastMonth==6){
          lastMonth=`06`
        } else if(lastMonth==7){
          lastMonth=`07`
        } else if(lastMonth==8){
          lastMonth=`08`
        } else if(lastMonth==9){
          lastMonth=`09`
        }
        // console.log(lastMonth);
        // 下月
        let nextMonth=month-1+2
        if (nextMonth==13) {
          nextMonth=1
        } else if(nextMonth==1){
          nextMonth=`01`
        } else if(nextMonth==2){
          nextMonth=`02`
        } else if(nextMonth==3){
          nextMonth=`03`
        } else if(nextMonth==4){
          nextMonth=`04`
        } else if(nextMonth==5){
          nextMonth=`05`
        } else if(nextMonth==6){
          nextMonth=`06`
        } else if(nextMonth==7){
          nextMonth=`07`
        } else if(nextMonth==8){
          nextMonth=`08`
        } else if(nextMonth==9){
          nextMonth=`09`
        }
        // console.log(nextMonth);
        // 解决真机无限滑动问题
        if (source === 'touch') {
          this.setData({
            swiperIndex: currentIndex,
          })
        }

        this.setData({
          // swiperIndex: currentIndex,
          //文档上不推荐这么做,但是滑动并不会改变current的值,所以随之而来的计算会出错
          year,
          month,
          date,
          day,
          calendar,
          
          lastMonth,
          nextMonth
        })
        // console.log(calendar)
      },
      /**
       * 
       * 点击切换月份,生成本月视图以及临近两个月的视图
       * @param {any} year 
       * @param {any} month 
       * @returns {object} calendar
       */
      generateThreeMonths(year, month) {
        let { swiperIndex, swiperMap, calendar } = this.data
          , thisKey = swiperMap[swiperIndex]
          , lastKey = swiperMap[swiperIndex - 1 === -1 ? 3 : swiperIndex - 1]
          , nextKey = swiperMap[swiperIndex + 1 === 4 ? 0 : swiperIndex + 1]
          , time = this.countMonth(year, month)
        delete calendar[lastKey]
        calendar[lastKey] = this.generateAllDays(time.lastMonth.year, time.lastMonth.month)
        delete calendar[thisKey]
        calendar[thisKey] = this.generateAllDays(time.thisMonth.year, time.thisMonth.month)
        delete calendar[nextKey]
        calendar[nextKey] = this.generateAllDays(time.nextMonth.year, time.nextMonth.month)
        return calendar
      },
      bindDayTap(e) {
        let { month, year } = this.data
          , time = this.countMonth(year, month)
          , tapMon = e.currentTarget.dataset.month
          , day = e.currentTarget.dataset.day
        if (tapMon == time.lastMonth.month) {
          this.changeDate(time.lastMonth.year, time.lastMonth.month)
        } else if (tapMon == time.nextMonth.month) {
          this.changeDate(time.nextMonth.year, time.nextMonth.month)
        } else {
          this.setData({
            day
          })
        }
        // 回今天
        let bindDayTap = year + '-' + month + '-' + day;
        
        //发送事件监听
        this.triggerEvent('bindDayTap', bindDayTap);
        console.log(bindDayTap);


        let beSelectDate = e.currentTarget.dataset.date;
        this.setData({
          beSelectDate,
          showCaldenlar: false,
          bindDayTap
        })
        // console.log(beSelectDate)
      },
      bindDateChange(e) {
        if (e.detail.value === this.data.date) {
          return
        }
  
        const month = e.detail.value.slice(-2)
          , year = e.detail.value.slice(0, 4)
  
        this.changeDate(year, month)
      },
      prevMonth(e) {
        let { year, month } = this.data
          , time = this.countMonth(year, month)
        this.changeDate(time.lastMonth.year, time.lastMonth.month)
      },
      nextMonth(e) {
        let { year, month } = this.data
          , time = this.countMonth(year, month)
        this.changeDate(time.nextMonth.year, time.nextMonth.month)
      },
      /**
       * 
       * 直接改变日期
       * @param {any} year 
       * @param {any} month 
       */
      changeDate(year, month) {
        let { day, today } = this.data
          , calendar = this.generateThreeMonths(year, month)
          , date = `${year}-${month}`
        date.indexOf(today) === -1
          ? day = '01'
          : day = today.slice(-2)
  
        this.setData({
          calendar,
          day,
          date,
          month,
          year,
        })
      },
      /**
       * 
       * 月份处理
       * @param {any} year 
       * @param {any} month 
       * @returns 
       */
      countMonth(year, month) {
        let lastMonth = {
          month: this.formatMonth(parseInt(month) - 1)
        }
          , thisMonth = {
            year,
            month,
            num: this.getNumOfDays(year, month)
          }
          , nextMonth = {
            month: this.formatMonth(parseInt(month) + 1)
          }
  
        lastMonth.year = parseInt(month) === 1 && parseInt(lastMonth.month) === 12
          ? `${parseInt(year) - 1}`
          : year + ''
        lastMonth.num = this.getNumOfDays(lastMonth.year, lastMonth.month)
        nextMonth.year = parseInt(month) === 12 && parseInt(nextMonth.month) === 1
          ? `${parseInt(year) + 1}`
          : year + ''
        nextMonth.num = this.getNumOfDays(nextMonth.year, nextMonth.month)
        // console.log(nextMonth.month);
        return {
          lastMonth,
          thisMonth,
          nextMonth
        }
      },
      currentMonthDays(year, month) {
        const numOfDays = this.getNumOfDays(year, month)
        return this.generateDays(year, month, numOfDays)
      },
      /**
       * 生成上个月应显示的天
       * @param {any} year 
       * @param {any} month 
       * @returns 
       */
      lastMonthDays(year, month) {
        const lastMonth = this.formatMonth(parseInt(month) - 1)
          , lastMonthYear = parseInt(month) === 1 && parseInt(lastMonth) === 12
            ? `${parseInt(year) - 1}`
            : year
          , lastNum = this.getNumOfDays(lastMonthYear, lastMonth) //上月天数
        let startWeek = this.getWeekOfDate(year, month - 1, 1) //本月1号是周几
          , days = []
        if (startWeek == 7) {
          return days
        }
  
        const startDay = lastNum - startWeek
  
        return this.generateDays(lastMonthYear, lastMonth, lastNum, { startNum: startDay, notCurrent: true })
      },
      /**
       * 生成下个月应显示天
       * @param {any} year 
       * @param {any} month
       * @returns 
       */
      nextMonthDays(year, month) {
        const nextMonth = this.formatMonth(parseInt(month) + 1)
          , nextMonthYear = parseInt(month) === 12 && parseInt(nextMonth) === 1
            ? `${parseInt(year) + 1}`
            : year
          , nextNum = this.getNumOfDays(nextMonthYear, nextMonth)  //下月天数
        let endWeek = this.getWeekOfDate(year, month)						 //本月最后一天是周几
          , days = []
          , daysNum = 14
        // if (endWeek == 6) {
        //   return days
        // } else if (endWeek == 7) {
        //   daysNum = 6
        // } else {
        //   daysNum = 6 - endWeek
        // }
        return this.generateDays(nextMonthYear, nextMonth, daysNum, { startNum: 1, notCurrent: true })
      },
      /**
       * 
       * 生成一个月的日历
       * @param {any} year 
       * @param {any} month 
       * @returns Array
       */
      generateAllDays(year, month) {
        let lastMonth = this.lastMonthDays(year, month)
          , thisMonth = this.currentMonthDays(year, month)
          , nextMonth = this.nextMonthDays(year, month)
          , days = [].concat(lastMonth, thisMonth, nextMonth)
        // console.log("jin")
        // console.log(year, month, days)
        return days
      },
      /**
       * 
       * 生成日详情
       * @param {any} year 
       * @param {any} month 
       * @param {any} daysNum 
       * @param {boolean} [option={
       * 		startNum:1,
       * 		grey: false
       * 	}] 
       * @returns Array 日期对象数组
       */
      generateDays(year, month, daysNum, option = {
        startNum: 1,
        notCurrent: false
      }) {
        const weekMap = ['一', '二', '三', '四', '五', '六', '日']
        let days = []
        for (let i = option.startNum; i <= daysNum; i++) {
          let week = weekMap[new Date(year, month - 1, i).getUTCDay()]
          let day = this.formatDay(i)
          days.push({
            date: `${year}-${month}-${day}`,
            event: false,
            day,
            week,
            month,
            year
          })
        }
        return days
      },
      /**
       * 
       * 获取指定月第n天是周几		|
       * 9月第1天: 2017, 08, 1 |
       * 9月第31天:2017, 09, 0 
       * @param {any} year 
       * @param {any} month 
       * @param {number} [day=0] 0为最后一天,1为第一天
       * @returns number 周 1-7, 
       */
      getWeekOfDate(year, month, day = 0) {
        let dateOfMonth = new Date(year, month, 0).getUTCDay() + 1;
        dateOfMonth == 7 ? dateOfMonth = 0 : '';
        return dateOfMonth;
      },
      /**
       * 
       * 获取本月天数
       * @param {number} year 
       * @param {number} month 
       * @param {number} [day=0] 0为本月0最后一天的
       * @returns number 1-31
       */
      getNumOfDays(year, month, day = 0) {
        return new Date(year, month, day).getDate()
      },
      /**
       * 
       * 月份处理
       * @param {number} month 
       * @returns format month MM 1-12
       */
      formatMonth(month) {
        let monthStr = ''
        if (month > 12 || month < 1) {
          monthStr = Math.abs(month - 12) + ''
        } else {
          monthStr = month + ''
        }
        monthStr = `${monthStr.length > 1 ? '' : '0'}${monthStr}`
        return monthStr
      },
      formatDay(day) {
        return `${(day + '').length > 1 ? '' : '0'}${day}`
      },

      // 列表
      // riliList: function(){
      //   // /home/home/get_class_date_list
      //   let arr = {
      //       classId:6,
      //       year:2021,
      //       type:0,
      //       month:12
      //   }
      //   wx.request({
      //       url:'/home/home/get_class_date_list',
      //       method:"post",
      //       register:true,
      //       data:{
      //           data:arr
      //       },
      //       success (res) {
      //           console.log(res)
      //       }
      //   })
      // },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      // this.riliList()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
        this.getinit()
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})

rili.wxss页面

/* pages/rili/rili.wxss */
.container{
    width: 100%;
    height: auto;
    padding: 6rpx;
    font-size: 28rpx;
    background: #F9F9F9;
  }
   .month{
    width: 100%;
    /* height: 50rpx; */
    /* display: flex; */
    /* align-items: center; */
    /* justify-content: center; */
    font-size: 32rpx;
     color:#333333;
     font-weight: 700;
    border-bottom: 1px solid #f5f5f5;
    padding: 19rpx 30rpx;
    box-sizing: border-box;
  }
  .shijian{
    font-size: 36rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #333333;
    line-height: 50rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .jintian{
    font-size: 22rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #B4222D;
    line-height: 30rpx;
    padding: 7rpx 22rpx;
    border: 1px solid #B4222D;
    border-radius: 22rpx;
  }
  .days-table {
    flex-wrap: wrap;
    align-content: flex-start;
  }
  .wid100{
    width: 100%;
  }
  .calendar{
    z-index:10000;
    
  }
  
  .grid {
    height:85rpx;
    padding: 3rpx 0;
    text-align: center;
    font-size:32rpx;
    color:#333333;
    flex: 1;
  }
  .weeks{
    height: auto !important;
    background: #F6F6F6;
    font-size: 26rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    /* color: #A1A1A1; */
    line-height: 37rpx;
  }
  .today {
    /* color: red; */
  }
  .grid .views {
    height:85rpx;
    width:106rpx;
    flex: 1;
    position: relative;
    background: #fff;
  }
  .yellow{
    color: #fff !important;
    background: #F5B31A !important;
  }
  .blue{
    color: #fff !important;
    background: #84B8FF !important;  
  }
  .weizhi{
    font-size: 32rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    line-height: 45rpx;
    /* color: #666;   */

    position: absolute;
    top: 7rpx;
    left: 14rpx;
  }
  .tods{
    position: absolute;
    bottom: 3rpx;
    right: 4rpx;

    font-size: 24rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333;
  }
  .red{
    border: 1rpx solid #B4222D !important;
  }
  .choice .view{
    flex: 1;
    /* border-radius: 50%; */
    /* background: #88a1fd; */
    border: 1px solid #B4222D !important;
    background-position:center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }
  .fw {
    font-weight: 700;
    font-size: 28rpx;
    position: relative;
    border-right: 1px solid #F6F6F6;
  }
  .grid text.da{
    display: flex;
    width: 32rpx;
    height: 32rpx;
    position: absolute;
    right:12rpx;
    top:1rpx;
    font-weight: 1000;
    background: red;
    border-radius: 50%;
    overflow: hidden;
    text-align: center;
    line-height: 24rpx;
    color: #ffffff;
    font-size: 8px;
  align-items: center;
  justify-content: center
  }
  .grid text.da2 {
    width: 100%;
    height: 100%;
    text-align: center;
    font-size: 12px;
    font-weight: 800;
    color: red;
    position: absolute;
    bottom:-25rpx;
    display: flex;
    left: -4rpx;
    align-items: center;
    justify-content: center;
    
  }
  /* 非本月日期 */
  .notCurrent {
    color: silver;
    font-weight: normal;
    position: relative;
  }
  .day-hover {
    background: red;
  }
  .container .corred {
    color: red;
  }
  .swpier-box {
    /* height: 600rpx; */
    height: 520rpx;
    width: 100%;
  }
  .arrow {
    width: 100rpx;
    color: #88a1fd;
    text-align: center;
  }
  
  .flex {
    display: flex;
  }
  /* 轴向 */
  .column {
    flex-direction: column;
  }
  /* 主轴方向 */
  .m-start {
    justify-content: flex-start;
  }
  
  .m-end {
    justify-content: flex-end;
  }
  
  .m-around {
    justify-content: space-around;
     display: grid;
     grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
  }
  
  .m-between {
    justify-content: space-between;
  }
  .m-center {
    justify-content: center;
  }
  /* 侧轴方向 */
  .s-start {
    align-items: flex-start;
  }
  .s-end {
    align-items: flex-end;
  }
  
  .s-around {
    align-items: space-around;
  }
  .s-between {
    align-items: space-between;
  }
  .s-center {
    align-items: center;
  }
  
  /* 轮播月 */
  .lunbo_yue{
    /* width: 50%; */
    display: flex;
    justify-content: center;
    /* width: auto; */
    /* height: 20rpx; */
  }
  .lunbo_yue view{
    display: flex;
    align-items: center;
    width: auto;
    margin-right: 13rpx ;
    color: #A1A1A1;
  }
  .lunbo_yue .center{
    color: #B4222D;
    margin: 0 48rpx;
  }
  .lunbo_yue .center .cicle{
    background: #B4222D;
    
  }
  .lunbo_yue .cicle{
    width: 12rpx;
    height: 12rpx;
    background: #DDDDDD;
    border-radius: 50%;
  }

  /* 列表 */
  .lis{
    background-color: #fff;
    margin: 14rpx 26rpx 0;
    padding: 26rpx 24rpx 22rpx;
    box-sizing: border-box;
    border-radius: 6rpx; 
  }
  .lis .my_class{
    font-size: 32rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #333333;
    line-height: 45rpx;
  }
  .lis .conts{
    margin-top: 24rpx;
    display: flex;
    justify-content: space-between;
  }
  .lis .conts image{
    width: 210rpx;
    height: 118rpx;  
    margin-right: 26rpx;
  }
  .lis .conts .con{
    font-size: 26rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 37rpx;

    width: 414rpx;
  }
  .lis .class_date{
    font-size: 26rpx;
    color: #333333;
    margin-top: 23rpx;
    display: flex;
    font-family: PingFangSC-Regular, PingFang SC;
  }
  .lis .class_date view{
    color: #666 !important;
  }
  .lis .last_cont{
    display: flex;
    justify-content: space-between; 
    align-items: center;
  }
  .lis .last_cont .study{
    font-size: 26rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 37rpx;
    display: flex;
  }
  .lis .last_cont .study view{
    color: #666 !important;
  }
  .lis .last_cont .sty_type{
    /* padding: 12rpx 32rpx; */
    width: 172rpx;
    height: 60rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 30rpx;
    font-size: 26rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #FFFFFF;
    line-height: 37rpx;
    letter-spacing: 1rpx;
  }
  .lis .last_cont .dian_sty{
    background: #B4222D;
    /* background: #ffde00ff; */
    /* background: #de2910ff; */
  }
  .lis .last_cont .yi_sty{
    background: #B0B0B0;
  }
  .lis .last_cont .deng_sty{
    background: #99C7FF;
  }
  .lis .last_cont .que_sty{
    background: #D2636B;
  }
uniapp 微信小程序使用ec-canvas图表 在uniapp项目中找到js-sdk文件夹,把其中的uni-ec-canvas放到要用的包的components中。微信小程序中使用到了ec-canvas图表,从DCloud插件市场中下载echarts-for-wx; 阅读详情

相关推荐

微信小程序----使用微信内置地图查看位置wx.openLocation(Object object)

使用微信内置地图查看位置wx.openLocation(Object object) 1、官方文档 wx.openLocation(Object object)官方文档 2、wxml <!--pages/test/test.wxml--> <text>pages/test/test.wxml</text> <view class="container"&g...

吾行远方 2万+

小程序基本命令

onLoad: function () { // 生命周期函数--监听页面加载 onReady: function () { // 生命周期函数--监听页面初次渲染完成 }, onShow: function () { // 生命周期函数--监听页面显示 }, onHide: function () { // 生命周期函数--监...

aiven1637的博客 3558

微信小程序滑动日历实现思路

因为代码的篇幅比较大,所以没有粘贴全部,只是一部分,详细的代码可见小程序业务组件日历。github里面的组件目前只是单纯的提供日历的显示,暂时还没有提供获取后端数据并且格式化的方法,这个可自行添加,也可以在切换月份的时候回调事件处理。组件整体的效果变现为:来源:转自微信开发社区。

2202_75483062的博客 3160

echarts-for-weixin:全面解析

echarts-for-weixin是基于微信小程序的echarts图表库,拥有echarts的强大功能和小程序的优势,支持各种类型的图表和数据绑定。同时,echarts-for-weixin还继承了echarts的高度定制化能力,支持图表类型、组件、主题等内容自定义,能够满足复杂的图表需求。如果你在小程序中有制作图表的需求,echarts-for-weixin会是一个不错的选择。

pickinguptrash的博客 2351

仪表数字图像识别的传统方法

虽然现有很多机器学习算法能够准确地识别数字,但是传统方法对于一些需要离线识别且计算能力有限的下位机设备来说,仍然有非常不错的效果。因此,今天就向大家讲解一下传统的数字识别方法在仪表读数方面的应用。 1.图像预处理技术 1.1 主要流程 图像处理依次需要进行图片预处理、字轮区域定位、字符分割和字符识别等过程。其中图像处理流程如下图所示。 2. 详细过程 2.1 灰度化 为了减小图像原始数据量,本系...

XYZ 4523

halcon3D 点云拟合球体

halon3D 点云拟合球面

weixin_43213429的博客 1639

微信小程序自定义组件---日历打卡组件

最近需求要求实现一个用日历显示用户打卡记录的功能,百度google了微信小程序的组件,都没有找到合适的,索性就懒得找了,自己动手,丰衣足食。 下面先来看看日历组件的效果吧: 设计要求: 1、能够折叠日历组件 2、能够标记日期 3、能够根据左右滑动切换月份,并且刷新数据。 设计思路: 1、折叠可以通过添加移除class实现动画折叠。 2、每个日期都是一个格子,可以放时间,也可以放图标,只需要根据wx:if来控制是否显示图标和样式。 3、使用微信的原生组件swiper来实现左右滑动的.

qq_41756580的博客 5475

手把手教你搞定CAC会议投稿:从LaTeX模板到PDF eXpress避坑全流程

本文详细解析CAC会议投稿全流程,重点介绍LaTeX模板调整、Turnitin查重技巧及PDF eXpress校验避坑指南。通过实战案例和代码示例,帮助研究者高效完成IEEE格式论文投稿,避免常见技术性失误,提升投稿成功率。

weixin_29969209的博客 397

微信小程序滑动日历-签到日历

拿到本页日历中所有天数格子的数据,因为每个月不可能都是从周日开始到周六结束,所以这个时候就需要我们去计算上月残余天数和下月残余天数。这一部分简单来说,就是获取用户的签到数据,跟日历的数据进行匹配,最终组合出日历和签到数据的结构。本月日历天数格子总数: 上月残余 + 本月天数大于35就是42个格子,小于35就是35个格子。下月残余:本月日历天数格子总数 - 上月残余天数 - 本月天数。上月残余 + 本月天数 + 下月残余就组成了当前月日历的数据。上月残余:本月第一天从周几开始上月残余就有几天。

weixin_46265708的博客 1010

生信分析实战指南:Linux环境下EMBOSS的安装与核心功能详解

本文详细介绍了在Linux环境下安装和使用EMBOSS工具包的实战指南,涵盖源码编译、包管理器安装和Conda安装三种方法,并演示了序列比对、序列特征提取和引物设计等核心功能。EMBOSS作为生物信息学领域的开源工具集,适用于序列分析、蛋白质结构预测等多种任务,帮助研究人员高效完成生信分析工作。

weixin_29202213的博客 462

OrCAD Capture CIS 17.4 原理图绘制

OrCAD Capture CIS 17.4 原理图绘制

qq_38960013的博客 7633

小程序踩坑问题记录

微信小程序不支持svg引入iconfont的方法 https://zhuanlan.zhihu.com/p/27607422 其实复制iconfont.css到微信iconfont.wxss中即可 微信小程序使用原生WebSokcet实现断线重连及数据拼接 wx.onNetworkStatusChange(function (res) { // console.log(res....

总结,交流,记录,成长 646

深度探索:机器学习中的Label Propagation算法(基于图论的半监督学习方法)原理及其应用

Label Propagation算法作为一种基于图论的半监督学习方法,有效地利用了数据的内在结构和未标注样本信息,降低了对标注数据的依赖。尽管存在对初始标签敏感、易陷入局部最优等局限性,但在图像分类、社交网络分析、生物信息学等领域展现了良好的应用前景。未来的研究方向可能包括:探索更稳健的标签初始化策略、设计抗噪声和异常值的相似度计算方法、结合深度学习模型提升模型表示能力等。随着半监督学习理论和技术的不断发展,Label Propagation及其变种算法将在更大范围内推动机器学习在标注数据有限情况下的应用

qq_51320133的博客 2280

微信小程序日历组件:打造移动端高效日期交互解决方案

微信小程序日历组件是一款专为移动端场景设计的高效日期交互工具,通过原生小程序技术构建,提供流畅的滑动体验、灵活的日期标记和智能的禁用控制功能。无论是电商平台的促销日期选择,还是企业应用的项目排期管理,这款组件都能帮助开发者快速实现专业级的日期交互界面,显著提升用户体验和开发效率。 ## 核心价值:重新定义移动端日期交互体验 ### 实现丝滑流畅的月份切换 采用三swiper-item架构设计,

gitblog_00668的博客 288

工业级稳定!C# 实现 Modbus RTU 多设备并发通信实战

摘要:本文提出一种基于C#的Modbus RTU多设备并发通信方案,解决工业自动化中单线程通信的串口抢占、数据阻塞等问题。采用任务队列+线程安全锁+异步调度的三层架构,实现16台及以上RTU设备的稳定并发读写。方案包含串口管理单例、Modbus通信核心和任务调度层,支持超时重试、异常捕获等工业级容错机制。通过NModbus库和.NET框架,提供可直接用于工业现场的代码实现,已在工控项目中长期验证,有效提升多设备通信效率和稳定性。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 581

SAP FICO 中的 F-02 :概念、使用场景及案例解析

在 SAP FICO (财务会计与管理会计) 模块中,F-02 是一个用于录入总账凭证的事务代码。这个事务代码主要用于手动输入总账凭证,适用于各类财务交易,例如资产购入、费用支付、收入确认等。F-02 的重要性在于,它允许财务人员在 SAP 系统中创建凭证,并确保这些凭证能够正确影响总账账户。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 2060

微信小程序日历组件完整使用指南:打造专业级日期选择体验

想要为你的微信小程序添加一个功能强大、交互流畅的日历组件吗?这款原生微信小程序日历组件正是你需要的解决方案!它支持左右滑动切换月份、智能日期标记和灵活的日期禁用控制,能够轻松满足打卡系统、预约应用、日程管理等多样化需求。 ## 🎯 核心功能亮点 这款日历组件拥有三大核心能力,确保你的小程序拥有出色的用户体验: - **无缝月份切换**:支持左右滑动切换月份,操作流畅自然 - **智能日期标

gitblog_00515的博客 163

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

微信小程序swiper实现滑动轮播日历效果

微信小程序swiper实现滑动轮播日历效果 先看效果 新的改变 我们对Markdown编辑器进行了一些功能拓展与语法支持,除了标准的Markdown编辑器功能,我们增加了如下几点新功能,帮助你用它写博客: 全新的界面设计 ,将会带来全新的写作体验; 在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样式 进行展示; 增加了 图片拖拽 功能,你可以将本地的图片直接拖拽到...

Letmesee的博客 1894

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

左右滑动日历(微信小程序)

最近因为某些原因,又在自己的小程序业务组件项目中添加了可左右滑动的日历。 实现思路 获取每月的总天数,使用getDate() getTotalDays(date) { let value = new Date(date.year, date.month, 0).getDate() return value } 每月1号是周几,使用getDay() getFirstDayWeek(date) { return new Date(date.year, date.month - 1, 1).g

weixin_44113868的博客 1156

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

教你如何写一个符合自己需求的小程序日历组件

很多时候,我们生活中会有各种打卡的情况,比如 keep 的运动打卡、单词的学习打卡和各种签到打卡或者酒店的入住时间选择,这时候就需要我们书写一个日历组件来处理我们这种需求。但是更多时候,我们都是网上找一个插件直接套用了,有没有想过自己实现一下呢?如果有,但是感觉不太会的话,接下来跟着我一起实现符合自己需求的日历吧。

Noah_ZX的博客 4791

微信小程序:实现左右滑动的日历组件效果

效果如下 使用<swiper></swiper>实现左右滑动效果,设置swiper 属性circular 为循环,使月份数据在3个swiper-item中轮流播放,思路如下 m 当为前月,swiper当前所在滑块的下标为 index ,index默认1,页面可以左右滑动 当左右滑动时,页面数组数据和对应滑块的下标关系如下: index==1时:[m-1,m,m+1] index==2 时:[m+1,m-1,m] index== 0 时:[m,m+1,...

Julie_Go的专栏 2041

如何快速集成微信小程序日历组件:新手实战指南

想要在微信小程序中添加一个功能齐全的日历组件吗?wx-calendar是一个原生的微信小程序日历组件,支持滑动切换、日期标点、动态禁用等核心功能,让你5分钟内就能为小程序添加强大的日期交互能力。无论是打卡记录、活动排期还是日程管理,这个组件都能完美胜任。 ## 为什么选择wx-calendar日历组件? 在微信小程序开发中,日期选择与展示是高频需求,但自己开发日历组件常常会遇到各种问题: -

gitblog_01167的博客 100

微信小程序原生日历组件架构解析:高性能日期交互的工程实践

作为微信小程序生态中处理日期选择与展示的核心解决方案,wx-calendar日历组件通过原生的WXML/WXSS架构,为开发者提供了流畅的滑动切换、智能日期标记和灵活的禁用控制能力。该组件专为打卡系统、预约应用、日程管理等场景设计,在保持轻量级的同时实现了企业级的交互体验。 ## 核心理念:性能优先的日期渲染策略 ### 三视图缓存机制 wx-calendar采用独特的"三视图"缓存架构,通过

gitblog_00719的博客 248

wx-calendar:原生微信小程序日历组件深度解析与实战应用

在微信小程序开发中,日期选择与展示是高频需求场景,无论是电商促销日历、健康打卡记录还是项目排期管理,都需要一个稳定、灵活且性能优异的日历组件。wx-calendar作为原生微信小程序日历组件,通过滑动切换、日期标点、动态禁用等核心功能,为开发者提供了完整的日期交互解决方案。 ## 一、开发者痛点与组件设计哲学 ### 1.1 小程序日历组件的常见挑战 在小程序开发实践中,我们经常面临以下问题:

gitblog_00329的博客 310

修改vant的calendar组件修改为横向滑动(swiper形式),用于微信小程序

1.通过npm i @vant/weapp -S --production安装vant 2.在项目的node_modules/@vant/weapp/lib/calendar/calendar.wxml进行修改,将以下代码块修改为以下形式 3.其余细节的调整,自己修改,是不是很简单,虽然我不会写这个日历组件,但是我们要有可以将别人的东西修改为自己想要的样子 ...

ALiMaMaYang的博客 2224

微信小程序日期组件高效开发实战指南:从功能实现到性能优化

在微信小程序开发中,日期选择与展示是许多应用的核心功能模块。如何构建一个交互流畅、功能完善且性能优异的日历组件?wx-calendar作为一款原生微信小程序日历组件,以其轻量级架构和丰富功能,为开发者提供了高效解决方案。本文将从核心价值解析到深度拓展应用,全面讲解如何利用该组件提升开发效率,解决实际项目中的日期处理难题。 ## 核心价值:为何选择wx-calendar组件? 如何在有限的小程序

gitblog_00102的博客 318
上一篇: 没啥用的小知识 只有自己能看懂
下一篇: 小程序swiper组件的bindchange方法重复执行问题(解决真机无限滑动问题)
钟Bubble
博客等级 码龄6年 205粉丝 91原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

钟Bubble

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值