var t = require("../../../../49539051658710DF2F35F8564970FAA0.js"), i = wx.cloud.database();

Page({
    data: {
        competition: "",
        buttonText: ""
    },
    onLoad: function(t) {
        this.data.id = t.id, wx.showLoading({
            title: "正在加载",
            mask: !0
        }), this.getCompetition(t.id), wx.hideShareMenu();
    },
    getCompetition: function(e) {
        var o = this;
        i.collection("competitions").doc(e).field({
            title: !0,
            startTime: !0,
            site: !0,
            sponsor: !0,
            organizer: !0,
            poster: !0,
            rule: !0,
            settings: !0,
            posterSize: !0
        }).get().then(function(i) {
            wx.hideLoading();
            var e = i.data;
            e.startTime = t.formatTime("short", e.startTime), o.setData({
                competition: e
            });
        }).catch(function(i) {
            t.competitionNoExistShowModal(i.errCode);
        });
    },
    switchChangeAllowProgramImage: function(t) {
        this.data.competition.settings.allowProgramImage = t.detail.value, this.setData({
            buttonText: "保存设置"
        });
    },
    switchChangeSkipJuries: function(t) {
        this.data.competition.settings.skipJuries = t.detail.value, this.setData({
            buttonText: "保存设置"
        });
    },
    switchChangeShowVote: function(t) {
        this.data.competition.settings.showVote = t.detail.value, this.setData({
            buttonText: "保存设置"
        });
    },
    switchChangeShowVoteSearch: function(t) {
        this.data.competition.settings.showVoteSearch = t.detail.value, this.setData({
            buttonText: "保存设置"
        });
    },
    switchChangeSubmitComment: function(t) {
        this.data.competition.settings.submitComment = t.detail.value, this.setData({
            buttonText: "保存设置"
        });
    },
    switchChangeJudgeItemBySingleColumn: function(t) {
        this.data.competition.settings.judgeItemBySingleColumn = t.detail.value, this.setData({
            buttonText: "保存设置"
        });
    },
    updateRule: function() {
        var t = this, i = {
            _id: this.data.competition._id,
            settings: this.data.competition.settings
        };
        wx.showLoading({
            title: "更新设置",
            mask: !0
        }), wx.cloud.callFunction({
            name: "updateVipV2",
            data: {
                competition_id: i._id,
                competition_settings: i.settings,
                operation: "updateCompetitionSettings"
            }
        }).then(function(i) {
            wx.hideLoading(), wx.showToast({
                title: "compSettings",
                icon: "success",
                duration: 1500
            }), t.setData({
                buttonText: ""
            });
        });
    }
});