var t = getApp();

Page({
    data: {
        form: {},
        copyright: "",
        t1v: "",
        t2v: "",
        t3v: "",
        t4v: "",
        rv: "",
        cv: "",
        av: "",
        av1: "",
        blist: {},
        tcolor: "",
        hide_tabbar: "0"
    },
    onLoad: function(a) {
        var e = t.siteInfo.uniacid;
        this.setData({
            copyright: t.globalData.copyright
        });
        var r = this;
        t.util.request({
            url: "message",
            data: {
                m: "yyf_company",
                action:"message",
                uniacid: e
            },
            cachetime: 0,
            success: function(t) {
                t.data.errno || (r.setTabBar(), r.setData({
                    form: t.data.data
                }), wx.setNavigationBarTitle({
                    title: t.data.data.catname
                }));
            }
        }), t.util.request({
            url: "?action=tabbar",
            data: {
              m: "yyf_company",
              action: "tabbar",
              uniacid: n
            },
            cachetime: 0,
            success: function(t) {
                if (!t.data.errno) {
                    var a = wx.getStorageSync("barlist");
                    "" != a && a.uptime == t.data.data.uptime || (wx.setStorageSync("barlist", t.data.data), 
                    r.setTabBar());
                }
            }
        });
    },
    notice: function(t) {
        wx.showModal({
            title: t,
            content: "",
            success: function(t) {}
        });
    },
    notice1: function(t) {
        wx.showModal({
            title: "",
            content: t,
            success: function(t) {}
        });
    },
    t1: function(t) {
        console.log(t.detail.value), this.setData({
            t1v: t.detail.value
        });
    },
    t2: function(t) {
        this.setData({
            t2v: t.detail.value
        });
    },
    t3: function(t) {
        this.setData({
            t3v: t.detail.value
        });
    },
    t4: function(t) {
        this.setData({
            t4v: t.detail.value
        });
    },
    radioChange: function(t) {
        this.setData({
            rv: t.detail.value
        });
    },
    checkChange: function(t) {
        this.setData({
            cv: t.detail.value
        });
    },
    textareaBlur: function(t) {
        this.setData({
            av: t.detail.value
        });
    },
    submitClick: function(a) {
        var e = !0, r = this.data;
        if ("" == r.t1v && "1" == r.form.t1full && "1" == r.form.t1show) return this.notice(r.form.t1name + "不能为空!"), 
        e = !1, !1;
        if ("" == r.t2v && "1" == r.form.t2full && "1" == r.form.t2show) return this.notice(r.form.t2name + "不能为空!"), 
        e = !1, !1;
        if ("" == r.t3v && "1" == r.form.t3full && "1" == r.form.t3show) return this.notice(r.form.t3name + "不能为空!"), 
        e = !1, !1;
        if ("" == r.t4v && "1" == r.form.t4full && "1" == r.form.t4show) return this.notice(r.form.t4name + "不能为空!"), 
        e = !1, !1;
        if ("" == r.rv && "1" == r.form.rfull && "1" == r.form.rshow) return this.notice(r.form.rname + "不能为空!"), 
        e = !1, !1;
        if ("" == r.cv && "1" == r.form.cfull && "1" == r.form.cshow) return this.notice(r.form.cname + "不能为空!"), 
        e = !1, !1;
        if ("" == r.av && "1" == r.form.afull && "1" == r.form.ashow) return this.notice(r.form.aname + "不能为空!"), 
        e = !1, !1;
        if (e) {
            var i = t.siteInfo.uniacid, o = this;
            t.util.footer(o);
            var n = wx.getStorageSync("sendtime");
            "" == n && (n = 0), t.util.request({
              url: "?action=messageadd",
              header: {
                'Content-Type': 'application/x-www-form-urlencoded;charset=gbk'
              },
              data: {
                    action:"messageadd",
                    t1v: encodeURI(encodeURI(o.data.t1v)),
                    //t1name: o.data.form.t1name,
                    t2v: encodeURI(encodeURI(o.data.t2v)),
                    //t2name: o.data.form.t2name,
                    t3v: encodeURI(encodeURI(o.data.t3v)),
                    //t3name: o.data.form.t3name,
                    t4v: encodeURI(encodeURI(o.data.t4v)),
                    //t4name: o.data.form.t4name,
                    //rv: o.data.rv,
                    //rname: o.data.form.rname,
                    //cv: o.data.cv,
                    //cname: o.data.form.cname,
                    //av: o.data.av,
                    //aname: o.data.form.aname,
                    //sendtime: n
                },
                cachetime: 0,
                success: function(t) {
                    if (!t.data.errno) if (1 == t.data.errno) o.notice(t.data.message); else {
                        var a = Date.parse(new Date());
                        a /= 1e3, wx.setStorageSync("sendtime", a), o.notice1(o.data.form.successtext);
                    }
                }
            });
        }
    },
    onShareAppMessage: function(t) {
        return {
            title: this.data.catname,
            path: "/yyf_company/pages/message/message"
        };
    },
    setTabBar: function() {
        if (!(i = wx.getStorageSync("barlist"))) return !1;
        this.setData({
            blist: i,
            tcolor: i.tcolor,
            hide_tabbar: i.hide_tabbar
        });
        var t, a;
        t = "" != i.font_color ? i.font_color : "#ffffff", a = "" != i.head_color ? i.head_color : i.tcolor, 
        wx.setNavigationBarColor({
            frontColor: t,
            backgroundColor: a
        });
        var e = getCurrentPages(), r = e[e.length - 1].route, i = this.data.blist, o = r.split("/");
        "message" == o[o.length - 1] && (i.isCurrentPage = !0);
        var n = new Array(i.m1_path, i.m2_path, i.m3_path, i.m4_path), s = 0;
        for (var c in n) "message" == n[c] && (s = parseInt(c) + 1);
        i.currentNum = s, this.setData({
            blist: i
        });
    },
    testUrl: function(a, e) {
        //var r = t.siteInfo.siteroot + "?i=" + t.siteInfo.uniacid + "&t=" + t.siteInfo.multiid + "&v=" + t.siteInfo.version + "&from=wxapp&";
        //return a && ((a = a.split("/"))[0] && (r += "c=" + a[0] + "&"), a[1] && (r += "a=" + a[1] + "&"), 
        //a[2] && (r += "do=" + a[2] + "&")), r;

        var r = t.siteInfo.siteroot + "?";
        return a && ((a = a.split("/"))[0] && (r += "")), r;
    },
    tel: function() {
        var t = this.data.blist.phone;
        wx.makePhoneCall({
            phoneNumber: t
        });
    },
    driver: function() {
        wx.openLocation({
            latitude: Number(this.data.blist.jing),
            longitude: Number(this.data.blist.wei),
            address: this.data.blist.address
        });
    },
    tabNav: function(t) {
        var a = t.currentTarget.dataset.url, e = t.currentTarget.dataset.tab;
        "-1" != a.indexOf("https") ? (wx.setStorageSync("navurl", a), a = "../webview/webview?op=" + e, 
        wx.navigateTo({
            url: a
        })) : wx.redirectTo({
            url: a
        });
    },
    copy_action: function() {
        var t = this.data.blist.copyright;
        if ("1" == t.copy_kind) {
            var a = t.copy_phone;
            wx.makePhoneCall({
                phoneNumber: a
            });
        }
        if ("2" == t.copy_kind) {
            var e = t.copy_appid, r = t.copy_ddress;
            wx.navigateToMiniProgram({
                appId: e,
                path: r,
                success: function(t) {}
            });
        }
    }
});