PickTime.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div class="toast-wrap">
  3. <p v-show="val" :class="['tab',{'check':val != '请选择'}]" @click="showPicker">{{val}}</p>
  4. <p v-show="val != '请选择'" class="tip">点击可修改</p>
  5. <div class="content" v-show="show">
  6. <van-picker
  7. :columns="columns"
  8. :visible-item-count='3'
  9. />
  10. <div class="confBtn">
  11. <div @click="getVal">确认</div>
  12. </div>
  13. </div>
  14. </div>
  15. </template>
  16. <script type="text/javascript">
  17. import $ from 'jquery';
  18. // import {getNum} from '@utils/tools.js';
  19. // const num = getNum();
  20. const num = [0,1,2,3,4,5,6,7,8,9];
  21. const unit = ['分钟', '小时', '天', '周', '月','年'];
  22. export default {
  23. name:'PickTime',
  24. data() {
  25. return {
  26. columns: [
  27. {
  28. values:num,
  29. className:'column1'
  30. },
  31. {
  32. values:num,
  33. className:'column2',
  34. defaultIndex: 2
  35. },
  36. {
  37. values:unit,
  38. className:'column3'
  39. },
  40. ],
  41. val:this.item.value || '请选择',
  42. show:false
  43. }
  44. },
  45. props:['item'],
  46. methods: {
  47. showPicker(){
  48. this.show = true;
  49. },
  50. getVal(){
  51. const val1 = $(".column1 ul .van-picker-column__item--selected")[0].innerText;
  52. const val2 = $(".column2 ul .van-picker-column__item--selected")[0].innerText;
  53. const val3 = $(".column3 ul .van-picker-column__item--selected")[0].innerText;
  54. this.val = val1 + val2 + val3;
  55. this.show = false;
  56. const newData = Object.assign({},this.item,{value:this.val,valueP:this.val});
  57. this.$emit("updata",newData);
  58. }
  59. }
  60. };
  61. </script>
  62. <style lang="less" scoped>
  63. @import '../less/base.less';
  64. .toast-wrap{
  65. margin-bottom: .2rem;
  66. position: relative;
  67. .tab{
  68. width:100%;
  69. height: .8rem;
  70. line-height: .8rem;
  71. text-align: center;
  72. border:1px solid #E6E6E6;
  73. border-radius: .1rem;
  74. color:#7C828E;
  75. }
  76. .content{
  77. padding-top: 25px;
  78. width: 100%;
  79. height: 227px;
  80. background: #fff;
  81. z-index: 999;
  82. position: absolute;
  83. top:.88rem;
  84. left: 50%;
  85. transform: translateX(-50%);
  86. box-sizing: border-box;
  87. border-radius: .2rem;
  88. z-index: 1000;
  89. font-size: .3rem;
  90. overflow-y: hidden;
  91. box-shadow: 0 .12rem .24rem 0 rgba(79,129,255,0.40);
  92. .confBtn{
  93. height: 44px;
  94. line-height: 44px;
  95. text-align: center;
  96. border-top: 1px solid #ebedf0;
  97. margin-top: 25px;
  98. div{
  99. color: #colors[theme];
  100. }
  101. }
  102. }
  103. .check{
  104. color: #colors[theme] !important;
  105. }
  106. .tip{
  107. color: #7C828E;
  108. }
  109. }
  110. </style>