Пример #1
0
        /// <summary>
        /// 返回页面消息弹框
        /// </summary>
        /// <param name="msg">消息内容</param>
        /// <param name="url">跳转链接</param>
        /// <param name="icon">消息类型</param>
        /// <param name="anim">消息动画</param>
        /// <param name="time">出现时间</param>
        /// <returns></returns>
        public static string LayerMsg(string msg, Icon icon, string url = "", int anim = -1, int time = 2000)
        {
            // 链接
            if (string.IsNullOrEmpty(url))
            {
                url = Utils.GetUrlInfo();
            }
            // 动画
            anim = anim % 7;
            if (anim < 0)
            {
                anim = new Random().Next(0, 7);
            }

            StringBuilder str = new StringBuilder();

            Dictionary <object, object> dic = new Dictionary <object, object> {
                { "skin", layer_Skin },
                { "anim", anim },
                { "time", time },
                { "icon", GetIconNum(icon) }
            };

            str.Append("<script>");
            str.Append("location.href='" + url + "'; ");
            // 由于要返回的是父窗的方法,所以加上parent.
            str.Append("parent.layer.msg('" + msg + "',{");
            str.Append(Utils.MosaicKeyVal(dic) + "});");
            str.Append("</script>");

            return(str.ToString());
        }