<style lang="less">
    @import "../../styles/common.less";
    .ivu-card-head {
        p {
            height: 32px;
            line-height: 32px;
        }
        button {
            float: right;
        }
    }
</style>

<template>
    <div>
        <Row class="margin-top-10">
            <Col>
            <Card>
                <p slot="title">打赏金额</p>
                <div class="edittable-table-height-con">
                    <Form :label-width="80">
                        <FormItem label="金额">
                            <Input v-model="price" placeholder="请输入打赏金额（元）" />
                        </FormItem>
                    </Form>
                    <div class="submit">
                        <Button @click="changePrice" :loading="publishLoading" icon="ios-checkmark" size="large" type="primary">提交</Button>
                    </div>
                </div>
            </Card>
            </Col>
        </Row>
    </div>
</template>

<script>
    export default {
        name: "reward",
        data() {
            return {
                price: "",
                publishLoading: false
            };
        },
        methods: {
            changePrice() {
                if (!this.price) {
                    return this.$Message.warning('请输入正确的价格');
                }
                this.publishLoading = true;
                this.axios.post("/reward/price", {
                        price: parseFloat(this.price)
                    })
                    .then(res => {
                        if (res.data.status == 0) {
                            this.$Message.success("操作成功");
                            this.publishLoading = false;
                        }
                    });
            },
            init() {
                this.axios.get("/reward/price", {})
                    .then(res => {
                        if (res.data.status == 0) {
                            this.price = res.data.data.price;
                        }
                    });
            }
        },
        mounted() {
            this.init();
        }
    };
</script>
