作者 李洪娟

修改

要显示太多修改。

为保证性能只显示 5 of 5+ 个文件。

  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 +<head>
  4 +
  5 + <meta charset="UTF-8">
  6 + <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
  7 + <link rel="stylesheet" href="https://at.alicdn.com/t/font_1023063_7fxauzqx2h8.css">
  8 + <link rel="stylesheet" href="css/rolldate.css">
  9 +
  10 + <link rel="stylesheet" type="text/css" href="css/mui.min.css">
  11 + <link rel="stylesheet" type="text/css" href="css/swiper.min.css">
  12 + <link rel="stylesheet" type="text/css" href="css/calendar_base.css">
  13 + <link rel="stylesheet" type="text/css" href="css/showcase.css">
  14 + <script src="js/base.js" type="text/javascript"></script>
  15 + <title>日期设置</title>
  16 + <style>
  17 + body,html{
  18 + background: #fff;
  19 + }
  20 +
  21 + .datelist{
  22 + display:flex;
  23 + justify-content: space-between;
  24 + align-items: center;
  25 + height:0.8rem;
  26 + line-height: 0.8rem;
  27 + margin:0;
  28 + padding: 0;
  29 + background: #fff;
  30 + border-bottom: 1px solid #f5f5f5;
  31 + }
  32 + .datelist li{
  33 + width:1.62rem;
  34 + text-decoration: none;
  35 + list-style: none;
  36 + color:#333333;
  37 + font-size: 0.3rem;
  38 + /*border-right:1px solid #f5f5f5;*/
  39 + text-align: center;
  40 + height:0.8rem;
  41 + position: relative;
  42 +
  43 + }
  44 + .datelist li:after{
  45 + display:block;
  46 + content:'';
  47 + width:1px;
  48 + height:0.5rem;
  49 + background: #f5f5f5;
  50 + position: absolute;
  51 + top:0.19rem;
  52 + right:0;
  53 + }
  54 + .datelist li:last-child:after{
  55 + display:block;
  56 + content:'';
  57 + width:1px;
  58 + height:0.5rem;
  59 + background: #fff;
  60 + position: absolute;
  61 + top:0.19rem;
  62 + right:0;
  63 + }
  64 + .datelist li.active{
  65 + color:#2C82E6;
  66 + }
  67 + .repeathead{
  68 + display:flex;
  69 + justify-content: space-between;
  70 + align-items: center;
  71 +
  72 + width:6.86rem;
  73 + padding: 0 0.29rem;
  74 + height:1rem;
  75 + background:rgba(255,255,255,1);
  76 + box-shadow:0px 1px 5px 0px rgba(89,89,89,0.1);
  77 + border-radius:0.1rem;
  78 + margin: 0.33rem auto 0;
  79 + box-sizing: border-box;
  80 +
  81 + }
  82 + .icon-youjiantou{
  83 + color:#666666;
  84 + font-size: 0.5rem;
  85 + }
  86 + .repeattype{
  87 + color:#333333;
  88 + font-size: 0.3rem;
  89 + }
  90 + .daytype{
  91 + display:flex;
  92 + align-items: center;
  93 + }
  94 + .dayname,.selectrepeatname{
  95 + color:#333333;
  96 + font-size: 0.3rem;
  97 + }
  98 + .repeatcontent{
  99 + width:6.86rem;
  100 + margin: 0 auto;
  101 +
  102 + }
  103 + .repeatlist{
  104 + padding-left: 0;
  105 + margin: 0;
  106 + }
  107 + .repeatlist li{
  108 + height:1rem;
  109 + line-height: 1rem;
  110 + /*width:6.86rem;*/
  111 + list-style: none;
  112 + text-align: center;
  113 + font-size: 0.3rem;
  114 + color:#333;
  115 + border-bottom: 1px solid #f5f5f5;
  116 + }
  117 + .repeatlist li.repeatactive{
  118 + color:#2C82E6;
  119 + font-size: 0.48rem;
  120 + background:#FAFAFA;
  121 + }
  122 +
  123 + .repeatweek{
  124 + width:6.86rem;
  125 + margin: 0 auto;
  126 + }
  127 + .weeklist{
  128 + list-style: none;
  129 + display:flex;
  130 + flex-wrap: wrap;
  131 + padding: 0;
  132 + margin: 0;
  133 +
  134 + }
  135 + .weeklist li{
  136 + width:1.2rem;
  137 + height:0.38rem;
  138 + background:rgba(44,130,230,0);
  139 + border:1px solid rgba(106, 107, 120, 0.15);
  140 + border-radius:0.17rem;
  141 + color:#6A6B78;
  142 + font-size: 0.24rem;
  143 + margin-left: 0.4rem;
  144 + text-align: center;
  145 + line-height: 0.38rem;
  146 + margin-top: 0.16rem;
  147 +
  148 + }
  149 + .weeklist li.weekactive{
  150 + background: #2C82E6;
  151 + color:#fff;
  152 + }
  153 + .repeatmonth{
  154 + width:6.86rem;
  155 + margin: 0 auto;
  156 + }
  157 + .monthlist{
  158 + display:flex;
  159 + flex-wrap: wrap;
  160 + margin: 0;
  161 + padding: 0;
  162 + }
  163 + .monthlist li{
  164 + list-style: none;
  165 + color:#333333;
  166 + font-size: 0.26rem;
  167 + width:0.48rem;
  168 + height:0.48rem;
  169 + line-height: 0.48rem;
  170 + border-radius: 50%;
  171 + margin-left: 0.26rem;
  172 + margin-top: 0.2rem;
  173 + text-align: center;
  174 + }
  175 + .monthlist li.monthactive{
  176 + background: #2C82E6;
  177 + color:#fff;
  178 + }
  179 + .beginend{
  180 + width:6.86rem;
  181 + margin: 0.3rem auto;
  182 + display:flex;
  183 + align-items: center;
  184 +
  185 + }
  186 + .andate{
  187 + display:flex;
  188 + color:#2C82E6;
  189 + align-items: center;
  190 + }
  191 + .noxuan .xuan{
  192 + font-size: 0.3rem;
  193 + }
  194 + .andatename{
  195 + font-size:0.3rem ;
  196 + margin-left: 0.21rem;
  197 + }
  198 + .forever{
  199 + margin-left: 0.31rem;
  200 + }
  201 + .date{
  202 + color: #333333;
  203 + font-size: 0.3rem;
  204 + }
  205 + .em-red{
  206 + color:#2C82E6
  207 + }
  208 + .em-calendar-content .em-calendar-item:nth-child(7n) .day, .em-calendar-content .em-calendar-item:nth-child(7n+1) .day {
  209 + color: #333;
  210 + font-size: 16px;
  211 + }
  212 + .em-journal-title {
  213 + width: 100%;
  214 + display: flex;
  215 + justify-content: center;
  216 + height: 50px;
  217 + line-height: 50px;
  218 + background-color: #fff;
  219 + }
  220 + .em-per-block span{
  221 + color:#333
  222 + }
  223 + </style>
  224 +</head>
  225 +<body>
  226 +<div class="datehead">
  227 + <ul class="datelist">
  228 + <li data-selectid="1">单日</li>
  229 + <li data-selectid="2">多日</li>
  230 + <li class="active" data-selectid="3">起止</li>
  231 + <li data-selectid="4">重复</li>
  232 + </ul>
  233 +</div>
  234 +
  235 +<!--单日-->
  236 +<div class="dateitem singleday" >
  237 + <div class="mui-content">
  238 + <div class="em-journal-title">
  239 + <!--<div class="em-per-block pre">-->
  240 + <!--<span class="mui-icon mui-icon-arrowleft"></span>-->
  241 + <!--<span>上一月</span>-->
  242 + <!--</div>-->
  243 + <div class="collect">
  244 + <!--<img src="img/ghgfhs@2x.png" alt="">-->
  245 + </div>
  246 + <div class="em-per-block mid" >
  247 + <span>2019-01-18</span>
  248 + </div>
  249 + <div>
  250 + <!--<img src="" alt="">-->
  251 + </div>
  252 + <!--<div class="em-per-block next">-->
  253 + <!--<span>下一月</span>-->
  254 + <!--<span class="mui-icon mui-icon-arrowright"></span>-->
  255 + <!--</div>-->
  256 + </div>
  257 +
  258 + <!--日历容器-->
  259 + <div id="calendar">
  260 + <div class="em-calendar-container">
  261 + <div class="em-week">
  262 + <span class="em-red"></span>
  263 + <span></span>
  264 + <span></span>
  265 + <span></span>
  266 + <span></span>
  267 + <span></span>
  268 + <span class="em-red"></span>
  269 + </div>
  270 + <div class="swiper-container swiper-container-horizontal">
  271 + <div class="swiper-wrapper"
  272 + style="transform: translate3d(-1423px, 0px, 0px); transition-duration: 0ms;">
  273 + <div class="swiper-slide swiper-slide-prev" style="width: 1423px;">
  274 + <div class="em-calendar-content">
  275 + <div class="em-calendar-wrapper">
  276 + <div class="em-calendar-item isforbid0 tipprev" date="2018-11-25">
  277 + <span class="day">25</span>
  278 + <p class="lunar">十八</p>
  279 + </div>
  280 + <div class="em-calendar-item isforbid0 tipprev" date="2018-11-26">
  281 + <span class="day">26</span>
  282 + <p class="lunar">十九</p>
  283 + </div>
  284 + <div class="em-calendar-item isforbid0 tipprev" date="2018-11-27">
  285 + <span class="day">27</span>
  286 + <p class="lunar">廿</p>
  287 + </div>
  288 + <div class="em-calendar-item isforbid0 tipprev" date="2018-11-28">
  289 + <span class="day">28</span>
  290 + <p class="lunar">廿一</p>
  291 + </div>
  292 + <div class="em-calendar-item isforbid0 tipprev" date="2018-11-29">
  293 + <span class="day">29</span>
  294 + <p class="lunar">廿二</p>
  295 + </div>
  296 + <div class="em-calendar-item isforbid0 tipprev" date="2018-11-30">
  297 + <span class="day">30</span>
  298 + <p class="lunar">廿三</p>
  299 + </div>
  300 + <div class="em-calendar-item isforbid1 tip" date="2018-12-01">
  301 + <span class="day">1</span>
  302 + <p class="lunar">廿四</p>
  303 + </div>
  304 + <div class="em-calendar-item isforbid1 tip" date="2018-12-02">
  305 + <span class="day">2</span>
  306 + <p class="lunar">廿五</p>
  307 + </div>
  308 + <div class="em-calendar-item isforbid1 tip" date="2018-12-03">
  309 + <span class="day">3</span>
  310 + <p class="lunar">廿六</p>
  311 + </div>
  312 + <div class="em-calendar-item isforbid1 tip" date="2018-12-04">
  313 + <span class="day">4</span>
  314 + <p class="lunar">廿七</p>
  315 + </div>
  316 + <div class="em-calendar-item isforbid1 tip" date="2018-12-05">
  317 + <span class="day">5</span>
  318 + <p class="lunar">廿八</p>
  319 + </div>
  320 + <div class="em-calendar-item isforbid1 tip" date="2018-12-06">
  321 + <span class="day">6</span>
  322 + <p class="lunar">廿九</p>
  323 + </div>
  324 + <div class="em-calendar-item isforbid1 tip" date="2018-12-07">
  325 + <span class="day">7</span>
  326 + <p class="lunar">初一</p>
  327 + </div>
  328 + <div class="em-calendar-item isforbid1 tip" date="2018-12-08">
  329 + <span class="day">8</span>
  330 + <p class="lunar">初二</p>
  331 + </div>
  332 + <div class="em-calendar-item isforbid1 tip" date="2018-12-09">
  333 + <span class="day">9</span>
  334 + <p class="lunar">初三</p>
  335 + </div>
  336 + <div class="em-calendar-item isforbid1 tip" date="2018-12-10">
  337 + <span class="day">10</span>
  338 + <p class="lunar">初四</p>
  339 + </div>
  340 + <div class="em-calendar-item isforbid1 tip" date="2018-12-11">
  341 + <span class="day">11</span>
  342 + <p class="lunar">初五</p>
  343 + </div>
  344 + <div class="em-calendar-item isforbid1 tip" date="2018-12-12">
  345 + <span class="day">12</span>
  346 + <p class="lunar">初六</p>
  347 + </div>
  348 + <div class="em-calendar-item isforbid1 tip" date="2018-12-13">
  349 + <span class="day">13</span>
  350 + <p class="lunar">初七</p>
  351 + </div>
  352 + <div class="em-calendar-item isforbid1 tip" date="2018-12-14">
  353 + <span class="day">14</span>
  354 + <p class="lunar">初八</p>
  355 + </div>
  356 + <div class="em-calendar-item isforbid1 tip" date="2018-12-15">
  357 + <span class="day">15</span>
  358 + <p class="lunar">初九</p>
  359 + </div>
  360 + <div class="em-calendar-item isforbid1 tip" date="2018-12-16">
  361 + <span class="day">16</span>
  362 + <p class="lunar">初十</p>
  363 + </div>
  364 + <div class="em-calendar-item isforbid1 tip" date="2018-12-17">
  365 + <span class="day">17</span>
  366 + <p class="lunar">十一</p>
  367 + </div>
  368 + <div class="em-calendar-item isforbid1 tip" date="2018-12-18">
  369 + <span class="day">18</span>
  370 + <p class="lunar">十二</p>
  371 + </div>
  372 + <div class="em-calendar-item isforbid1 tip" date="2018-12-19">
  373 + <span class="day">19</span>
  374 + <p class="lunar">十三</p>
  375 + </div>
  376 + <div class="em-calendar-item isforbid1 tip" date="2018-12-20">
  377 + <span class="day">20</span>
  378 + <p class="lunar">十四</p>
  379 + </div>
  380 + <div class="em-calendar-item isforbid1 tip" date="2018-12-21">
  381 + <span class="day">21</span>
  382 + <p class="lunar">十五</p>
  383 + </div>
  384 + <div class="em-calendar-item isforbid1 tip" date="2018-12-22">
  385 + <span class="day">22</span>
  386 + <p class="lunar">十六</p>
  387 + </div>
  388 + <div class="em-calendar-item isforbid1 tip" date="2018-12-23">
  389 + <span class="day">23</span>
  390 + <p class="lunar">十七</p>
  391 + </div>
  392 + <div class="em-calendar-item isforbid1 tip" date="2018-12-24">
  393 + <span class="day">24</span>
  394 + <p class="lunar">十八</p>
  395 + </div>
  396 + <div class="em-calendar-item isforbid1 tip" date="2018-12-25">
  397 + <span class="day">25</span>
  398 + <p class="lunar">十九</p>
  399 + </div>
  400 + <div class="em-calendar-item isforbid1 tip" date="2018-12-26">
  401 + <span class="day">26</span>
  402 + <p class="lunar">廿</p>
  403 + </div>
  404 + <div class="em-calendar-item isforbid1 tip" date="2018-12-27">
  405 + <span class="day">27</span>
  406 + <p class="lunar">廿一</p>
  407 + </div>
  408 + <div class="em-calendar-item isforbid1 tip" date="2018-12-28">
  409 + <span class="day">28</span>
  410 + <p class="lunar">廿二</p>
  411 + </div>
  412 + <div class="em-calendar-item isforbid1 tip" date="2018-12-29">
  413 + <span class="day">29</span>
  414 + <p class="lunar">廿三</p>
  415 + </div>
  416 + <div class="em-calendar-item isforbid1 tip" date="2018-12-30">
  417 + <span class="day">30</span>
  418 + <p class="lunar">廿四</p></div>
  419 + <div class="em-calendar-item isforbid1 tip" date="2018-12-31">
  420 + <span class="day">31</span>
  421 + <p class="lunar">廿五</p></div>
  422 + <div class="em-calendar-item isforbid0 tipnext" date="2019-01-01">
  423 + <span class="day">1</span>
  424 + <p class="lunar">廿六</p></div>
  425 + <div class="em-calendar-item isforbid0 tipnext" date="2019-01-02">
  426 + <span class="day">2</span>
  427 + <p class="lunar">廿七</p></div>
  428 + <div class="em-calendar-item isforbid0 tipnext" date="2019-01-03">
  429 + <span class="day">3</span>
  430 + <p class="lunar">廿八</p></div>
  431 + <div class="em-calendar-item isforbid0 tipnext" date="2019-01-04">
  432 + <span class="day">4</span>
  433 + <p class="lunar">廿九</p></div>
  434 + <div class="em-calendar-item isforbid0 tipnext" date="2019-01-05">
  435 + <span class="day">5</span>
  436 + <p class="lunar">三十</p></div>
  437 + </div>
  438 + </div>
  439 + </div>
  440 + <div class="swiper-slide swiper-slide-active" style="width: 1423px;">
  441 + <div class="em-calendar-content">
  442 + <div class="em-calendar-wrapper">
  443 + <div class="em-calendar-item isforbid0 tipprev" date="2018-12-30"><span
  444 + class="day">30</span>
  445 + <p class="lunar">廿四</p></div>
  446 + <div class="em-calendar-item isforbid0 tipprev" date="2018-12-31"><span
  447 + class="day">31</span>
  448 + <p class="lunar">廿五</p></div>
  449 + <div class="em-calendar-item isforbid1 tip" date="2019-01-01"><span class="day">1</span>
  450 + <p class="lunar">廿六</p></div>
  451 + <div class="em-calendar-item isforbid1 tip" date="2019-01-02"><span class="day">2</span>
  452 + <p class="lunar">廿七</p></div>
  453 + <div class="em-calendar-item isforbid1 tip" date="2019-01-03"><span class="day">3</span>
  454 + <p class="lunar">廿八</p></div>
  455 + <div class="em-calendar-item isforbid1 tip" date="2019-01-04"><span class="day">4</span>
  456 + <p class="lunar">廿九</p></div>
  457 + <div class="em-calendar-item isforbid1 tip" date="2019-01-05"><span class="day">5</span>
  458 + <p class="lunar">三十</p></div>
  459 + <div class="em-calendar-item isforbid1 tip" date="2019-01-06"><span class="day">6</span>
  460 + <p class="lunar">初一</p></div>
  461 + <div class="em-calendar-item isforbid1 tip" date="2019-01-07"><span class="day">7</span>
  462 + <p class="lunar">初二</p></div>
  463 + <div class="em-calendar-item isforbid1 tip" date="2019-01-08"><span class="day">8</span>
  464 + <p class="lunar">初三</p></div>
  465 + <div class="em-calendar-item isforbid1 tip" date="2019-01-09"><span class="day">9</span>
  466 + <p class="lunar">初四</p></div>
  467 + <div class="em-calendar-item isforbid1 tip" date="2019-01-10"><span
  468 + class="day">10</span>
  469 + <p class="lunar">初五</p></div>
  470 + <div class="em-calendar-item isforbid1 tip" date="2019-01-11"><span
  471 + class="day">11</span>
  472 + <p class="lunar">初六</p></div>
  473 + <div class="em-calendar-item isforbid1 tip" date="2019-01-12"><span
  474 + class="day">12</span>
  475 + <p class="lunar">初七</p></div>
  476 + <div class="em-calendar-item isforbid1 tip" date="2019-01-13"><span
  477 + class="day">13</span>
  478 + <p class="lunar">初八</p></div>
  479 + <div class="em-calendar-item isforbid1 tip" date="2019-01-14"><span
  480 + class="day">14</span>
  481 + <p class="lunar">初九</p></div>
  482 + <div class="em-calendar-item isforbid1 tip" date="2019-01-15"><span
  483 + class="day">15</span>
  484 + <p class="lunar">初十</p></div>
  485 + <div class="em-calendar-item isforbid1 tip" date="2019-01-16"><span
  486 + class="day">16</span>
  487 + <p class="lunar">十一</p></div>
  488 + <div class="em-calendar-item isforbid1 tip" date="2019-01-17"><span
  489 + class="day">17</span>
  490 + <p class="lunar">十二</p></div>
  491 + <div class="em-calendar-item em-calendar-active isforbid1" date="2019-01-18"><span
  492 + class="day">18</span>
  493 + <p class="lunar">今天</p>
  494 + </div>
  495 + <div class="em-calendar-item isforbid1 tip" date="2019-01-19"><span
  496 + class="day">19</span>
  497 + <p class="lunar">十四</p></div>
  498 + <div class="em-calendar-item isforbid1 tip" date="2019-01-20"><span
  499 + class="day">20</span>
  500 + <p class="lunar">十五</p></div>
  501 + <div class="em-calendar-item isforbid1 tip" date="2019-01-21"><span
  502 + class="day">21</span>
  503 + <p class="lunar">十六</p></div>
  504 + <div class="em-calendar-item isforbid1 tip" date="2019-01-22"><span
  505 + class="day">22</span>
  506 + <p class="lunar">十七</p></div>
  507 + <div class="em-calendar-item isforbid1 tip" date="2019-01-23"><span
  508 + class="day">23</span>
  509 + <p class="lunar">十八</p></div>
  510 + <div class="em-calendar-item isforbid1 tip" date="2019-01-24"><span
  511 + class="day">24</span>
  512 + <p class="lunar">十九</p></div>
  513 + <div class="em-calendar-item isforbid1 tip" date="2019-01-25"><span
  514 + class="day">25</span>
  515 + <p class="lunar">廿</p></div>
  516 + <div class="em-calendar-item isforbid1 tip" date="2019-01-26"><span
  517 + class="day">26</span>
  518 + <p class="lunar">廿一</p></div>
  519 + <div class="em-calendar-item isforbid1 tip" date="2019-01-27"><span
  520 + class="day">27</span>
  521 + <p class="lunar">廿二</p></div>
  522 + <div class="em-calendar-item isforbid1 tip" date="2019-01-28"><span
  523 + class="day">28</span>
  524 + <p class="lunar">廿三</p></div>
  525 + <div class="em-calendar-item isforbid1 tip" date="2019-01-29"><span
  526 + class="day">29</span>
  527 + <p class="lunar">廿四</p></div>
  528 + <div class="em-calendar-item isforbid1 tip" date="2019-01-30"><span
  529 + class="day">30</span>
  530 + <p class="lunar">廿五</p></div>
  531 + <div class="em-calendar-item isforbid1 tip" date="2019-01-31"><span
  532 + class="day">31</span>
  533 + <p class="lunar">廿六</p></div>
  534 + <div class="em-calendar-item isforbid0 tipnext" date="2019-02-01"><span
  535 + class="day">1</span>
  536 + <p class="lunar">廿七</p></div>
  537 + <div class="em-calendar-item isforbid0 tipnext" date="2019-02-02"><span
  538 + class="day">2</span>
  539 + <p class="lunar">廿八</p></div>
  540 + <div class="em-calendar-item isforbid0 tipnext" date="2019-02-03"><span
  541 + class="day">3</span>
  542 + <p class="lunar">廿九</p></div>
  543 + <div class="em-calendar-item isforbid0 tipnext" date="2019-02-04"><span
  544 + class="day">4</span>
  545 + <p class="lunar">三十</p></div>
  546 + <div class="em-calendar-item isforbid0 tipnext" date="2019-02-05"><span
  547 + class="day">5</span>
  548 + <p class="lunar">初一</p></div>
  549 + <div class="em-calendar-item isforbid0 tipnext" date="2019-02-06"><span
  550 + class="day">6</span>
  551 + <p class="lunar">初二</p></div>
  552 + <div class="em-calendar-item isforbid0 tipnext" date="2019-02-07"><span
  553 + class="day">7</span>
  554 + <p class="lunar">初三</p></div>
  555 + <div class="em-calendar-item isforbid0 tipnext" date="2019-02-08"><span
  556 + class="day">8</span>
  557 + <p class="lunar">初四</p></div>
  558 + <div class="em-calendar-item isforbid0 tipnext" date="2019-02-09"><span
  559 + class="day">9</span>
  560 + <p class="lunar">初五</p></div>
  561 + </div>
  562 + </div>
  563 + </div>
  564 + <div class="swiper-slide swiper-slide-next" style="width: 1423px;">
  565 + <div class="em-calendar-content">
  566 + <div class="em-calendar-wrapper">
  567 + <div class="em-calendar-item isforbid0 tipprev" date="2019-01-27"><span
  568 + class="day">27</span>
  569 + <p class="lunar">廿二</p></div>
  570 + <div class="em-calendar-item isforbid0 tipprev" date="2019-01-28"><span
  571 + class="day">28</span>
  572 + <p class="lunar">廿三</p></div>
  573 + <div class="em-calendar-item isforbid0 tipprev" date="2019-01-29"><span
  574 + class="day">29</span>
  575 + <p class="lunar">廿四</p></div>
  576 + <div class="em-calendar-item isforbid0 tipprev" date="2019-01-30"><span
  577 + class="day">30</span>
  578 + <p class="lunar">廿五</p></div>
  579 + <div class="em-calendar-item isforbid0 tipprev" date="2019-01-31"><span
  580 + class="day">31</span>
  581 + <p class="lunar">廿六</p></div>
  582 + <div class="em-calendar-item isforbid1 tip" date="2019-02-01"><span
  583 + class="day">1</span>
  584 + <p class="lunar">廿七</p></div>
  585 + <div class="em-calendar-item isforbid1 tip" date="2019-02-02"><span
  586 + class="day">2</span>
  587 + <p class="lunar">廿八</p></div>
  588 + <div class="em-calendar-item isforbid1 tip" date="2019-02-03"><span
  589 + class="day">3</span>
  590 + <p class="lunar">廿九</p></div>
  591 + <div class="em-calendar-item isforbid1 tip" date="2019-02-04"><span
  592 + class="day">4</span>
  593 + <p class="lunar">三十</p></div>
  594 + <div class="em-calendar-item isforbid1 tip" date="2019-02-05"><span
  595 + class="day">5</span>
  596 + <p class="lunar">初一</p></div>
  597 + <div class="em-calendar-item isforbid1 tip" date="2019-02-06"><span
  598 + class="day">6</span>
  599 + <p class="lunar">初二</p></div>
  600 + <div class="em-calendar-item isforbid1 tip" date="2019-02-07"><span
  601 + class="day">7</span>
  602 + <p class="lunar">初三</p></div>
  603 + <div class="em-calendar-item isforbid1 tip" date="2019-02-08"><span
  604 + class="day">8</span>
  605 + <p class="lunar">初四</p></div>
  606 + <div class="em-calendar-item isforbid1 tip" date="2019-02-09"><span
  607 + class="day">9</span>
  608 + <p class="lunar">初五</p></div>
  609 + <div class="em-calendar-item isforbid1 tip" date="2019-02-10"><span
  610 + class="day">10</span>
  611 + <p class="lunar">初六</p></div>
  612 + <div class="em-calendar-item isforbid1 tip" date="2019-02-11"><span
  613 + class="day">11</span>
  614 + <p class="lunar">初七</p></div>
  615 + <div class="em-calendar-item isforbid1 tip" date="2019-02-12"><span
  616 + class="day">12</span>
  617 + <p class="lunar">初八</p></div>
  618 + <div class="em-calendar-item isforbid1 tip" date="2019-02-13"><span
  619 + class="day">13</span>
  620 + <p class="lunar">初九</p></div>
  621 + <div class="em-calendar-item isforbid1 tip" date="2019-02-14"><span
  622 + class="day">14</span>
  623 + <p class="lunar">初十</p></div>
  624 + <div class="em-calendar-item isforbid1 tip" date="2019-02-15"><span
  625 + class="day">15</span>
  626 + <p class="lunar">十一</p></div>
  627 + <div class="em-calendar-item isforbid1 tip" date="2019-02-16"><span
  628 + class="day">16</span>
  629 + <p class="lunar">十二</p></div>
  630 + <div class="em-calendar-item isforbid1 tip" date="2019-02-17"><span
  631 + class="day">17</span>
  632 + <p class="lunar">十三</p></div>
  633 + <div class="em-calendar-item isforbid1 tip" date="2019-02-18"><span
  634 + class="day">18</span>
  635 + <p class="lunar">十四</p></div>
  636 + <div class="em-calendar-item isforbid1 tip" date="2019-02-19"><span
  637 + class="day">19</span>
  638 + <p class="lunar">十五</p></div>
  639 + <div class="em-calendar-item isforbid1 tip" date="2019-02-20"><span
  640 + class="day">20</span>
  641 + <p class="lunar">十六</p></div>
  642 + <div class="em-calendar-item isforbid1 tip" date="2019-02-21"><span
  643 + class="day">21</span>
  644 + <p class="lunar">十七</p></div>
  645 + <div class="em-calendar-item isforbid1 tip" date="2019-02-22"><span
  646 + class="day">22</span>
  647 + <p class="lunar">十八</p></div>
  648 + <div class="em-calendar-item isforbid1 tip" date="2019-02-23"><span
  649 + class="day">23</span>
  650 + <p class="lunar">十九</p></div>
  651 + <div class="em-calendar-item isforbid1 tip" date="2019-02-24"><span
  652 + class="day">24</span>
  653 + <p class="lunar">廿</p></div>
  654 + <div class="em-calendar-item isforbid1 tip" date="2019-02-25"><span
  655 + class="day">25</span>
  656 + <p class="lunar">廿一</p></div>
  657 + <div class="em-calendar-item isforbid1 tip" date="2019-02-26"><span
  658 + class="day">26</span>
  659 + <p class="lunar">廿二</p></div>
  660 + <div class="em-calendar-item isforbid1 tip" date="2019-02-27"><span
  661 + class="day">27</span>
  662 + <p class="lunar">廿三</p></div>
  663 + <div class="em-calendar-item isforbid1 tip" date="2019-02-28"><span
  664 + class="day">28</span>
  665 + <p class="lunar">廿四</p></div>
  666 + <div class="em-calendar-item isforbid0 tipnext" date="2019-03-01"><span
  667 + class="day">1</span>
  668 + <p class="lunar">廿五</p></div>
  669 + <div class="em-calendar-item isforbid0 tipnext" date="2019-03-02"><span
  670 + class="day">2</span>
  671 + <p class="lunar">廿六</p></div>
  672 + <div class="em-calendar-item isforbid0 tipnext" date="2019-03-03"><span
  673 + class="day">3</span>
  674 + <p class="lunar">廿七</p></div>
  675 + <div class="em-calendar-item isforbid0 tipnext" date="2019-03-04"><span
  676 + class="day">4</span>
  677 + <p class="lunar">廿八</p></div>
  678 + <div class="em-calendar-item isforbid0 tipnext" date="2019-03-05"><span
  679 + class="day">5</span>
  680 + <p class="lunar">廿九</p></div>
  681 + <div class="em-calendar-item isforbid0 tipnext" date="2019-03-06"><span
  682 + class="day">6</span>
  683 + <p class="lunar">三十</p></div>
  684 + <div class="em-calendar-item isforbid0 tipnext" date="2019-03-07"><span
  685 + class="day">7</span>
  686 + <p class="lunar">初一</p></div>
  687 + <div class="em-calendar-item isforbid0 tipnext" date="2019-03-08"><span
  688 + class="day">8</span>
  689 + <p class="lunar">初二</p></div>
  690 + <div class="em-calendar-item isforbid0 tipnext" date="2019-03-09"><span
  691 + class="day">9</span>
  692 + <p class="lunar">初三</p></div>
  693 + </div>
  694 + </div>
  695 + </div>
  696 + </div>
  697 + </div>
  698 + </div>
  699 + </div>
  700 + </div>
  701 +</div>
  702 +
  703 +<!--重复方式-->
  704 +<div class="dateitem repeatday" style="display:none">
  705 + <div class="dateitemhdead">
  706 + <div class="repeathead repeattypekind">
  707 + <p class="repeattype">重复方式</p>
  708 + <div class="daytype">
  709 + <p class="selectrepeatname"></p>
  710 + <p class="iconfont icon-youjiantou"></p>
  711 + </div>
  712 +
  713 + </div>
  714 + <div class="repeattext" style="display:none">
  715 + <div class="repeatcontent repeatkind" >
  716 + <ul class="repeatlist">
  717 + <li class="repeatactive" data-dayid="1"></li>
  718 + <li data-dayid="2"></li>
  719 + <li data-dayid="3"></li>
  720 + <li data-dayid="4"></li>
  721 + </ul>
  722 +
  723 + </div>
  724 +
  725 +
  726 + <!--重复周-->
  727 + <div class="repeatweek" style="display:none">
  728 + <ul class="weeklist">
  729 + <li>周一</li>
  730 + <li>周二</li>
  731 + <li>周三</li>
  732 + <li>周四</li>
  733 + <li>周五</li>
  734 + <li>周六</li>
  735 + <li>周日</li>
  736 + </ul>
  737 + </div>
  738 +
  739 + <!--重复月-->
  740 + <div class="repeatmonth" style="display:none">
  741 + <ul class="monthlist">
  742 + <li>1</li>
  743 + </ul>
  744 + </div>
  745 + </div>
  746 +
  747 +
  748 +
  749 + <div class="repeathead repeatforever">
  750 + <p class="repeattype">截止</p>
  751 +
  752 + <div class="daytype">
  753 + <div class="date" style="display:none"></div>
  754 + <div class="dayname">永不结束</div>
  755 + <div class="iconfont icon-youjiantou"></div>
  756 + </div>
  757 +
  758 + </div>
  759 + <div class="beginend" style="display:none">
  760 + <div class="andate">
  761 + <div class="iconfont icon-xiaoqing-tubiao-weixuanze noxuan" data-kindid="1" id="date5"></div>
  762 + <div class="andatename">按日期</div>
  763 + <!--<input readonly type="text" id="date5" placeholder="blue">-->
  764 + </div>
  765 + <div class="andate forever">
  766 + <div class="iconfont icon-danxuanxuanzhong noxuan" data-kindid="2"></div>
  767 + <div class="andatename">永不结束</div>
  768 + </div>
  769 + </div>
  770 + </div>
  771 +</div>
  772 +
  773 +</body>
  774 +<script type="text/javascript" src="js/jquery.min.js"></script>
  775 +
  776 +<script src="js/rolldate.min.js"></script>
  777 +<script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js"></script>
  778 +
  779 +<script src="js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
  780 +<script src="js/mustache.min.js" type="text/javascript" charset="utf-8"></script>
  781 +<script src="js/calendar_beginend.js" type="text/javascript" charset="utf-8"></script>
  782 +<script src="js/calendar_showcase.js" type="text/javascript" charset="utf-8"></script>
  783 +<script>
  784 +
  785 +
  786 + $(".datelist li").click(function(){
  787 + var selectkindid=$(this).attr("data-selectid");
  788 + if(selectkindid==1){
  789 +
  790 + window.location.href='setdate.html'
  791 + }else if(selectkindid==2){
  792 +
  793 + window.location.href='manyday.html'
  794 + }else if(selectkindid==3){
  795 +
  796 + window.location.href='beginend.html'
  797 + }else if(selectkindid==4){
  798 + window.location.href='repeatday.html'
  799 + }
  800 + // $(this).addClass("active");
  801 + // $(this).siblings("li").removeClass("active")
  802 + });
  803 +
  804 +</script>
  805 +</html>
@@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
41 <!--</div>--> 41 <!--</div>-->
42 </div> 42 </div>
43 43
  44 +
44 <!--日历容器--> 45 <!--日历容器-->
45 <div id="calendar"> 46 <div id="calendar">
46 <div class="em-calendar-container"> 47 <div class="em-calendar-container">
@@ -572,7 +573,6 @@ @@ -572,7 +573,6 @@
572 <!--返回今天--> 573 <!--返回今天-->
573 <!--</div>--> 574 <!--</div>-->
574 575
575 -  
576 </body> 576 </body>
577 577
578 578
@@ -656,6 +656,7 @@ @@ -656,6 +656,7 @@
656 $(".addtaskcontent").click(function(){ 656 $(".addtaskcontent").click(function(){
657 window.location.href='newtask.html' 657 window.location.href='newtask.html'
658 }) 658 })
  659 +
659 </script> 660 </script>
660 661
661 </html> 662 </html>
@@ -595,26 +595,26 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -595,26 +595,26 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
595 595
596 // 头部日期计算 596 // 头部日期计算
597 for(var i = 1; i < nowXingQiJi + 1; i++) { 597 for(var i = 1; i < nowXingQiJi + 1; i++) {
598 - var preMonthDay = preDayCount - nowXingQiJi + i;  
599 - var tmpName = 'day' + i;  
600 - var lunar = 'lunar' + i;  
601 - //日、农历、完整日期  
602 - var y = parseInt(self.nowYear);  
603 - var m = parseInt(self.nowMonth);  
604 - m = -1 + m;  
605 - if(m == 0) {  
606 - m = 12  
607 - y = parseInt(self.nowYear - 1)  
608 - }  
609 - fileInfo[tmpName] = preMonthDay;  
610 - fileInfo[lunar] = self._getLunar(preMonthDay, m, y); 598 + // var preMonthDay = preDayCount - nowXingQiJi + i;
  599 + // var tmpName = 'day' + i;
  600 + // var lunar = 'lunar' + i;
  601 + // //日、农历、完整日期
  602 + // var y = parseInt(self.nowYear);
  603 + // var m = parseInt(self.nowMonth);
  604 + // m = -1 + m;
  605 + // if(m == 0) {
  606 + // m = 12
  607 + // y = parseInt(self.nowYear - 1)
  608 + // }
  609 + // fileInfo[tmpName] = preMonthDay;
  610 + // fileInfo[lunar] = self._getLunar(preMonthDay, m, y);
611 // console.log("农历:" + fileInfo[lunar]); 611 // console.log("农历:" + fileInfo[lunar]);
612 //存储前一个月数据 612 //存储前一个月数据
613 //console.log(self.nowYear + "-" + self.tom(parseInt(self.nowMonth - 1)) + "-" + self.tod(preMonthDay)); 613 //console.log(self.nowYear + "-" + self.tom(parseInt(self.nowMonth - 1)) + "-" + self.tod(preMonthDay));
614 tmpInfo.push({ 614 tmpInfo.push({
615 - day: preMonthDay, //日  
616 - lunar: self._getLunar(preMonthDay, m, y), //农历  
617 - date: y + "-" + self.tom(m) + "-" + self.tod(preMonthDay), //完整日期 615 + //day: preMonthDay, //日
  616 + // lunar: self._getLunar(preMonthDay, m, y), //农历
  617 + //date: y + "-" + self.tom(m) + "-" + self.tod(preMonthDay), //完整日期
618 isforbid: "0", //前一个月和后一个月不可点击 618 isforbid: "0", //前一个月和后一个月不可点击
619 tip: 'prev', 619 tip: 'prev',
620 }); 620 });
@@ -626,14 +626,14 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -626,14 +626,14 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
626 if(dayCount == '28') { 626 if(dayCount == '28') {
627 daonale = 28 + nowXingQiJi; 627 daonale = 28 + nowXingQiJi;
628 for(var index = nowXingQiJi + 1, indexindex = 1; index < (28 + nowXingQiJi + 1); index++, indexindex++) { 628 for(var index = nowXingQiJi + 1, indexindex = 1; index < (28 + nowXingQiJi + 1); index++, indexindex++) {
629 - var tmpName = 'day' + index; 629 + //var tmpName = 'day' + index;
630 var lunar = 'lunar' + index; 630 var lunar = 'lunar' + index;
631 - fileInfo[tmpName] = indexindex; 631 + // fileInfo[tmpName] = indexindex;
632 fileInfo[lunar] = self._getLunar(indexindex); 632 fileInfo[lunar] = self._getLunar(indexindex);
633 //存储当前月数据 633 //存储当前月数据
634 tmpInfo.push({ 634 tmpInfo.push({
635 day: indexindex, //日 635 day: indexindex, //日
636 - lunar: self._getLunar(indexindex), //农历 636 + lunar: self._getLunar(indexindex), //农历
637 date: self.nowYear + "-" + self.tom(self.nowMonth) + "-" + self.tod(indexindex), //完整日期 637 date: self.nowYear + "-" + self.tom(self.nowMonth) + "-" + self.tod(indexindex), //完整日期
638 isforbid: "1" //当前月可点击 638 isforbid: "1" //当前月可点击
639 }); 639 });
@@ -644,9 +644,9 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -644,9 +644,9 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
644 if(dayCount == '29') { 644 if(dayCount == '29') {
645 daonale = 29 + nowXingQiJi; 645 daonale = 29 + nowXingQiJi;
646 for(var index = nowXingQiJi + 1, indexindex = 1; index < (29 + nowXingQiJi + 1); index++, indexindex++) { 646 for(var index = nowXingQiJi + 1, indexindex = 1; index < (29 + nowXingQiJi + 1); index++, indexindex++) {
647 - var tmpName = 'day' + index;  
648 - var lunar = 'lunar' + index;  
649 - fileInfo[tmpName] = indexindex; 647 + //var tmpName = 'day' + index;
  648 + var lunar = 'lunar' + index;
  649 + // fileInfo[tmpName] = indexindex;
650 fileInfo[lunar] = self._getLunar(indexindex); 650 fileInfo[lunar] = self._getLunar(indexindex);
651 //存储当前月数据 651 //存储当前月数据
652 tmpInfo.push({ 652 tmpInfo.push({
@@ -662,9 +662,9 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -662,9 +662,9 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
662 if(dayCount == '30') { 662 if(dayCount == '30') {
663 daonale = 30 + nowXingQiJi; 663 daonale = 30 + nowXingQiJi;
664 for(var index = nowXingQiJi + 1, indexindex = 1; index < (30 + nowXingQiJi + 1); index++, indexindex++) { 664 for(var index = nowXingQiJi + 1, indexindex = 1; index < (30 + nowXingQiJi + 1); index++, indexindex++) {
665 - var tmpName = 'day' + index; 665 + // var tmpName = 'day' + index;
666 var lunar = 'lunar' + index; 666 var lunar = 'lunar' + index;
667 - fileInfo[tmpName] = indexindex; 667 + // fileInfo[tmpName] = indexindex;
668 fileInfo[lunar] = self._getLunar(indexindex); 668 fileInfo[lunar] = self._getLunar(indexindex);
669 //存储当前月数据 669 //存储当前月数据
670 tmpInfo.push({ 670 tmpInfo.push({
@@ -679,10 +679,10 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -679,10 +679,10 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
679 if(dayCount == '31') { 679 if(dayCount == '31') {
680 daonale = 31 + nowXingQiJi; 680 daonale = 31 + nowXingQiJi;
681 for(var index = nowXingQiJi + 1, indexindex = 1; index < (31 + nowXingQiJi + 1); index++, indexindex++) { 681 for(var index = nowXingQiJi + 1, indexindex = 1; index < (31 + nowXingQiJi + 1); index++, indexindex++) {
682 - var tmpName = 'day' + index; 682 + //var tmpName = 'day' + index;
683 var lunar = 'lunar' + index; 683 var lunar = 'lunar' + index;
684 - fileInfo[tmpName] = indexindex;  
685 - fileInfo[lunar] = self._getLunar(indexindex); 684 + //fileInfo[tmpName] = indexindex;
  685 + //fileInfo[lunar] = self._getLunar(indexindex);
686 //存储当前月数据 686 //存储当前月数据
687 tmpInfo.push({ 687 tmpInfo.push({
688 day: indexindex, //日 688 day: indexindex, //日
@@ -696,22 +696,22 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -696,22 +696,22 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
696 // 尾部日期计算 696 // 尾部日期计算
697 for(var index2 = daonale + 1, index3 = 1; index2 <= 42; index2++, index3++) { 697 for(var index2 = daonale + 1, index3 = 1; index2 <= 42; index2++, index3++) {
698 var tmpName = 'day' + index2; 698 var tmpName = 'day' + index2;
699 - var lunar = 'lunar' + index2; 699 + //var lunar = 'lunar' + index2;
700 //日、农历、完整日期 700 //日、农历、完整日期
701 - var y2 = parseInt(self.nowYear);  
702 - var m2 = parseInt(self.nowMonth) + parseInt(1);  
703 - if(m2 == 13) {  
704 - m2 = 1;  
705 - y2 = parseInt(self.nowYear) + parseInt(1)  
706 - }  
707 - fileInfo[tmpName] = index3;  
708 - fileInfo[lunar] = self._getLunar(index3, m2, y2); 701 + // var y2 = parseInt(self.nowYear);
  702 + // var m2 = parseInt(self.nowMonth) + parseInt(1);
  703 + // if(m2 == 13) {
  704 + // m2 = 1;
  705 + // y2 = parseInt(self.nowYear) + parseInt(1)
  706 + // }
  707 + // // fileInfo[tmpName] = index3;
  708 + // fileInfo[lunar] = self._getLunar(index3, m2, y2);
709 //存储当前月数据 709 //存储当前月数据
710 tmpInfo.push({ 710 tmpInfo.push({
711 - day: index3, //日  
712 - lunar: self._getLunar(index3, m2, y2), //农历  
713 - date: y2 + "-" + self.tom(m2) + "-" + self.tod(index3), //完整日期  
714 - isforbid: "0", //前一月和后一月不可点击 711 + // day: index3, //日
  712 + // lunar: self._getLunar(index3, m2, y2), //农历
  713 + // date: y2 + "-" + self.tom(m2) + "-" + self.tod(index3), //完整日期
  714 + // isforbid: "0", //前一月和后一月不可点击
715 tip: 'next', 715 tip: 'next',
716 }); 716 });
717 //console.log("后面一个月的数据:\n" + JSON.stringify(tmpInfo) + "\n"); 717 //console.log("后面一个月的数据:\n" + JSON.stringify(tmpInfo) + "\n");
@@ -919,6 +919,7 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -919,6 +919,7 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
919 // 可点击区域 919 // 可点击区域
920 if(!_this.classList.contains('isforbid0')) { 920 if(!_this.classList.contains('isforbid0')) {
921 if(_this.getAttribute("date")) { 921 if(_this.getAttribute("date")) {
  922 + // console.log(_this.getAttribute("date"))
922 _this.classList.add('em-calendar-active'); 923 _this.classList.add('em-calendar-active');
923 self.sibling(_this, function (el) { 924 self.sibling(_this, function (el) {
924 el.classList.remove('em-calendar-active'); 925 el.classList.remove('em-calendar-active');
@@ -1123,6 +1124,9 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -1123,6 +1124,9 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
1123 // 给前后月的点击日期加选中标记 1124 // 给前后月的点击日期加选中标记
1124 var clickactives = document.querySelector('.swiper-slide-active').querySelectorAll('.em-calendar-item'); 1125 var clickactives = document.querySelector('.swiper-slide-active').querySelectorAll('.em-calendar-item');
1125 for(var i = 0; i < clickactives.length; i++) { 1126 for(var i = 0; i < clickactives.length; i++) {
  1127 + clickactives[i].onclick=function(){
  1128 +
  1129 + }
1126 if(clickactives[i].getAttribute("date") == dateStr) { 1130 if(clickactives[i].getAttribute("date") == dateStr) {
1127 clickactives[i].classList.add('em-calendar-active'); 1131 clickactives[i].classList.add('em-calendar-active');
1128 self.sibling(clickactives[i], function (el) { 1132 self.sibling(clickactives[i], function (el) {
@@ -1176,7 +1180,7 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -1176,7 +1180,7 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
1176 * 获取当前农历 1180 * 获取当前农历
1177 * @param {Object} currentday 1181 * @param {Object} currentday
1178 * @param {Object} month 1182 * @param {Object} month
1179 - * @return {String} 1183 + * @return {String}
1180 */ 1184 */
1181 _getLunar: function (currentday, month, year) { 1185 _getLunar: function (currentday, month, year) {
1182 var self = this; 1186 var self = this;
@@ -1242,17 +1246,17 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -1242,17 +1246,17 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
1242 * @param {Object} arr 有效数组 1246 * @param {Object} arr 有效数组
1243 */ 1247 */
1244 _inArray: function (str, arr) { 1248 _inArray: function (str, arr) {
1245 - // 不是数组则抛出异常 1249 + // 不是数组则抛出异常
1246 if(!Array.isArray(arr)) { 1250 if(!Array.isArray(arr)) {
1247 throw "arguments is not Array"; 1251 throw "arguments is not Array";
1248 } 1252 }
1249 - // 遍历是否在数组中 1253 + // 遍历是否在数组中
1250 for(var i = 0, k = arr.length; i < k; i++) { 1254 for(var i = 0, k = arr.length; i < k; i++) {
1251 if(str == arr[i]) { 1255 if(str == arr[i]) {
1252 return true; 1256 return true;
1253 } 1257 }
1254 } 1258 }
1255 - // 如果不在数组中就会返回false 1259 + // 如果不在数组中就会返回false
1256 return false; 1260 return false;
1257 }, 1261 },
1258 // 遍历查找同级元素 1262 // 遍历查找同级元素
@@ -1269,7 +1273,7 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -1269,7 +1273,7 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
1269 }, 1273 },
1270 _getBit: function (m, n) { 1274 _getBit: function (m, n) {
1271 var self = this; 1275 var self = this;
1272 - // 农历转换 1276 + // 农历转换
1273 return(m >> n) & 1; 1277 return(m >> n) & 1;
1274 }, 1278 },
1275 _e2c: function () { 1279 _e2c: function () {
@@ -1331,7 +1335,7 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -1331,7 +1335,7 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
1331 }, 1335 },
1332 _getLunarDay: function (solarYear, solarMonth, solarDay) { 1336 _getLunarDay: function (solarYear, solarMonth, solarDay) {
1333 var self = this; 1337 var self = this;
1334 - //solarYear = solarYear<1900?(1900+solarYear):solarYear; 1338 + //solarYear = solarYear<1900?(1900+solarYear):solarYear;
1335 if(solarYear < 1921 || solarYear > 2080) { 1339 if(solarYear < 1921 || solarYear > 2080) {
1336 return ""; 1340 return "";
1337 } else { 1341 } else {
@@ -1422,6 +1426,6 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) { @@ -1422,6 +1426,6 @@ window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
1422 }, 1426 },
1423 1427
1424 }; 1428 };
1425 -  
1426 window.Calendar = Calendar; 1429 window.Calendar = Calendar;
1427 -})();  
  1430 +
  1431 +})();
  1 +/**
  2 + * 作者: 孙尊路
  3 + * 创建时间: 2017-07-14 13:26:47
  4 + * 版本: [1.0, 2017/7/14]
  5 + * 版权: 江苏国泰新点软件有限公司
  6 + * 说明: 常用工具js
  7 + */
  8 +window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
  9 +
  10 + /**
  11 + * 产生一个 唯一uuid,默认为32位的随机字符串,8-4-4-4-12 格式
  12 + * @param {Object} options 配置参数
  13 + * len 默认为32位,最大不能超过36,最小不能小于4
  14 + * radix 随机的基数,如果小于等于10代表只用纯数字,最大为62,最小为2,默认为62
  15 + * type 类别,默认为default代表 8-4-4-4-12的模式,如果为 noline代表不会有连线
  16 + * @return {String} 返回一个随机性的唯一uuid
  17 + */
  18 + exports.uuid = function (options) {
  19 + options = options || {};
  20 +
  21 + var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),
  22 + uuid = [],
  23 + i;
  24 + var radix = options.radix || chars.length;
  25 + var len = options.len || 32;
  26 + var type = options.type || 'default';
  27 +
  28 + len = Math.min(len, 36);
  29 + len = Math.max(len, 4);
  30 + radix = Math.min(radix, 62);
  31 + radix = Math.max(radix, 2);
  32 +
  33 + if(len) {
  34 + for(i = 0; i < len; i++) {
  35 + uuid[i] = chars[0 | Math.random() * radix];
  36 + }
  37 +
  38 + if(type === 'default') {
  39 + len > 23 && (uuid[23] = '-');
  40 + len > 18 && (uuid[18] = '-');
  41 + len > 13 && (uuid[13] = '-');
  42 + len > 8 && (uuid[8] = '-');
  43 + }
  44 + }
  45 +
  46 + return uuid.join('');
  47 + };
  48 +
  49 + var class2type = {};
  50 +
  51 + exports.noop = function () {};
  52 +
  53 + exports.isFunction = function (value) {
  54 + return exports.type(value) === 'function';
  55 + };
  56 + exports.isPlainObject = function (obj) {
  57 + return exports.isObject(obj) && !exports.isWindow(obj) && Object.getPrototypeOf(obj) === Object.prototype;
  58 + };
  59 + exports.isArray = Array.isArray ||
  60 + function (object) {
  61 + return object instanceof Array;
  62 + };
  63 +
  64 + /**
  65 + * isWindow(需考虑obj为undefined的情况)
  66 + * @param {Object} obj 需要判断的对象
  67 + * @return {Boolean} 返回true或false
  68 + */
  69 + exports.isWindow = function (obj) {
  70 + return obj && obj === window;
  71 + };
  72 + exports.isObject = function (obj) {
  73 + return exports.type(obj) === 'object';
  74 + };
  75 + exports.type = function (obj) {
  76 + return(obj === null || obj === undefined) ? String(obj) : class2type[{}.toString.call(obj)] || 'object';
  77 + };
  78 + /**
  79 + * each遍历操作
  80 + * @param {Object} elements 元素
  81 + * @param {Function} callback 回调
  82 + * @param {Function} hasOwnProperty 过滤函数
  83 + * @returns {global} 返回调用的上下文
  84 + */
  85 + exports.each = function (elements, callback, hasOwnProperty) {
  86 + if(!elements) {
  87 + return this;
  88 + }
  89 + if(typeof elements.length === 'number') {
  90 + [].every.call(elements, function (el, idx) {
  91 + return callback.call(el, idx, el) !== false;
  92 + });
  93 + } else {
  94 + for(var key in elements) {
  95 + if(hasOwnProperty) {
  96 + if(elements.hasOwnProperty(key)) {
  97 + if(callback.call(elements[key], key, elements[key]) === false) {
  98 + return elements;
  99 + }
  100 + }
  101 + } else {
  102 + if(callback.call(elements[key], key, elements[key]) === false) {
  103 + return elements;
  104 + }
  105 + }
  106 + }
  107 + }
  108 +
  109 + return this;
  110 + };
  111 +
  112 + /**
  113 + * extend 合并多个对象,可以递归合并
  114 + * @param {type} deep 是否递归合并
  115 + * @param {type} target 最终返回的就是target
  116 + * @param {type} source 从左到又,优先级依次提高,最右侧的是最后覆盖的
  117 + * @returns {Object} 最终的合并对象
  118 + */
  119 + exports.extend = function () {
  120 + var args = [].slice.call(arguments);
  121 +
  122 + // 目标
  123 + var target = args[0] || {},
  124 + // 默认source从1开始
  125 + index = 1,
  126 + len = args.length,
  127 + // 默认非深复制
  128 + deep = false;
  129 +
  130 + if(typeof target === 'boolean') {
  131 + // 如果开启了深复制
  132 + deep = target;
  133 + target = args[index] || {};
  134 + index++;
  135 + }
  136 +
  137 + if(!exports.isObject(target)) {
  138 + // 确保拓展的一定是object
  139 + target = {};
  140 + }
  141 +
  142 + for(; index < len; index++) {
  143 + // source的拓展
  144 + var source = args[index];
  145 +
  146 + if(source && exports.isObject(source)) {
  147 + for(var name in source) {
  148 + if(!Object.prototype.hasOwnProperty.call(source, name)) {
  149 + // 防止原型上的数据
  150 + continue;
  151 + }
  152 +
  153 + var src = target[name];
  154 + var copy = source[name];
  155 + var clone,
  156 + copyIsArray;
  157 +
  158 + if(target === copy) {
  159 + // 防止环形引用
  160 + continue;
  161 + }
  162 +
  163 + // 这里必须用isPlainObject,只有同样是普通的object才会复制继承,如果是FormData之流的,会走后面的覆盖路线
  164 + if(deep && copy && (exports.isPlainObject(copy) || (copyIsArray = exports.isArray(copy)))) {
  165 + if(copyIsArray) {
  166 + copyIsArray = false;
  167 + clone = src && exports.isArray(src) ? src : [];
  168 + } else {
  169 + clone = src && exports.isPlainObject(src) ? src : {};
  170 + }
  171 +
  172 + target[name] = exports.extend(deep, clone, copy);
  173 + } else if(copy !== undefined) {
  174 + // 如果不是普通的object,直接覆盖,例如FormData之类的会覆盖
  175 + target[name] = copy;
  176 + }
  177 + }
  178 + }
  179 + }
  180 +
  181 + return target;
  182 + };
  183 +
  184 + exports.each(['Boolean', 'Number', 'String', 'Function', 'Array', 'Date', 'RegExp', 'Object', 'Error'], function (i, name) {
  185 + class2type['[object ' + name + ']'] = name.toLowerCase();
  186 + });
  187 +
  188 + /**
  189 + * 选择这段代码用到的太多了,因此抽取封装出来
  190 + * @param {Object} element dom元素或者selector
  191 + * @return {HTMLElement} 返回对应的dom
  192 + */
  193 + exports.selector = function (element) {
  194 + if(typeof element === 'string') {
  195 + element = document.querySelector(element);
  196 + }
  197 +
  198 + return element;
  199 + };
  200 +
  201 + /**
  202 + * 设置一个Util对象下的命名空间
  203 + * @param {String} namespace 命名空间
  204 + * @param {Object} obj 需要赋值的目标对象
  205 + * @return {Object} 返回目标对象
  206 + */
  207 + exports.namespace = function (namespace, obj) {
  208 + var parent = window.Util;
  209 +
  210 + if(!namespace) {
  211 + return parent;
  212 + }
  213 +
  214 + var namespaceArr = namespace.split('.'),
  215 + len = namespaceArr.length;
  216 +
  217 + for(var i = 0; i < len - 1; i++) {
  218 + var tmp = namespaceArr[i];
  219 +
  220 + // 不存在的话要重新创建对象
  221 + parent[tmp] = parent[tmp] || {};
  222 + // parent要向下一级
  223 + parent = parent[tmp];
  224 + }
  225 + parent[namespaceArr[len - 1]] = obj;
  226 +
  227 + return parent[namespaceArr[len - 1]];
  228 + };
  229 +
  230 + /**
  231 + * 获取这个模块下对应命名空间的对象
  232 + * 如果不存在,则返回null,这个api只要是供内部获取接口数据时调用
  233 + * @param {Object} module 模块
  234 + * @param {Array} namespace 命名空间
  235 + * @return {Object} 返回目标对象
  236 + */
  237 + exports.getNameSpaceObj = function (module, namespace) {
  238 + if(!namespace) {
  239 + return null;
  240 + }
  241 + var namespaceArr = namespace.split('.'),
  242 + len = namespaceArr.length;
  243 +
  244 + for(var i = 0; i < len; i++) {
  245 + module && (module = module[namespaceArr[i]]);
  246 + }
  247 +
  248 + return module;
  249 + };
  250 +
  251 + /**
  252 + * 将string字符串转为html对象,默认创一个div填充
  253 + * 因为很常用,所以单独提取出来了
  254 + * @param {String} strHtml 目标字符串
  255 + * @return {HTMLElement} 返回处理好后的html对象,如果字符串非法,返回null
  256 + */
  257 + exports.parseHtml = function (strHtml) {
  258 + if(!strHtml || typeof (strHtml) !== 'string') {
  259 + return null;
  260 + }
  261 + // 创一个灵活的div
  262 + var i,
  263 + a = document.createElement('div');
  264 + var b = document.createDocumentFragment();
  265 +
  266 + a.innerHTML = strHtml;
  267 + while((i = a.firstChild)) {
  268 + b.appendChild(i);
  269 + }
  270 +
  271 + return b;
  272 + };
  273 +
  274 + /**
  275 + * 图片的base64字符串转Blob
  276 + * @param {String} urlData 完整的base64字符串
  277 + * @return {Blob} 转换后的Blob对象,可用于表单文件上传
  278 + */
  279 + exports.base64ToBlob = function (urlData) {
  280 + var arr = urlData.split(',');
  281 + var mime = arr[0].match(/:(.*?);/)[1] || 'image/png';
  282 + // 去掉url的头,并转化为byte
  283 + var bytes = window.atob(arr[1]);
  284 + // 处理异常,将ascii码小于0的转换为大于0
  285 + var ab = new ArrayBuffer(bytes.length);
  286 + // 生成视图(直接针对内存):8位无符号整数,长度1个字节
  287 + var ia = new Uint8Array(ab);
  288 +
  289 + for(var i = 0; i < bytes.length; i++) {
  290 + ia[i] = bytes.charCodeAt(i);
  291 + }
  292 +
  293 + return new Blob([ab], {
  294 + type: mime
  295 + });
  296 + };
  297 +
  298 + /**
  299 + * 通过传入key值,得到页面key的初始化传值
  300 + * 实际情况是获取 window.location.href 中的参数的值
  301 + * @param {String} key 键名
  302 + * @return {String} 键值
  303 + */
  304 + exports.getExtraDataByKey = function (key) {
  305 + if(!key) {
  306 + return null;
  307 + }
  308 + // 获取url中的参数值
  309 + var getUrlParamsValue = function (url, paramName) {
  310 + var paraString = url.substring(url.indexOf('?') + 1, url.length).split('&');
  311 + var paraObj = {};
  312 + var i,
  313 + j;
  314 +
  315 + for(i = 0;
  316 + (j = paraString[i]); i++) {
  317 + paraObj[j.substring(0, j.indexOf('=')).toLowerCase()] = j.substring(j.indexOf('=') + 1, j.length);
  318 + }
  319 + var returnValue = paraObj[paramName.toLowerCase()];
  320 +
  321 + // 需要解码浏览器编码
  322 + returnValue = decodeURIComponent(returnValue);
  323 + if(typeof (returnValue) === 'undefined') {
  324 + return undefined;
  325 + } else {
  326 + return returnValue;
  327 + }
  328 + };
  329 + var value = getUrlParamsValue(window.location.href, key);
  330 +
  331 + if(value === 'undefined') {
  332 + value = null;
  333 + }
  334 +
  335 + return value;
  336 + };
  337 +
  338 + // 避免提示警告
  339 + var Console = console;
  340 +
  341 + exports.log = function () {
  342 + // 方便后续控制
  343 + Console.log.apply(this, arguments);
  344 + };
  345 +
  346 + exports.warn = function () {
  347 + Console.warn.apply(this, arguments);
  348 + };
  349 +
  350 + exports.error = function () {
  351 + Console.error.apply(this, arguments);
  352 + };
  353 +
  354 + return exports;
  355 +})({});
  356 +/**
  357 + * 作者: 孙尊路
  358 + * 创建时间: 2017-07-14 13:26:47
  359 + * 版本: [1.0, 2017/7/14]
  360 + * 版权: 江苏国泰新点软件有限公司
  361 + * 描述:日历组件基类
  362 + * 实现方案:自定义日历组件+swiper插件的完美结合。
  363 + * 更新日志:
  364 + * (1)修复了农历显示不正确、不对应的问题
  365 + * (2)增加了外部刷新的方法
  366 + * (3)整体优化日程的解耦合情形
  367 + * (4)优化实例化日期,增加时间戳
  368 + */
  369 +
  370 +(function () {
  371 + "use strict";
  372 +
  373 + /**
  374 + * 全局生效默认设置
  375 + * 默认设置可以最大程度的减小调用时的代码
  376 + */
  377 + var defaultOptions = {
  378 + // 默认日历组件容器
  379 + container: "#calendar",
  380 + // swiper滑动容器
  381 + swiper: ".swiper-container",
  382 + // 默认显示农历
  383 + isLunar: true,
  384 + // 默认开启水平方向切换月份
  385 + isSwipeH: true,
  386 + // 默认开启垂直方向切换月份
  387 + isSwipeV: true,
  388 + // 滑动回调
  389 + swipeCallback: noop,
  390 + // 上一月节点
  391 + pre: ".pre",
  392 + // 上一月回调
  393 + preCallback: noop,
  394 + // 下一月节点
  395 + next: ".next",
  396 + // 下一月回调
  397 + nextCallback: noop,
  398 + // 点击回调
  399 + onItemClick: noop,
  400 + // 自定义输入模板
  401 + template: noop,
  402 + // 业务数据绑定
  403 + dataRequest: noop,
  404 + // 是否开启调试
  405 + isDebug: false
  406 + };
  407 +
  408 + function noop() {}
  409 +
  410 + /**
  411 + * 日历的构造函数
  412 + * @param {Object} options 配置参数,和init以及_initData的一致
  413 + * @constructor
  414 + */
  415 + function Calendar(options) {
  416 +
  417 + options = innerCalendarUtil.extend({}, defaultOptions, options);
  418 + if(!this._selector(options.container)) {
  419 + // 抛异常
  420 + throw new Error("传入的日历组件容器Selector #id不存在或者为空,请仔细检查!");
  421 + return;
  422 + }
  423 + this.container = this._selector(options.container);
  424 +
  425 + this._initData(options);
  426 + }
  427 +
  428 + Calendar.prototype = {
  429 + /**
  430 + * 初始化数据单独提取,方便refreshData使用
  431 + * @param {Object} options 配置参数
  432 + */
  433 + _initData: function (options) {
  434 + var self = this;
  435 + this.options = options;
  436 +
  437 + // 创建日历DOM结构体
  438 + this.CreateDOMFactory(function () {
  439 + // 程序入口
  440 + self._initParams();
  441 + });
  442 + },
  443 + _initParams: function () {
  444 + var self = this;
  445 + self.nowYear = self.DateObj().getFullYear();
  446 + self.nowMonth = self.tod(self.DateObj().getMonth() + 1);
  447 + self.nowDay = self.tod(self.DateObj().getDate());
  448 + // 当前日期
  449 + self.currentDate = self.nowYear + "-" + self.nowMonth + "-" + self.nowDay;
  450 +
  451 + // 定义全局变量 计算农历
  452 + self.CalendarData = new Array(100);
  453 + self.madd = new Array(12);
  454 + self.tgString = "甲乙丙丁戊己庚辛壬癸";
  455 + self.dzString = "子丑寅卯辰巳午未申酉戌亥";
  456 + self.numString = "一二三四五六七八九十";
  457 + self.monString = "正二三四五六七八九十冬腊";
  458 + self.weekString = "日一二三四五六";
  459 + self.sx = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
  460 + self.cYear, self.cMonth, self.cDay, self.TheDate;
  461 + self.CalendarData = new Array(0xA4B, 0x5164B, 0x6A5, 0x6D4, 0x415B5, 0x2B6, 0x957, 0x2092F, 0x497, 0x60C96, 0xD4A, 0xEA5, 0x50DA9, 0x5AD, 0x2B6, 0x3126E, 0x92E, 0x7192D, 0xC95, 0xD4A, 0x61B4A, 0xB55, 0x56A, 0x4155B, 0x25D, 0x92D, 0x2192B, 0xA95, 0x71695, 0x6CA, 0xB55, 0x50AB5, 0x4DA, 0xA5B, 0x30A57, 0x52B, 0x8152A, 0xE95, 0x6AA, 0x615AA, 0xAB5, 0x4B6, 0x414AE, 0xA57, 0x526, 0x31D26, 0xD95, 0x70B55, 0x56A, 0x96D, 0x5095D, 0x4AD, 0xA4D, 0x41A4D, 0xD25, 0x81AA5, 0xB54, 0xB6A, 0x612DA, 0x95B, 0x49B, 0x41497, 0xA4B, 0xA164B, 0x6A5, 0x6D4, 0x615B4, 0xAB6, 0x957, 0x5092F, 0x497, 0x64B, 0x30D4A, 0xEA5, 0x80D65, 0x5AC, 0xAB6, 0x5126D, 0x92E, 0xC96, 0x41A95, 0xD4A, 0xDA5, 0x20B55, 0x56A, 0x7155B, 0x25D, 0x92D, 0x5192B, 0xA95, 0xB4A, 0x416AA, 0xAD5, 0x90AB5, 0x4BA, 0xA5B, 0x60A57, 0x52B, 0xA93, 0x40E95);
  462 + self.madd[0] = 0;
  463 + self.madd[1] = 31;
  464 + self.madd[2] = 59;
  465 + self.madd[3] = 90;
  466 + self.madd[4] = 120;
  467 + self.madd[5] = 151;
  468 + self.madd[6] = 181;
  469 + self.madd[7] = 212;
  470 + self.madd[8] = 243;
  471 + self.madd[9] = 273;
  472 + self.madd[10] = 304;
  473 + self.madd[11] = 334;
  474 +
  475 + // 生成日历
  476 + self.initEntry();
  477 +
  478 + },
  479 + /**
  480 + * 初始化日历
  481 + */
  482 + initEntry: function (op) {
  483 + var self = this;
  484 + var options = innerCalendarUtil.extend({
  485 + year: "",
  486 + month: "",
  487 + day: ""
  488 + }, op);
  489 + //console.log("合并后:"+JSON.stringify(options));
  490 + // 获取前一个月份
  491 + if(!options.year) {
  492 + options.year = self.DateObj().getFullYear(); //默认不传为"当前年"
  493 + } else {
  494 + options.year = op.year;
  495 + }
  496 + if(!options.month) {
  497 + options.month = self.tod(self.DateObj().getMonth() + 1); //默认不传为"当前月"
  498 + } else {
  499 + options.month = op.month;
  500 + }
  501 +
  502 + var preYear = options.year;
  503 + var m = options.month;
  504 + var preMonth = parseInt(m) - parseInt(1);
  505 +
  506 + if(preMonth == 0) {
  507 + preYear = options.year - 1;
  508 + preMonth = 12;
  509 + }
  510 + preMonth = self.tom(preMonth);
  511 + var preDay = self.tod("01");
  512 + //if(self.options.isDebug) {
  513 + if(self.options.isDebug) {
  514 + console.log("(前)初始化年月日:" + preYear + "-" + preMonth + "-" + preDay);
  515 +
  516 + }
  517 +
  518 + // 生成上一个月份的日历
  519 + var outputs = [];
  520 + self.refreshData({
  521 + year: preYear,
  522 + month: preMonth,
  523 + day: preDay
  524 + }, function (output) {
  525 + outputs.push({
  526 + templ: output
  527 + });
  528 +
  529 + // 初始化默认当前日期
  530 + var curYear = options.year || self.DateObj().getFullYear();
  531 + var curMonth = options.month || self.tod(self.DateObj().getMonth() + 1);
  532 + var curDay = options.day || self.tod(self.DateObj().getDate());
  533 + //alert("默认对不对:"+curYear+"-"+curMonth+"-"+curDay);
  534 + self.curYear = options.year || self.DateObj().getFullYear();
  535 + self.curMonth = options.month || self.tod(self.DateObj().getMonth() + 1);
  536 + self.curDay = options.day || self.tod(self.DateObj().getDate());
  537 + if(self.options.isDebug) {
  538 + console.log("(中)初始化年月日:" + curYear + "-" + curMonth + "-" + curDay);
  539 + }
  540 +
  541 + // 生成本月份的日历
  542 + self.refreshData({
  543 + year: curYear,
  544 + month: curMonth,
  545 + day: curDay
  546 + }, function (output1) {
  547 + outputs.push({
  548 + templ: output1
  549 + });
  550 + // 渲染日历模板
  551 + var templ = self.SLIDER_ITEM_CONTAINER;
  552 +
  553 + var html = "";
  554 + for(var i = 0; i < outputs.length; i++) {
  555 + html += Mustache.render(templ, outputs[i]);
  556 + }
  557 + document.querySelector(".swiper-wrapper").innerHTML = html;
  558 + // 初始化swiper监听
  559 + self._addEvent();
  560 + });
  561 + });
  562 + },
  563 + /**
  564 + * 刷新日历,传入日期格式须:2017-07-01 或2017-12-09
  565 + */
  566 + //refreshData: function(year, month, day, activeSlideNode) {
  567 + refreshData: function (dateObj, callback) {
  568 + var self = this;
  569 +
  570 + self.nowYear = parseInt(dateObj.year);
  571 + self.nowMonth = self.tom(dateObj.month);
  572 + self.nowDay = self.tod(dateObj.day);
  573 +
  574 + // 获取星期
  575 + var tmptmp = new Date(Date.parse(self.nowYear + '/' + self.nowMonth + '/01'));
  576 + var nowXingQiJi = tmptmp.getDay();
  577 + // console.log("星期"+nowXingQiJi);
  578 + nowXingQiJi = parseInt(nowXingQiJi);
  579 + if(nowXingQiJi == 0) {
  580 + nowXingQiJi = 7;
  581 + }
  582 + // 根据年份、月份 计算月份中的天数(比如:28、29、30、31等)
  583 + var dayCount = self._judgeDaysByYearMonth(self.nowYear, self.nowMonth);
  584 + // 总天数
  585 + self.dayCount = dayCount;
  586 + // 保留老的存储方式
  587 + var fileInfo = {};
  588 + // 新的存储方式
  589 + var tmpInfo = [];
  590 +
  591 + var preDayCount = self._judgeDaysByYearMonth(self.nowYear, parseInt(self.nowMonth - 1));
  592 + //console.log("前一月总天数:" + preDayCount);
  593 + preDayCount = parseInt(preDayCount);
  594 +
  595 + // 头部日期计算
  596 + for(var i = 1; i < nowXingQiJi + 1; i++) {
  597 + // var preMonthDay = preDayCount - nowXingQiJi + i;
  598 + // var tmpName = 'day' + i;
  599 + //var lunar = 'lunar' + i;
  600 + //日、农历、完整日期
  601 + var y = parseInt(self.nowYear);
  602 + var m = parseInt(self.nowMonth);
  603 + m = -1 + m;
  604 + if(m == 0) {
  605 + m = 12
  606 + y = parseInt(self.nowYear - 1)
  607 + }
  608 + // fileInfo[tmpName] = preMonthDay;
  609 + // fileInfo[lunar] = self._getLunar(preMonthDay, m, y);
  610 + // console.log("农历:" + fileInfo[lunar]);
  611 + //存储前一个月数据
  612 + //console.log(self.nowYear + "-" + self.tom(parseInt(self.nowMonth - 1)) + "-" + self.tod(preMonthDay));
  613 + tmpInfo.push({
  614 + // day: preMonthDay, //日
  615 + // lunar: self._getLunar(preMonthDay, m, y), //农历
  616 + // date: y + "-" + self.tom(m) + "-" + self.tod(preMonthDay), //完整日期
  617 + isforbid: "0", //前一个月和后一个月不可点击
  618 + tip: 'prev',
  619 + });
  620 + //console.log("年份:" + self.nowYear);
  621 + //console.log("上个月的数据:\n" + JSON.stringify(tmpInfo)+"\n");
  622 + }
  623 + var daonale = 0;
  624 +
  625 + if(dayCount == '28') {
  626 + daonale = 28 + nowXingQiJi;
  627 + for(var index = nowXingQiJi + 1, indexindex = 1; index < (28 + nowXingQiJi + 1); index++, indexindex++) {
  628 + //var tmpName = 'day' + index;
  629 + var lunar = 'lunar' + index;
  630 + // fileInfo[tmpName] = indexindex;
  631 + fileInfo[lunar] = self._getLunar(indexindex);
  632 + //存储当前月数据
  633 + tmpInfo.push({
  634 + day: indexindex, //日
  635 + lunar: self._getLunar(indexindex), //农历
  636 + date: self.nowYear + "-" + self.tom(self.nowMonth) + "-" + self.tod(indexindex), //完整日期
  637 + isforbid: "1" //当前月可点击
  638 + });
  639 + // console.log(self.tom(parseInt(self.nowMonth)) + "月份:" + self.tod(indexindex));
  640 +
  641 + }
  642 + }
  643 + if(dayCount == '29') {
  644 + daonale = 29 + nowXingQiJi;
  645 + for(var index = nowXingQiJi + 1, indexindex = 1; index < (29 + nowXingQiJi + 1); index++, indexindex++) {
  646 + //var tmpName = 'day' + index;
  647 + var lunar = 'lunar' + index;
  648 + //fileInfo[tmpName] = indexindex;
  649 + fileInfo[lunar] = self._getLunar(indexindex);
  650 + //存储当前月数据
  651 + tmpInfo.push({
  652 + day: indexindex, //日
  653 + lunar: self._getLunar(indexindex), //农历
  654 + date: self.nowYear + "-" + self.tom(self.nowMonth) + "-" + self.tod(indexindex), //完整日期
  655 + isforbid: "1" //当前月可点击
  656 + });
  657 + //console.log(self.tom(parseInt(self.nowMonth)) + "月份:" + self.tod(indexindex));
  658 +
  659 + }
  660 + }
  661 + if(dayCount == '30') {
  662 + daonale = 30 + nowXingQiJi;
  663 + for(var index = nowXingQiJi + 1, indexindex = 1; index < (30 + nowXingQiJi + 1); index++, indexindex++) {
  664 + //var tmpName = 'day' + index;
  665 + var lunar = 'lunar' + index;
  666 + //fileInfo[tmpName] = indexindex;
  667 + fileInfo[lunar] = self._getLunar(indexindex);
  668 + //存储当前月数据
  669 + tmpInfo.push({
  670 + day: indexindex, //日
  671 + lunar: self._getLunar(indexindex), //农历
  672 + date: self.nowYear + "-" + self.tom(self.nowMonth) + "-" + self.tod(indexindex), //完整日期
  673 + isforbid: "1" //当前月可点击
  674 + });
  675 + //console.log(self.tom(parseInt(self.nowMonth)) + "月份:" + self.tod(indexindex));
  676 + }
  677 + }
  678 + if(dayCount == '31') {
  679 + daonale = 31 + nowXingQiJi;
  680 + for(var index = nowXingQiJi + 1, indexindex = 1; index < (31 + nowXingQiJi + 1); index++, indexindex++) {
  681 + //var tmpName = 'day' + index;
  682 + var lunar = 'lunar' + index;
  683 + //fileInfo[tmpName] = indexindex;
  684 + fileInfo[lunar] = self._getLunar(indexindex);
  685 + //存储当前月数据
  686 + tmpInfo.push({
  687 + day: indexindex, //日
  688 + lunar: self._getLunar(indexindex), //农历
  689 + date: self.nowYear + "-" + self.tom(self.nowMonth) + "-" + self.tod(indexindex), //完整日期
  690 + isforbid: "1" //当前月可点击
  691 + });
  692 + //console.log(self.tom(parseInt(self.nowMonth)) + "月份:" + self.tod(indexindex));
  693 + }
  694 + }
  695 + // 尾部日期计算
  696 + // for(var index2 = daonale + 1, index3 = 1; index2 <= 42; index2++, index3++) {
  697 + // var tmpName = 'day' + index2;
  698 + // var lunar = 'lunar' + index2;
  699 + // //日、农历、完整日期
  700 + // var y2 = parseInt(self.nowYear);
  701 + // var m2 = parseInt(self.nowMonth) + parseInt(1);
  702 + // if(m2 == 13) {
  703 + // m2 = 1;
  704 + // y2 = parseInt(self.nowYear) + parseInt(1)
  705 + // }
  706 + // fileInfo[tmpName] = index3;
  707 + // fileInfo[lunar] = self._getLunar(index3, m2, y2);
  708 + // //存储当前月数据
  709 + // tmpInfo.push({
  710 + // day: index3, //日
  711 + // lunar: self._getLunar(index3, m2, y2), //农历
  712 + // date: y2 + "-" + self.tom(m2) + "-" + self.tod(index3), //完整日期
  713 + // isforbid: "0", //前一月和后一月不可点击
  714 + // tip: 'next',
  715 + // });
  716 + // //console.log("后面一个月的数据:\n" + JSON.stringify(tmpInfo) + "\n");
  717 + // //console.log(self.tom(parseInt(self.nowMonth) + parseInt(1)) + "月份:" + self.tod(index3));
  718 + // }
  719 + if(self.options.isDebug) {
  720 + console.log("*********日历格式********:\n" + JSON.stringify(tmpInfo) + "\n");
  721 + }
  722 + //this._render(fileInfo, tmpInfo, dateObj.activeSlideNode);
  723 + this._render({
  724 + fileInfo: fileInfo,
  725 + tmpInfo: tmpInfo,
  726 + activeSlideNode: dateObj.activeSlideNode,
  727 + }, callback);
  728 + },
  729 +
  730 + /**
  731 + * 视图的渲染和数据分离,采用内部的数据
  732 + */
  733 + //_render: function(fileInfo, tmpInfo, activeSlideNode) {
  734 + _render: function (dataObj, callback) {
  735 + var self = this;
  736 + //console.log("XXXX" + JSON.stringify(dataObj.fileInfo));
  737 + // 渲染之前,业务ajax请求,显示日历上日程标记
  738 + var dateStr = self.nowYear + "-" + self.nowMonth + "-";
  739 +
  740 + // 必须设置延迟300ms,否则滑动有偏差
  741 + setTimeout(function () {
  742 + self.options.dataRequest(dateStr, function (data) {
  743 + var res = data || [];
  744 + //和业务绑定
  745 + if(self.options.isDebug) {
  746 + console.log("*********业务数据:********:\n" + JSON.stringify(res) + "\n");
  747 + }
  748 + for(var j = 0; j < res.length; j++) {
  749 + for(var i = 0; i < dataObj.tmpInfo.length; i++) {
  750 + if(res[j].date == dataObj.tmpInfo[i].date) {
  751 + dataObj.tmpInfo[i].isSelected = "1";
  752 + }
  753 + }
  754 + }
  755 + //完全支持自定义外部传入模板
  756 + var html = self.getThemeHtml(dataObj);
  757 +
  758 + if(self.options.isDebug) {
  759 + console.log("*********日历模板********:\n" + html + "\n");
  760 + }
  761 + if(typeof (callback) == "function") {
  762 + callback && callback(html, dataObj.tmpInfo);
  763 + }
  764 +
  765 + return;
  766 + }, self);
  767 + }, 100);
  768 + },
  769 + /**
  770 + * 获取主题模板
  771 + */
  772 + getThemeHtml: function (dataObj) {
  773 + var self = this;
  774 + // 模板集合
  775 + var html = "";
  776 + // 模板项
  777 + var template = "";
  778 + // 当前日期
  779 + var curr = self.currentDate;
  780 +
  781 + for(var i = 0, len = dataObj.tmpInfo.length; i < len; i++) {
  782 + // 如果传入模板为空,则默认日历主题模板
  783 + var value = dataObj.tmpInfo[i];
  784 + var templData = self.options.template(value, curr);
  785 + if(!templData) {
  786 + //console.log("=======默认日历主题模板=======");
  787 + // =======默认日历主题模板=======
  788 + // 上一月和下一月不可点击模板
  789 + if(value.date == curr) {
  790 + //今天
  791 + if(value.isSelected) {
  792 + template = '<div class="em-calendar-item em-calendar-active isforbid{{isforbid}}" date="{{date}}"><span class="day">{{day}}</span><p class="lunar">今天</p><span class="dot dot-type1"></span></div>';
  793 + } else {
  794 + template = '<div class="em-calendar-item em-calendar-active isforbid{{isforbid}}" date="{{date}}"><span class="day">{{day}}</span><p class="lunar">今天</p></div>';
  795 + }
  796 + } else {
  797 + if(value.isSelected) {
  798 + // 个性化和业务贴近
  799 + template = '<div class="em-calendar-item isforbid{{isforbid}} tip{{tip}}" date="{{date}}" ><span class="day">{{day}}</span><p class="lunar">{{lunar}}</p><span class="dot dot-type1"></span></div>';
  800 + } else {
  801 + template = '<div class="em-calendar-item isforbid{{isforbid}} tip{{tip}}" date="{{date}}"><span class="day">{{day}}</span><p class="lunar">{{lunar}}</p></div>';
  802 + }
  803 + }
  804 + html += Mustache.render(template, value);
  805 + } else {
  806 + // console.log("=======自定义传入=======");
  807 + // =======自定义传入=======
  808 + html += Mustache.render(templData, value);
  809 + }
  810 + }
  811 +
  812 + return html;
  813 + },
  814 + /**
  815 + * 创建DOM元素工厂,将样式固定结构存储起来,外部可通过样式修改
  816 + */
  817 + CreateDOMFactory: function (callback) {
  818 + var self = this;
  819 + // 头部样式
  820 + self.HEADER_BAR = '<div class="em-calendar-container"><div class="em-week">\
  821 + <span class="em-red">日</span>\
  822 + <span>一</span>\
  823 + <span>二</span>\
  824 + <span>三</span>\
  825 + <span>四</span>\
  826 + <span>五</span>\
  827 + <span class="em-red">六</span>\
  828 + </div>';
  829 +
  830 + self.HEADER = '<div class="swiper-container">\
  831 + <div class="swiper-wrapper">';
  832 +
  833 + // 底部样式
  834 + self.FOOTER = '</div>\
  835 + </div>\
  836 + </div>';
  837 +
  838 + // 日历面板容器样式
  839 + self.SLIDER_ITEM_CONTAINER = '<div class="swiper-slide">\
  840 + <div class="em-calendar-content">\
  841 + <div class="em-calendar-wrapper">{{{templ}}}</div>\
  842 + </div></div>';
  843 +
  844 + var output = self.HEADER_BAR + self.HEADER + self.FOOTER;
  845 + self.container.innerHTML = output;
  846 +
  847 + // 执行回调
  848 + callback && callback();
  849 + },
  850 + /*
  851 + * JSON数组去重
  852 + * @param: [array] json Array
  853 + * @param: [string] 唯一的key名,根据此键名进行去重
  854 + */
  855 + uniqueArray: function (array, key) {
  856 + var result = [array[0]];
  857 + for(var i = 1; i < array.length; i++) {
  858 + var item = array[i];
  859 + var repeat = false;
  860 + for(var j = 0; j < result.length; j++) {
  861 + if(item[key] == result[j][key]) {
  862 + repeat = true;
  863 + break;
  864 + }
  865 + }
  866 + if(!repeat) {
  867 + result.push(item);
  868 + }
  869 + }
  870 + return result;
  871 +
  872 + },
  873 + /**
  874 + * 增加事件,包括
  875 + * 日历点击的监听
  876 + * 日历左滑、右滑切换,等等
  877 + */
  878 + _addEvent: function () {
  879 + var self = this;
  880 + var onItemClick = self.options.onItemClick;
  881 + var swipeCallback = self.options.swipeCallback;
  882 + var preCallback = self.options.preCallback;
  883 + var nextCallback = self.options.nextCallback;
  884 +
  885 + // 记录上一月和上一年的索引
  886 + var preMonthIndex = parseInt(self.curMonth) - parseInt(2);;
  887 + var preYearIndex = self.curYear;
  888 + // 记录下一月和下一年的索引
  889 + var nextMonthIndex = parseInt(self.curMonth);
  890 + var nextYearIndex = self.DateObj().getFullYear();
  891 + var nextYear = self.curYear;
  892 + var nextMonth;
  893 +
  894 + var count = 0;
  895 + var currYearIndex = self.curYear;
  896 + var currMonthIndex = parseInt(self.curMonth);
  897 + var currDayIndex = self.curDay;
  898 + // 创建swiper 组件对象
  899 + self.mySwiper = new Swiper('.swiper-container', {
  900 + loop: false,
  901 + initialSlide: 1,
  902 + speed: 150,
  903 + prevButton: self.options.pre,
  904 + nextButton: self.options.next,
  905 + // 增加监听点击事件
  906 + onClick: function (swiper, e) {
  907 + // console.log(e.target.innerHTML);
  908 + // 日期灰色部分不启用
  909 + var _this = e.target.parentNode;
  910 +
  911 +
  912 + // 日期输出值
  913 + var dateStr = _this.getAttribute('date');
  914 +
  915 + // 农历输出值
  916 + if(_this.querySelector('.lunar')) {
  917 + var lunarStr = _this.querySelector('.lunar').innerText.trim();
  918 + } else {
  919 + var lunarStr = "已签";
  920 + }
  921 + // 可点击区域
  922 + if(!_this.classList.contains('isforbid0')) {
  923 + console.log($(_this).siblings())
  924 + if(_this.getAttribute("date")) {
  925 + var mydate=new Date();
  926 + var year=mydate.getFullYear();
  927 + var month=mydate.getMonth()+1;
  928 + if(month<10){
  929 + month='0'+month
  930 + }
  931 + var day=mydate.getDate();
  932 + if(day<10){
  933 + day='0'+day
  934 + }
  935 + var newday=year+'-'+month+'-'+day;
  936 + console.log(newday)
  937 +
  938 + var nowlen=''
  939 + var nextlen=''
  940 + //var clickactives = document.querySelector('.swiper-slide-active').querySelectorAll('.em-calendar-item');
  941 +
  942 + var clickactives = document.querySelectorAll('.em-calendar-item');
  943 + for(var i = 0; i < clickactives.length; i++) {
  944 + if(clickactives[i].getAttribute("date") == newday) {
  945 + nowlen=clickactives[i]
  946 + $( nowlen).prevAll().removeClass("em-calendar-active")
  947 + }
  948 + }
  949 +
  950 + // console.log(_this.getAttribute("date"));
  951 + var time1=_this.getAttribute("date");
  952 + // var time2=_this.getAttribute("date");
  953 + if(time1>newday){
  954 + _this.classList.add('em-calendar-active');
  955 + $(_this).nextAll().removeClass("em-calendar-active")
  956 + var lenlen=''
  957 + nextlen= $(_this).prevAll()
  958 + var prelen=$(nowlen).nextAll();
  959 + // console.log(nextlen);
  960 + // console.log(prelen)
  961 + var arr=[]
  962 + for(var i=0;i<nextlen.length;i++){
  963 +
  964 + for(var j=0;j<prelen.length;j++){
  965 + // console.log(nextlen[i].getAttribute("date"))
  966 + // console.log(prelen[j].getAttribute("date"))
  967 +
  968 + if(nextlen[i].getAttribute("date")==prelen[j].getAttribute("date")){ arr.push(nextlen[i])
  969 + console.log(nextlen[i].getAttribute("date"));
  970 + $(nextlen[i]).addClass("em-calendar-active");
  971 + // console.log($(nextlen[i]).siblings())
  972 + // $(nextlen[i]).siblings().removeClass("em-calendar-active")
  973 + }
  974 + }
  975 +
  976 + }
  977 + // console.log(arr.length)
  978 + // for(var k=0;k<arr.length;k++){
  979 + // console.log(k)
  980 + //
  981 + //
  982 + // }
  983 +
  984 + // for(var i=0;i<nextlen.length;i++){
  985 + // for(var j=0;j<prelen.length;i++){
  986 + // if(nextlen[i]==prelen[j]){
  987 + // console.log(444);
  988 + // // console.log(prelen[j])
  989 + // }
  990 + // }
  991 + // }
  992 + // if(lenlen==prelen&&lenlen==nextlen){
  993 + // console.log(lenlen)
  994 + // }
  995 + // $(_this).prevAll().addClass('em-calendar-active');
  996 + //console.log(nextlen)
  997 +
  998 + }
  999 + // console.log(time1);
  1000 + // console.log(time2);
  1001 +
  1002 + // self.sibling(_this, function (el) {
  1003 + // el.classList.remove('em-calendar-active');
  1004 + // });
  1005 + }
  1006 + } else {
  1007 + // 不可点击区域
  1008 + if(_this.classList.contains('tipprev')) {
  1009 + // 前进
  1010 + self.slidePrev().then(function () {
  1011 + // 给特定日期新增点击激活样式
  1012 + // self.addActiveStyleFordate(dateStr);
  1013 + });
  1014 + } else if(_this.classList.contains('tipnext')) {
  1015 + // 后退
  1016 + self.slideNext().then(function () {
  1017 + // 给特定日期新增点击激活样式
  1018 + // self.addActiveStyleFordate(dateStr);
  1019 + });
  1020 +
  1021 + }
  1022 + }
  1023 + // 点击回调
  1024 + onItemClick && onItemClick({
  1025 + date: dateStr, //日期
  1026 + lunar: lunarStr //农历
  1027 + });
  1028 + },
  1029 + /**
  1030 + * @description 月份递增
  1031 + * @param {Object} swiper swiper对象
  1032 + */
  1033 + onSlideNextStart: function (swiper) {
  1034 + count++;
  1035 + if(count == "1") {
  1036 + //alert("等于1,并不能代表是当前月");
  1037 + //alert("传过来的是"+self.nowYear+self.nowMonth);
  1038 + currDayIndex = self.curDay;
  1039 + currMonthIndex = parseInt(self.curMonth);
  1040 + } else {
  1041 + currMonthIndex = currMonthIndex + 1;
  1042 + currDayIndex = "01";
  1043 +
  1044 + }
  1045 + if(currMonthIndex == "13") {
  1046 + currYearIndex = parseInt(currYearIndex) + parseInt(1);
  1047 + currMonthIndex = 1;
  1048 + }
  1049 + // 开启调试模式
  1050 + if(self.options.isDebug) {
  1051 + console.log("currMonthIndex:" + currMonthIndex);
  1052 + console.log("currYearIndex:" + currYearIndex);
  1053 + console.log(">>>>>>" + self.nowYear + "-" + self.nowMonth + "-" + self.nowDay);
  1054 + }
  1055 + //alert("向后回调"+">>>>>>" + currYearIndex + "-" + currMonthIndex + "-" + self.nowDay);
  1056 + //回调
  1057 + swipeCallback && swipeCallback({
  1058 + year: currYearIndex,
  1059 + month: self.tom(currMonthIndex),
  1060 + day: currDayIndex,
  1061 + date: currYearIndex + "-" + self.tom(currMonthIndex) + "-" + currDayIndex,
  1062 + dayCount: self.dayCount
  1063 + });
  1064 + /**
  1065 + * @description 后加
  1066 + */
  1067 + nextMonthIndex += parseInt(1);
  1068 + if(nextMonthIndex == 13) {
  1069 + nextYear = nextYearIndex + 1;
  1070 + nextMonthIndex = 1;
  1071 + }
  1072 + nextMonth = self.tom(nextMonthIndex);
  1073 +
  1074 + if(self.options.isDebug) {
  1075 + console.log("(后)初始化年月日:" + nextYear + "-" + nextMonth + "-" + "01");
  1076 + }
  1077 +
  1078 + self.refreshData({
  1079 + year: nextYear,
  1080 + month: nextMonth,
  1081 + day: "01"
  1082 + }, function (output1) {
  1083 + var outputs = [];
  1084 + outputs.push({
  1085 + templ: output1
  1086 + });
  1087 + // 渲染日历模板
  1088 + var templ = self.SLIDER_ITEM_CONTAINER;
  1089 + var html = "";
  1090 + for(var i = 0; i < outputs.length; i++) {
  1091 + html += Mustache.render(templ, outputs[i]);
  1092 + }
  1093 + swiper.appendSlide(html);
  1094 + });
  1095 + // 如果往后滑动时后一个月非当前月,重新渲染1号样式
  1096 + if(self.tom(currMonthIndex) !== self.curMonth) {
  1097 + var chooseDom = document.querySelector('.swiper-slide-active .em-calendar-active')
  1098 + if(chooseDom) {
  1099 + chooseDom.classList.remove('em-calendar-active')
  1100 + }
  1101 + document.querySelector('.swiper-slide-active .isforbid1').classList.add('em-calendar-active')
  1102 +
  1103 + }
  1104 +
  1105 + },
  1106 + /**
  1107 + * @description 月份递减
  1108 + * @param {Object} swiper swiper对象
  1109 + */
  1110 + onSlidePrevStart: function (swiper) {
  1111 + count--;
  1112 + if(count == "1") {
  1113 + currDayIndex = self.curDay;
  1114 + currMonthIndex = parseInt(self.curMonth);
  1115 + } else {
  1116 + currMonthIndex = parseInt(currMonthIndex) - parseInt(1);
  1117 + currDayIndex = "01";
  1118 +
  1119 + }
  1120 +
  1121 + if(currMonthIndex == 0) {
  1122 + currYearIndex = parseInt(currYearIndex) - parseInt(1);
  1123 + currMonthIndex = 12;
  1124 + }
  1125 + // 开启调试模式
  1126 + if(self.options.isDebug) {
  1127 + console.log("currMonthIndex:" + currMonthIndex);
  1128 + console.log("currYearIndex:" + currYearIndex);
  1129 + console.log("当前" + self.nowYear + "-" + self.nowMonth + "月份");
  1130 + }
  1131 +
  1132 + // 点击回调
  1133 + swipeCallback && swipeCallback({
  1134 + year: currYearIndex,
  1135 + month: self.tom(currMonthIndex),
  1136 + day: currDayIndex,
  1137 + date: currYearIndex + "-" + self.tom(currMonthIndex) + "-" + currDayIndex,
  1138 + dayCount: self.dayCount
  1139 + });
  1140 +
  1141 + if(preMonthIndex == 0) {
  1142 + preYearIndex--;
  1143 + preMonthIndex = 12;
  1144 + }
  1145 + var preMonth = self.tom(preMonthIndex);
  1146 + //console.log("前加:" + preYearIndex + "-" + preMonth + "-" + "01");
  1147 + //ejs.ui.toast("前加:" + preYearIndex + "-" + preMonth + "-" + preDay);
  1148 +
  1149 + preMonthIndex--;
  1150 + // 刷新日历
  1151 +
  1152 + self.refreshData({
  1153 + year: preYearIndex,
  1154 + month: preMonth,
  1155 + day: "01"
  1156 + }, function (output1) {
  1157 +
  1158 + var outputs = [];
  1159 + outputs.push({
  1160 + templ: output1
  1161 + });
  1162 + // 渲染日历模板
  1163 + var templ = self.SLIDER_ITEM_CONTAINER;
  1164 + var html = "";
  1165 + for(var i = 0; i < outputs.length; i++) {
  1166 + html += Mustache.render(templ, outputs[i]);
  1167 + }
  1168 + swiper.prependSlide(html);
  1169 + });
  1170 +
  1171 + // 如果往前滑动时前一个月非当前月,重新渲染1号样式
  1172 + if(self.tom(currMonthIndex) !== self.curMonth) {
  1173 + var chooseDom = document.querySelector('.swiper-slide-active .em-calendar-active')
  1174 + if(chooseDom) {
  1175 + chooseDom.classList.remove('em-calendar-active')
  1176 + }
  1177 + document.querySelector('.swiper-slide-active .isforbid1').classList.add('em-calendar-active')
  1178 +
  1179 + }
  1180 + }
  1181 + });
  1182 +
  1183 + // 回到今天
  1184 + if(self._selector(self.options.backToToday)) {
  1185 + self._selector(self.options.backToToday).addEventListener("touchstart", function () {
  1186 + // 外部执行回调
  1187 + var curYear = self.DateObj().getFullYear();
  1188 + var curMonth = self.tod(self.DateObj().getMonth() + 1);
  1189 + var curDay = self.tod(self.DateObj().getDate());
  1190 + // 刷新
  1191 + self.refresh();
  1192 +
  1193 + });
  1194 + }
  1195 + },
  1196 + /**
  1197 + * @description 给特定日期新增选中激活样式
  1198 + * @param {Object} dateStr 点击后的日期 ,例如:“2018-08-20”
  1199 + */
  1200 +
  1201 +
  1202 +
  1203 + addActiveStyleFordate: function (dateStr) {
  1204 + // console.log(dateStr)
  1205 + var self = this;
  1206 + // 给前后月的点击日期加选中标记
  1207 + var clickactives = document.querySelector('.swiper-slide-active').querySelectorAll('.em-calendar-item');
  1208 + for(var i = 0; i < clickactives.length; i++) {
  1209 + if(clickactives[i].getAttribute("date") == dateStr) {
  1210 + clickactives[i].classList.add('em-calendar-active');
  1211 + self.sibling(clickactives[i], function (el) {
  1212 + // el.classList.remove('em-calendar-active');
  1213 + });
  1214 + }
  1215 + }
  1216 + },
  1217 + /**
  1218 + * 向前滑动
  1219 + */
  1220 + slidePrev: function (options) {
  1221 + var self = this;
  1222 + return new Promise(function (resolve, reject) {
  1223 + self.mySwiper.slidePrev();
  1224 + return resolve(options);
  1225 + });
  1226 + },
  1227 +
  1228 + /**
  1229 + * 向后滑动
  1230 + */
  1231 + slideNext: function (options) {
  1232 + var self = this;
  1233 + return new Promise(function (resolve, reject) {
  1234 + self.mySwiper.slideNext();
  1235 + return resolve(options);
  1236 + });
  1237 + },
  1238 + /**
  1239 + * 外部刷新
  1240 + */
  1241 + refresh: function (options) {
  1242 + var self = this;
  1243 + // 销毁
  1244 + self.destroySwiper();
  1245 + // 创建
  1246 + self.initEntry(options);
  1247 +
  1248 + },
  1249 + /**
  1250 + * 销毁swiper
  1251 + */
  1252 + destroySwiper: function () {
  1253 + var self = this;
  1254 + // 销毁
  1255 + self.mySwiper.destroy(true);
  1256 + },
  1257 +
  1258 + /**
  1259 + * 获取当前农历
  1260 + * @param {Object} currentday
  1261 + * @param {Object} month
  1262 + * @return {String}
  1263 + */
  1264 + _getLunar: function (currentday, month, year) {
  1265 + var self = this;
  1266 + // 中间需默认当前年和当前月,两头需要传年和月
  1267 + var yy = year || self.nowYear;
  1268 + var mm = month || self.nowMonth;
  1269 + var dd = currentday;
  1270 + return this._getLunarDay(yy, mm, dd);
  1271 + },
  1272 + /**
  1273 + * 根据年月计算当月的天数
  1274 + * @param {Object} y
  1275 + * @param {Object} m
  1276 + */
  1277 + _judgeDaysByYearMonth: function (y, m) {
  1278 + var self = this;
  1279 + if(y == undefined || y == null) {
  1280 + throw "=====获取当前月份天数时,缺少y参数,未定义!=======";
  1281 + }
  1282 + if(m == undefined || m == null) {
  1283 + throw "=====获取当前月份天数时,缺少m参数,未定义!=======";
  1284 + }
  1285 + var y = parseInt(y);
  1286 + var m = parseInt(m);
  1287 + if(m == 0) {
  1288 + y--;
  1289 + m = 12;
  1290 + }
  1291 + if(m == 2) {
  1292 + if((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) {
  1293 + return '29';
  1294 + } else {
  1295 + return '28';
  1296 + }
  1297 + } else {
  1298 + if(self._inArray(m, [1, 3, 5, 7, 8, 10, 12])) {
  1299 + return '31';
  1300 + } else {
  1301 + return '30';
  1302 + }
  1303 + }
  1304 +
  1305 + },
  1306 +
  1307 + /**
  1308 + * 进行一次全局验证,验证输入的合法性
  1309 + * 这个验证是强制性的
  1310 + */
  1311 + _validate: function () {
  1312 + var flag = true;
  1313 + if(!this.options.container) {
  1314 + flag = false;
  1315 + }
  1316 + return flag;
  1317 + },
  1318 + _selector: function (el) {
  1319 + // 减少耦合
  1320 + return document.querySelector(el);
  1321 + },
  1322 + /**
  1323 + * 判断元素在数组中是否存在
  1324 + * @param {Object} str 数字或者字符串元素
  1325 + * @param {Object} arr 有效数组
  1326 + */
  1327 + _inArray: function (str, arr) {
  1328 + // 不是数组则抛出异常
  1329 + if(!Array.isArray(arr)) {
  1330 + throw "arguments is not Array";
  1331 + }
  1332 + // 遍历是否在数组中
  1333 + for(var i = 0, k = arr.length; i < k; i++) {
  1334 + if(str == arr[i]) {
  1335 + return true;
  1336 + }
  1337 + }
  1338 + // 如果不在数组中就会返回false
  1339 + return false;
  1340 + },
  1341 + // 遍历查找同级元素
  1342 + _sibling: function (elem, forCB) {
  1343 + var r = [];
  1344 + var n = elem.parentNode.firstChild;
  1345 + for(; n; n = n.nextSibling) {
  1346 + if(n.nodeType === 1 && n !== elem) {
  1347 + if(forCB && typeof (forCB) == "function") {
  1348 + forCB(n);
  1349 + }
  1350 + }
  1351 + }
  1352 + },
  1353 + _getBit: function (m, n) {
  1354 + var self = this;
  1355 + // 农历转换
  1356 + return(m >> n) & 1;
  1357 + },
  1358 + _e2c: function () {
  1359 + var self = this;
  1360 + self.TheDate = (arguments.length != 3) ? new Date() : new Date(arguments[0], arguments[1], arguments[2]);
  1361 + var total, m, n, k;
  1362 + var isEnd = false;
  1363 + var tmp = self.TheDate.getYear();
  1364 + if(tmp < 1900) {
  1365 + tmp += 1900;
  1366 + }
  1367 + total = (tmp - 1921) * 365 + Math.floor((tmp - 1921) / 4) + self.madd[self.TheDate.getMonth()] + self.TheDate.getDate() - 38;
  1368 +
  1369 + if(self.TheDate.getYear() % 4 == 0 && self.TheDate.getMonth() > 1) {
  1370 + total++;
  1371 + }
  1372 + for(m = 0;; m++) {
  1373 + k = (self.CalendarData[m] < 0xfff) ? 11 : 12;
  1374 + for(n = k; n >= 0; n--) {
  1375 + if(total <= 29 + self._getBit(self.CalendarData[m], n)) {
  1376 + isEnd = true;
  1377 + break;
  1378 + }
  1379 + total = total - 29 - self._getBit(self.CalendarData[m], n);
  1380 + }
  1381 + if(isEnd) break;
  1382 + }
  1383 + self.cYear = 1921 + m;
  1384 + self.cMonth = k - n + 1;
  1385 + self.cDay = total;
  1386 + if(k == 12) {
  1387 + if(self.cMonth == Math.floor(self.CalendarData[m] / 0x10000) + 1) {
  1388 + self.cMonth = 1 - self.cMonth;
  1389 + }
  1390 + if(self.cMonth > Math.floor(self.CalendarData[m] / 0x10000) + 1) {
  1391 + self.cMonth--;
  1392 + }
  1393 + }
  1394 +
  1395 + },
  1396 +
  1397 + _getcDateString: function () {
  1398 + var self = this;
  1399 + var tmp = "";
  1400 + /*显示农历年:( 如:甲午(马)年 )*/
  1401 + if(self.cMonth < 1) {
  1402 + // tmp += "(闰)";
  1403 + // tmp += self.monString.charAt(-self.cMonth - 1);
  1404 + } else {
  1405 + // tmp += self.monString.charAt(self.cMonth - 1);
  1406 + }
  1407 + //tmp += "月";
  1408 + tmp += (self.cDay < 11) ? "初" : ((self.cDay < 20) ? "十" : ((self.cDay < 30) ? "廿" : "三十"));
  1409 + if(self.cDay % 10 != 0 || self.cDay == 10) {
  1410 + tmp += self.numString.charAt((self.cDay - 1) % 10);
  1411 + }
  1412 + return tmp;
  1413 +
  1414 + },
  1415 + _getLunarDay: function (solarYear, solarMonth, solarDay) {
  1416 + var self = this;
  1417 + //solarYear = solarYear<1900?(1900+solarYear):solarYear;
  1418 + if(solarYear < 1921 || solarYear > 2080) {
  1419 + return "";
  1420 + } else {
  1421 + solarMonth = (parseInt(solarMonth) > 0) ? (solarMonth - 1) : 11;
  1422 + self._e2c(solarYear, solarMonth, solarDay);
  1423 + return self._getcDateString();
  1424 + }
  1425 +
  1426 + },
  1427 + /**
  1428 + * 将1,2,3,4,5格式化01,02,03,04,05
  1429 + * @param {Object} m 月份转换
  1430 + */
  1431 + tom: function (m) {
  1432 + if(parseInt(m) > 9) {
  1433 + m = "" + parseInt(m);
  1434 + } else {
  1435 + m = "0" + parseInt(m);
  1436 + }
  1437 + return m;
  1438 + },
  1439 + /**
  1440 + * 将1,2,3,4,5格式化01,02,03,04,05
  1441 + * @param {Object} 日转换
  1442 + */
  1443 + tod: function (d) {
  1444 + if(parseInt(d) > 9) {
  1445 + d = "" + parseInt(d);
  1446 + } else {
  1447 + d = "0" + parseInt(d);
  1448 + }
  1449 + return d;
  1450 + },
  1451 + /**
  1452 + * 获取小时、分钟、秒 例如:18:09:00
  1453 + * @param {Object} format hh:mm 输出00:00 hh:mm:ss 输出00:00:00
  1454 + */
  1455 + getTime: function (format) {
  1456 + var self = this;
  1457 + var hh = self.DateObj().getHours();
  1458 + var mm = self.DateObj().getMinutes();
  1459 + var ss = self.DateObj().getSeconds();
  1460 + var timeStr = "";
  1461 + if("hh:mm" == format) {
  1462 + timeStr += hh + ":" + mm;
  1463 + } else if("hh:mm:ss" == format) {
  1464 + timeStr += hh + ":" + mm + ":" + ss;
  1465 + }
  1466 + return timeStr;
  1467 + },
  1468 + /**
  1469 + * 获取对象
  1470 + */
  1471 + DateObj: function (dateStr) {
  1472 + var dateObj;
  1473 + if(!dateStr) {
  1474 + //throw("请输入合法日期格式!"+str);
  1475 + dateObj = new Date();
  1476 + } else {
  1477 + // 注意:须先把时间戳(122891289)转成字符串然后进行查找
  1478 + var index = dateStr.toString().indexOf('-');
  1479 + if(index == "-1") {
  1480 + // 解析时间戳
  1481 + dateObj = new Date(dateStr);
  1482 + } else {
  1483 + // 解析正常格式时间戳,切记不要直接传 new Date 2017-09-09 19:00:00,
  1484 + dateObj = new Date(dateStr.replace(/-/g, '/'));
  1485 + }
  1486 + }
  1487 + return dateObj;
  1488 + },
  1489 + /**
  1490 + * @description 获取某个元素的所有兄弟节点;这里还是建议使用库来实现 ,喜欢深究的可以参考下面代码(原理类似Zepto,jquery 的silbling()方法)。
  1491 + * @param {Object} elem 选中的当前节点
  1492 + * @param {Function} forCB 遍历回调每个兄弟节点
  1493 + * 用法如下:
  1494 + */
  1495 + sibling: function (elem, forCB) {
  1496 + var r = [];
  1497 + var n = elem.parentNode.firstChild;
  1498 + for(; n; n = n.nextSibling) {
  1499 + if(n.nodeType === 1 && n !== elem) {
  1500 + if(forCB && typeof (forCB) == "function") {
  1501 + forCB(n);
  1502 + }
  1503 + }
  1504 + }
  1505 + },
  1506 +
  1507 + };
  1508 +
  1509 + window.Calendar = Calendar;
  1510 +
  1511 + // var lenq=document.querySelectorAll('.em-calendar-item');
  1512 +
  1513 + // var lenq=document.querySelectorAll('.em-calendar-item');
  1514 + // console.log(lenq)
  1515 + //
  1516 + // for(var i=0;i<lenq.length;i++) {
  1517 + //
  1518 + // lenq[i].onclick=function(){
  1519 + // alert(111)
  1520 + // var time1 = $(this).getAttribute("date");
  1521 + // // var time2=_this.getAttribute("date");
  1522 + // if (time1 > newday) {
  1523 + // $(this).addClass('em-calendar-active');
  1524 + // $(this).nextAll().removeClass("em-calendar-active")
  1525 + // var lenlen = ''
  1526 + // nextlen = $(_this).prevAll()
  1527 + // var prelen = $(nowlen).nextAll();
  1528 + // // console.log(nextlen);
  1529 + // // console.log(prelen)
  1530 + // var arr = []
  1531 + // for (var i = 0; i < nextlen.length; i++) {
  1532 + //
  1533 + // for (var j = 0; j < prelen.length; j++) {
  1534 + // // console.log(nextlen[i].getAttribute("date"))
  1535 + // // console.log(prelen[j].getAttribute("date"))
  1536 + //
  1537 + // if (nextlen[i].getAttribute("date") == prelen[j].getAttribute("date")) {
  1538 + // arr.push(nextlen[i])
  1539 + // console.log(nextlen[i].getAttribute("date"));
  1540 + // $(nextlen[i]).addClass("em-calendar-active");
  1541 + // // console.log($(nextlen[i]).siblings())
  1542 + // // $(nextlen[i]).siblings().removeClass("em-calendar-active")
  1543 + // }
  1544 + // }
  1545 + //
  1546 + // }
  1547 + // }
  1548 + // }
  1549 + // var mydate = new Date();
  1550 + // var year = mydate.getFullYear();
  1551 + // var month = mydate.getMonth() + 1;
  1552 + // if (month < 10) {
  1553 + // month = '0' + month
  1554 + // }
  1555 + // var day = mydate.getDate();
  1556 + // if (day < 10) {
  1557 + // day = '0' + day
  1558 + // }
  1559 + // var newday = year + '-' + month + '-' + day;
  1560 + // console.log(newday)
  1561 + //
  1562 + // var nowlen = ''
  1563 + // var nextlen = ''
  1564 + // // var clickactives = document.querySelector('.swiper-slide-active').querySelectorAll('.em-calendar-item');
  1565 + //
  1566 + // if (lenq[i].getAttribute("date") == newday) {
  1567 + // nowlen = lenq[i]
  1568 + // $(nowlen).prevAll().removeClass("em-calendar-active")
  1569 + //
  1570 + // }
  1571 + // // for(var i = 0; i < clickactives.length; i++) {
  1572 + // //
  1573 + // // }
  1574 + //
  1575 + // // console.log(_this.getAttribute("date"));
  1576 + //
  1577 + //
  1578 + // }
  1579 +
  1580 +})();
  1581 +
  1 +/**
  2 + * 作者: 孙尊路
  3 + * 创建时间: 2017-07-14 13:26:47
  4 + * 版本: [1.0, 2017/7/14]
  5 + * 版权: 江苏国泰新点软件有限公司
  6 + * 说明: 常用工具js
  7 + */
  8 +window.innerCalendarUtil = window.innerCalendarUtil || (function (exports) {
  9 +
  10 + /**
  11 + * 产生一个 唯一uuid,默认为32位的随机字符串,8-4-4-4-12 格式
  12 + * @param {Object} options 配置参数
  13 + * len 默认为32位,最大不能超过36,最小不能小于4
  14 + * radix 随机的基数,如果小于等于10代表只用纯数字,最大为62,最小为2,默认为62
  15 + * type 类别,默认为default代表 8-4-4-4-12的模式,如果为 noline代表不会有连线
  16 + * @return {String} 返回一个随机性的唯一uuid
  17 + */
  18 + exports.uuid = function (options) {
  19 + options = options || {};
  20 +
  21 + var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),
  22 + uuid = [],
  23 + i;
  24 + var radix = options.radix || chars.length;
  25 + var len = options.len || 32;
  26 + var type = options.type || 'default';
  27 +
  28 + len = Math.min(len, 36);
  29 + len = Math.max(len, 4);
  30 + radix = Math.min(radix, 62);
  31 + radix = Math.max(radix, 2);
  32 +
  33 + if(len) {
  34 + for(i = 0; i < len; i++) {
  35 + uuid[i] = chars[0 | Math.random() * radix];
  36 + }
  37 +
  38 + if(type === 'default') {
  39 + len > 23 && (uuid[23] = '-');
  40 + len > 18 && (uuid[18] = '-');
  41 + len > 13 && (uuid[13] = '-');
  42 + len > 8 && (uuid[8] = '-');
  43 + }
  44 + }
  45 +
  46 + return uuid.join('');
  47 + };
  48 +
  49 + var class2type = {};
  50 +
  51 + exports.noop = function () {};
  52 +
  53 + exports.isFunction = function (value) {
  54 + return exports.type(value) === 'function';
  55 + };
  56 + exports.isPlainObject = function (obj) {
  57 + return exports.isObject(obj) && !exports.isWindow(obj) && Object.getPrototypeOf(obj) === Object.prototype;
  58 + };
  59 + exports.isArray = Array.isArray ||
  60 + function (object) {
  61 + return object instanceof Array;
  62 + };
  63 +
  64 + /**
  65 + * isWindow(需考虑obj为undefined的情况)
  66 + * @param {Object} obj 需要判断的对象
  67 + * @return {Boolean} 返回true或false
  68 + */
  69 + exports.isWindow = function (obj) {
  70 + return obj && obj === window;
  71 + };
  72 + exports.isObject = function (obj) {
  73 + return exports.type(obj) === 'object';
  74 + };
  75 + exports.type = function (obj) {
  76 + return(obj === null || obj === undefined) ? String(obj) : class2type[{}.toString.call(obj)] || 'object';
  77 + };
  78 + /**
  79 + * each遍历操作
  80 + * @param {Object} elements 元素
  81 + * @param {Function} callback 回调
  82 + * @param {Function} hasOwnProperty 过滤函数
  83 + * @returns {global} 返回调用的上下文
  84 + */
  85 + exports.each = function (elements, callback, hasOwnProperty) {
  86 + if(!elements) {
  87 + return this;
  88 + }
  89 + if(typeof elements.length === 'number') {
  90 + [].every.call(elements, function (el, idx) {
  91 + return callback.call(el, idx, el) !== false;
  92 + });
  93 + } else {
  94 + for(var key in elements) {
  95 + if(hasOwnProperty) {
  96 + if(elements.hasOwnProperty(key)) {
  97 + if(callback.call(elements[key], key, elements[key]) === false) {
  98 + return elements;
  99 + }
  100 + }
  101 + } else {
  102 + if(callback.call(elements[key], key, elements[key]) === false) {
  103 + return elements;
  104 + }
  105 + }
  106 + }
  107 + }
  108 +
  109 + return this;
  110 + };
  111 +
  112 + /**
  113 + * extend 合并多个对象,可以递归合并
  114 + * @param {type} deep 是否递归合并
  115 + * @param {type} target 最终返回的就是target
  116 + * @param {type} source 从左到又,优先级依次提高,最右侧的是最后覆盖的
  117 + * @returns {Object} 最终的合并对象
  118 + */
  119 + exports.extend = function () {
  120 + var args = [].slice.call(arguments);
  121 +
  122 + // 目标
  123 + var target = args[0] || {},
  124 + // 默认source从1开始
  125 + index = 1,
  126 + len = args.length,
  127 + // 默认非深复制
  128 + deep = false;
  129 +
  130 + if(typeof target === 'boolean') {
  131 + // 如果开启了深复制
  132 + deep = target;
  133 + target = args[index] || {};
  134 + index++;
  135 + }
  136 +
  137 + if(!exports.isObject(target)) {
  138 + // 确保拓展的一定是object
  139 + target = {};
  140 + }
  141 +
  142 + for(; index < len; index++) {
  143 + // source的拓展
  144 + var source = args[index];
  145 +
  146 + if(source && exports.isObject(source)) {
  147 + for(var name in source) {
  148 + if(!Object.prototype.hasOwnProperty.call(source, name)) {
  149 + // 防止原型上的数据
  150 + continue;
  151 + }
  152 +
  153 + var src = target[name];
  154 + var copy = source[name];
  155 + var clone,
  156 + copyIsArray;
  157 +
  158 + if(target === copy) {
  159 + // 防止环形引用
  160 + continue;
  161 + }
  162 +
  163 + // 这里必须用isPlainObject,只有同样是普通的object才会复制继承,如果是FormData之流的,会走后面的覆盖路线
  164 + if(deep && copy && (exports.isPlainObject(copy) || (copyIsArray = exports.isArray(copy)))) {
  165 + if(copyIsArray) {
  166 + copyIsArray = false;
  167 + clone = src && exports.isArray(src) ? src : [];
  168 + } else {
  169 + clone = src && exports.isPlainObject(src) ? src : {};
  170 + }
  171 +
  172 + target[name] = exports.extend(deep, clone, copy);
  173 + } else if(copy !== undefined) {
  174 + // 如果不是普通的object,直接覆盖,例如FormData之类的会覆盖
  175 + target[name] = copy;
  176 + }
  177 + }
  178 + }
  179 + }
  180 +
  181 + return target;
  182 + };
  183 +
  184 + exports.each(['Boolean', 'Number', 'String', 'Function', 'Array', 'Date', 'RegExp', 'Object', 'Error'], function (i, name) {
  185 + class2type['[object ' + name + ']'] = name.toLowerCase();
  186 + });
  187 +
  188 + /**
  189 + * 选择这段代码用到的太多了,因此抽取封装出来
  190 + * @param {Object} element dom元素或者selector
  191 + * @return {HTMLElement} 返回对应的dom
  192 + */
  193 + exports.selector = function (element) {
  194 + if(typeof element === 'string') {
  195 + element = document.querySelector(element);
  196 + }
  197 +
  198 + return element;
  199 + };
  200 +
  201 + /**
  202 + * 设置一个Util对象下的命名空间
  203 + * @param {String} namespace 命名空间
  204 + * @param {Object} obj 需要赋值的目标对象
  205 + * @return {Object} 返回目标对象
  206 + */
  207 + exports.namespace = function (namespace, obj) {
  208 + var parent = window.Util;
  209 +
  210 + if(!namespace) {
  211 + return parent;
  212 + }
  213 +
  214 + var namespaceArr = namespace.split('.'),
  215 + len = namespaceArr.length;
  216 +
  217 + for(var i = 0; i < len - 1; i++) {
  218 + var tmp = namespaceArr[i];
  219 +
  220 + // 不存在的话要重新创建对象
  221 + parent[tmp] = parent[tmp] || {};
  222 + // parent要向下一级
  223 + parent = parent[tmp];
  224 + }
  225 + parent[namespaceArr[len - 1]] = obj;
  226 +
  227 + return parent[namespaceArr[len - 1]];
  228 + };
  229 +
  230 + /**
  231 + * 获取这个模块下对应命名空间的对象
  232 + * 如果不存在,则返回null,这个api只要是供内部获取接口数据时调用
  233 + * @param {Object} module 模块
  234 + * @param {Array} namespace 命名空间
  235 + * @return {Object} 返回目标对象
  236 + */
  237 + exports.getNameSpaceObj = function (module, namespace) {
  238 + if(!namespace) {
  239 + return null;
  240 + }
  241 + var namespaceArr = namespace.split('.'),
  242 + len = namespaceArr.length;
  243 +
  244 + for(var i = 0; i < len; i++) {
  245 + module && (module = module[namespaceArr[i]]);
  246 + }
  247 +
  248 + return module;
  249 + };
  250 +
  251 + /**
  252 + * 将string字符串转为html对象,默认创一个div填充
  253 + * 因为很常用,所以单独提取出来了
  254 + * @param {String} strHtml 目标字符串
  255 + * @return {HTMLElement} 返回处理好后的html对象,如果字符串非法,返回null
  256 + */
  257 + exports.parseHtml = function (strHtml) {
  258 + if(!strHtml || typeof (strHtml) !== 'string') {
  259 + return null;
  260 + }
  261 + // 创一个灵活的div
  262 + var i,
  263 + a = document.createElement('div');
  264 + var b = document.createDocumentFragment();
  265 +
  266 + a.innerHTML = strHtml;
  267 + while((i = a.firstChild)) {
  268 + b.appendChild(i);
  269 + }
  270 +
  271 + return b;
  272 + };
  273 +
  274 + /**
  275 + * 图片的base64字符串转Blob
  276 + * @param {String} urlData 完整的base64字符串
  277 + * @return {Blob} 转换后的Blob对象,可用于表单文件上传
  278 + */
  279 + exports.base64ToBlob = function (urlData) {
  280 + var arr = urlData.split(',');
  281 + var mime = arr[0].match(/:(.*?);/)[1] || 'image/png';
  282 + // 去掉url的头,并转化为byte
  283 + var bytes = window.atob(arr[1]);
  284 + // 处理异常,将ascii码小于0的转换为大于0
  285 + var ab = new ArrayBuffer(bytes.length);
  286 + // 生成视图(直接针对内存):8位无符号整数,长度1个字节
  287 + var ia = new Uint8Array(ab);
  288 +
  289 + for(var i = 0; i < bytes.length; i++) {
  290 + ia[i] = bytes.charCodeAt(i);
  291 + }
  292 +
  293 + return new Blob([ab], {
  294 + type: mime
  295 + });
  296 + };
  297 +
  298 + /**
  299 + * 通过传入key值,得到页面key的初始化传值
  300 + * 实际情况是获取 window.location.href 中的参数的值
  301 + * @param {String} key 键名
  302 + * @return {String} 键值
  303 + */
  304 + exports.getExtraDataByKey = function (key) {
  305 + if(!key) {
  306 + return null;
  307 + }
  308 + // 获取url中的参数值
  309 + var getUrlParamsValue = function (url, paramName) {
  310 + var paraString = url.substring(url.indexOf('?') + 1, url.length).split('&');
  311 + var paraObj = {};
  312 + var i,
  313 + j;
  314 +
  315 + for(i = 0;
  316 + (j = paraString[i]); i++) {
  317 + paraObj[j.substring(0, j.indexOf('=')).toLowerCase()] = j.substring(j.indexOf('=') + 1, j.length);
  318 + }
  319 + var returnValue = paraObj[paramName.toLowerCase()];
  320 +
  321 + // 需要解码浏览器编码
  322 + returnValue = decodeURIComponent(returnValue);
  323 + if(typeof (returnValue) === 'undefined') {
  324 + return undefined;
  325 + } else {
  326 + return returnValue;
  327 + }
  328 + };
  329 + var value = getUrlParamsValue(window.location.href, key);
  330 +
  331 + if(value === 'undefined') {
  332 + value = null;
  333 + }
  334 +
  335 + return value;
  336 + };
  337 +
  338 + // 避免提示警告
  339 + var Console = console;
  340 +
  341 + exports.log = function () {
  342 + // 方便后续控制
  343 + Console.log.apply(this, arguments);
  344 + };
  345 +
  346 + exports.warn = function () {
  347 + Console.warn.apply(this, arguments);
  348 + };
  349 +
  350 + exports.error = function () {
  351 + Console.error.apply(this, arguments);
  352 + };
  353 +
  354 + return exports;
  355 +})({});
  356 +/**
  357 + * 作者: 孙尊路
  358 + * 创建时间: 2017-07-14 13:26:47
  359 + * 版本: [1.0, 2017/7/14]
  360 + * 版权: 江苏国泰新点软件有限公司
  361 + * 描述:日历组件基类
  362 + * 实现方案:自定义日历组件+swiper插件的完美结合。
  363 + * 更新日志:
  364 + * (1)修复了农历显示不正确、不对应的问题
  365 + * (2)增加了外部刷新的方法
  366 + * (3)整体优化日程的解耦合情形
  367 + * (4)优化实例化日期,增加时间戳
  368 + */
  369 +
  370 +(function () {
  371 + "use strict";
  372 +
  373 + /**
  374 + * 全局生效默认设置
  375 + * 默认设置可以最大程度的减小调用时的代码
  376 + */
  377 + var defaultOptions = {
  378 + // 默认日历组件容器
  379 + container: "#calendar",
  380 + // swiper滑动容器
  381 + swiper: ".swiper-container",
  382 + // 默认显示农历
  383 + isLunar: true,
  384 + // 默认开启水平方向切换月份
  385 + isSwipeH: true,
  386 + // 默认开启垂直方向切换月份
  387 + isSwipeV: true,
  388 + // 滑动回调
  389 + swipeCallback: noop,
  390 + // 上一月节点
  391 + pre: ".pre",
  392 + // 上一月回调
  393 + preCallback: noop,
  394 + // 下一月节点
  395 + next: ".next",
  396 + // 下一月回调
  397 + nextCallback: noop,
  398 + // 点击回调
  399 + onItemClick: noop,
  400 + // 自定义输入模板
  401 + template: noop,
  402 + // 业务数据绑定
  403 + dataRequest: noop,
  404 + // 是否开启调试
  405 + isDebug: false
  406 + };
  407 +
  408 + function noop() {}
  409 +
  410 + /**
  411 + * 日历的构造函数
  412 + * @param {Object} options 配置参数,和init以及_initData的一致
  413 + * @constructor
  414 + */
  415 + function Calendar(options) {
  416 +
  417 + options = innerCalendarUtil.extend({}, defaultOptions, options);
  418 + if(!this._selector(options.container)) {
  419 + // 抛异常
  420 + throw new Error("传入的日历组件容器Selector #id不存在或者为空,请仔细检查!");
  421 + return;
  422 + }
  423 + this.container = this._selector(options.container);
  424 +
  425 + this._initData(options);
  426 + }
  427 +
  428 + Calendar.prototype = {
  429 + /**
  430 + * 初始化数据单独提取,方便refreshData使用
  431 + * @param {Object} options 配置参数
  432 + */
  433 + _initData: function (options) {
  434 + var self = this;
  435 + this.options = options;
  436 +
  437 + // 创建日历DOM结构体
  438 + this.CreateDOMFactory(function () {
  439 + // 程序入口
  440 + self._initParams();
  441 + });
  442 + },
  443 + _initParams: function () {
  444 + var self = this;
  445 + self.nowYear = self.DateObj().getFullYear();
  446 + self.nowMonth = self.tod(self.DateObj().getMonth() + 1);
  447 + self.nowDay = self.tod(self.DateObj().getDate());
  448 + // 当前日期
  449 + self.currentDate = self.nowYear + "-" + self.nowMonth + "-" + self.nowDay;
  450 +
  451 + // 定义全局变量 计算农历
  452 + self.CalendarData = new Array(100);
  453 + self.madd = new Array(12);
  454 + self.tgString = "甲乙丙丁戊己庚辛壬癸";
  455 + self.dzString = "子丑寅卯辰巳午未申酉戌亥";
  456 + self.numString = "一二三四五六七八九十";
  457 + self.monString = "正二三四五六七八九十冬腊";
  458 + self.weekString = "日一二三四五六";
  459 + self.sx = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
  460 + self.cYear, self.cMonth, self.cDay, self.TheDate;
  461 + self.CalendarData = new Array(0xA4B, 0x5164B, 0x6A5, 0x6D4, 0x415B5, 0x2B6, 0x957, 0x2092F, 0x497, 0x60C96, 0xD4A, 0xEA5, 0x50DA9, 0x5AD, 0x2B6, 0x3126E, 0x92E, 0x7192D, 0xC95, 0xD4A, 0x61B4A, 0xB55, 0x56A, 0x4155B, 0x25D, 0x92D, 0x2192B, 0xA95, 0x71695, 0x6CA, 0xB55, 0x50AB5, 0x4DA, 0xA5B, 0x30A57, 0x52B, 0x8152A, 0xE95, 0x6AA, 0x615AA, 0xAB5, 0x4B6, 0x414AE, 0xA57, 0x526, 0x31D26, 0xD95, 0x70B55, 0x56A, 0x96D, 0x5095D, 0x4AD, 0xA4D, 0x41A4D, 0xD25, 0x81AA5, 0xB54, 0xB6A, 0x612DA, 0x95B, 0x49B, 0x41497, 0xA4B, 0xA164B, 0x6A5, 0x6D4, 0x615B4, 0xAB6, 0x957, 0x5092F, 0x497, 0x64B, 0x30D4A, 0xEA5, 0x80D65, 0x5AC, 0xAB6, 0x5126D, 0x92E, 0xC96, 0x41A95, 0xD4A, 0xDA5, 0x20B55, 0x56A, 0x7155B, 0x25D, 0x92D, 0x5192B, 0xA95, 0xB4A, 0x416AA, 0xAD5, 0x90AB5, 0x4BA, 0xA5B, 0x60A57, 0x52B, 0xA93, 0x40E95);
  462 + self.madd[0] = 0;
  463 + self.madd[1] = 31;
  464 + self.madd[2] = 59;
  465 + self.madd[3] = 90;
  466 + self.madd[4] = 120;
  467 + self.madd[5] = 151;
  468 + self.madd[6] = 181;
  469 + self.madd[7] = 212;
  470 + self.madd[8] = 243;
  471 + self.madd[9] = 273;
  472 + self.madd[10] = 304;
  473 + self.madd[11] = 334;
  474 +
  475 + // 生成日历
  476 + self.initEntry();
  477 +
  478 + },
  479 + /**
  480 + * 初始化日历
  481 + */
  482 + initEntry: function (op) {
  483 + var self = this;
  484 + var options = innerCalendarUtil.extend({
  485 + year: "",
  486 + month: "",
  487 + day: ""
  488 + }, op);
  489 + //console.log("合并后:"+JSON.stringify(options));
  490 + // 获取前一个月份
  491 + if(!options.year) {
  492 + options.year = self.DateObj().getFullYear(); //默认不传为"当前年"
  493 + } else {
  494 + options.year = op.year;
  495 + }
  496 + if(!options.month) {
  497 + options.month = self.tod(self.DateObj().getMonth() + 1); //默认不传为"当前月"
  498 + } else {
  499 + options.month = op.month;
  500 + }
  501 +
  502 + var preYear = options.year;
  503 + var m = options.month;
  504 + var preMonth = parseInt(m) - parseInt(1);
  505 +
  506 + if(preMonth == 0) {
  507 + preYear = options.year - 1;
  508 + preMonth = 12;
  509 + }
  510 + preMonth = self.tom(preMonth);
  511 + var preDay = self.tod("01");
  512 + //if(self.options.isDebug) {
  513 + if(self.options.isDebug) {
  514 + console.log("(前)初始化年月日:" + preYear + "-" + preMonth + "-" + preDay);
  515 +
  516 + }
  517 +
  518 + // 生成上一个月份的日历
  519 + var outputs = [];
  520 + self.refreshData({
  521 + year: preYear,
  522 + month: preMonth,
  523 + day: preDay
  524 + }, function (output) {
  525 + outputs.push({
  526 + templ: output
  527 + });
  528 +
  529 + // 初始化默认当前日期
  530 + var curYear = options.year || self.DateObj().getFullYear();
  531 + var curMonth = options.month || self.tod(self.DateObj().getMonth() + 1);
  532 + var curDay = options.day || self.tod(self.DateObj().getDate());
  533 + //alert("默认对不对:"+curYear+"-"+curMonth+"-"+curDay);
  534 + self.curYear = options.year || self.DateObj().getFullYear();
  535 + self.curMonth = options.month || self.tod(self.DateObj().getMonth() + 1);
  536 + self.curDay = options.day || self.tod(self.DateObj().getDate());
  537 + if(self.options.isDebug) {
  538 + console.log("(中)初始化年月日:" + curYear + "-" + curMonth + "-" + curDay);
  539 + }
  540 +
  541 + // 生成本月份的日历
  542 + self.refreshData({
  543 + year: curYear,
  544 + month: curMonth,
  545 + day: curDay
  546 + }, function (output1) {
  547 + outputs.push({
  548 + templ: output1
  549 + });
  550 + // 渲染日历模板
  551 + var templ = self.SLIDER_ITEM_CONTAINER;
  552 +
  553 + var html = "";
  554 + for(var i = 0; i < outputs.length; i++) {
  555 + html += Mustache.render(templ, outputs[i]);
  556 + }
  557 + document.querySelector(".swiper-wrapper").innerHTML = html;
  558 + // 初始化swiper监听
  559 + self._addEvent();
  560 + });
  561 + });
  562 + },
  563 + /**
  564 + * 刷新日历,传入日期格式须:2017-07-01 或2017-12-09
  565 + */
  566 + //refreshData: function(year, month, day, activeSlideNode) {
  567 + refreshData: function (dateObj, callback) {
  568 + var self = this;
  569 +
  570 + self.nowYear = parseInt(dateObj.year);
  571 + self.nowMonth = self.tom(dateObj.month);
  572 + self.nowDay = self.tod(dateObj.day);
  573 +
  574 + // 获取星期
  575 + var tmptmp = new Date(Date.parse(self.nowYear + '/' + self.nowMonth + '/01'));
  576 + var nowXingQiJi = tmptmp.getDay();
  577 + //console.log("星期"+nowXingQiJi);
  578 +
  579 + nowXingQiJi = parseInt(nowXingQiJi);
  580 + if(nowXingQiJi == 0) {
  581 + nowXingQiJi = 7;
  582 + }
  583 + // 根据年份、月份 计算月份中的天数(比如:28、29、30、31等)
  584 + var dayCount = self._judgeDaysByYearMonth(self.nowYear, self.nowMonth);
  585 + // 总天数
  586 + self.dayCount = dayCount;
  587 + // 保留老的存储方式
  588 + var fileInfo = {};
  589 + // 新的存储方式
  590 + var tmpInfo = [];
  591 +
  592 + var preDayCount = self._judgeDaysByYearMonth(self.nowYear, parseInt(self.nowMonth - 1));
  593 + //console.log("前一月总天数:" + preDayCount);
  594 + preDayCount = parseInt(preDayCount);
  595 +
  596 + // 头部日期计算
  597 + for(var i = 1; i < nowXingQiJi + 1; i++) {
  598 + //var preMonthDay = preDayCount - nowXingQiJi + i;
  599 + //var tmpName = 'day' + i;
  600 + // var lunar = 'lunar' + i;
  601 + //日、农历、完整日期
  602 + // var y = parseInt(self.nowYear);
  603 + // var m = parseInt(self.nowMonth);
  604 + // m = -1 + m;
  605 + // if(m == 0) {
  606 + // m = 12
  607 + // y = parseInt(self.nowYear - 1)
  608 + // }
  609 + //fileInfo[tmpName] = preMonthDay;
  610 + //fileInfo[lunar] = self._getLunar(preMonthDay, m, y);
  611 + // console.log("农历:" + fileInfo[lunar]);
  612 + //存储前一个月数据
  613 + //console.log(self.nowYear + "-" + self.tom(parseInt(self.nowMonth - 1)) + "-" + self.tod(preMonthDay));
  614 + tmpInfo.push({
  615 + // day: preMonthDay, //日
  616 + // lunar: self._getLunar(preMonthDay, m, y), //农历
  617 + //date: y + "-" + self.tom(m) + "-" + self.tod(preMonthDay), //完整日期
  618 + //isforbid: "0", //前一个月和后一个月不可点击
  619 + // tip: 'prev',
  620 + });
  621 + //console.log("年份:" + self.nowYear);
  622 + //console.log("上个月的数据:\n" + JSON.stringify(tmpInfo)+"\n");
  623 + }
  624 + var daonale = 0;
  625 +
  626 + if(dayCount == '28') {
  627 + daonale = 28 + nowXingQiJi;
  628 + for(var index = nowXingQiJi + 1, indexindex = 1; index < (28 + nowXingQiJi + 1); index++, indexindex++) {
  629 + //var tmpName = 'day' + index;
  630 + var lunar = 'lunar' + index;
  631 + fileInfo[tmpName] = indexindex;
  632 + fileInfo[lunar] = self._getLunar(indexindex);
  633 + //存储当前月数据
  634 + tmpInfo.push({
  635 + day: indexindex, //日
  636 + lunar: self._getLunar(indexindex), //农历
  637 + date: self.nowYear + "-" + self.tom(self.nowMonth) + "-" + self.tod(indexindex), //完整日期
  638 + isforbid: "1" //当前月可点击
  639 + });
  640 + // console.log(self.tom(parseInt(self.nowMonth)) + "月份:" + self.tod(indexindex));
  641 +
  642 + }
  643 + }
  644 + if(dayCount == '29') {
  645 + daonale = 29 + nowXingQiJi;
  646 + for(var index = nowXingQiJi + 1, indexindex = 1; index < (29 + nowXingQiJi + 1); index++, indexindex++) {
  647 + var tmpName = 'day' + index;
  648 + var lunar = 'lunar' + index;
  649 + //fileInfo[tmpName] = indexindex;
  650 + fileInfo[lunar] = self._getLunar(indexindex);
  651 + //存储当前月数据
  652 + tmpInfo.push({
  653 + day: indexindex, //日
  654 + lunar: self._getLunar(indexindex), //农历
  655 + date: self.nowYear + "-" + self.tom(self.nowMonth) + "-" + self.tod(indexindex), //完整日期
  656 + isforbid: "1" //当前月可点击
  657 + });
  658 + //console.log(self.tom(parseInt(self.nowMonth)) + "月份:" + self.tod(indexindex));
  659 +
  660 + }
  661 + }
  662 + if(dayCount == '30') {
  663 + daonale = 30 + nowXingQiJi;
  664 + for(var index = nowXingQiJi + 1, indexindex = 1; index < (30 + nowXingQiJi + 1); index++, indexindex++) {
  665 + // var tmpName = 'day' + index;
  666 + var lunar = 'lunar' + index;
  667 + // fileInfo[tmpName] = indexindex;
  668 + fileInfo[lunar] = self._getLunar(indexindex);
  669 + //存储当前月数据
  670 + tmpInfo.push({
  671 + day: indexindex, //日
  672 + lunar: self._getLunar(indexindex), //农历
  673 + date: self.nowYear + "-" + self.tom(self.nowMonth) + "-" + self.tod(indexindex), //完整日期
  674 + isforbid: "1" //当前月可点击
  675 + });
  676 + //console.log(self.tom(parseInt(self.nowMonth)) + "月份:" + self.tod(indexindex));
  677 + }
  678 + }
  679 + if(dayCount == '31') {
  680 + daonale = 31 + nowXingQiJi;
  681 + for(var index = nowXingQiJi + 1, indexindex = 1; index < (31 + nowXingQiJi + 1); index++, indexindex++) {
  682 + var tmpName = 'day' + index;
  683 + var lunar = 'lunar' + index;
  684 + // fileInfo[tmpName] = indexindex;
  685 + //fileInfo[lunar] = self._getLunar(indexindex);
  686 + //存储当前月数据
  687 + tmpInfo.push({
  688 + day: indexindex, //日
  689 + lunar: self._getLunar(indexindex), //农历
  690 + date: self.nowYear + "-" + self.tom(self.nowMonth) + "-" + self.tod(indexindex), //完整日期
  691 + isforbid: "1" //当前月可点击
  692 + });
  693 + //console.log(self.tom(parseInt(self.nowMonth)) + "月份:" + self.tod(indexindex));
  694 + }
  695 + }
  696 + // 尾部日期计算
  697 + // for(var index2 = daonale + 1, index3 = 1; index2 <= 42; index2++, index3++) {
  698 + // var tmpName = 'day' + index2;
  699 + // var lunar = 'lunar' + index2;
  700 + // //日、农历、完整日期
  701 + // var y2 = parseInt(self.nowYear);
  702 + // var m2 = parseInt(self.nowMonth) + parseInt(1);
  703 + // if(m2 == 13) {
  704 + // m2 = 1;
  705 + // y2 = parseInt(self.nowYear) + parseInt(1)
  706 + // }
  707 + // fileInfo[tmpName] = index3;
  708 + // fileInfo[lunar] = self._getLunar(index3, m2, y2);
  709 + // //存储当前月数据
  710 + // tmpInfo.push({
  711 + // day: index3, //日
  712 + // lunar: self._getLunar(index3, m2, y2), //农历
  713 + // date: y2 + "-" + self.tom(m2) + "-" + self.tod(index3), //完整日期
  714 + // isforbid: "0", //前一月和后一月不可点击
  715 + // tip: 'next',
  716 + // });
  717 + // //console.log("后面一个月的数据:\n" + JSON.stringify(tmpInfo) + "\n");
  718 + // //console.log(self.tom(parseInt(self.nowMonth) + parseInt(1)) + "月份:" + self.tod(index3));
  719 + // }
  720 + if(self.options.isDebug) {
  721 + console.log("*********日历格式********:\n" + JSON.stringify(tmpInfo) + "\n");
  722 + }
  723 + //this._render(fileInfo, tmpInfo, dateObj.activeSlideNode);
  724 + this._render({
  725 + fileInfo: fileInfo,
  726 + tmpInfo: tmpInfo,
  727 + activeSlideNode: dateObj.activeSlideNode,
  728 + }, callback);
  729 + },
  730 +
  731 + /**
  732 + * 视图的渲染和数据分离,采用内部的数据
  733 + */
  734 + //_render: function(fileInfo, tmpInfo, activeSlideNode) {
  735 + _render: function (dataObj, callback) {
  736 + var self = this;
  737 + //console.log("XXXX" + JSON.stringify(dataObj.fileInfo));
  738 + // 渲染之前,业务ajax请求,显示日历上日程标记
  739 + var dateStr = self.nowYear + "-" + self.nowMonth + "-";
  740 +
  741 + // 必须设置延迟300ms,否则滑动有偏差
  742 + setTimeout(function () {
  743 + self.options.dataRequest(dateStr, function (data) {
  744 + var res = data || [];
  745 + //和业务绑定
  746 + if(self.options.isDebug) {
  747 + console.log("*********业务数据:********:\n" + JSON.stringify(res) + "\n");
  748 + }
  749 + for(var j = 0; j < res.length; j++) {
  750 + for(var i = 0; i < dataObj.tmpInfo.length; i++) {
  751 + if(res[j].date == dataObj.tmpInfo[i].date) {
  752 + dataObj.tmpInfo[i].isSelected = "1";
  753 + }
  754 + }
  755 + }
  756 + //完全支持自定义外部传入模板
  757 + var html = self.getThemeHtml(dataObj);
  758 +
  759 + if(self.options.isDebug) {
  760 + console.log("*********日历模板********:\n" + html + "\n");
  761 + }
  762 + if(typeof (callback) == "function") {
  763 + callback && callback(html, dataObj.tmpInfo);
  764 + }
  765 +
  766 + return;
  767 + }, self);
  768 + }, 100);
  769 + },
  770 + /**
  771 + * 获取主题模板
  772 + */
  773 + getThemeHtml: function (dataObj) {
  774 + var self = this;
  775 + // 模板集合
  776 + var html = "";
  777 + // 模板项
  778 + var template = "";
  779 + // 当前日期
  780 + var curr = self.currentDate;
  781 +
  782 + for(var i = 0, len = dataObj.tmpInfo.length; i < len; i++) {
  783 + // 如果传入模板为空,则默认日历主题模板
  784 + var value = dataObj.tmpInfo[i];
  785 + var templData = self.options.template(value, curr);
  786 + if(!templData) {
  787 + //console.log("=======默认日历主题模板=======");
  788 + // =======默认日历主题模板=======
  789 + // 上一月和下一月不可点击模板
  790 + if(value.date == curr) {
  791 + //今天
  792 + if(value.isSelected) {
  793 + template = '<div class="em-calendar-item em-calendar-active isforbid{{isforbid}}" date="{{date}}"><span class="day">{{day}}</span><p class="lunar">今天</p><span class="dot dot-type1"></span></div>';
  794 + } else {
  795 + template = '<div class="em-calendar-item em-calendar-active isforbid{{isforbid}}" date="{{date}}"><span class="day">{{day}}</span><p class="lunar">今天</p></div>';
  796 + }
  797 + } else {
  798 + if(value.isSelected) {
  799 + // 个性化和业务贴近
  800 + template = '<div class="em-calendar-item isforbid{{isforbid}} tip{{tip}}" date="{{date}}" ><span class="day">{{day}}</span><p class="lunar">{{lunar}}</p><span class="dot dot-type1"></span></div>';
  801 + } else {
  802 + template = '<div class="em-calendar-item isforbid{{isforbid}} tip{{tip}}" date="{{date}}"><span class="day">{{day}}</span><p class="lunar">{{lunar}}</p></div>';
  803 + }
  804 + }
  805 + html += Mustache.render(template, value);
  806 + } else {
  807 + // console.log("=======自定义传入=======");
  808 + // =======自定义传入=======
  809 + html += Mustache.render(templData, value);
  810 + }
  811 + }
  812 +
  813 + return html;
  814 + },
  815 + /**
  816 + * 创建DOM元素工厂,将样式固定结构存储起来,外部可通过样式修改
  817 + */
  818 + CreateDOMFactory: function (callback) {
  819 + var self = this;
  820 + // 头部样式
  821 + self.HEADER_BAR = '<div class="em-calendar-container"><div class="em-week">\
  822 + <span class="em-red">日</span>\
  823 + <span>一</span>\
  824 + <span>二</span>\
  825 + <span>三</span>\
  826 + <span>四</span>\
  827 + <span>五</span>\
  828 + <span class="em-red">六</span>\
  829 + </div>';
  830 +
  831 + self.HEADER = '<div class="swiper-container">\
  832 + <div class="swiper-wrapper">';
  833 +
  834 + // 底部样式
  835 + self.FOOTER = '</div>\
  836 + </div>\
  837 + </div>';
  838 +
  839 + // 日历面板容器样式
  840 + self.SLIDER_ITEM_CONTAINER = '<div class="swiper-slide">\
  841 + <div class="em-calendar-content">\
  842 + <div class="em-calendar-wrapper">{{{templ}}}</div>\
  843 + </div></div>';
  844 +
  845 + var output = self.HEADER_BAR + self.HEADER + self.FOOTER;
  846 + self.container.innerHTML = output;
  847 +
  848 + // 执行回调
  849 + callback && callback();
  850 + },
  851 + /*
  852 + * JSON数组去重
  853 + * @param: [array] json Array
  854 + * @param: [string] 唯一的key名,根据此键名进行去重
  855 + */
  856 + uniqueArray: function (array, key) {
  857 + var result = [array[0]];
  858 + for(var i = 1; i < array.length; i++) {
  859 + var item = array[i];
  860 + var repeat = false;
  861 + for(var j = 0; j < result.length; j++) {
  862 + if(item[key] == result[j][key]) {
  863 + repeat = true;
  864 + break;
  865 + }
  866 + }
  867 + if(!repeat) {
  868 + result.push(item);
  869 + }
  870 + }
  871 + return result;
  872 +
  873 + },
  874 + /**
  875 + * 增加事件,包括
  876 + * 日历点击的监听
  877 + * 日历左滑、右滑切换,等等
  878 + */
  879 + _addEvent: function () {
  880 + var self = this;
  881 + var onItemClick = self.options.onItemClick;
  882 + var swipeCallback = self.options.swipeCallback;
  883 + var preCallback = self.options.preCallback;
  884 + var nextCallback = self.options.nextCallback;
  885 +
  886 + // 记录上一月和上一年的索引
  887 + var preMonthIndex = parseInt(self.curMonth) - parseInt(2);;
  888 + var preYearIndex = self.curYear;
  889 + // 记录下一月和下一年的索引
  890 + var nextMonthIndex = parseInt(self.curMonth);
  891 + var nextYearIndex = self.DateObj().getFullYear();
  892 + var nextYear = self.curYear;
  893 + var nextMonth;
  894 +
  895 + var count = 0;
  896 + var currYearIndex = self.curYear;
  897 + var currMonthIndex = parseInt(self.curMonth);
  898 + var currDayIndex = self.curDay;
  899 + // 创建swiper 组件对象
  900 + self.mySwiper = new Swiper('.swiper-container', {
  901 + loop: false,
  902 + initialSlide: 1,
  903 + speed: 150,
  904 + prevButton: self.options.pre,
  905 + nextButton: self.options.next,
  906 + // 增加监听点击事件
  907 + onClick: function (swiper, e) {
  908 + // console.log(e.target.innerHTML);
  909 + // 日期灰色部分不启用
  910 + var _this = e.target.parentNode;
  911 + // 日期输出值
  912 + var dateStr = _this.getAttribute('date');
  913 +
  914 + // 农历输出值
  915 + if(_this.querySelector('.lunar')) {
  916 + var lunarStr = _this.querySelector('.lunar').innerText.trim();
  917 + } else {
  918 + var lunarStr = "已签";
  919 + }
  920 + // 可点击区域
  921 + if(!_this.classList.contains('isforbid0')) {
  922 + // _this.classList.add('em-calendar-active');
  923 + if(_this.classList.contains('em-calendar-active')){
  924 + _this.classList.remove('em-calendar-active');
  925 + }else{
  926 + _this.classList.add('em-calendar-active');
  927 + var dat=_this.getAttribute("date");
  928 + console.log(dat)
  929 + }
  930 +
  931 + } else {
  932 + // 不可点击区域
  933 + if(_this.classList.contains('tipprev')) {
  934 + // 前进
  935 + self.slidePrev().then(function () {
  936 + // 给特定日期新增点击激活样式
  937 + // self.addActiveStyleFordate(dateStr);
  938 + });
  939 + } else if(_this.classList.contains('tipnext')) {
  940 + // 后退
  941 + self.slideNext().then(function () {
  942 + // 给特定日期新增点击激活样式
  943 + // self.addActiveStyleFordate(dateStr);
  944 + });
  945 +
  946 + }
  947 + }
  948 + // 点击回调
  949 + onItemClick && onItemClick({
  950 + date: dateStr, //日期
  951 + lunar: lunarStr //农历
  952 + });
  953 + },
  954 + /**
  955 + * @description 月份递增
  956 + * @param {Object} swiper swiper对象
  957 + */
  958 + onSlideNextStart: function (swiper) {
  959 + count++;
  960 + if(count == "1") {
  961 + //alert("等于1,并不能代表是当前月");
  962 + //alert("传过来的是"+self.nowYear+self.nowMonth);
  963 + currDayIndex = self.curDay;
  964 + currMonthIndex = parseInt(self.curMonth);
  965 + } else {
  966 + currMonthIndex = currMonthIndex + 1;
  967 + currDayIndex = "01";
  968 +
  969 + }
  970 + if(currMonthIndex == "13") {
  971 + currYearIndex = parseInt(currYearIndex) + parseInt(1);
  972 + currMonthIndex = 1;
  973 + }
  974 + // 开启调试模式
  975 + if(self.options.isDebug) {
  976 + console.log("currMonthIndex:" + currMonthIndex);
  977 + console.log("currYearIndex:" + currYearIndex);
  978 + console.log(">>>>>>" + self.nowYear + "-" + self.nowMonth + "-" + self.nowDay);
  979 + }
  980 + //alert("向后回调"+">>>>>>" + currYearIndex + "-" + currMonthIndex + "-" + self.nowDay);
  981 + //回调
  982 + swipeCallback && swipeCallback({
  983 + year: currYearIndex,
  984 + month: self.tom(currMonthIndex),
  985 + day: currDayIndex,
  986 + date: currYearIndex + "-" + self.tom(currMonthIndex) + "-" + currDayIndex,
  987 + dayCount: self.dayCount
  988 + });
  989 + /**
  990 + * @description 后加
  991 + */
  992 + nextMonthIndex += parseInt(1);
  993 + if(nextMonthIndex == 13) {
  994 + nextYear = nextYearIndex + 1;
  995 + nextMonthIndex = 1;
  996 + }
  997 + nextMonth = self.tom(nextMonthIndex);
  998 +
  999 + if(self.options.isDebug) {
  1000 + console.log("(后)初始化年月日:" + nextYear + "-" + nextMonth + "-" + "01");
  1001 + }
  1002 +
  1003 + self.refreshData({
  1004 + year: nextYear,
  1005 + month: nextMonth,
  1006 + day: "01"
  1007 + }, function (output1) {
  1008 + var outputs = [];
  1009 + outputs.push({
  1010 + templ: output1
  1011 + });
  1012 + // 渲染日历模板
  1013 + var templ = self.SLIDER_ITEM_CONTAINER;
  1014 + var html = "";
  1015 + for(var i = 0; i < outputs.length; i++) {
  1016 + html += Mustache.render(templ, outputs[i]);
  1017 + }
  1018 + swiper.appendSlide(html);
  1019 + });
  1020 + // 如果往后滑动时后一个月非当前月,重新渲染1号样式
  1021 + if(self.tom(currMonthIndex) !== self.curMonth) {
  1022 + var chooseDom = document.querySelector('.swiper-slide-active .em-calendar-active')
  1023 + if(chooseDom) {
  1024 + chooseDom.classList.remove('em-calendar-active')
  1025 + }
  1026 + document.querySelector('.swiper-slide-active .isforbid1').classList.add('em-calendar-active')
  1027 +
  1028 + }
  1029 +
  1030 + },
  1031 + /**tipprev
  1032 + * @description 月份递减
  1033 + * @param {Object} swiper swiper对象
  1034 + */
  1035 + onSlidePrevStart: function (swiper) {
  1036 + count--;
  1037 + if(count == "1") {
  1038 + currDayIndex = self.curDay;
  1039 + currMonthIndex = parseInt(self.curMonth);
  1040 + } else {
  1041 + currMonthIndex = parseInt(currMonthIndex) - parseInt(1);
  1042 + currDayIndex = "01";
  1043 +
  1044 + }
  1045 +
  1046 + if(currMonthIndex == 0) {
  1047 + currYearIndex = parseInt(currYearIndex) - parseInt(1);
  1048 + currMonthIndex = 12;
  1049 + }
  1050 + // 开启调试模式
  1051 + if(self.options.isDebug) {
  1052 + console.log("currMonthIndex:" + currMonthIndex);
  1053 + console.log("currYearIndex:" + currYearIndex);
  1054 + console.log("当前" + self.nowYear + "-" + self.nowMonth + "月份");
  1055 + }
  1056 +
  1057 + // 点击回调
  1058 + swipeCallback && swipeCallback({
  1059 + year: currYearIndex,
  1060 + month: self.tom(currMonthIndex),
  1061 + day: currDayIndex,
  1062 + date: currYearIndex + "-" + self.tom(currMonthIndex) + "-" + currDayIndex,
  1063 + dayCount: self.dayCount
  1064 + });
  1065 +
  1066 + if(preMonthIndex == 0) {
  1067 + preYearIndex--;
  1068 + preMonthIndex = 12;
  1069 + }
  1070 + var preMonth = self.tom(preMonthIndex);
  1071 + //console.log("前加:" + preYearIndex + "-" + preMonth + "-" + "01");
  1072 + //ejs.ui.toast("前加:" + preYearIndex + "-" + preMonth + "-" + preDay);
  1073 +
  1074 + preMonthIndex--;
  1075 + // 刷新日历
  1076 +
  1077 + self.refreshData({
  1078 + year: preYearIndex,
  1079 + month: preMonth,
  1080 + day: "01"
  1081 + }, function (output1) {
  1082 +
  1083 + var outputs = [];
  1084 + outputs.push({
  1085 + templ: output1
  1086 + });
  1087 + // 渲染日历模板
  1088 + var templ = self.SLIDER_ITEM_CONTAINER;
  1089 + var html = "";
  1090 + for(var i = 0; i < outputs.length; i++) {
  1091 + html += Mustache.render(templ, outputs[i]);
  1092 + }
  1093 + swiper.prependSlide(html);
  1094 + });
  1095 +
  1096 + // 如果往前滑动时前一个月非当前月,重新渲染1号样式
  1097 + if(self.tom(currMonthIndex) !== self.curMonth) {
  1098 + var chooseDom = document.querySelector('.swiper-slide-active .em-calendar-active')
  1099 + if(chooseDom) {
  1100 + chooseDom.classList.remove('em-calendar-active')
  1101 + }
  1102 + document.querySelector('.swiper-slide-active .isforbid1').classList.add('em-calendar-active')
  1103 +
  1104 + }
  1105 + }
  1106 + });
  1107 +
  1108 + // 回到今天
  1109 + if(self._selector(self.options.backToToday)) {
  1110 + self._selector(self.options.backToToday).addEventListener("touchstart", function () {
  1111 + // 外部执行回调
  1112 + var curYear = self.DateObj().getFullYear();
  1113 + var curMonth = self.tod(self.DateObj().getMonth() + 1);
  1114 + var curDay = self.tod(self.DateObj().getDate());
  1115 + // 刷新
  1116 + self.refresh();
  1117 +
  1118 + });
  1119 + }
  1120 + },
  1121 + /**
  1122 + * @description 给特定日期新增选中激活样式
  1123 + * @param {Object} dateStr 点击后的日期 ,例如:“2018-08-20”
  1124 + */
  1125 + addActiveStyleFordate: function (dateStr) {
  1126 + var self = this;
  1127 + // 给前后月的点击日期加选中标记
  1128 + var clickactives = document.querySelector('.swiper-slide-active').querySelectorAll('.em-calendar-item');
  1129 + for(var i = 0; i < clickactives.length; i++) {
  1130 + clickactives[i].onclick=function(){
  1131 + // console.log($(this).attr("date"))
  1132 + }
  1133 + // clickactives[i].classList.add('em-calendar-active');
  1134 + if(clickactives[i].getAttribute("date") == dateStr) {
  1135 + clickactives[i].classList.add('em-calendar-active');
  1136 + self.sibling(clickactives[i], function (el) {
  1137 + el.classList.remove('em-calendar-active');
  1138 + });
  1139 + }
  1140 + }
  1141 + },
  1142 + /**
  1143 + * 向前滑动
  1144 + */
  1145 + slidePrev: function (options) {
  1146 + var self = this;
  1147 + return new Promise(function (resolve, reject) {
  1148 + self.mySwiper.slidePrev();
  1149 + return resolve(options);
  1150 + });
  1151 + },
  1152 +
  1153 + /**
  1154 + * 向后滑动
  1155 + */
  1156 + slideNext: function (options) {
  1157 + var self = this;
  1158 + return new Promise(function (resolve, reject) {
  1159 + self.mySwiper.slideNext();
  1160 + return resolve(options);
  1161 + });
  1162 + },
  1163 + /**
  1164 + * 外部刷新
  1165 + */
  1166 + refresh: function (options) {
  1167 + var self = this;
  1168 + // 销毁
  1169 + self.destroySwiper();
  1170 + // 创建
  1171 + self.initEntry(options);
  1172 +
  1173 + },
  1174 + /**
  1175 + * 销毁swiper
  1176 + */
  1177 + destroySwiper: function () {
  1178 + var self = this;
  1179 + // 销毁
  1180 + self.mySwiper.destroy(true);
  1181 + },
  1182 +
  1183 + /**
  1184 + * 获取当前农历
  1185 + * @param {Object} currentday
  1186 + * @param {Object} month
  1187 + * @return {String}
  1188 + */
  1189 + _getLunar: function (currentday, month, year) {
  1190 + var self = this;
  1191 + // 中间需默认当前年和当前月,两头需要传年和月
  1192 + var yy = year || self.nowYear;
  1193 + var mm = month || self.nowMonth;
  1194 + var dd = currentday;
  1195 + return this._getLunarDay(yy, mm, dd);
  1196 + },
  1197 + /**
  1198 + * 根据年月计算当月的天数
  1199 + * @param {Object} y
  1200 + * @param {Object} m
  1201 + */
  1202 + _judgeDaysByYearMonth: function (y, m) {
  1203 + var self = this;
  1204 + if(y == undefined || y == null) {
  1205 + throw "=====获取当前月份天数时,缺少y参数,未定义!=======";
  1206 + }
  1207 + if(m == undefined || m == null) {
  1208 + throw "=====获取当前月份天数时,缺少m参数,未定义!=======";
  1209 + }
  1210 + var y = parseInt(y);
  1211 + var m = parseInt(m);
  1212 + if(m == 0) {
  1213 + y--;
  1214 + m = 12;
  1215 + }
  1216 + if(m == 2) {
  1217 + if((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) {
  1218 + return '29';
  1219 + } else {
  1220 + return '28';
  1221 + }
  1222 + } else {
  1223 + if(self._inArray(m, [1, 3, 5, 7, 8, 10, 12])) {
  1224 + return '31';
  1225 + } else {
  1226 + return '30';
  1227 + }
  1228 + }
  1229 +
  1230 + },
  1231 +
  1232 + /**
  1233 + * 进行一次全局验证,验证输入的合法性
  1234 + * 这个验证是强制性的
  1235 + */
  1236 + _validate: function () {
  1237 + var flag = true;
  1238 + if(!this.options.container) {
  1239 + flag = false;
  1240 + }
  1241 + return flag;
  1242 + },
  1243 + _selector: function (el) {
  1244 + // 减少耦合
  1245 + return document.querySelector(el);
  1246 + },
  1247 + /**
  1248 + * 判断元素在数组中是否存在
  1249 + * @param {Object} str 数字或者字符串元素
  1250 + * @param {Object} arr 有效数组
  1251 + */
  1252 + _inArray: function (str, arr) {
  1253 + // 不是数组则抛出异常
  1254 + if(!Array.isArray(arr)) {
  1255 + throw "arguments is not Array";
  1256 + }
  1257 + // 遍历是否在数组中
  1258 + for(var i = 0, k = arr.length; i < k; i++) {
  1259 + if(str == arr[i]) {
  1260 + return true;
  1261 + }
  1262 + }
  1263 + // 如果不在数组中就会返回false
  1264 + return false;
  1265 + },
  1266 + // 遍历查找同级元素
  1267 + _sibling: function (elem, forCB) {
  1268 + var r = [];
  1269 + var n = elem.parentNode.firstChild;
  1270 + for(; n; n = n.nextSibling) {
  1271 + if(n.nodeType === 1 && n !== elem) {
  1272 + if(forCB && typeof (forCB) == "function") {
  1273 + forCB(n);
  1274 + }
  1275 + }
  1276 + }
  1277 + },
  1278 + _getBit: function (m, n) {
  1279 + var self = this;
  1280 + // 农历转换
  1281 + return(m >> n) & 1;
  1282 + },
  1283 + _e2c: function () {
  1284 + var self = this;
  1285 + self.TheDate = (arguments.length != 3) ? new Date() : new Date(arguments[0], arguments[1], arguments[2]);
  1286 + var total, m, n, k;
  1287 + var isEnd = false;
  1288 + var tmp = self.TheDate.getYear();
  1289 + if(tmp < 1900) {
  1290 + tmp += 1900;
  1291 + }
  1292 + total = (tmp - 1921) * 365 + Math.floor((tmp - 1921) / 4) + self.madd[self.TheDate.getMonth()] + self.TheDate.getDate() - 38;
  1293 +
  1294 + if(self.TheDate.getYear() % 4 == 0 && self.TheDate.getMonth() > 1) {
  1295 + total++;
  1296 + }
  1297 + for(m = 0;; m++) {
  1298 + k = (self.CalendarData[m] < 0xfff) ? 11 : 12;
  1299 + for(n = k; n >= 0; n--) {
  1300 + if(total <= 29 + self._getBit(self.CalendarData[m], n)) {
  1301 + isEnd = true;
  1302 + break;
  1303 + }
  1304 + total = total - 29 - self._getBit(self.CalendarData[m], n);
  1305 + }
  1306 + if(isEnd) break;
  1307 + }
  1308 + self.cYear = 1921 + m;
  1309 + self.cMonth = k - n + 1;
  1310 + self.cDay = total;
  1311 + if(k == 12) {
  1312 + if(self.cMonth == Math.floor(self.CalendarData[m] / 0x10000) + 1) {
  1313 + self.cMonth = 1 - self.cMonth;
  1314 + }
  1315 + if(self.cMonth > Math.floor(self.CalendarData[m] / 0x10000) + 1) {
  1316 + self.cMonth--;
  1317 + }
  1318 + }
  1319 +
  1320 + },
  1321 +
  1322 + _getcDateString: function () {
  1323 + var self = this;
  1324 + var tmp = "";
  1325 + /*显示农历年:( 如:甲午(马)年 )*/
  1326 + if(self.cMonth < 1) {
  1327 + // tmp += "(闰)";
  1328 + // tmp += self.monString.charAt(-self.cMonth - 1);
  1329 + } else {
  1330 + // tmp += self.monString.charAt(self.cMonth - 1);
  1331 + }
  1332 + //tmp += "月";
  1333 + tmp += (self.cDay < 11) ? "初" : ((self.cDay < 20) ? "十" : ((self.cDay < 30) ? "廿" : "三十"));
  1334 + if(self.cDay % 10 != 0 || self.cDay == 10) {
  1335 + tmp += self.numString.charAt((self.cDay - 1) % 10);
  1336 + }
  1337 + return tmp;
  1338 +
  1339 + },
  1340 + _getLunarDay: function (solarYear, solarMonth, solarDay) {
  1341 + var self = this;
  1342 + //solarYear = solarYear<1900?(1900+solarYear):solarYear;
  1343 + if(solarYear < 1921 || solarYear > 2080) {
  1344 + return "";
  1345 + } else {
  1346 + solarMonth = (parseInt(solarMonth) > 0) ? (solarMonth - 1) : 11;
  1347 + self._e2c(solarYear, solarMonth, solarDay);
  1348 + return self._getcDateString();
  1349 + }
  1350 +
  1351 + },
  1352 + /**
  1353 + * 将1,2,3,4,5格式化01,02,03,04,05
  1354 + * @param {Object} m 月份转换
  1355 + */
  1356 + tom: function (m) {
  1357 + if(parseInt(m) > 9) {
  1358 + m = "" + parseInt(m);
  1359 + } else {
  1360 + m = "0" + parseInt(m);
  1361 + }
  1362 + return m;
  1363 + },
  1364 + /**
  1365 + * 将1,2,3,4,5格式化01,02,03,04,05
  1366 + * @param {Object} 日转换
  1367 + */
  1368 + tod: function (d) {
  1369 + if(parseInt(d) > 9) {
  1370 + d = "" + parseInt(d);
  1371 + } else {
  1372 + d = "0" + parseInt(d);
  1373 + }
  1374 + return d;
  1375 + },
  1376 + /**
  1377 + * 获取小时、分钟、秒 例如:18:09:00
  1378 + * @param {Object} format hh:mm 输出00:00 hh:mm:ss 输出00:00:00
  1379 + */
  1380 + getTime: function (format) {
  1381 + var self = this;
  1382 + var hh = self.DateObj().getHours();
  1383 + var mm = self.DateObj().getMinutes();
  1384 + var ss = self.DateObj().getSeconds();
  1385 + var timeStr = "";
  1386 + if("hh:mm" == format) {
  1387 + timeStr += hh + ":" + mm;
  1388 + } else if("hh:mm:ss" == format) {
  1389 + timeStr += hh + ":" + mm + ":" + ss;
  1390 + }
  1391 + return timeStr;
  1392 + },
  1393 + /**
  1394 + * 获取对象
  1395 + */
  1396 + DateObj: function (dateStr) {
  1397 + var dateObj;
  1398 + if(!dateStr) {
  1399 + //throw("请输入合法日期格式!"+str);
  1400 + dateObj = new Date();
  1401 + } else {
  1402 + // 注意:须先把时间戳(122891289)转成字符串然后进行查找
  1403 + var index = dateStr.toString().indexOf('-');
  1404 + if(index == "-1") {
  1405 + // 解析时间戳
  1406 + dateObj = new Date(dateStr);
  1407 + } else {
  1408 + // 解析正常格式时间戳,切记不要直接传 new Date 2017-09-09 19:00:00,
  1409 + dateObj = new Date(dateStr.replace(/-/g, '/'));
  1410 + }
  1411 + }
  1412 + return dateObj;
  1413 + },
  1414 + /**
  1415 + * @description 获取某个元素的所有兄弟节点;这里还是建议使用库来实现 ,喜欢深究的可以参考下面代码(原理类似Zepto,jquery 的silbling()方法)。
  1416 + * @param {Object} elem 选中的当前节点
  1417 + * @param {Function} forCB 遍历回调每个兄弟节点
  1418 + * 用法如下:
  1419 + */
  1420 + sibling: function (elem, forCB) {
  1421 + var r = [];
  1422 + var n = elem.parentNode.firstChild;
  1423 + for(; n; n = n.nextSibling) {
  1424 + if(n.nodeType === 1 && n !== elem) {
  1425 + if(forCB && typeof (forCB) == "function") {
  1426 + forCB(n);
  1427 + }
  1428 + }
  1429 + }
  1430 + },
  1431 +
  1432 + };
  1433 +
  1434 + window.Calendar = Calendar;
  1435 +})();