index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view>
  3. <view class="time1" :class='isShow==true?"on":""'>
  4. <view class="top acea-row row-between-wrapper">
  5. <text @tap="cancel">取消</text>
  6. <text @tap="confirm">确定</text>
  7. </view>
  8. <picker-view class="picker" :value="value" @change="getime" indicator-style="height:34px;">
  9. <picker-view-column>
  10. <view class="hours" v-for="(item,index) in hoursList" :key="index">{{item}}</view>
  11. </picker-view-column>
  12. <picker-view-column>
  13. <view class="minutes" v-for="(item,index) in minutes" :key="index">{{item}}</view>
  14. </picker-view-column>
  15. <picker-view-column>
  16. <view class="center">-</view>
  17. </picker-view-column>
  18. <picker-view-column>
  19. <view class="hours" v-for="(item,index) in hoursList" :key="index">{{item}}</view>
  20. </picker-view-column>
  21. <picker-view-column>
  22. <view class="minutes" v-for="(item,index) in minutes" :key="index">{{item}}</view>
  23. </picker-view-column>
  24. </picker-view>
  25. </view>
  26. <view class="mask" @tap="cancel" catchtouchmove="true" :hidden="isShow==false"></view>
  27. </view>
  28. </template>
  29. <script>
  30. // +----------------------------------------------------------------------
  31. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  32. // +----------------------------------------------------------------------
  33. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  34. // +----------------------------------------------------------------------
  35. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  36. // +----------------------------------------------------------------------
  37. // | Author: CRMEB Team <admin@crmeb.com>
  38. // +----------------------------------------------------------------------
  39. let minutes=[]
  40. for (let i = 0; i <= 59; i++) {
  41. if(i<10){
  42. i="0"+i
  43. }
  44. minutes.push(i)
  45. }
  46. let hoursList = []
  47. for (let i = 0; i <= 23; i++) {
  48. if(i<10){
  49. i="0"+i
  50. }
  51. hoursList.push(i)
  52. }
  53. export default{
  54. props:{
  55. isShow:{
  56. type: Boolean,
  57. default: false
  58. },
  59. time:{
  60. type: Array,
  61. default() {
  62. return [];
  63. }
  64. }
  65. },
  66. watch:{
  67. time:function(){
  68. this.value=this.time
  69. }
  70. },
  71. created(){
  72. },
  73. data(){
  74. return{
  75. value:this.time,//默认结束开始时间
  76. hoursList,
  77. minutes,
  78. }
  79. },
  80. methods:{
  81. confirm(){
  82. let time = this.value[0]+":"+this.value[1]+" - "+this.value[3]+":"+this.value[4]
  83. if(this.value[3]>this.value[0] || (this.value[3]==this.value[0] && this.value[4]>=this.value[1])){
  84. this.$emit("confrim",{time:time,val:this.value})
  85. }else{
  86. return this.$util.Tips({
  87. title: '开始时间必须小于结束时间'
  88. });
  89. }
  90. },
  91. cancel(){
  92. let time = this.value[0]+":"+this.value[1]+" - "+this.value[3]+":"+this.value[4]
  93. this.$emit("cancel",{time:time})
  94. },
  95. getime(e){
  96. let val = e.detail.value
  97. this.value[0] = this.hoursList[val[0]]
  98. this.value[1] = this.minutes[val[1]]
  99. this.value[2] = val[2]
  100. this.value[3] = this.hoursList[val[3]]
  101. this.value[4] = this.minutes[val[4]]
  102. },
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. .time1{
  108. width:100%;
  109. margin: 0 auto;
  110. background-color:#FFFFFF;
  111. color: #000;
  112. height: 568rpx;
  113. position: fixed;
  114. bottom: 0;
  115. z-index: 99;
  116. transform: translate3d(0, 200%, 0);
  117. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  118. &.on{
  119. transform: translate3d(0, 0, 0);
  120. }
  121. .top{
  122. height: 90rpx;
  123. border-bottom: 1px solid #eee;
  124. padding: 0 30rpx;
  125. text{
  126. font-size: 32rpx;
  127. &:nth-child(1){
  128. color: #888;
  129. }
  130. &:nth-child(2){
  131. color: #007aff;
  132. }
  133. }
  134. }
  135. .tip12{
  136. width: 100%;
  137. height: 100rpx;
  138. view{
  139. width: 50%;
  140. text-align: center;
  141. line-height: 100rpx;
  142. font-size: 40rpx;
  143. color: #000000;
  144. }
  145. }
  146. .hours{
  147. font-size: 32rpx;
  148. color: #000;
  149. line-height:34px;
  150. text-align: center;
  151. }
  152. .minutes{
  153. font-size: 32rpx;
  154. color: #000;
  155. line-height:34px;
  156. text-align: center;
  157. }
  158. .center{
  159. line-height:34px;
  160. text-align: center;
  161. }
  162. }
  163. .picker{
  164. width: 100%;
  165. height: 476rpx;
  166. }
  167. </style>