gui-radio.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view class="gui-flex gui-rows gui-nowrap gui-align-items-center"
  3. :style="{justifyContent:justifyContent}"
  4. @tap.stop="changeStatus">
  5. <view
  6. :style="{
  7. width:(size+5)+'rpx',
  8. height:(size+5)+'rpx',
  9. overflow:'hidden',
  10. backgroundColor:status?checkedColor:'',
  11. borderRadius:(size)+'rpx'
  12. }">
  13. <text v-if="status"
  14. class="gui-radio-btn gui-icons gui-block-text gui-text-center"
  15. :style="{
  16. fontSize:(size-12)+'rpx',
  17. lineHeight:(size+8)+'rpx',
  18. color : '#FFFFFF',
  19. }">&#xe60f;</text>
  20. <text v-else
  21. class="gui-radio-btn gui-icons gui-block-text gui-text-center"
  22. :style="{
  23. fontSize:(size)+'rpx',
  24. lineHeight:(size+5)+'rpx',
  25. color : color
  26. }">&#xe762;</text>
  27. </view>
  28. <view class="gui-radio-lable"><slot></slot></view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. name : "gui-radio",
  34. props : {
  35. size : {
  36. type : Number,
  37. default : 38
  38. },
  39. color : {
  40. type : String,
  41. default : '#EEEEEE'
  42. },
  43. checked : {
  44. type : Boolean,
  45. default : false
  46. },
  47. checkedColor : {
  48. type : String,
  49. default : '#008AFF'
  50. },
  51. parameter : {
  52. type : Array,
  53. default : function () {
  54. return []
  55. }
  56. },
  57. justifyContent:{type:String, default:'flex-start'}
  58. },
  59. data() {
  60. return {
  61. status : false
  62. }
  63. },
  64. watch: {
  65. checked : function (val, old) {
  66. this.status = val;
  67. }
  68. },
  69. created : function(){
  70. this.status = this.checked;
  71. },
  72. methods:{
  73. changeStatus : function(){
  74. this.status = !this.status;
  75. this.$emit('change', [this.status, this.parameter]);
  76. }
  77. }
  78. }
  79. </script>
  80. <style scoped>
  81. .gui-radio-btn{color:#999999;}
  82. .gui-radio-lable{margin-left:15rpx;}
  83. </style>