var t = getApp();

Page({
    data: {
        list: [],
        lastid: 0,
        tid: 0,
        catname: "",
        copyright: "",
        cats: [],
        currentTabsIndex: 0,
        fid: 0,
        currentCatId: 0,
        fatherId: 0,
        blist: {},
        tcolor: "",
        catkey: -1,
        hide_time: "0",
        hide_tabbar: "0",
        isData: 1
    },
    onLoad: function(a) {
        this.loadData(a.keyword), wx.setNavigationBarTitle({
            title: a.keyword + "搜索结果"
        }), this.setData({
            copyright: t.globalData.copyright
        }), this.setTabBar();
    },
    loadData: function(a) {
        var e = this, r = t.siteInfo.uniacid;
        t.util.request({
            url: "entry/wxapp/search",
            data: {
                m: "yyf_company",
                uniacid: r,
                keyword: a
            },
            cachetime: 0,
            success: function(t) {
                t.data.errno || (e.setData({
                    list: t.data.data.list
                }), "" == t.data.data.list && e.setData({
                    isData: 0
                }));
            }
        }), t.util.request({
            url: "entry/wxapp/TabBar",
            data: {
                m: "yyf_company",
                uniacid: r
            },
            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), 
                    e.setTabBar());
                }
            }
        });
    },
    listNavApp: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.appid, e = t.currentTarget.dataset.address;
        wx.navigateToMiniProgram({
            appId: a,
            path: e,
            success: function(t) {}
        });
    },
    setTabBar: function(t) {
        if (!(o = wx.getStorageSync("barlist"))) return !1;
        this.setData({
            blist: o,
            tcolor: o.tcolor,
            hide_tabbar: o.hide_tabbar
        });
        var a, e;
        a = "" != o.font_color ? o.font_color : "#ffffff", e = "" != o.head_color ? o.head_color : o.tcolor, 
        wx.setNavigationBarColor({
            frontColor: a,
            backgroundColor: e
        });
        var r = getCurrentPages(), i = r[r.length - 1], o = this.data.blist, n = (i.options, 
        new Array(o.m1_path, o.m2_path, o.m3_path, o.m4_path)), s = 0;
        for (var c in n) n[c] == t && (s = parseInt(c) + 1);
        o.currentNum = s, this.setData({
            blist: o
        });
    },
    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) {}
            });
        }
    }
});