<template>
	<view class="g-components-item">
		<view class="m-set g_bg_f g_radius_8">
			<view
				class="item g_flex_row_start"
				v-for="(item, index) in list"
				:key="index"
				:hover-class="item.type == 'slot' ? 'none' : 'g_bg_f9'"
				@click="handleClickItem(item, index)"
				:style="{
					'padding-top': (item.pColumn ? item.pColumn : 19) + 'px',
					'padding-bottom': (item.pColumn ? item.pColumn : 19) + 'px',
					'padding-left': (item.pRow ? item.pRow : 10) + 'px',
					'padding-right': (item.pRow ? item.pRow : 10) + 'px',
				}"
			>
				<view class="g_pl_10 g_pr_10 g_flex_column_center"
					:style="{
						'paddingLeft':(item.fpl ? 10 : 0) + 'px',
						'paddingRight':(item.fpl ? 10 : 0) + 'px'
					}"
				>
					<view class="g_flex_1 g_flex_row_start flex_center" :class="item.require ? 'labelRequire' : ''">
						<view class="iconfont  g_fs_24 g_mr_5" 
							 v-if="item.icon" 
							 :class="'icon-' + item.icon"
							 :style="{
								 'paddingLeft':(item.rpl ? 7 : 0) + 'px'
							 }"
						></view>
						<view class="g_flex_column_center g_c_3 g_fs_16">{{ item.label }}</view>
					</view>
				</view>
				<view class="g_flex_1 g_flex_column_center">
					<view class="g_flex_row_end">
						<view class="g_flex_row_end">
							<!-- 通用类型 -->
							<view class="g_fs_16 g_ell_1 g_lh_1_2" style="max-width:45vw" :class="item.fontColor" v-if="item.result">{{ item.result }}</view>
							<!-- 迷你二维码 -->
							<view class="g_flex_rowRight_columnCenter" v-if="item.tip == 'code'">
								<i class="iconfont icon-a-erweimabeifen2 g_fs_21 g_c_c" style="font-size: 21px"></i>
							</view>
							<!-- 头像类，只有正式版才显示 -->
							<view class="g_flex_rowRight_columnCenter" v-if="item.tip == 'avatar' && isRelease">
								<img :src="item.value" alt="" class="g_w_48 g_h_48 g_radius_50" />
							</view>
							<!-- 右箭头 -->
							<view class="g_flex_column_center" v-if="item.type != 'slot'">
								<i class="iconfont icon-gengduo11 g_c_c"></i>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
/* item单行卡片
 * 示例：我的页面中的设置展示UI
 */
export default {
	data() {
		return {
			localBaseImg: "",
			isRelease: uni.getAccountInfoSync().miniProgram.envVersion === 'release',
		};
	},
	props: {
		rpl:{
			default:()=>{
				return 7;
			}
		},
		list: {
			type: Array,
			default: () => {
				return [];
			},
		},
	},
	created() {
		this.localBaseImg = this.G.store().localBaseImg;
	},
	methods: {
		// 当前行
		handleClickItem($item, $index) {
			this.$emit("clickItem", {
				item: $item,
				index: $index,
			});
		},

	},
};
</script>

<style lang="scss">
.g-components-item {
	.m-set {
		width: calc(100% - 40rpx);
		margin: 0 auto;

		.item {
			position:relative;
			// border-bottom: 1rpx solid #eee;
			&:after{
				content:'';
				position: absolute;
				bottom:0;
				left:16px;
				border-bottom: 1rpx solid #eee;
				height: 1rpx solid #eee;
				width: calc(100vw - 52px);
				
			}
			

			&:last-child {
				border-bottom: none;
				&:after{
					content:none;
				}
			}
		}

		.labelRequire {
			&::afrer {
				content: "*";
				color: #ff4400;
				margin-top: 8px;
				margin-right: 2px;
			}
		}
	}

	.btn-text {
		.btn-con {
			border-left: 1rpx solid #eee;
			padding: 0 0 0 16px;
			background-color: transparent;
			border-radius: 0;
			height: 40rpx;
			line-height: 40rpx;
		}
	}
}
</style>
