select_date.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="popup-mask" @tap="closePopup">
  3. <view class="popup-content" @tap.stop>
  4. <view class="popup-header">
  5. <text>选择时间段</text>
  6. </view>
  7. <view class="popup-body">
  8. <view class="time-picker">
  9. <text>开始时间</text>
  10. <picker mode="date" :value="startTime" @change="onStartTimeChange">
  11. <view class="picker">{{ startTime }}</view>
  12. </picker>
  13. </view>
  14. <view class="time-picker">
  15. <text>结束时间</text>
  16. <picker mode="date" :value="endTime" @change="onEndTimeChange">
  17. <view class="picker">{{ endTime }}</view>
  18. </picker>
  19. </view>
  20. </view>
  21. <view class="popup-footer">
  22. <button @tap="closePopup">取消</button>
  23. <button @tap="confirm">确定</button>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. startTime: '开始时间',
  33. endTime: '结束时间'
  34. };
  35. },
  36. methods: {
  37. closePopup() {
  38. this.$emit('close');
  39. },
  40. confirm() {
  41. this.$emit('confirm', {
  42. startTime: this.startTime,
  43. endTime: this.endTime
  44. });
  45. this.closePopup();
  46. },
  47. onStartTimeChange(e) {
  48. this.startTime = e.detail.value;
  49. },
  50. onEndTimeChange(e) {
  51. this.endTime = e.detail.value;
  52. }
  53. }
  54. };
  55. </script>
  56. <style>
  57. .popup-mask {
  58. position: fixed;
  59. top: 0;
  60. left: 0;
  61. width: 100%;
  62. height: 100%;
  63. background-color: rgba(0, 0, 0, 0.5);
  64. display: flex;
  65. justify-content: center;
  66. align-items: center;
  67. z-index: 99;
  68. }
  69. .popup-content {
  70. background-color: #fff;
  71. width: 80%;
  72. border-radius: 10px;
  73. overflow: hidden;
  74. }
  75. .popup-header {
  76. padding: 20px;
  77. border-bottom: 1px solid #eee;
  78. text-align: center;
  79. font-size: 18px;
  80. font-weight: bold;
  81. }
  82. .popup-body {
  83. padding: 20px;
  84. }
  85. .time-picker {
  86. margin-bottom: 20px;
  87. }
  88. .time-picker text {
  89. display: block;
  90. margin-bottom: 10px;
  91. font-size: 16px;
  92. }
  93. .picker {
  94. padding: 10px;
  95. border: 1px solid #eee;
  96. border-radius: 5px;
  97. text-align: center;
  98. }
  99. .popup-footer {
  100. display: flex;
  101. justify-content: space-between;
  102. padding: 10px;
  103. border-top: 1px solid #eee;
  104. }
  105. .popup-footer button {
  106. flex: 1;
  107. margin: 0 5px;
  108. }
  109. </style>