en-radio.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="row-justify-sb center p-tb30 bor-bottom-1 size-28">
  3. <view class="wh-text"><text>{{name?name:label}}</text></view>
  4. <view class="row-c">
  5. <view class="row-c radiu-item m-l20" :class="{'active-radiu':radioValue === item.value}"
  6. v-for="(item,index) in list" :key="index" @click="onSelect(item.value)">
  7. <image class="wh-30 m-r20"
  8. :src="radioValue == item.value?'https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/information/correct.png':'https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/information/error.png'"
  9. mode="aspectFill"></image>
  10. <text>{{item.text}}</text>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. props: {
  18. name: {
  19. type: String,
  20. default: ''
  21. },
  22. label: {
  23. type: String,
  24. default: ''
  25. },
  26. value: {
  27. type: Number,
  28. default: 0
  29. },
  30. disabled: {
  31. default: false
  32. },
  33. list: {
  34. type: Array,
  35. default: () => []
  36. }
  37. },
  38. watch: {
  39. value: {
  40. handler(value) {
  41. this.radioValue = value
  42. },
  43. immediate: true
  44. },
  45. },
  46. data() {
  47. return {
  48. radioValue: 0
  49. }
  50. },
  51. methods: {
  52. onSelect(value) {
  53. if(this.disabled){
  54. return
  55. }
  56. this.radioValue = value
  57. this.$emit('input', value)
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. .wh-text {
  64. width: 110rpx;
  65. text-align: justify;
  66. text-align-last: justify;
  67. vertical-align: top;
  68. height: 38rpx;
  69. }
  70. .wh-text:after {
  71. content: '';
  72. width: 110rpx;
  73. height: 0;
  74. display: inline-block;
  75. overflow: hidden;
  76. }
  77. .radiu-item {
  78. width: 140rpx;
  79. padding: 6rpx 16rpx;
  80. border-radius: 100rpx;
  81. border: 1rpx solid #CCCCCC;
  82. }
  83. .active-radiu {
  84. color: #0FB160;
  85. border: 1rpx solid #0FB160;
  86. }
  87. </style>