"Front End" Applet Calendar control share __ Applet

Source: Internet
Author: User

Small program development requires a calendar control before, but the actual resources available for small programs are limited, so they wrote one, now the project on the line to share it, hoping to help people in need.
Effect diagram:

JS Code:

Datedata:function () {Let Dataall = []//Total calendar data Let dataAll2 = []//Total calendar data Let Datamonth = []//month calendar data let dat E = new date//current date let year = Date.getfullyear ()//When the year before last Let week = Date.getday ()//day of the week a few let weeks=[] let mo Nth = Date.getmonth () + 1//The current month Let day = Date.getdate ()//Today let Dayscount = 100//altogether shows how many days let Dayscnow = 0//count Let monthlist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]//month list let nowmonthlist=[]//the remainder of the year for (Let i = Month ; i<13;i++) {Nowmonthlist.push (i)} let yearlist = [year]//year maximum possible for (let i = 0; i < dayscount/365  +2;i++) {Yearlist.push (year+i+1)} Let Leapyear = function (year) {//To determine if leap year if ((4) = = 0) && (year% 100)!= 0) | | ((year% 400) = = 0))
      {return (TRUE);
    else {return (false);} for (Let i = 0; i < yearlist.length;i++) {//Over the years let Mlist if (yearlist[i] = = year) {//Determine the current age ML ist = nowmonthlist}else{mlist = monthlist} for (Let j = 0; J < mlist.length;j++) {//Cycle month datamonth=[] L
        ET t_days = [To, + Leapyear (Yearlist[i]), to, from, to, and to, let t_days_thisyear=[] if (yearlist[i] = = year) {for (let M = 0; m<nowmonthlist.length;m++) {T_days_thisyear.push (T_da Ys[mlist[m]-1]} t_days = t_days_thisyear} else {t_days = [to + leapyear (year
          List[i]), to (let k = 0; k < t_days[j];k++) {//cycle per day), from, to, to
            dayscnow++ let Nowdata if (Dayscnow < Dayscount) {//If the counter is not full let days = k + 1 if (days < ten) {days = "0" + days} if (yearlist[i] = = Year && mlist[ J] = = month) {//judge the current month if (k + 1 >= day) {Nowdata = {Year:yearlist[i] , MontH:MLIST[J], Day:k + 1, date:yearlist[i] + "" + mlist[j] + days, s elected:0, Re:yearlist[i] + "-" + mlist[j] + "-" + Days,} DATAMONTH.P Ush (Nowdata) if (k+1 = = day) {Let date = new Date (Yearlist[i] + "-" + mlist[j] + "-" +
                  (k + 1))
            Let WEEKSS = Date.getday ()//Get the first day of each month is the weeks Weeks.push (WEEKSS)}} else {//other case nowdata = {//assemble the data you need year:yearlist[i], month: MLIST[J], Day:k + 1, date:yearlist[i] + "" + mlist[j] + days, selected:
              0, Re:yearlist[i] + "-" + mlist[j] + "-" + Days,} datamonth.push (Nowdata)
             if (k = = 0) {Let date = new Date (Yearlist[i] + "-" + mlist[j] + "-" + K + 1)   Let WEEKSS = Date.getday ()//Get the first day of each month is the weeks Weeks.push (WEEKSS)}}}els e{break} {Dataall.push (Datamonth)}} for (Let i = 0; i < Dataal
      l.length;i++) {if (dataall[i].length!=0) {Dataall2.push (dataall[i]); } this.setdata ({date:dataall2, weeks:weeks})},

The main function of the above code is to render as a data source
Wxml code:

<view class= "Headbox2" > <view class= "headdate" > Day </view> <view class= "Headdate" > One </view&
  Gt <view class= "Headdate" > Two </view> <view class= "Headdate" > Three </view> <view class= "Headdate" > Four </view> <view class= "Headdate" > Five </view> <view class= "Headdate" > Six </view> </ view> <view class= "Headbox" > <view class= "headdate" > Day </view> <view class= "Headdate" > One < /view> <view class= "Headdate" > Two </view> <view class= "Headdate" > Three </view> <view class= "he Addate "> Four </view> <view class=" Headdate "> Five </view> <view class=" Headdate "> Six </view> & lt;/view> <view class= "mouth" wx:for= "{{date}}" wx:for-item= "date" wx:for-index= "index" > <view class= " Mouthhead ' >{{date[index].year} {date[index].month}} month </view> <view class= ' Daybox ' > <view class= ' Day ' wx:if= ' {{weeks[index]>0}} ' ></view> <view class= ' Day ' wx:if= ' {{weeks[index]>1}} ' ></view> <view class= ' Day ' wx:if= ' {{Weeks[index] &GT;2} ' ></view> <view class= ' Day ' wx:if= ' {{weeks[index]>3}} ' ></view> <view class= ' Day ' Wx:if= ' {{weeks[index]>4}} ' ></view> <view class= ' Day ' wx:if= ' {{weeks[index]>5}} ' ></view > <view class= "Day {item.selected = 1?" ' BC ': '} ' wx:for= ' {{date}} ' wx:for-index= ' idx ' data-index= ' {{index}} ' data-indexs= ' {{idx}} ' bindtap= ' Selectday ' > <view class= "actname {item.selected = = 1?" ' Bc2 ': '} ' >{{date[idx].act.subject}}</view> {date[idx].day}} <view class= ' actname2 {{item.selected = = 1?
' Bc2 ': '} ' wx:if= ' {{date[idx].act.rate}} ' >{{date[idx].act.rate/10}} </view> </view> </view> </view> <view class= "none88" wx:if= "{{pagetype== ' Day '}}" ></view> <view class= "Fixedbtn" Bindtap = ' submitbtn ' wx:if= ' {{pagetype== ' Day '}} ' > Confirm selection </view>

Render the data to Wxml

WXSS Style Code:

. headdate{height:30px;
  Background-color:white;
  Flex:1;
  Text-align:center;
line-height:30px;
  }. headbox{Display:flex;
  Display:-webkit-flex;
border-bottom:1px solid #e5e5e5;
  }. headbox2{Display:flex;
  position:fixed;
  WIDTH:750RPX;
  Display:-webkit-flex;
  border-bottom:1px solid #e5e5e5;
  Background-color:white;
Z-index:2;
  }. mouthhead{Height:88rpx;
  Background-color: #f4f4f4;
  WIDTH:750RPX;
  LINE-HEIGHT:88RPX;
Text-align:center;
  }. mouth{/* background-color:white;//////////* PADDING-TOP:10RPX  PADDING-BOTTOM:10RPX; 
   */}. daybox{Background-color:white;
   PADDING-TOP:10RPX;   

PADDING-BOTTOM:10RPX;
  }. day{Width:107rpx;
  HEIGHT:107RPX;
  LINE-HEIGHT:107RPX;
  Text-align:center;
  Display:inline-block;
  position:relative;
  top:0;
  Margin-top: -10RPX;
  Overflow:hidden;
  Color: #353535;
FONT-SIZE:34RPX;
  day2{color: #04babe;
  WIDTH:107RPX;
  HEIGHT:107RPX;
  LINE-HEIGHT:107RPX; Text-aligN:center;
  Display:inline-block;
  position:relative;
  bottom:0;
margin-top:0;
  actname{color: #04babe;
  Position:absolute;
  FONT-SIZE:20RPX;
  Top: -30RPX;
  WIDTH:107RPX;
Text-align:center;
  actname2{color: #04babe;
  Position:absolute;
  FONT-SIZE:20RPX;
  Bottom: -30rpx;
  WIDTH:107RPX;
Text-align:center;
   }. bc{Background-color: #04babe;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.