var t = getApp();

Page({
    data: {
        info: {},
        copyright: "",
        blist: {},
        tcolor: "",
        contact_name_size: 22,
        hide_tabbar: "0",
        markers: [ {
            iconPath: "../../resource/images/mark1.png",
            id: 0,
            latitude: 22.54043,
            longitude: 113.93454,
            width: 40,
            height: 40
        } ]
    },
    onLoad: function() {
        var a = this, e = t.siteInfo.uniacid;
        this.setData({
            copyright: t.globalData.copyright
        }), t.util.request({
            url: "contact",
            data: {
                m: "yyf_company",
                uniacid: e,
                action:"contact"
            },
            cachetime: 0,
            success: function(t) {
                if (!t.data.errno) {
                    a.setTabBar();
                    var e = t.data.data.contact_name, n = 22;
                    e.length > 10 && (n = 16), e.length > 14 && (n = 14);
                    var i = a.data.markers;
                    i[0].latitude = t.data.data.jing, i[0].longitude = t.data.data.wei, console.log(i), 
                    a.setData({
                        contact_name_size: n,
                        info: t.data.data,
                        markers: i
                    }), wx.setNavigationBarTitle({
                        title: "联系我们"
                    });
                }
            }
          }), t.util.request({
              url: "?action=tabbar",
              data: {
                m: "yyf_company",
                action: "tabbar",
                uniacid: n
              },
            cachetime: 0,
            success: function(t) {
                if (!t.data.errno) {
                    var e = wx.getStorageSync("barlist");
                    "" != e && e.uptime == t.data.data.uptime || (wx.setStorageSync("barlist", t.data.data), 
                    a.setTabBar());
                }
            }
        });
    },
    isEmptyObject: function(t) {
        for (var a in t) return !1;
        return !0;
    },
    calling1: function() {
        this.data.info.phone, wx.makePhoneCall({
            phoneNumber: this.data.info.phone
        });
    },
    calling2: function() {
        this.data.info.phone2, wx.makePhoneCall({
            phoneNumber: this.data.info.phone2
        });
    },
    ri1: function() {
        this.data.info.phone, wx.makePhoneCall({
            phoneNumber: this.data.info.phone
        });
    },
    ri2: function() {
        this.data.info.phone, wx.makePhoneCall({
            phoneNumber: this.data.info.phone
        });
    },
    gomap: function() {
        wx.openLocation({
            latitude: Number(this.data.info.jing),
            longitude: Number(this.data.info.wei),
            address: this.data.info.address
        });
    },
    onShareAppMessage: function(t) {
        return {
            title: this.data.catname,
            path: "/yyf_company/pages/contact/contact"
        };
    },
    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(), n = e[e.length - 1].route, i = this.data.blist, o = n.split("/");
        "contact" == o[o.length - 1] && (i.isCurrentPage = !0);
        var r = new Array(i.m1_path, i.m2_path, i.m3_path, i.m4_path), s = 0;
        for (var c in r) "contact" == r[c] && (s = parseInt(c) + 1);
        i.currentNum = s, this.setData({
            blist: i
        });
    },
    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, n = t.copy_ddress;
            wx.navigateToMiniProgram({
                appId: e,
                path: n,
                success: function(t) {}
            });
        }
    }
});