/**
格式化时间显示方式、用法:format="yyyy-MM-dd hh:mm:ss";
*/
formatDate = function (v, format) {
    if (!v) return "";
    var d = v;
    if (typeof v === 'string') {
        if (v.indexOf("/Date(") > -1)
            d = new Date(parseInt(v.replace("/Date(", "").replace(")/", ""), 10));
        else
            d = new Date(Date.parse(v.replace(/-/g, "/").replace("T", " ").split(".")[0]));//.split(".")[0] 用来处理出现毫秒的情况，截取掉.xxx，否则会出错
    }
    var o = {
        "M+": d.getMonth() + 1,  //month
        "d+": d.getDate(),       //day
        "h+": d.getHours(),      //hour
        "m+": d.getMinutes(),    //minute
        "s+": d.getSeconds(),    //second
        "q+": Math.floor((d.getMonth() + 3) / 3),  //quarter
        "S": d.getMilliseconds() //millisecond
    };
    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (d.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
};

$(function () {
    if ($('#loadingToast').length > 0) {
        //增加loading
        var strLoading = "";
        strLoading += '<div id="loadingToast" class="weui_loading_toast" style="display:none ;">';
        strLoading += '    <div class="weui_mask_transparent"></div>';
        strLoading += '    <div class="weui_toast">';
        strLoading += '        <div class="weui_loading">';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_0"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_1"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_2"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_3"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_4"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_5"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_6"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_7"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_8"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_9"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_10"></div>';
        strLoading += '            <div class="weui_loading_leaf weui_loading_leaf_11"></div>';
        strLoading += '        </div>';
        strLoading += '        <p class="weui_toast_content">数据加载中</p>';
        strLoading += '    </div>';
        strLoading += '</div>';

        $(document.body).append(strLoading);
        $('#loadingToast').show();
    }

    if ($(".weui_tabbar").length > 0 && $(".weui_tabbar").html()!="") {
        var strFooter = "";
        strFooter += '<a href="/index.html" class="weui_tabbar_item">';
        strFooter += '    <div class="weui_tabbar_icon">';
        strFooter += '        <i class="fa fa-home"></i>';
        strFooter += '    </div>';
        strFooter += '    <p class="weui_tabbar_label">主页</p>';
        strFooter += '</a>';
        strFooter += '<a href="/MySelf/MyFavorite" class="weui_tabbar_item">';
        strFooter += '    <div class="weui_tabbar_icon">';
        strFooter += '        <i class="fa fa-star-o"></i>';
        strFooter += '    </div>';
        strFooter += '    <p class="weui_tabbar_label">收藏</p>';
        strFooter += '</a>';
        strFooter += '<a href="/Search/Index" class="weui_tabbar_item">';
        strFooter += '    <div class="weui_tabbar_icon">';
        strFooter += '        <i class="fa fa-search"></i>';
        strFooter += '    </div>';
        strFooter += '    <p class="weui_tabbar_label">搜索</p>';
        strFooter += '</a>';
        strFooter += '<a href="/MySelf/MyIndex" class="weui_tabbar_item">';
        strFooter += '    <div class="weui_tabbar_icon">';
        strFooter += '        <i class="fa fa-user"></i>';
        strFooter += '    </div>';
        strFooter += '    <p class="weui_tabbar_label">我的</p>';
        strFooter += '</a>';
        $(".weui_tabbar").html(strFooter);
    }
});