<template>
    <div class="edit">
        <div class="edit-title">{{ type === 'name' ? '展馆标题' : '展馆主题' }}</div>
        <van-field
            label=" "
            label-width="0"
            v-model="message"
            rows="4"
            autosize
            type="textarea"
            :maxlength="type === 'name' ? 10 : 200"
            :placeholder="type === 'name' ? '给展馆起个响亮的名字吧' : '介绍一下展馆主题吧'"
            show-word-limit
            :border="false"
        />

        <div class="btn">
            <van-button type="primary" round block @click="save">保存</van-button>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            message: '',
            type: 'intr'
        };
    },
    mounted() {
        if (this.$route.query.message) {
            this.message = this.$route.query.message;
        }
        if (this.$route.query.type) {
            this.type = this.$route.query.type;
        }
    },
    methods: {
        save() {
            if (this.type === 'name') {
                this.emitter.emit('setName', this.message);
            } else {
                this.emitter.emit('setIntroduction', this.message);
            }
            this.$router.back();
        }
    }
};
</script>

<style lang="less" scoped>
.edit {
    background-color: #1c1c1c;
}

.edit-title {
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
    line-height: 24px;
    padding: 13px 16px;
    background-color: #222426;
    border-bottom: 1px solid #303133;
}

.van-field {
    background-color: #222426;
    color: #ffffff;
    /deep/.van-field__label {
        margin-right: 0;
    }
    /deep/.van-field__control {
        color: #fff;
    }
}

.btn {
    margin: 80px 50px;
}
</style>
