redioPicker.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view>
  3. <u-popup v-model="isShow" @close="isShow = false" mode="bottom" safe-area-inset-bottom border-radius="20" >
  4. <view class="content flex flex_column">
  5. <view class="con">
  6. <view class="choose-list u-flex u-row-between" v-for="(item,i) in dataList" :key="item.id" @click="getChooseItem(i)">
  7. <view>{{item.name}}</view>
  8. <u-icon v-show="chooseFlag==i" name="checkbox-mark" color="#2979ff" size="28"></u-icon>
  9. </view>
  10. </view>
  11. <view class="btn u-flex">
  12. <view class="cancleStyle" @click="isShow = false">取消</view>
  13. <view class="confimStyle" :style="{background:$config('primaryColor'),color:'#fff'}" @click="submit">确定</view>
  14. </view>
  15. </view>
  16. </u-popup>
  17. </view>
  18. </template>
  19. <script>
  20. export default{
  21. props:{
  22. showModal:{
  23. type: Boolean,
  24. default: false
  25. },
  26. dataList:{
  27. type: Array,
  28. default: ()=>[]
  29. }
  30. },
  31. data(){
  32. return{
  33. isShow:this.showModal,
  34. chooseObj:null,
  35. chooseFlag:-1
  36. }
  37. },
  38. methods:{
  39. submit(index){
  40. if(this.chooseFlag == -1){
  41. this.chooseObj = null
  42. }
  43. this.$emit('chooseItem',this.chooseObj)
  44. this.isShow = false
  45. },
  46. getChooseItem(index){
  47. if(this.chooseFlag == index){
  48. this.chooseFlag = -1
  49. }else{
  50. this.chooseFlag = index
  51. }
  52. this.chooseObj=this.dataList[index]
  53. }
  54. },
  55. watch:{
  56. // 父页面传过来的弹框状态
  57. showModal (newValue, oldValue) {
  58. this.isShow = newValue
  59. },
  60. // 重定义的弹框状态
  61. isShow (newValue, oldValue) {
  62. if (!newValue) {
  63. this.$emit('close')
  64. }
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .content{
  71. width: 100%;
  72. height: 100%;
  73. .con{
  74. flex-grow: 1;
  75. overflow: auto;
  76. padding:0 40rpx;
  77. .choose-list{
  78. border-bottom: 1rpx solid #efefef;
  79. padding:20rpx 0;
  80. &:last-child{
  81. border-bottom: 0rpx solid #efefef;
  82. }
  83. }
  84. }
  85. .btn{
  86. border-top: 1rpx solid #efefef;
  87. .cancleStyle,.confimStyle{
  88. width: 50%;
  89. text-align: center;
  90. height: 89rpx;
  91. line-height: 89rpx;
  92. text-align: center;
  93. }
  94. }
  95. }
  96. </style>