<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      uniapp 日歷

       先看效果圖!!!

       

      上代碼:

      <view class="content">
        <ren-calendar ref='ren' :markDays='markDays' :headerBar='false' @onDayClick='onDayClick'></ren-calendar>
        <view class="change">選中日期:{{curDate}}</view>
      </view>
      
      import RenCalendar from '@/components/ren-calendar/ren-calendar.vue'
      export default {
      	components:{
      		RenCalendar
      	},
      	data() {
      	   return {
      	    curDate:'',
      	    markDays:[]
      	     };
      	},
      	onLoad() {
      		
      	},
      	onReady() {
      	  let today = this.$refs.ren.getToday().date;
      	  this.curDate = today;
      	  this.markDays.push(today);
          },
           methods: {
      	    // 展開日歷
      	    onDayClick(data){
      		  this.curDate = data.date;
      	    }
          }
      };
      ren-calendar.vue組件代碼:
      <template>
          <view class="calendar-wrapper">
              <view class="header" v-if="headerBar">
                  <view class="pre" @click="changeMonth('pre')">上個月</view>
                  <view>{{y+'年'+formatNum(m)+'月'}}</view>
                  <view class="next" @click="changeMonth('next')">下個月</view>
              </view>
              <view class="week">
                  <view class="week-day" v-for="(item, index) in weekDay" :key="index">{{ item }}</view>
              </view>
              <view :class="{ hide: !monthOpen }" class="content" :style="{ height: height }">
                  <view :style="{ top: positionTop + 'rpx' }" class="days">
                      <view class="item" v-for="(item, index) in dates" :key="index">
                          <view
                              class="day"
                              @click="selectOne(item, $event)"
                              :class="{
                                  choose: choose == `${item.year}-${item.month}-${item.date}`&&item.isCurM,
                                  nolm: !item.isCurM,
                                  today: isToday(item.year, item.month, item.date),
                                  isWorkDay: isWorkDay(item.year, item.month, item.date)
                              }"
                          >
                              {{ Number(item.date) }}
                          </view>
                          <!-- <view class="markDay" v-if="isMarkDay(item.year, item.month, item.date)&&item.isCurM"></view> -->
                      </view>
                  </view>
              </view>
              <image src="https://i.loli.net/2020/07/16/2MmZsucVTlRjSwK.png" mode="scaleToFill" v-if="collapsible" @click="toggle" class="weektoggle" :class="{ down: monthOpen }"></image>
          </view>
      </template>
      
      <script>
      export default {
          name: 'ren-calendar',
          props: {
              // 星期幾為第一天(0為星期日)
              weekstart: {
                  type: Number,
                  default: 0
              },
              // 標記的日期
              markDays: {
                  type: Array,
                  default: ()=>{
                      return [];
                  }
              },
              //是否展示月份切換按鈕
              headerBar:{
                  type: Boolean,
                  default: true
              },
              // 是否展開
              open: {
                  type: Boolean,
                  default: true
              },
              //是否可收縮
              collapsible:{
                  type: Boolean,
                  default: true
              },
              //未來日期是否不可點擊
              disabledAfter: {
                  type: Boolean,
                  default: false
              }
          },
          data() {
              return {
                  weektext: ['日', '一', '二', '三', '四', '五', '六'],
                  y: new Date().getFullYear(), // 年
                  m: new Date().getMonth() + 1, // 月
                  dates: [], // 當前月的日期數據
                  positionTop: 0,
                  monthOpen: true,
                  choose: ''
              };
          },
          created() {
              this.dates = this.monthDay(this.y, this.m);
              !this.open && this.toggle();
          },
          mounted() {
              this.choose = this.getToday().date;
          },
          computed: {
              // 頂部星期欄
              weekDay() {
                  return this.weektext.slice(this.weekstart).concat(this.weektext.slice(0, this.weekstart));
              },
              height() {
                  return (this.dates.length / 7) * 80 + 'rpx';
              }
          },
          methods: {
              formatNum(num) {
                  let res = Number(num);
                  return res < 10 ? '0' + res : res;
              },
              getToday() {
                  let date = new Date();
                  let y = date.getFullYear();
                  let m = date.getMonth();
                  let d = date.getDate();
                  let week = new Date().getDay();
                  let weekText = ['日', '一', '二', '三', '四', '五', '六'];
                  let formatWeek = '星期' + weekText[week];
                  let today = {
                      date: y + '-' + this.formatNum(m + 1) + '-' + this.formatNum(d),
                      week: formatWeek
                  };
                  return today;
              },
              // 獲取當前月份數據
              monthDay(y, month) {
                  let dates = [];
                  let m = Number(month);
                  let firstDayOfMonth = new Date(y, m - 1, 1).getDay(); // 當月第一天星期幾
                  let lastDateOfMonth = new Date(y, m, 0).getDate(); // 當月最后一天
                  let lastDayOfLastMonth = new Date(y, m - 2, 0).getDate(); // 上一月的最后一天
                  let weekstart = this.weekstart == 7 ? 0 : this.weekstart;
                  let startDay = (() => {
                      // 周初有幾天是上個月的
                      if (firstDayOfMonth == weekstart) {
                          return 0;
                      } else if (firstDayOfMonth > weekstart) {
                          return firstDayOfMonth - weekstart;
                      } else {
                          return 7 - weekstart + firstDayOfMonth;
                      }
                  })();
                  let endDay = 7 - ((startDay + lastDateOfMonth) % 7); // 結束還有幾天是下個月的
                  for (let i = 1; i <= startDay; i++) {
                      dates.push({
                          date: this.formatNum(lastDayOfLastMonth - startDay + i),
                          day: weekstart + i - 1 || 7,
                          month: m - 1 >= 0 ? this.formatNum(m - 1) : 12,
                          year: m - 1 >= 0 ? y : y - 1
                      });
                  }
                  for (let j = 1; j <= lastDateOfMonth; j++) {
                      dates.push({
                          date: this.formatNum(j),
                          day: (j % 7) + firstDayOfMonth - 1 || 7,
                          month: this.formatNum(m),
                          year: y,
                          isCurM: true //是否當前月份
                      });
                  }
                  for (let k = 1; k <= endDay; k++) {
                      dates.push({
                          date: this.formatNum(k),
                          day: (lastDateOfMonth + startDay + weekstart + k - 1) % 7 || 7,
                          month: m + 1 <= 11 ? this.formatNum(m + 1) : 0,
                          year: m + 1 <= 11 ? y : y + 1
                      });
                  }
                  // console.log(dates);
                  return dates;
              },
              isWorkDay(y, m, d) {
                  //是否工作日
                  let ymd = `${y}/${m}/$w0obha2h00`;
                  let formatDY = new Date(ymd.replace(/-/g, '/'));
                  let week = formatDY.getDay();
                  if (week == 0 || week == 6) {
                      return false;
                  } else {
                      return true;
                  }
              },
              isFutureDay(y, m, d) {
                  //是否未來日期
                  let ymd = `${y}/${m}/$w0obha2h00`;
                  let formatDY = new Date(ymd.replace(/-/g, '/'));
                  let showTime = formatDY.getTime();
                  let curTime = new Date().getTime();
                  if (showTime > curTime) {
                      return true;
                  } else {
                      return false;
                  }
              },
              // 標記日期
              isMarkDay(y, m, d) {
                  let flag = false;
                  for (let i = 0; i < this.markDays.length; i++) {
                      let dy = `${y}-${m}-$w0obha2h00`;
                      if (this.markDays[i] == dy) {
                          flag = true;
                          break;
                      }
                  }
                  return flag;
              },
              isToday(y, m, d) {
                  let checkD = y + '-' + m + '-' + d;
                  let today = this.getToday().date;
                  if (checkD == today) {
                      return true;
                  } else {
                      return false;
                  }
              },
              // 展開收起
              toggle() {
                  this.monthOpen = !this.monthOpen;
                  if (this.monthOpen) {
                      this.positionTop = 0;
                  } else {
                      let index = -1;
                      this.dates.forEach((i, x) => {
                          this.isToday(i.year, i.month, i.date) && (index = x);
                      });
                      this.positionTop = -((Math.ceil((index + 1) / 7) || 1) - 1) * 80;
                  }
              },
              // 點擊回調
              selectOne(i, event) {
                  let date = `${i.year}-${i.month}-${i.date}`;
                  let selectD = new Date(date).getTime();
                  let curTime = new Date().getTime();
                  let week = new Date(date).getDay();
                  let weekText = ['日', '一', '二', '三', '四', '五', '六'];
                  let formatWeek = '星期' + weekText[week];
                  let response = {
                      date: date,
                      week: formatWeek
                  };
                  if (!i.isCurM) {
                      // console.log('不在當前月范圍內');
                      return false;
                  }
                  if (selectD > curTime) {
                      if (this.disabledAfter) {
                          console.log('未來日期不可選');
                          return false;
                      } else {
                          this.choose = date;
                          this.$emit('onDayClick', response);
                      }
                  } else {
                      this.choose = date;
                      this.$emit('onDayClick', response);
                  }
                  console.log(response);
              },
              //改變年月
              changYearMonth(y, m) {
                  this.dates = this.monthDay(y, m);
                  this.y = y;
                  this.m = m;
              },
              changeMonth(type){
                  if(type=='pre'){
                     if (this.m + 1 == 2) {
                         this.m = 12;
                         this.y = this.y - 1;
                     } else {
                         this.m = this.m - 1;
                     } 
                  }else{
                      if (this.m + 1 == 13) {
                          this.m = 1;
                          this.y = this.y + 1;
                      } else {
                          this.m = this.m + 1;
                      }
                  }
                  this.dates = this.monthDay(this.y, this.m);
              }
          }
      };
      </script>
      
      <style lang="scss" scoped>
      .calendar-wrapper {
          color: #bbb7b7;
          font-size: 28rpx;
          text-align: center;
          background-color: #fff;
          padding-bottom: 10rpx;
      	border-radius: 20rpx;
          
          .header{
              display: flex;
              align-items: center;
              justify-content: center;
              height: 88rpx;
              color: #42464A;
              font-size: 32rpx;
              font-weight: bold;
              border-bottom: 2rpx solid #f2f2f2;
              .pre,.next{
                    color: #4d7df9;
                    font-size: 28rpx;
                    font-weight: normal;
                    padding: 8rpx 15rpx;
                    border-radius: 10rpx;
                    border: 2rpx solid #dcdfe6;
              }
              .pre{
                  margin-right: 30rpx;
              }
              .next{
                  margin-left: 30rpx;
              }
          }
      
          .week {
              display: flex;
              align-items: center;
              height: 80rpx;
              line-height: 80rpx;
              border-bottom: 1rpx solid rgba(255, 255, 255, 0.2);
      
              view {
                  flex: 1;
              }
          }
      
          .content {
              position: relative;
              overflow: hidden;
              transition: height 0.4s ease;
      
              .days {
                  transition: top 0.3s;
                  display: flex;
                  align-items: center;
                  flex-wrap: wrap;
                  position: relative;
      
                  .item {
                      position: relative;
                      display: block;
                      height: 80rpx;
                      line-height: 80rpx;
                      width: calc(100% / 7);
      
                      .day {
                          font-style: normal;
                          display: inline-block;
                          vertical-align: middle;
                          width: 60rpx;
                          height: 60rpx;
                          line-height: 60rpx;
                          overflow: hidden;
                          border-radius: 60rpx;
      
                          &.choose {
                              background-color: #E18326;
                              color: #fff;
                          }
      
                          &.nolm {
                              color: #fff;
                              opacity: 0.3;
                          }
                      }
                      .isWorkDay {
                          color: #42464a;
                      }
      
                      .notSigned {
                          font-style: normal;
                          width: 8rpx;
                          height: 8rpx;
                          background: #fa7268;
                          border-radius: 10rpx;
                          position: absolute;
                          left: 50%;
                          bottom: 0;
                          pointer-events: none;
                      }
                      .today {
                          color: #E18326;
                          background-color: #FAEEE1;
                      }
                      .workDay {
                          font-style: normal;
                          width: 8rpx;
                          height: 8rpx;
                          background: #4d7df9;
                          border-radius: 10rpx;
                          position: absolute;
                          left: 50%;
                          bottom: 0;
                          pointer-events: none;
                      }
                      .markDay{
                          font-style: normal;
                          width: 8rpx;
                          height: 8rpx;
                          background: #fc7a64;
                          border-radius: 10rpx;
                          position: absolute;
                          left: 50%;
                          bottom: 0;
                          pointer-events: none;
                      }
                  }
              }
          }
      
          .hide {
              height: 80rpx !important;
          }
      
          .weektoggle {
              width: 85rpx;
              height: 32rpx;
              position: relative;
              bottom: -42rpx;
              &.down {
                  transform: rotate(180deg);
                  bottom: 0;
              }
          }
      }
      </style>

        

       如有問題請大佬評論,謝謝您嘞。

      posted @ 2021-06-17 10:33  前端—小白  閱讀(1780)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 色综合中文字幕色综合激情| 无遮挡aaaaa大片免费看| 另类 专区 欧美 制服| 无码人妻一区二区三区在线视频 | 丝袜欧美视频首页在线| 久久精品国产99久久久古代| 亚洲情A成黄在线观看动漫尤物| 亚洲国产精品高清久久久| 激情综合色综合啪啪开心| 亚洲精品一区二区妖精| 波多野结衣无内裤护士| 精品人妻系列无码人妻免费视频| 起碰免费公开97在线视频| 少妇av一区二区三区无码| 午夜免费国产体验区免费的| 国产大学生粉嫩无套流白浆| 2019国产精品青青草原| 久热久精久品这里在线观看| 亚洲狠狠婷婷综合久久久久图片| 免费无码成人AV片在线| 镶黄旗| 国产偷国产偷亚洲高清午夜| 99久久精品看国产一区| 清新县| 成人午夜福利视频一区二区| 好男人官网资源在线观看| 日韩精品不卡一区二区三区| 得荣县| 亚洲精品一区二区三区大| 最新国产精品好看的精品| 国产另类ts人妖一区二区| 国产精品无遮挡猛进猛出| 自拍偷拍第一区二区三区| 久久精品无码专区免费东京热 | 武夷山市| 亚洲最大的熟女水蜜桃AV网站| 中文字幕在线视频不卡一区二区 | 久久精品视频一二三四区| 龙泉市| 欧美野外伦姧在线观看| 欧美一本大道香蕉综合视频|