<template>
    <div>
        <van-field
                v-model="content"
                rows="5"
                autosize
                label="留言"
                label-width="50px"
                type="textarea"
                maxlength="200"
                placeholder="请输入您的宝贵建议与意见（200字以内）"
                show-word-limit
        ></van-field>
        <div style="height: 44px;width: 80%;margin: 20px auto 0">
            <van-button block type="info" @click="_ok">保存</van-button>
        </div>
    </div>
</template>

<script>
    import {advise} from '../../api'

    export default {
        name: "FeedBack",
        data() {
            return {
                content: ''
            }
        },
        methods: {
            async _ok() {
                if (this.content === '') {
                    this.$toast('请输入内容');
                } else {
                    let result = await advise.advise({content: this.content})
                    if (result) {
                        this.content = '';
                        this.$toast.success('提交成功！您的意见我们会慎重考虑！')
                        setTimeout(() => {
                            this.$router.go(-1)
                        }, 2000)
                    }
                }
            }
        }
    }
</script>

<style scoped>

</style>
