<!--#include file="../inc/conn2.asp"-->

<%
dim shopxpptid,username,action
action=request.QueryString("action")
username=session("user_xxx_name")
shopxpptid=request.QueryString("pid")
pro_color=vbsUnEscape(request.QueryString("color"))
pro_size=vbsUnEscape(request.QueryString("size"))
pro_color_id=request.QueryString("p_color_id")
pro_size_id=request.QueryString("p_size_id")

if session("user_xxx_name")<>"" then
username=trim(session("user_xxx_name"))
else
	if request.Cookies("shopxp")("dingdanusername")="" then
	username=now()
	username=replace(trim(username),"-","")
	username=replace(username,":","")
	username=replace(username," ","")
	username=username
	response.Cookies("shopxp")("dingdanusername")=username

	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from [com_user] ",conn,1,3
	rs.addnew
	rs("username")=username
	rs("niming")=1
	rs.update
	rs.close
	set rs=nothing
	
	else
	username=request.Cookies("shopxp")("dingdanusername")
set rss=server.CreateObject("adodb.recordset")
rss.open "select * from [com_user] where username='"&username&"'",conn,1,3
if rss.bof or rss.eof then
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from [com_user] ",conn,1,3
	rs.addnew
	rs("username")=username
	rs("niming")=1
	rs.update
	rs.close
	set rs=nothing
end if
rss.close
set rss=nothing
	end if
end if

select case action
case "addFavorites"  '//收藏
'//收藏，判断是否存在
if session("user_xxx_name")<>"" then
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select username,shopxpptid from com_fav where username='"&username&"' and shopxpptid="&shopxpptid&"",conn,1,1
	if not rs.eof and not rs.bof then
		response.Write("1105")
		'response.Write("对不起，此商品已存在于您的收藏架中，不可以重复添加！")
		response.end
		rs.close
		set rs=nothing
	else
		'//判断收藏数
		set rs2=server.CreateObject("adodb.recordset")
		rs2.open "select username,shopxpptid from com_fav where username='"&username&"'",conn,1,1
		if rs2.recordcount>=10 then
		response.Write("1103")
		'response.Write("对不起，您最多只能收藏10件商品")
		response.end
		end if
		rs2.close
		set rs2=nothing
	rs.close
	set rs=nothing
		'//添加收藏
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select shopxpptid,userid,username from com_fav",conn,1,3
		rs.addnew
		rs("shopxpptid")=shopxpptid
		rs("username")=username
		rs("userid")=session("UserID")
		rs.update
		rs.close
		response.Write("1120")
	end if

else
	response.Write("1101")
end if

case "clearHistoryProduct"
	response.Cookies("RecentlyGoods")=""
	if Request.Cookies("RecentlyGoods")<>"" then
	response.Write("-1")
	else
	response.Write("1120")
	end if

case else 
	response.write""
end select 


%>