<!--#include file="../conn/conn2.asp" -->
<!--#include file="../conn/function.asp" -->
﻿<%Session.CodePage=65001
Response.Charset="UTF-8"

p=request("p")
s=request("s")
t=request("t")


if p="" or s="" or t="" then
response.End()
end if

select case t
'--------------------------------------新闻---------------------------------------------
case "news"
if s<>0 then
S_info="and S_id="&s
else
S_info=""
end if
sql="select top 20 * from SL_news,SL_Nsort where N_sort=S_id "&S_info&" and N_id not in (select top "&(p-1)*20&" N_id from SL_news,SL_nsort where N_sort=S_id "&S_info&" order by N_sort,N_order,N_id desc) order by N_sort,N_order,N_id desc"
Set rs= Server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,1
if not rs.eof then
Do while Not rs.eof

slide_sort="<select name='sort_"&rs("N_id")&"'>"
sql3="Select * from SL_nsort order by S_id"
set rs3=Server.CreateObject("ADODB.RecordSet")
rs3.open sql3,conn,1,1
if not rs3.eof then
for i=1 to rs3.recordcount

if rs("S_id")=rs3("S_id") then
sort_select="selected='selected'"
else
sort_select=""
end if

slide_sort=slide_sort&"<option value='"&rs3("S_id")&"' "&sort_select&">"&rs3("S_title")&"</option>"
rs3.movenext
next
end if
rs3.close
set rs3=nothing
slide_sort=slide_sort&"</select>"


if rs("N_top")=1 then
sort_select1="selected='selected'"
sort_select0=""
else
sort_select0="selected='selected'"
sort_select1=""
end if
news_top="<select name='top_"&rs("N_id")&"'>"
news_top=news_top&"<option value='1' "&sort_select1&">置顶</option>"
news_top=news_top&"<option value='0' "&sort_select0&">取消</option>"
news_top=news_top&"</select>"

		if rs("N_sh")=0 then
		sh_info="<font color='#009900'>已通过</font>"
		bg="#ffffff"
		end if
		if rs("N_sh")=1 then
		sh_info="<font color='#ff0000'>未通过</font>"
		bg="#FFEEEE"
		end if
		if rs("N_sh")=2 then
		sh_info="<font color='#ff9900'>未审核</font>"
		bg="#FFEED5"
		end if

json=json&"{""N_id"":"""&rs("N_id")&""",""N_title"":"""&rs("N_title")&""",""N_pic"":"""&rs("N_pic")&""",""N_order"":"""&rs("N_order")&""",""N_select"":"""&slide_sort&""",""N_top"":"""&news_top&""",""N_sh"":"""&sh_info&""",""bg"":"""&bg&"""},"
rs.movenext
		loop
	end if
rs.close
set rs=nothing
response.Write "["&left(json,len(json)-1)&"]"

'--------------------------------------产品---------------------------------------------
case "product"

if s<>0 then
S_info="and S_id="&s
else
S_info=""
end if
sql="select top 20 * from SL_product,SL_Psort where P_sort=S_id "&S_info&" and P_id not in (select top "&(p-1)*20&" P_id from SL_product,SL_Psort where P_sort=S_id "&S_info&" order by P_sort,P_order,P_id desc) order by P_sort,P_order,P_id desc"
Set rs= Server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,1
if not rs.eof then
Do while Not rs.eof

product_sort="<select name='sort_"&rs("P_id")&"'>"
sql3="Select * from SL_Psort where not S_sub=0 order by S_id"
set rs3=Server.CreateObject("ADODB.RecordSet")
rs3.open sql3,conn,1,1
if not rs3.eof then
for i=1 to rs3.recordcount

if rs("S_id")=rs3("S_id") then
sort_select="selected='selected'"
else
sort_select=""
end if

product_sort=product_sort&"<option value='"&rs3("S_id")&"' "&sort_select&">"&rs3("S_title")&"</option>"
rs3.movenext
next
end if
rs3.close
set rs3=nothing
product_sort=product_sort&"</select>"



product_radio=product_radio&"<input type='radio' name='buy_"&rs("P_id")&"' value='1'"
if rs("P_buy")=1 then
product_radio=product_radio&"checked='checked'"
end if
product_radio=product_radio&"/>开 <input type='radio' name='buy_"&rs("P_id")&"' value='0'"
if rs("P_buy")=0 then
product_radio=product_radio&"checked='checked'"
end if
product_radio=product_radio&" />关"



if rs("P_top")=1 then
sort_select1="selected='selected'"
sort_select0=""
else
sort_select0="selected='selected'"
sort_select1=""
end if
news_top="<select name='top_"&rs("P_id")&"'>"
news_top=news_top&"<option value='1' "&sort_select1&">置顶</option>"
news_top=news_top&"<option value='0' "&sort_select0&">取消</option>"
news_top=news_top&"</select>"

json=json&"{""P_id"":"""&rs("P_id")&""",""P_title"":"""&rs("P_title")&""",""P_price"":"""&formatnumber(rs("P_price"),2,-1)&""",""P_thumb"":"""&rs("P_thumb")&""",""P_path"":"""&rs("P_path")&""",""P_order"":"""&rs("P_order")&""",""P_select"":"""&product_sort&""",""P_top"":"""&news_top&""",""P_radio"":"""&product_radio&"""},"
rs.movenext
product_radio=""
		loop
	end if
rs.close
set rs=nothing
response.Write "["&left(json,len(json)-1)&"]"

case else
response.end()
end select

%>