'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import {
  emitter,
  listeners
} from '../mixins'
 
function getRadio (weex) {
  return {
    name: 'Radio',
    mixins: [emitter, listeners],
    props: {
      checked: {
        type: [Boolean, String],
        default: false
      },
      id: {
        type: String,
        default: ''
      },
      disabled: {
        type: [Boolean, String],
        default: false
      },
      color: {
        type: String,
        default: '#007AFF'
      },
      value: {
        type: String,
        default: ''
      }
    },
    data: function data () {
      return {
        radioChecked: this.checked,
        radioValue: this.value
      }
    },
    listeners: {
      'label-click': '_onClick',
      '@label-click': '_onClick'
    },
    computed: {
      checkedStyle: function checkedStyle () {
        return {
          backgroundColor: this.color,
          borderColor: this.color
        }
      },
      uncheckedStyle () {
        return {
          borderColor: '#d1d1d1'
        }
      }
    },
    watch: {
      checked: function checked (val) {
        this.radioChecked = val
      },
      value: function value (val) {
        this.radioValue = val
      }
    },
    beforeCreate () {
    },
    created () {
      this.$dispatch('RadioGroup', 'uni-radio-group-update', {
        type: 'add',
        vm: this
      })
      this.$dispatch('Form', 'uni-form-group-update', {
        type: 'add',
        vm: this
      })
    },
    beforeDestroy () {
      this.$dispatch('RadioGroup', 'uni-radio-group-update', {
        type: 'remove',
        vm: this
      })
      this.$dispatch('Form', 'uni-form-group-update', {
        type: 'remove',
        vm: this
      })
    },
    methods: {
      _onClick ($event) {
        if (this.disabled || this.radioChecked) {
          return
        }
        this.radioChecked = true
        this.$dispatch('RadioGroup', 'uni-radio-change', $event, this)
      },
      _resetFormData () {
        this.radioChecked = false
      }
    },
    render (createElement) {
      const _vm = this
      return createElement('div', _vm._g({
        staticClass: ['uni-radio'],
        on: {
          'click': _vm._onClick
        }
      }, _vm.$listeners), [createElement('div', {
        staticClass: ['uni-radio-input'],
        style: _vm.radioChecked ? _vm.checkedStyle : _vm.uncheckedStyle
      }, [(_vm.radioChecked) ? createElement('u-text', {
        staticClass: ['uni-radio-input-icon']
      }, [_vm._v(_vm._s('\uEA08'))]) : _vm._e()], 1), createElement('u-text', {
        staticClass: ['uni-text']
      }, [_vm._t('default')], 2)], 1)
    },
    style: {
      'uni-radio': {
        'alignItems': 'center',
        'flexDirection': 'row'
      },
      'uni-radio-input': {
        'position': 'relative',
        'alignItems': 'center',
        'justifyContent': 'center',
        'marginRight': '5',
        'backgroundColor': '#ffffff',
        'borderStyle': 'solid',
        'borderWidth': '1',
        'borderColor': '#d1d1d1',
        'borderRadius': 50,
        'width': '22',
        'height': '22',
        'outline': 0
      },
      'uni-radio-input-icon': {
        'fontFamily': 'unincomponents',
        'fontSize': '14',
        'color': '#ffffff'
      },
      'uni-radio-input-disabled': {
        'backgroundColor': '#e1e1e1',
        'borderColor': '#d1d1d1',
        'color': '#adadad'
      }
    }
  }
}
 
export default function init (Vue, weex) {
  Vue.component('radio', getRadio(weex))
}