<template>
	<view class="app-associated-link dir-left-nowrap main-left cross-center" :style="{backgroundColor: background}">
		<app-jump-button style="width: 100%" form :open_type="link.open_type" :url="link.value" :params="link.params">
			<view class="dir-left-nowrap" :class="[`${className}`]" :style="{backgroundColor: background}">
				<view v-if="styleNum == '1'" class="app-link-title box-grow-1" :style="{textAlign: position}">
					<image class="app-title-icon" v-if="picSwitch" :src="picUrl">
					</image>
					<text :style="{color: color}">{{title}}</text>
				</view>
				<view v-else-if="styleNum == '2'" class="app-link-title box-grow-1 main-center cross-center">
                    <image :style="{backgroundColor: styleColor}" class="app-title-line" :src="styleImg.line"></image>
                    <view :style="{color: color}">{{title}}</view>
                    <image :style="{backgroundColor: styleColor}" class="app-title-line" :src="styleImg.line"></image>
                </view>
                <view v-else-if="styleNum == '3'" class="app-link-title box-grow-1 main-center cross-center">
                    <view class="app-title-line star">
                    	<view :style="{backgroundColor: styleColor}" class="top-icon"></view>
                    	<view :style="{backgroundColor: styleColor}" class="bottom-icon"></view>
                    </view>
                    <view :style="{color: color}">{{title}}</view>
                    <view class="app-title-line star">
                    	<view :style="{backgroundColor: styleColor}" class="top-icon"></view>
                    	<view :style="{backgroundColor: styleColor}" class="bottom-icon"></view>
                    </view>
                </view>
                <view v-else-if="styleNum == '4'" class="app-link-title box-grow-1 dir-left-nowrap cross-center">
                    <image :style="{backgroundColor: styleColor}" class="app-title-line div" :src="styleImg.div"></image>
                    <view :style="{color: color}">{{title}}</view>
                </view>
                <view v-else-if="styleNum == '5'" class="app-link-title box-grow-1 dir-left-nowrap cross-center">
                    <view :style="[{'border-color':`${styleColor}`,'background-color':`${background}`}]" class="app-title-line radius"></view>
                    <view :style="{color: color}">{{title}}</view>
                </view>
                <block v-if="arrowsSwitch">
                    <view class="app-more-btn">
                        <text>进入会场</text>
                        <icon class="app-icon"></icon>
                    </view>
                </block>
			</view>
		</app-jump-button>
	</view>
</template>

<script>
    import {mapState, mapGetters} from 'vuex';

    export default {
        name: "app-associated-link",
        data() {
            return {
                className: '',
            }
        },
        computed: {
            ...mapState({
                styleImg: state => state.mallConfig.__wxapp_img.diy,
            }),
        },
	    props: {
            arrowsSwitch: {
                type: Boolean,
	            default: function() {
	                return false;
	            }
            },
            background: {
                type: String,
	            default: function() {
	                return '#E11B1B';
	            }
            },
            color: {
                type: String,
	            default: function() {
	                return '#F4EBEB';
	            }
            },
            link: {
                type: Object,
	            default: function() {
	                return {
                        open_type: "tel",
                        params: [
	                        {
                                value: "111",
	                        }
                        ],
	                }
	            }
            },
            styleColor: {
                type: String,
	            default: function() {
	                return '#353535';
	            }
            },
            picSwitch: {
                type:Boolean,
	            default: function() {
	                return false;
	            }
            },
            picUrl: {
                type: String,
	            default: function() {
	                return '';
	            }
            },
		    position: {
                type: String,
	            default: function() {
	                return 'left';
	            }
		    },
		    title: {
                type: String,
			    default: function() {
			        return '';
			    }
		    },
		    styleNum: {
                type: String,
			    default: function() {
			        return '1';
			    }
		    },
		    fontSize: {
                type: String,
			    default: function() {
			        return '36';
			    }
		    }
	    },
        created() {
            let that = this;
            if(this.fontSize == '36') {
            	this.className = 'big-style'
            }else if(this.fontSize == '28') {
            	this.className = 'medium-style'
            }else {
            	this.className = 'small-style'
            }
        },
    }
</script>

<style scoped lang="scss">
	.app-associated-link {
		width: #{750rpx};
		height: #{90rpx};
		position: relative;
        display: flex;
        align-items: center;
		.app-more-text {
			font-size: #{24rpx};
			color: #999;
			white-space: nowrap;
		}
        .app-more-btn{
            min-width: 200rpx;
            color: #ffffff;
            -webkit-border-radius: 7px;
            border-radius: 30rpx;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 30rpx;
            height: 60rpx;
            margin-right: 20rpx;
            background: #F61921;
        }
		.app-icon {
			background-image: url("../../../static/image/icon/arrow-right-white.png");
			width: #{12rpx};
			height: #{22rpx};
			background-repeat: no-repeat;
			background-size: cover;
            margin-left: 10rpx;
		}
		.app-link-title {
        	flex-grow: 1;
        	width: 100%;
        	padding: 0 24rpx;
        	.app-title-line {
		        width: 82rpx;
		        height: 5rpx;
		        margin: 0 20rpx;
		    }
		    .app-title-line.star {
		        width: 28rpx;
		        height: 20rpx;
		        .top-icon {
		        	width: 28rpx;
		        	height: 4rpx;
		        	margin-bottom: 12rpx;
		        }
		        .bottom-icon {
		        	width: 28rpx;
		        	height: 4rpx;
		        }
		    }
		    .app-title-line.div {
		        width: 8rpx;
		        height: 28rpx;
		        margin: 0 10rpx 0 0;
		    }
		    .app-title-line.radius {
		        width: 28rpx;
		        margin: 0 10rpx 0 0;
		        border-radius: 14rpx;
		        border: 2rpx solid #353535;
		        height: 28rpx;
		    }
		}
    	.big-style {
	        height: 65rpx;
	        line-height: 65rpx;
	        font-size: 32rpx;
	        width: 100%;
	        // padding-right: 48rpx;
	        .app-title-icon {
		        width: 65rpx;
		        height: 65rpx;
		        margin-right: 16rpx;
		        vertical-align: top;
		    }
    	}
    	.medium-style {
	        height: 36rpx;
	        line-height: 36rpx;
	        font-size: 28rpx;
	        width: 100%;
	        padding-right: 48rpx;
	        .app-title-icon {
		        width: 36rpx;
		        height: 36rpx;
		        margin-right: 16rpx;
		        vertical-align: top;
		    }
    	}
    	.small-style {
	        height: 28rpx;
	        line-height: 28rpx;
	        font-size: 24rpx;
	        width: 100%;
	        padding-right: 48rpx;
	        .app-title-icon {
		        width: 28rpx;
		        height: 28rpx;
		        margin-right: 16rpx;
		        vertical-align: top;
		    }
    	}
	}
</style>
