﻿var jsonweburl = "http://1.a.rompy.cn";
jsonweburl = "http://center.rompy.cn";
$(document).ready(function () {
    setTimeout("rtnNewMsg()", 60);
});


function rtnNewMsg() {
    if (!document.getElementById("morenew")) {
        return false;
    }
    var rtnstr = "";
    //所有新闻，按时间先后
    $.getJSON(jsonweburl + "/rompycenter/handler/yby_getInfo.ashx?flag=1&&format=json&&jsoncallback=?", function (data) {
        //获取JSON对象中的实体，并填充表单
        //i索引  第2个是对象
        $.each(data, function (i) {
            rtnstr += "<li><img src='images/xtb.gif' /><a href='" + jsonweburl + "/rompycenter/newsdetail.aspx?wsn=" + data[i].Sn + "&&sn=" + data[i].Shopsn + "' title='" + data[i].Stitle + "' class='i_right_a'>" + "【" + data[i].Shopname + "】" + subStr(data[i].Stitle) + "</a></li>";
        });
        if (rtnstr == "") {
            $("#morenew").html("暂无新闻");
        } else {
            $("#morenew").html("<ul id='i_right_b_ul'>" + rtnstr + "</ul>");
        }
    });
}

function subStr(title) {
    if (title.length >8) {
        return title.substr(0, 7) + "..";
    }
    else {
        return title;
    }
}
