chooseDate.vue 939 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <view class="chooseDate">
  3. <u-calendar
  4. startText="住店"
  5. endText="离店"
  6. confirmDisabledText="请选择离店日期"
  7. :formatter="formatter"
  8. :show="show"
  9. :mode="mode"
  10. @confirm="confirm"
  11. ref="calendar"
  12. >
  13. </u-calendar>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. show: true,
  21. mode: 'range'
  22. }
  23. },
  24. onReady() {
  25. // 如果需要兼容微信小程序的话,需要用此写法
  26. this.$refs.calendar.setFormatter(this.formatter)
  27. },
  28. methods: {
  29. confirm(e) {
  30. console.log(e);
  31. },
  32. formatter(day) {
  33. const d = new Date()
  34. let month = d.getMonth() + 1
  35. const date = d.getDate()
  36. if(day.month == month && day.day == date + 3)
  37. {
  38. day.bottomInfo = '有优惠'
  39. day.dot = true
  40. }
  41. return day
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. .chooseDate{
  48. }
  49. </style>