<template>
    <el-button size="mini" type="text" icon="el-icon-refresh" :loading="loading"
        @click="refreshUserhangdle()">刷新应用</el-button>
</template>

<script>
import { refreshUser } from "@/api/accounts/ttAdapi";
/**
 * 刷新广告账户
 */
export default {
    data() {
        return {
            loading: false
        }
    },
    props: {
        adAppId: {
            type: Number,
            default: null,
        },
        authUserId: {
            type: Number,
            default: null,
        }
    },
    methods: {
        /** 刷新广告账户 */
        refreshUserhangdle() {
            if (this.adAppId && this.authUserId) {
                this.$confirm('确定刷新？', `刷新${this.authUserId}`, {
                    distinguishCancelAndClose: true,
                    confirmButtonText: '确定',
                    cancelButtonText: '取消'
                }).then(() => {
                    this.loading = true
                    refreshUser(this.adAppId, this.authUserId).then(res => {
                        this.loading = false
                        if (res.data) {
                            this.msgSuccess("刷新成功");
                            this.$emit("onChange");
                        }
                    }).catch(() => this.loading = false)
                })

            }
        }
    }
}
</script>