index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view class="u-demo">
  3. <view class="u-demo-wrap" style="background-color: #FFFFFF;">
  4. <view class="u-demo-title">演示效果</view>
  5. <view class="u-demo-area">
  6. <u-calendar v-model="show" ref="calendar" @change="change" :mode="mode"
  7. :start-text="startText" :end-text="endText" :range-color="rangeColor"
  8. :range-bg-color="rangeBgColor" :active-bg-color="activeBgColor" :btn-type="btnType"
  9. >
  10. </u-calendar>
  11. <view class="u-demo-result-line">
  12. {{result}}
  13. </view>
  14. </view>
  15. </view>
  16. <view class="u-config-wrap">
  17. <view class="u-config-title u-border-bottom">
  18. 参数配置
  19. </view>
  20. <view class="u-config-item">
  21. <view class="u-item-title">状态</view>
  22. <u-subsection :current="showBtnStatus" :list="['显示', '隐藏']" @change="showChange"></u-subsection>
  23. </view>
  24. <view class="u-config-item">
  25. <view class="u-item-title">模式</view>
  26. <u-subsection current="1" :list="['单个日期', '日期范围']" @change="modeChange"></u-subsection>
  27. </view>
  28. <view class="u-config-item">
  29. <view class="u-item-title">自定义样式</view>
  30. <u-subsection current="1" :list="['是', '否']" @change="styleChange"></u-subsection>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. show: false,
  40. mode: 'range',
  41. result: "请选择日期",
  42. startText: '开始',
  43. endText: '结束',
  44. rangeColor: '#2979ff',
  45. rangeBgColor: 'rgba(41,121,255,0.13)',
  46. activeBgColor: '#2979ff',
  47. btnType: 'primary',
  48. }
  49. },
  50. computed: {
  51. showBtnStatus() {
  52. return this.show ? 0 : 1;
  53. }
  54. },
  55. methods: {
  56. showChange(index) {
  57. this.show = !index;
  58. },
  59. modeChange(index) {
  60. this.mode = index == 0 ? 'date' : 'range';
  61. this.show = true;
  62. },
  63. styleChange(index) {
  64. if(index == 0) {
  65. this.startText = '住店';
  66. this.endText = '离店';
  67. this.activeBgColor = '#19be6b';
  68. this.rangeColor = '#19be6b';
  69. this.rangeBgColor = 'rgba(25,190,107, 0.13)';
  70. this.btnType = 'success';
  71. } else {
  72. this.startText = '开始';
  73. this.endText = '结束';
  74. this.activeBgColor = '#2979ff';
  75. this.rangeColor = '#2979ff';
  76. this.rangeBgColor = 'rgba(41,121,255,0.13)';
  77. this.btnType = 'primary';
  78. }
  79. this.show = true;
  80. },
  81. customChange(index) {
  82. if(index == 0) {
  83. this.icon1 = 'map';
  84. this.icon2 = 'photo';
  85. this.arrow = true;
  86. } else {
  87. this.icon1 = '';
  88. this.icon2 = '';
  89. this.arrow = false;
  90. }
  91. },
  92. textareaChange(index) {
  93. this.type = index == 0 ? 'textarea' : 'text';
  94. },
  95. change(e) {
  96. if (this.mode == 'range') {
  97. this.result = e.startDate + " - " + e.endDate;
  98. } else {
  99. this.result = e.result;
  100. }
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. .u-demo {
  107. }
  108. </style>