<template>
    <div class="preview-form-main">
        <div class="form-title">
            <img class="icon" src="@/assets/img/sa_06.png" />
            <span>预览</span>
        </div>
        <div class="form-content">
            <div class="preview-cell-poster-photo border">
                <img class="poster-photo" :src="poster_photo" />
                <div class="title-panel">
                    <p class="title">{{ title }}</p>
                    <p class="subtitle">{{ subtitle }}</p>
                </div>
            </div>
            <div class="org-info-cell border">
                <div class="logo">
                    <img :src="$store.getters.xt_user.org.org_logo" />
                </div>
                <div class="text-info">
                    <p class="name">{{ $store.getters.xt_user.org.org_name }}</p>
                    <p class="address">{{ address }}</p>
                </div>
                <div class="arrow-panel">
                    <img src="@/assets/img/sa_52.png" />
                </div>
            </div>
            <div class="simple-cell border">
                <div class="icon">
                    <img src="@/assets/img/sa_21.png" />
                </div>
                <div class="text">
                    <p>{{ activity_time }}</p>
                </div>
                <div class="arrow-panel">
                    <img src="@/assets/img/sa_52.png" />
                </div>
            </div>
            <div class="simple-cell border">
                <div class="icon">
                    <img src="@/assets/img/sa_24.png" />
                </div>
                <div class="text">
                    <p>{{ phone_number }}</p>
                </div>
                <div class="arrow-panel">
                    <img src="@/assets/img/sa_52.png" />
                </div>
            </div>
            <div class="simple-cell border">
                <div class="title">
                    <p>活动名额</p>
                </div>
                <div class="detail">
                    <p>{{ limit_num }}</p>
                </div>
            </div>
            <div class="large-text-cell border">
                <div class="title">
                    <img src="@/assets/img/sa_25.png" />
                    <span>报名须知</span>
                </div>
                <p class="content" v-html="sign_up_notice">
                </p>
            </div>
            <div class="large-text-cell border">
                <div class="title">
                    <img src="@/assets/img/sa_26.png" />
                    <span>{{ paragraph_title }}</span>
                </div>
                <p class="content" v-html="paragraph_content">
                </p>
            </div>
        </div>
    </div>
</template>

<script>
import { parseTime } from "@/utils"

export default {
    name: "EditActivityPreviewForm",
    props: {
        activity: {
            type: Object,
            required: true,
        },
        paragraph: {
            type: Object,
            required: true,
        },
    },
    data() {
        return {
            
        }
    },
    computed: {
        poster_photo: function() {
            return this.activity.poster_photo.length > 0 ? this.activity.poster_photo : require("@/assets/img/activity_poster_photo_default.png")
        },
        title: function() {
            return this.activity.title.length > 0 ? this.activity.title : "与孩子一起挑选采摘新鲜有机马陆葡萄，体验采摘乐趣"
        },
        subtitle: function() {
            return this.activity.subtitle.length > 0 ? this.activity.subtitle : "亲子采摘活动"
        },
        address: function() {
            return this.activity.address.length > 0 ? this.activity.address : "深圳市南山区高新园"
        },
        activity_time: function() {
            if (this.activity.start_time > 0) {
                return parseTime(this.activity.start_time, "{y}-{m}-{d} {h}:{i}")
            } else {
                return "2019-01-01 09:00:00"
            }
        },
        phone_number: function() {
            return this.activity.phone_number.length > 0 ? this.activity.phone_number : "0755-86879866"
        },
        limit_num: function() {
            return this.activity.limit_num > 0 ? (this.activity.limit_num + "人") : "无限制"
        },
        sign_up_notice: function() {
            var notice = this.activity.sign_up_notice.length > 0 ? this.activity.sign_up_notice : "1.活动费用88元（2斤葡萄 1只手绘风筝 车费 包含1个大人 1个小孩）。\n2.多加1个大人另收30元/人。\n3.葡萄采摘时在园内可以适当品尝。"
            return notice.replace(/\n/g, "<br/>")
        },

        paragraph_title: function() {
            return this.paragraph.title.length > 0 ? this.paragraph.title : "商家介绍"
        },
        paragraph_content: function() {
            var content = this.paragraph.content.length > 0 ? this.paragraph.content : "1.活动费用88元（2斤葡萄 1只手绘风筝 车费 包含1个大人 1个小孩）。<br/>2.多加1个大人另收30元/人。<br/>3.葡萄采摘时在园内可以适当品尝。"
            return content
        },
    },
}
</script>

<style lang="scss" scoped>
.preview-form-main {
    .form-title {
        width: 100%;
        height: 60px;
        padding: 20px 0 20px 30px;
        border-bottom: 1px #dee2e5 solid;

        .icon {
            margin-top: -4px;
            vertical-align: middle;
        }

        span {
            font-size: 18px;
            font-weight: 500;
            color: #485b6d;
            margin-left: 10px;
        }
    }

    .form-content {
        width: 100%;
        padding: 14px 30px 14px 30px;

        .preview-cell-poster-photo {
            .poster-photo {
                width: 100%;
            }

            .title-panel {
                padding: 15px 15px 16px 20px;

                .title {
                    font-size: 18px;
                    color: #485b6d;
                    font-weight: bold;
                    line-height: 28px;
                }

                .subtitle {
                    margin-top: 6px;
                    color: #a6a6a6;
                    font-size: 14px;
                }
            }
        }

        .org-info-cell {
            padding: 20px 20px;
            margin-top: 15px;
            position: relative;
            display: flex;
            -webkit-box-align: center;
            align-items: center;

            .logo {
                img {
                    width: 40px;
                    height: 40px;
                    border-radius: 20px;
                    object-fit: cover;
                    object-position: center;
                }
            }
            .text-info {
                flex: 1;
                padding-left: 17px;
                color: #485b6d;

                .name {
                    font-size: 16px;
                    line-height: 22px;
                    font-weight: 500;
                }
                .address {
                    font-size: 14px;
                    line-height: 20px;
                    margin-top: 5px;
                }
            }
            .arrow-panel {
                width: 20px;
                position: relative;

                img {
                    width: 8px;
                    float: right;
                    vertical-align: middle;
                }
            }
        }

        .simple-cell {
            padding: 20px 20px;
            margin-top: 15px;
            position: relative;
            display: flex;
            -webkit-box-align: center;
            align-items: center;

            .icon {
                img {
                    width: 20px;
                    height: auto;//20px;
                    vertical-align: middle;
                }
            }
            .text {
                flex: 1;
                padding-left: 17px;
                color: #485b6d;
                line-height: 20px;
            }
            .arrow-panel {
                width: 20px;
                position: relative;

                img {
                    width: 8px;
                    float: right;
                    vertical-align: middle;
                }
            }

            .title {
                p {
                    color: #485b6d;
                }
            }
            .detail {
                flex: 1;
                padding-left: 23px;
                color: #485b6d;

                p {
                    color: #485b6d;
                    float: right;
                    text-align: right;
                }
            }
        }

        .large-text-cell {
            padding: 20px 20px;
            position: relative;
            -webkit-box-align: center;
            align-items: center;
            margin-top: 15px;

            .title {
                color: #485b6d;
                line-height: 18px;
                height: 18px;

                img {
                    // width: 18px;
                    // height: auto;
                    margin-right: 11px;
                    float: left;
                }
            }
            .content {
                color: #a8b3ba;
                margin: 10px 0 0 0;
                font-size: 14px;
                line-height: 20px;
            }
        }
    }
}
</style>

<style scoped>
.border {
    border: solid 1px #dee2e5;
    border-radius: 4px;
}
</style>
