请选择 进入手机版 | 继续访问电脑版
帖子
帖子
用户
博客
课程
显示全部楼层
1682
帖子
10
勋章
Y币

UICalendar模块(日历)demo示例

  [复制链接]
发表于 2017-8-1 10:47:03
UICalendar 是一个日历选择模块;可自定义日历的样式,添加特殊日期标注,切换月份,设置指定日期;用于实现常用的日期选择,日历展示功能。

点击进入模块详情

index.html
  1. <!doctype html>
  2. <html>
  3.         <head>
  4.                 <meta charset="utf-8">
  5.                 <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
  6.                 <meta name="format-detection" content="tephone=no,email=no,date=no,address=no">
  7.                 <style type="text/css">
  8.                         html{ background-color: white; }
  9.                         header{ border-bottom: 1px solid #ccc; padding: 25px 0; }
  10.                         span {
  11.                 padding: 10px 15px;
  12.                                 margin: 10px;
  13.                                 display: inline-block;
  14.                                 background-color: #e8e8e8;
  15.                         }
  16.             .hover{ opacity: .4; }
  17.                 </style>
  18.         </head>
  19.         <body style="padding-bottom: 340px;">
  20.                 <div class="main">
  21.                         <header>
  22.                                 <h1>UICalendar</h1>
  23.                                 <mark>
  24.                                         使用前请详细阅读 文档 使用规则
  25.                                 </mark>
  26.                         </header>
  27.                         <span tapmode="hover" onclick="fnOpen()">open()</span>
  28.                         <span tapmode="hover" onclick="fnSetSpecialDates()">setSpecialDates()</span>
  29.                         <span tapmode="hover" onclick="fnCancelSpecialDates()">cancelSpecialDates()</span>
  30.                         <span tapmode="hover" onclick="fnClose()">close()</span>
  31.                         <span tapmode="hover" onclick="fnShow()">show()</span>
  32.                         <span tapmode="hover" onclick="fnHide()">hide()</span>
  33.                         <span tapmode="hover" onclick="fnNextMonth()">nextMonth()</span>
  34.                         <span tapmode="hover" onclick="fnPrevMonth()">prevMonth()</span>
  35.                         <span tapmode="hover" onclick="fnNextYear()">nextYear()</span>
  36.                         <span tapmode="hover" onclick="fnPrevYear()">prevYear()</span>
  37.                         <span tapmode="hover" onclick="fnSetDate()">setDate()</span>
  38.                         <span tapmode="hover" onclick="fnTurnPage()">turnPage()</span>
  39.                 </div>
  40.         </body>
  41.         <script type="text/javascript">
  42.                 var UICalendar;
  43.                 apiready = function() {
  44.                         UICalendar = api.require('UICalendar');
  45.                 };
  46.                 function fnOpen(){
  47.                         UICalendar.open({
  48.                             rect: {
  49.                                 x: 30,
  50.                                 y: document.querySelector( '.main' ).offsetHeight,
  51.                                 w: api.frameWidth - 60,
  52.                                 h: 340
  53.                             },
  54.                             styles: {
  55.                                 bg: '#fff',
  56.                                 week: {
  57.                                     weekdayColor: '#3b3b3b',
  58.                                     weekendColor: '#a8d400',
  59.                                     size: 12
  60.                                 },
  61.                                 date: {
  62.                                     color: '#3b3b3b',
  63.                                     selectedColor: '#fff',
  64.                                     selectedBg: '#a8d500',
  65.                                     size: 12
  66.                                 },
  67.                                 today: {
  68.                                     color: 'rgb(230,46,37)',
  69.                                     bg: ''
  70.                                 },
  71.                                 specialDate: {
  72.                                     color: '#fff'
  73.                                 }
  74.                             },
  75.                             specialDate: [{
  76.                                 date: '2016-06-30'
  77.                             }],
  78.                             switchMode: 'vertical',
  79.                             fixed: false
  80.                         }, function(ret, err){
  81.                             if( ret ){
  82.                                  alert( JSON.stringify( ret ) );
  83.                             }else{
  84.                                  alert( JSON.stringify( err ) );
  85.                             }
  86.                         });
  87.                 }
  88.                 function fnSetSpecialDates(){
  89.                         UICalendar.setSpecialDates({
  90.                             specialDates:[{
  91.                                date: '2016-05-29',
  92.                                color: '#fff',
  93.                                bg: '#0f0'
  94.                             },{
  95.                                date: '2016-05-31',
  96.                                color: '#fff',
  97.                                bg: '#0f0'
  98.                             }]
  99.                         });
  100.                 }
  101.                 function fnCancelSpecialDates(){
  102.                         UICalendar.cancelSpecialDates({
  103.                             specialDates:['2016-05-29','2016-05-31']
  104.                         });
  105.                 }
  106.                 function fnClose(){
  107.                         UICalendar.close();
  108.                 }
  109.                 function fnShow(){
  110.                         UICalendar.show();
  111.                 }
  112.                 function fnHide(){
  113.                         UICalendar.hide();
  114.                 }
  115.                 function fnNextMonth(){
  116.                         UICalendar.nextMonth(function(ret, err){      
  117.                             if( ret ){
  118.                                 alert( JSON.stringify( ret ) );
  119.                             }else{
  120.                                 alert( JSON.stringify( err ) );
  121.                             }
  122.                         });
  123.                 }
  124.                 function fnPrevMonth(){
  125.                         UICalendar.prevMonth(function(ret, err){      
  126.                             if( ret ){
  127.                                 alert( JSON.stringify( ret ) );
  128.                             }else{
  129.                                 alert( JSON.stringify( err ) );
  130.                             }
  131.                         });
  132.                 }
  133.                 function fnNextYear(){
  134.                         UICalendar.nextYear(function(ret, err){      
  135.                             if( ret ){
  136.                                 alert( JSON.stringify( ret ) );
  137.                             }else{
  138.                                 alert( JSON.stringify( err ) );
  139.                             }
  140.                         });
  141.                 }
  142.                 function fnPrevYear(){
  143.                         UICalendar.prevYear(function(ret, err){      
  144.                             if( ret ){
  145.                                 alert( JSON.stringify( ret ) );
  146.                             }else{
  147.                                 alert( JSON.stringify( err ) );
  148.                             }
  149.                         });
  150.                 }
  151.                 function fnSetDate(){
  152.                         UICalendar.setDate({
  153.                             date: '2015-08-08',
  154.                             ignoreSelected: false
  155.                         }, function(ret, err){      
  156.                             if( ret.status ){
  157.                                 alert( JSON.stringify( ret ) );
  158.                             }else{
  159.                                 alert( JSON.stringify( err ) );
  160.                             }
  161.                         });
  162.                 }
  163.                 function fnTurnPage(){
  164.                         UICalendar.turnPage({
  165.                             date: '2015-08'
  166.                         });
  167.                 }
  168.         </script>
  169. </html>
复制代码



config.xml
  1. <?xml version="1.0" encoding="UTF-8"?>

  2. <widget id="A6903177269708" version="0.0.1">
  3.   <name>test</name>  
  4.   <description>Example For APICloud.</description>  
  5.   <author email="developer@apicloud.com" href="http://www.apicloud.com">Developer</author>  
  6.   <content src="index.html"/>
  7.   <preference name="appBackground" value="rgba(255, 255, 255, 1)"/>
  8.   <preference name="windowBackground" value="rgba(0,0,0,0)"/>
  9.   <preference name="frameBackgroundColor" value="rgba(0,0,0,0)"/>
  10.   <preference name="autoLaunch" value="true"/>
  11.   <preference name="autoUpdate" value="true"/>
  12.   <preference name="smartUpdate" value="false"/>
  13.   <preference name="fullScreen" value="false"/>
  14.   <preference name="debug" value="true"/>
  15.   <preference name="statusBarAppearance" value="true"/>
  16.   <permission name="location"/>
  17.   <permission name="internet"/>
  18.   <access origin="*"/>
  19. </widget>
复制代码


258
帖子
4
勋章
1024
Y币
抢沙发。回帖拿金币,支持支持
5
帖子
0
勋章
417
Y币
回帖拿金币,支持支持
16
帖子
1
勋章
1699
Y币
回帖拿金币,支持支持
99
帖子
1
勋章
314
Y币
帖拿金币,支持支持
75
帖子
0
勋章
822
Y币
感觉样式不好看
136
帖子
1
勋章
853
Y币
捡个云币
86
帖子
0
勋章
533
Y币
我就是来拿云币的,从来不掩饰自己的目的
1
帖子
0
勋章
6
Y币
支持,有币必回:L:L:L:L
2
帖子
0
勋章
559
Y币

回帖拿金币,支持支持
12345678910... 12下一页
您需要登录后才可以回帖 登录

本版积分规则