江西小程序管理端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
2.8 KiB

1 year ago
  1. <template>
  2. <view class="popupCon">
  3. <view class="popTab">
  4. <view class="tabItem" :class="{active: currentPopTab==1}" @click="changePopTab(1)">月份选择</view>
  5. <view class="tabItem" :class="{active: currentPopTab==2}" @click="changePopTab(2)">自定义时间</view>
  6. </view>
  7. <view class="timer">
  8. <view class="tabCon" v-if="currentPopTab==1">
  9. <view class="dateBtn" @click="showDatePickerFn(1)" :class="{hui: !date1}">{{ date1 }}</view>
  10. <!-- <u-datetime-picker-my
  11. :show="show"
  12. v-model="value1"
  13. mode="year-month"
  14. :showToolbar="false"
  15. :visibleItemCount="4"
  16. @confirm="confirm"
  17. ></u-datetime-picker-my> -->
  18. </view>
  19. <view class="tabCon" v-else>
  20. <view class="dateBtn" :class="{hui: !date2}" @click="showDatePickerFn(2)">{{ date2 }}</view>
  21. <view class="to"></view>
  22. <view class="dateBtn" :class="{hui: !date3}" @click="showDatePickerFn(3)">{{ date3 }}</view>
  23. </view>
  24. <view class="btnBg" @click="selectDateClick">确定</view>
  25. <!-- <u-picker-my></u-picker-my> -->
  26. </view>
  27. <u-datetime-picker
  28. :show="showDatePicker"
  29. v-model="value1"
  30. mode="year-month"
  31. :visibleItemCount="4"
  32. :closeOnClickOverlay="false"
  33. @confirm="confirmDatePicker"
  34. ></u-datetime-picker>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. currentPopTab: 1,
  42. showDatePicker: false,
  43. value1: '',
  44. currentBtnDate: ''
  45. }
  46. },
  47. methods: {
  48. // 1打开时间选择器
  49. showDatePickerFn(num) {
  50. this.showDate = false
  51. this.showDatePicker = true
  52. this.currentBtnDate = num
  53. },
  54. // 2选择时间选择器里的时间
  55. confirmDatePicker(val) {
  56. this.showDatePicker = false
  57. let date = uni.$u.date(val.value, 'yyyy-mm-dd')
  58. if(this.currentBtnDate==1) {
  59. date = uni.$u.date(val.value, 'yyyy-mm')
  60. }
  61. this['date'+this.currentBtnDate] = date
  62. },
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .popupCon {
  68. height: 430rpx;
  69. .popTab {
  70. display: flex;
  71. padding: 40rpx 32rpx;
  72. .tabItem {
  73. font-size: 32rpx;
  74. color: #333;
  75. margin-right: 60rpx;
  76. &.active {
  77. color: $themC;
  78. position: relative;
  79. &::before {
  80. content: '';
  81. position: absolute;
  82. bottom: -20rpx;
  83. left: 50%;
  84. transform: translateX(-50%);
  85. width: 128rpx;
  86. height: 4rpx;
  87. background: #1989FA;
  88. border-radius: 3rpx;
  89. }
  90. }
  91. }
  92. }
  93. .tabCon {
  94. display: flex;
  95. align-items: center;
  96. padding-left: 32rpx;
  97. padding-top: 20rpx;
  98. .dateBtn {
  99. width: 280rpx;
  100. height: 80rpx;
  101. border-radius: 10rpx;
  102. border: 2rpx solid #1989FA;
  103. line-height: 80rpx;
  104. text-align: center;
  105. color: $themC;
  106. font-size: 32rpx;
  107. &.hui {
  108. border: 2rpx solid #E8E9EC;
  109. }
  110. }
  111. .to {
  112. font-size: 32rpx;
  113. margin: 0 40rpx;
  114. }
  115. }
  116. .btnBg {
  117. width: 396rpx;
  118. margin: 34rpx auto 42rpx auto;
  119. }
  120. }
  121. </style>