<%
'**************************************
'* 最后更新 2012-08-23 by 56770.kingdge
'* Copyright www.56770.com
'**************************************
Dim listprice,listtime,listtype,page,sle_type,brand,retime
Showpath = "<a href='"& Eshop_url & LangPath &"'>"& Lebi_word(0) &"</a> → "& Lebi_word(15)
retime=request("retime")
listprice=request("listprice")
listtime=request("listtime")
listtype=request("listtype")
page = request("page")
sort_id=request("sort_id")
page = checknum(page,1)
sort_id = checknum(sort_id,0)
retime = checknum(retime,9999)
session("oldUrl") = geturl()
'..................................
'读取精品推荐 商品列表
'动态页调用模块
'..................................
Public Function RecomProductList(showheadpage,showfootpage)
        Dim DataCount,DataList,Filename,i,showpic_width,showpic_height,div_width, div_height,j,briefed, RLoadStyle(5),RPList_pic,strFile,skin_ys,tmpstr,loopstr,stock,PList_url,icostr,List_num, LoadListStr,pic_url
        showheadpage = checknum(showheadpage,0) : showfootpage = checknum(showfootpage,0)
        skin_ys = Left(Trim(skin_ys2),1)
        If listtype="pic" Then skin_ys = 1
	    If listtype="word" Then skin_ys = 0
	    If listtype="listpic" Then skin_ys = 2
        If Not isnumeric(page) Or isempty(page) Then page=1
	    Dim ors,sqlwhere
	    Set ors=new Cls_vbsPage
	    Set ors.Conn=conn
	    With ors
		    .PageSize=top16
		    .PageName="Page"
			If IsSqlDataBase = 0 Then
		            .DbType="AC"
			Else
			        .DbType="MSSQL"
			End If
		    .RecType=-1
		    .Pkey="p.id"
    	    .Field="p.id,p.product_name"& LangTxt &",p.pic,p.sprice,p.cprice,p.cx,p.stj,p.ytj,p.p_jifen,p.briefed"& LangTxt &",p.sj,p.views,p.kucun,p.p_cx_sj,p.p_stj_sj,p.p_ytj_sj,p.pic_size,p.cpic,s.price as buyprice,p.IsNew,p.p_filename,bianhao"
		    .Table="[Lebi_product] as p,[Lebi_product_price] as s"
			sqlwhere = "s.product_id=p.id and s.grade_id="&Lebi_UserGrade
 			if IsSqlDataBase ="1" then sqlwhere = sqlwhere & " and zhuangtai=1 and (p.stj=1 or p.ytj=1) and datediff(d,p.sj,"&sqlnowstring&")<="&retime&""
            if IsSqlDataBase ="0" then sqlwhere = sqlwhere & " and zhuangtai=1 and (p.stj=1 or p.ytj=1) and datediff('d',p.sj,"&sqlnowstring&")<="&retime&""
			.Condition = sqlwhere
            If listprice="up" Then .OrderBy="s.price DESC"
            If listprice="down" Then .OrderBy="s.price asc"
            If listtime="up" Then .OrderBy="p.sj DESC"
            If listtime="down" Then .OrderBy="p.sj asc"
	        If listview="up" Then .OrderBy="p.views DESC"
	        If listview="down" Then .OrderBy="p.views ASC"
	        If listbuy="up" Then .OrderBy="p.buys DESC"
	        If listbuy="down" Then .OrderBy="p.buys ASC"
            If listprice="" And listtime="" And listview="" And listbuy="" Then .OrderBy="p.p_order desc,p.id desc"
	    End With
	    DataCount=ors.RecCount()
	    DataList=ors.ResultSet()
		List_num = 1
		RecomProductList = ""
		strFile = Eshop_url& Style_Folder &"Lebi.RecomProductList."
		RLoadStyle(0) = splits(LoadStyle(strFile&"11.style"))	'购买按钮
		RLoadStyle(2) = splits(LoadStyle(strFile&"12.style"))	'预订按钮
		RLoadStyle(3) = splits(LoadStyle(strFile&"13.style"))	'零库存
		RLoadStyle(1) = splits(LoadStyle(strFile&"14.style"))	'收藏按钮
		LoadListStr = "<form action="""" method=""post"" name=""LEBI_FORMBUY_0001"" id=""LEBI_FORMBUY_0001"">"
		LoadListStr = LoadListStr & LoadStyle(strFile&"0.style")
		If show_html = 0 Then
				Filename = "default.asp"
		Else
				Filename = Eshop_url & LangPath & Folder(4) &"list"
		End If
		If showheadpage = 1 Then
			tmpstr = LoadStyle(strFile&"1.style")
			ReplaceStyle "headpage",ors.ShowPageHead(Filename),tmpstr
			LoadListStr = LoadListStr & tmpstr
		End If
	    If DataCount > 0 Then
				If skin_ys <> 2 Then
					LoadListStr = LoadListStr & splits(LoadStyle(strFile&"3.style"))
				End If
				Select Case skin_ys
				       Case "0" : RLoadStyle(4) = splits(LoadStyle(strFile&"7.style")) '文字显示
				       Case "1" : RLoadStyle(4) = splits(LoadStyle(strFile&"5.style")) '图片显示
				       Case "2" : RLoadStyle(4) = splits(LoadStyle(strFile&"6.style")) '图片多列显示
				End Select
				LoadListStr = LoadListStr & LoadStyle(strFile&"4.style")
		        For i = 0 To Ubound(DataList,2)
				        loopstr = RloadStyle(4)
						stock=DataList(12,i)
		                briefed = DataList(9,i)
						Select Case show_html
							   Case "0"
									Select Case ISAPI_Rewrite
										   Case "0" PList_url=PagePath(10) &"?id="& DataList(0,i)
										   Case "1" PList_url=LangPath &"product-"& DataList(0,i) &".html"
									End Select
							   Case "1" : PList_url=LangPath & Folder(0) & DataList(20,i) &".1."& Sys_Ext
						End Select
						If Trim(DataList(2,i))<>"" Then
								tmpstr = ""
								ReplaceStyle "pic_url",PicturePath & DataList(2,i),loopstr
								ReplaceStyle "lazyload_pic_url",Eshop_url & PicturePath & DataList(2,i),loopstr
								If show_mouse = "0" Then
										If InStr(DataList(17,i),"@@") > 0 Then
												pic_url = Split(DataList(17,i),"@@")(0)
												If pic_url = "" Then pic_url = Split(DataList(17,i),"@@")(1)
										Else
												pic_url = DataList(17,i)
										End If
										tmpstr = " onMouseover=""javascript:ddrivetip('<img src="& Eshop_url & PicturePath & pic_url &" width="& pic_dw &">', '#ffffff', '"& pic_dw + 10 &"')"" onMouseout=""hideddrivetip()"""
								Else
										tmpstr = ""
								End If
								ReplaceStyle "onmouse",tmpstr,loopstr
						End If
						icostr=""
						If Config_Lebi_Eshop(7)=1 And DataList(19,i)=1 Then
								icostr=icostr&" <img src='"& Eshop_url & "images/icons/pro_3.gif' align='absmiddle'> "
						End if
						If Config_Lebi_Eshop(5)=1 And CLng(DataList(11,i))>CLng(Config_Lebi_Eshop(6)) Then
								icostr=icostr&" <img src='"& Eshop_url & "images/icons/pro_2.gif' align='absmiddle'> "
						End if
						If Config_Lebi_Eshop(3)=1 And DataList(5,i)=1 Then
								icostr=icostr&" <img src='"& Eshop_url &"images/icons/pro_1.gif' align='absmiddle'> "
						End If
						If Config_Lebi_Eshop(4)=1 Then
								icostr=icostr&" <img src='"& Eshop_url &"images/icons/pro_4.gif' align='absmiddle'> "
						End If
						ReplaceStyle "ico",icostr,loopstr
						ReplaceStyle "url",PList_url,loopstr
						ReplaceStyle "target",Config_Lebi_Eshop(9),loopstr
						ReplaceStyle "id",DataList(0,i),loopstr
						ReplaceStyle "name",DataList(1,i),loopstr
						rem	  会员组价格显示 2008-2-28 by 56770.WangLei
						If checkPricePurview(Lebi_UserGrade) Then
								Select Case DataList(5,i)
									   Case "0" : ReplaceStyle "buy_price",Formatnumber2(DataList(18,i)/moneyhl),loopstr
									   Case "1" : ReplaceStyle "buy_price",Formatnumber2(DataList(4,i)/moneyhl),loopstr
								End Select
						Else
								ReplaceStyle "buy_price",Lebi_word(66),loopstr
						End If
						ReplaceStyle "market_price",Formatnumber2(DataList(3,i)/moneyhl),loopstr
						ReplaceStyle "sale_price",Formatnumber2(DataList(4,i)/moneyhl),loopstr
						ReplaceStyle "point",DataList(8,i),loopstr
						ReplaceStyle "stock",DataList(12,i),loopstr
						ReplaceStyle "content",cutchar(briefed,100),loopstr
						ReplaceStyle "bianhao",DataList(21,i),loopstr
						rem	 购买、预订、零库存 样式 by 56770.WangLei
						If InStr(loopstr,"{@btn_buy}") > 0 Then
								tmpstr = ""
								if stock <= 0 then
										if CInt(getGradePurview(17)) = 1 Then
												tmpstr=tmpstr & RLoadStyle(2)	'预定
										else
												tmpstr=tmpstr & RLoadStyle(3)	'零库存
										end if
								else
										tmpstr=tmpstr & RLoadStyle(0)	'购买
								end If
								ReplaceStyle "listcode","0001",tmpstr
								ReplaceStyle "type","",tmpstr
								ReplaceStyle "isValid",getGradePurview(0),tmpstr
								ReplaceStyle "id",DataList(0,i),tmpstr
								ReplaceStyle "btn_buy",tmpstr,loopstr
						End If
						rem	}->
						rem	 收藏按钮 by 56770.WangLei
						If InStr(loopstr,"{@btn_fav}") > 0 Then
								tmpstr = ""
								tmpstr = RLoadStyle(1)	'收藏按钮
								ReplaceStyle "id",DataList(0,i),tmpstr
								ReplaceStyle "name",Urlencode(DataList(1,i)),tmpstr
								ReplaceStyle "backurl",Urlencode(geturl()),tmpstr
								ReplaceStyle "type","",tmpstr
								ReplaceStyle "btn_fav",tmpstr,loopstr
						End If
						rem	}->
						ReplaceStyle "loop_num",i + 1,loopstr
						LoadListStr = LoadListStr & loopstr
						List_num = List_num + 1
                Next
		Else
				LoadListStr = LoadListStr & splits(LoadStyle(strFile&"2.style"))
        End If
		LoadListStr = LoadListStr & LoadStyle(strFile&"8.style")
		If showfootpage = 1 Then
				tmpstr = LoadStyle(strFile&"9.style")
				ReplaceStyle "footpage",ors.ShowPageFoot(Filename),tmpstr
				LoadListStr = LoadListStr & tmpstr
		End If
		LoadListStr = LoadListStr & LoadStyle(strFile&"10.style")
		LoadListStr = LoadListStr & "</form>"
	    RecomProductList = LoadListStr
End Function

'..................................
'精品推荐 时间选择
'..................................
Public Function RecomProductViewMenu()
        If show_html = 1 Then
				Exit Function
		End If
        RecomProductViewMenu="<select class='form' name='sortby' onChange='self.location=document.all.sortby.value'>"&_
		"  <option value='#'>-"&Lebi_pro(56)&"-</option>"&_
       "  <option value='?retime=1'"
       if retime="1" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├== "&Lebi_pro(44)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=2'"
	   if retime="2" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├ "&Lebi_pro(45)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=3'"
	   if retime="3" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├ "&Lebi_pro(46)&"</option>"
	   RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=4'"
	   if retime="4" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├ "&Lebi_pro(47)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=5'"
	   if retime="5" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├ "&Lebi_pro(48)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=6'"
	   if retime="6" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├ "&Lebi_pro(49)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=7'"
	   if retime="7" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├== "&Lebi_pro(43)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=15'"
	   if retime="15" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├ "&Lebi_pro(50)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=30'"
	   if retime="30" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├ "&Lebi_pro(51)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=60'"
	   if retime="60" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├== "&Lebi_pro(52)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=100'"
	   if retime="100" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├ "&Lebi_pro(53)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=182'"
	   if retime="182" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├== "&Lebi_pro(54)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=365'"
	   if retime="365" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├ "&Lebi_pro(55)&"</option>"
       RecomProductViewMenu=RecomProductViewMenu&"<option value='?retime=56770'"
	   if retime="56770" then RecomProductViewMenu=RecomProductViewMenu&"selected" end If
       RecomProductViewMenu=RecomProductViewMenu&">├ "&Lebi_pro(57)&"</option>"&_
       "</select>"
	   RecomProductViewMenu = ArchiveHtml(RecomProductViewMenu)
End Function
%>