index.wxs 717 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* eslint-disable */
  2. var utils = require('./utils.wxs');
  3. function getMonths(minDate, maxDate) {
  4. var months = [];
  5. var cursor = getDate(minDate);
  6. cursor.setDate(1);
  7. do {
  8. months.push(cursor.getTime());
  9. cursor.setMonth(cursor.getMonth() + 1);
  10. } while (utils.compareMonth(cursor, getDate(maxDate)) !== 1);
  11. return months;
  12. }
  13. function getButtonDisabled(type, currentDate, minRange) {
  14. if (currentDate == null) {
  15. return true;
  16. }
  17. if (type === 'range') {
  18. return !currentDate[0] || !currentDate[1];
  19. }
  20. if (type === 'multiple') {
  21. return currentDate.length < minRange;
  22. }
  23. return !currentDate;
  24. }
  25. module.exports = {
  26. getMonths: getMonths,
  27. getButtonDisabled: getButtonDisabled
  28. };