en-radio.vue 1.7 KB

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