Giter Club home page Giter Club logo

Comments (6)

czcaiwj avatar czcaiwj commented on May 30, 2024

请具体描述需求,如果选择入住日期,然后再选离店日期,那理论上肯定是可以的,插件有dayClick事件,你可以根据这个事件来实现这个功能。

from calendar.

EasonGaoDevelop avatar EasonGaoDevelop commented on May 30, 2024

你好,需求例如日历展示的是2018-01-2018-06,跨度半年,开始日期选择2018-01-3,结束日期选择 2018-04-2,这时候我需要把,1月3号到4月2号期间的日期,标记为选中状态,通过dayClick可以实现么?

from calendar.

czcaiwj avatar czcaiwj commented on May 30, 2024

首先,目前插件只能最多显示1个月的日历,除非你引入多次。那我们以正常情况只引入一次来看。
事先准备:
page的data字段里面加几个变量:
begin_date, end_date, 初始化为0

操作步骤:
1、展示2018年1月的视图。用户点击1月3日那个,js页面的代码响应dayClick事件,获取点击日期,存入临时变量day中,进行以下判断:
if (begin_date == 0) {
begin_date = day;
} elseif (end_date == 0) {
if (day < begin_date) {
console.log('结束时间不能小于开始时间');
} else {
end_date = day;
}
} else {
console.log('已选择了开始日期和结束日期,请先清空');
}
2、这个时候要么只设置了begin_date,接下来看第3步, 要么begin_date和end_date都设置好了,接下来看第4步。
3、假设只设置了begin_day,那么用户就可以往后切换视图,假设切换到4月,用户点击了4月2日,那么继续第一步的判断逻辑。来设置end_date的值。
4、于是你的begin_date和end_date都设置好了,那么目前页面显示的日历视图的月份你是知道的,那只需在显示的时候,看当前页面月份的日期是否在begin_date到end_date之间,如果是,就设置相应的day_colors数组。

原理大概就这样。

from calendar.

EasonGaoDevelop avatar EasonGaoDevelop commented on May 30, 2024

好的,你讲解的很详细.现在遇到一个问题,当我打开show-more-days为true展示下个月或者上个月的日子,这些天的颜色会跟当月天数颜色不同,可否自己修改成同样颜色? 日历默认带上一个和下一月的按钮,这个有样式可以设置成文字么?我现在是通过小程序的wxID来添加的插件,是否需要通过源码导入去修改这些配置!

from calendar.

czcaiwj avatar czcaiwj commented on May 30, 2024

1、可以的,days-color的month字段设置为prev或next可以自定义非当前月的日期样式
2、按钮没有可以修改成文字的功能,可以隐藏掉,你可以在隐藏掉之后,自己叠加图层放你要的文字

from calendar.

EasonGaoDevelop avatar EasonGaoDevelop commented on May 30, 2024

我通过下载你的源码,改了某些功能,谢谢了☺

from calendar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.