kx-choose.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view name='KXDateTime'>
  3. <popup ref="popup" type="bottom" :zIndex="999">
  4. <view class="time-panel">
  5. <!-- <image src="/static/perm/cancel.png" mode="aspectFill" class="cancel-img" @click="close"></image> -->
  6. <view class="zicon-quxiao cancel" @click="close"></view>
  7. <view class="but">
  8. <text class="title">请选择</text>
  9. </view>
  10. <picker-view :indicator-style="indicatorStyle" :value="val" @change="bindChange">
  11. <picker-view-column>
  12. <view class="item" v-for="(item,index) in datas" :key="index">{{item.name}}</view>
  13. </picker-view-column>
  14. </picker-view>
  15. <view class="btn" @click="ok">确定</view>
  16. </view>
  17. </popup>
  18. </view>
  19. </template>
  20. <script>
  21. // import uniPopup from '../uni-popup/uni-popup.vue'
  22. export default {
  23. name: 'KXChoose',
  24. components: {
  25. // uniPopup
  26. },
  27. // props: {
  28. // datas:[],
  29. // },
  30. data() {
  31. return {
  32. title: 'picker-view',
  33. indicatorStyle: `height: 80rpx;`,
  34. datas:[],
  35. activeItem:'',
  36. val:[0],
  37. }
  38. },
  39. methods: {
  40. open(datas) {
  41. if(!datas && datas.length === 0){
  42. return;
  43. }
  44. this.datas = datas;
  45. this.activeItem = this.datas[this.val[0]];
  46. this.$refs.popup.show();
  47. },
  48. close() {
  49. this.$refs.popup.hide()
  50. this.$emit("close");
  51. },
  52. ok() {
  53. // 点击确定才触发
  54. if(!this.activeItem){
  55. return;
  56. }
  57. this.$emit("rundata",{item:this.activeItem,items:this.datas})
  58. this.$refs.popup.hide()
  59. },
  60. bindChange: function(e) {
  61. console.log('bindChange===',e);
  62. let val = e.detail.value; //只要上下滑动就触发
  63. this.val = val;
  64. this.activeItem = this.datas[val[0]]
  65. },
  66. },
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .time-panel{
  71. width: 100%;
  72. height: 687rpx;
  73. background: #ffffff;
  74. border-radius: 20rpx 20rpx 0rpx 0rpx;
  75. padding: 45rpx 30rpx 0;
  76. position: relative;
  77. .cancel{
  78. width: 88rpx;
  79. height: 88rpx;
  80. padding: 30rpx;
  81. position: absolute;
  82. top:0;
  83. right: 0;
  84. }
  85. }
  86. .cancel-img{
  87. width: 88rpx;
  88. height: 88rpx;
  89. padding: 30rpx;
  90. position: absolute;
  91. right: 0;
  92. top: 0;
  93. z-index: 6;
  94. }
  95. .but {
  96. background: #fff;
  97. // height: 80rpx;
  98. // line-height: 80rpx;
  99. width: 100%;
  100. text-align: left;
  101. .title{
  102. font-size: 36rpx;
  103. font-weight: 700;
  104. color: #333333;
  105. }
  106. }
  107. picker-view {
  108. width: 100%;
  109. background: #fff;
  110. height: 403rpx;
  111. text-align: center;
  112. .item{
  113. height: 80rpx;
  114. line-height: 80rpx;
  115. }
  116. }
  117. .btn{
  118. width: 620rpx;
  119. height: 90rpx;
  120. line-height: 90rpx;
  121. text-align: center;
  122. background: #009ffd;
  123. border-radius: 45rpx;
  124. box-shadow: 5rpx 5rpx 15rpx 0px rgba(0,159,253,0.6);
  125. font-size: 30rpx;
  126. font-weight: 500;
  127. color: #ffffff;
  128. margin:73rpx auto 42rpx;
  129. }
  130. </style>