📄 createjs.aspx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Shop.Web.UI;
namespace YXShop.Web.Admin.Accessories
{
public partial class CreateJs : System.Web.UI.Page
{
BasePage bp = null;
protected void Page_Load(object sender, EventArgs e)
{
string adurl;
string width;
string height;
string picurl;
string exp;
string jsname;
string AdType;
if (!PowerTree.PowerPass.isPass("013001006", PowerTree.PowerPanel.PowerType.other))
{
bp = new BasePage();
bp.PageError("对不起,你没有生成广告JS的权限!", "../index.aspx");
}
YXShop.BLL.AdvertiseManage datab = new YXShop.BLL.AdvertiseManage();
List<YXShop.Model.AdvertiseManage> data = datab.GetAll();
if (data.Count > 0)
{
int i = 0;
foreach (YXShop.Model.AdvertiseManage da in data)
{
adurl = da.AD_LinkAddress;
width = da.AD_SizeBreadth.ToString();
height = da.AD_Hight.ToString();
picurl = da.AD_UpspreadAdd;
exp = da.AD_Advertisecont;
jsname = da.AD_Name;
AdType = da.AD_lx.ToString();
CreateJss(adurl, width, height, picurl, exp, jsname, Convert.ToInt16(AdType));
i++;
}
BasePage bp = new BasePage();
bp.PageRight("共生成" + i.ToString() + "个广告JS,广告!", "AdvertiseManagelist.aspx");
}
}
/// <summary>
/// 生成广告JS
/// </summary>
/// <param name="adurl"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="picurl"></param>
/// <param name="exp"></param>
/// <param name="jsname"></param>
/// <param name="adtype">0:图片 1:Flash 3:幻灯片 4:对联 5:漂浮广告</param>
public void CreateJss(string adurl, string width, string height, string picurl, string exp, string jsname, int adtype)
{
//先创建文件
string path = "";
path = Server.MapPath("~") + "\\Include" + "\\Ad\\" + jsname + ".JS";
StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.UTF8);
string flash = "<a href='" + adurl + "' target='_blank'><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width='" + width + "' height='" + height + "'>";
StringBuilder adhtml = new StringBuilder();
if (adtype == 3)//幻灯片广告
{
YXShop.BLL.Websitepz configBll = new YXShop.BLL.Websitepz();
YXShop.Model.WebsitePz configObj = new YXShop.Model.WebsitePz();
List<YXShop.Model.WebsitePz> configObjs = configBll.GetId(1);
//ChangeHope_CMS cms = new ChangeHope_CMS();
adhtml.Append("<!-- \n");
adhtml.Append("var focus_width=" + width + "; \n");//图片宽
adhtml.Append("var focus_height=" + height + "; \n");//图片高
adhtml.Append("var text_height=20; \n");//设置显示文字标题高度,最佳为20(如果不显示标题值设为0即可)
adhtml.Append("var swf_height = focus_height+text_height; \n");
string AD = picurl.Replace("|", "|" + configObj.WP_Wzdz);
adhtml.Append("var pics = '" + configObj.WP_Wzdz + AD + "';\n");
adhtml.Append("var links = '" + adurl + "'; \n");
adhtml.Append("var texts = '" + exp + "'; \n");
adhtml.Append("document.write('<object ID=\"focus_flash\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"'+ focus_width +'\" height=\"'+ swf_height +'\">'); \n");
adhtml.Append("document.write('<param name=\"allowScriptAccess\" value=\"sameDomain\"><param name=\"movie\" value=\"" + configObj.WP_Wzdz + "include/playswf.swf\"><param name=\"quality\" value=\"high\"><param name=\"bgcolor\" value=\"#FFFFFF\">'); \n");
adhtml.Append("document.write('<param name=\"menu\" value=\"false\"><param name=wmode value=\"opaque\">'); \n");
adhtml.Append("document.write('<param name=\"FlashVars\" value=\"pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'\">'); \n");
adhtml.Append("document.write('<embed ID=\"focus_flash\" src=\"" + configObj.WP_Wzdz + "include/playswf.swf\" wmode=\"opaque\" FlashVars=\"pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'\" menu=\"false\" bgcolor=\"#C5C5C5\" quality=\"high\" width=\"'+ focus_width +'\" height=\"'+ swf_height +'\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />');\n");
adhtml.Append("document.write('</object>'); \n");
adhtml.Append("//-->");
}
string Stem_Swf = "";
if (adtype == 1)//FLASH广告
{
Stem_Swf += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width=" + width + " height=" + height + ">";
Stem_Swf += "<param name='movie' value='" + picurl + "' />";
Stem_Swf += "<param name='quality' value='high' />";
Stem_Swf += "<embed src='" + picurl + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width=" + width + " height=" + height + "></embed>";
Stem_Swf += "</object>";
}
string stem_float = "";
if (adtype == 5)//漂浮广告
{
stem_float += "document.write(\"<div id='img' style='position:absolute;'>\");";
stem_float += "document.write(\"<a href='" + adurl + "' target='_blank'><img src='" + picurl + "'onClick='pause_resume();' width=" + width + " height=" + height + "></a></div>\");\n";
stem_float += "<!-- Begin \n";
stem_float += "var xPos = 20;\n";
stem_float += "var yPos = document.body.clientHeight;\n";
stem_float += "var step = 1;\n";
stem_float += "var delay = 30;\n ";
stem_float += "var height = 0;\n";
stem_float += "var Hoffset = 0;\n";
stem_float += "var Woffset = 0;\n";
stem_float += "var yon = 0;\n";
stem_float += "var xon = 0;\n";
stem_float += "var pause = true;\n";
stem_float += "var interval;\n";
stem_float += "img.style.top = yPos;\n";
stem_float += "function changePos() {\n";
stem_float += "width = document.body.clientWidth;\n";
stem_float += "height = document.body.clientHeight;\n";
stem_float += "Hoffset = img.offsetHeight;\n";
stem_float += "Woffset = img.offsetWidth;\n";
stem_float += "img.style.left = xPos + document.body.scrollLeft;\n";
stem_float += "img.style.top = yPos + document.body.scrollTop;\n";
stem_float += "if (yon) {\n";
stem_float += "yPos = yPos + step;\n";
stem_float += "}\n";
stem_float += "else {\n";
stem_float += "yPos = yPos - step;\n";
stem_float += "}\n";
stem_float += "if (yPos < 0) {\n";
stem_float += "yon = 1;\n";
stem_float += "yPos = 0;\n";
stem_float += "}\n";
stem_float += "if (yPos >= (height - Hoffset)) {\n";
stem_float += "yon = 0;\n";
stem_float += "yPos = (height - Hoffset);\n";
stem_float += "}\n";
stem_float += "if (xon) {\n";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -