<template>
	<view class="pay-section">
		<view class="section-head">
			<text class="section-title">支付渠道</text>
		</view>
		<view class="option-list" v-if="channelList.length > 0">
			<view
				v-for="item in channelList"
				:key="item.id"
				class="option-item"
				:class="{ active: selectedChannelId === item.id }"
				hover-class="app-tap-hover"
				@click="$emit('select', item)"
			>
				<view class="option-icon-wrap">
					<image v-if="item.picture" class="option-icon-img" :src="item.picture" mode="aspectFit"></image>
				</view>
				<view class="option-info">
					<view class="option-name">{{ item.name }}</view>
				</view>
				<view class="radio" :class="{ checked: selectedChannelId === item.id }"></view>
			</view>
		</view>
		<view class="empty-tip" v-else>暂无可用支付渠道</view>
	</view>
</template>

<script>
	export default {
		name: 'PayChannelSelector',
		props: {
			channelList: {
				type: Array,
				default: () => []
			},
			selectedChannelId: {
				type: [String, Number],
				default: null
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import './agent-order-theme.scss';

	.pay-section {
		@include ao-section;
	}

	.section-head {
		@include ao-section-head;
	}

	.section-title {
		@include ao-section-title;
	}

	.option-item {
		@include ao-option-item;
	}

	.option-icon-wrap {
		width: 56rpx;
		height: 56rpx;
		border-radius: 12rpx;
		margin-right: 20rpx;
		flex-shrink: 0;
		background: #fff;
		overflow: hidden;
		display: flex;
		align-items: center;
		justify-content: center;
		border: 1rpx solid $ao-border;
	}

	.option-icon-img {
		width: 100%;
		height: 100%;
	}

	.option-info {
		flex: 1;
		min-width: 0;
	}

	.option-name {
		font-size: 30rpx;
		font-weight: 500;
		color: $ao-text;
	}

	.radio {
		@include ao-radio;
	}

	.empty-tip {
		@include ao-empty-tip;
	}
</style>
