en-radio.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view class="row-justify-sb center p-tb30 size-28" :class="{'bor-bottom-1':is_border}">
  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. is_border: {
  34. default: true
  35. },
  36. list: {
  37. type: Array,
  38. default: () => []
  39. }
  40. },
  41. watch: {
  42. value: {
  43. handler(value) {
  44. this.radioValue = value
  45. },
  46. immediate: true
  47. },
  48. },
  49. data() {
  50. return {
  51. radioValue: 0
  52. }
  53. },
  54. methods: {
  55. onSelect(value) {
  56. if (this.disabled) {
  57. return
  58. }
  59. this.radioValue = value
  60. this.$emit('input', value)
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .wh-text {
  67. width: 110rpx;
  68. text-align: justify;
  69. text-align-last: justify;
  70. vertical-align: top;
  71. height: 38rpx;
  72. }
  73. .wh-text:after {
  74. content: '';
  75. width: 110rpx;
  76. height: 0;
  77. display: inline-block;
  78. overflow: hidden;
  79. }
  80. .radiu-item {
  81. padding: 6rpx 30rpx;
  82. border-radius: 100rpx;
  83. border: 1rpx solid #CCCCCC;
  84. }
  85. .active-radiu {
  86. color: #0FB160;
  87. border: 1rpx solid #0FB160;
  88. }
  89. </style>