<template>
	<view class="row-justify-sb center p-tb30 size-28" :class="{'bor-bottom-1':is_border}">
		<view class="wh-text"><text>{{name?name:label}}</text></view>
		<view class="row-c">
			<view class="row-c radiu-item m-l20" :class="{'active-radiu':radioValue === item.value}"
				v-for="(item,index) in list" :key="index" @click="onSelect(item.value)">
				<image class="wh-30 m-r20"
					: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'"
					mode="aspectFill"></image>
				<text>{{item.text}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			name: {
				type: String,
				default: ''
			},
			label: {
				type: String,
				default: ''
			},
			value: {
				type: Number,
				default: 0
			},
			disabled: {
				default: false
			},
			is_border: {
				default: true
			},
			list: {
				type: Array,
				default: () => []
			}
		},
		watch: {
			value: {
				handler(value) {
					this.radioValue = value
				},
				immediate: true
			},
		},
		data() {
			return {
				radioValue: 0
			}
		},
		methods: {
			onSelect(value) {
				if (this.disabled) {
					return
				}
        this.$emit('updateData')
				this.radioValue = value
				this.$emit('input', value)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wh-text {
		width: 110rpx;
		text-align: justify;
		text-align-last: justify;
		vertical-align: top;
		height: 38rpx;
	}

	.wh-text:after {
		content: '';
		width: 110rpx;
		height: 0;
		display: inline-block;
		overflow: hidden;
	}

	.radiu-item {
		padding: 6rpx 30rpx;
		border-radius: 100rpx;
		border: 1rpx solid #CCCCCC;
	}

	.active-radiu {
		color: #0FB160;
		border: 1rpx solid #0FB160;
	}
</style>
